From d7578c0df016fe8f797e260208e10742ec84aeae Mon Sep 17 00:00:00 2001 From: David Morgan Date: Wed, 2 Oct 2024 13:07:25 +0100 Subject: Use corfu-indexed without tab/enter --- .emacs.d/lisp/init-completion.el | 20 +++++++++++++++++++- .emacs.d/lisp/init-minibuffer.el | 8 ++++---- 2 files changed, 23 insertions(+), 5 deletions(-) (limited to '.emacs.d') diff --git a/.emacs.d/lisp/init-completion.el b/.emacs.d/lisp/init-completion.el index 8fa04f6..c46ad5c 100644 --- a/.emacs.d/lisp/init-completion.el +++ b/.emacs.d/lisp/init-completion.el @@ -151,7 +151,25 @@ no words in between, beginning with the first word." :hook (elpaca-after-init . global-corfu-mode)) (use-extension corfu corfu-indexed - :config (corfu-indexed-mode 1)) + :config + (defmacro define-corfu-complete (n) + `(defun ,(intern (format "corfu-indexed-complete-%s" n)) () + ,(format "Complete with candidate %s." n) + (interactive) + (let ((corfu--index ,n)) + (funcall-interactively 'corfu-complete)))) + (defmacro define-corfu-insert (n) + `(defun ,(intern (format "corfu-indexed-insert-%s" n)) () + ,(format "Insert candidate %s." n) + (interactive) + (let ((corfu--index ,n)) + (funcall-interactively 'corfu-insert)))) + (dotimes (n 10) + (eval `(define-corfu-complete ,n)) + (eval `(define-corfu-insert ,n)) + (define-key corfu-map (kbd (format "C-%s" n)) (intern (format "corfu-indexed-complete-%s" n))) + (define-key corfu-map (kbd (format "M-%s" n)) (intern (format "corfu-indexed-insert-%s" n)))) + (corfu-indexed-mode 1)) (use-extension corfu corfu-quick :bind (:map corfu-map diff --git a/.emacs.d/lisp/init-minibuffer.el b/.emacs.d/lisp/init-minibuffer.el index c96ea98..0f8b97a 100644 --- a/.emacs.d/lisp/init-minibuffer.el +++ b/.emacs.d/lisp/init-minibuffer.el @@ -222,21 +222,21 @@ DEFS is a plist associating completion categories to commands." (use-extension vertico vertico-indexed :config - (defmacro define-choose (n) + (defmacro define-vertico-choose (n) `(defun ,(intern (format "vertico-indexed-choose-%s" n)) () ,(format "Exit minibuffer with candidate %s." n) (interactive) (let ((vertico--index ,n)) (funcall-interactively 'vertico-exit)))) - (defmacro define-insert (n) + (defmacro define-vertico-insert (n) `(defun ,(intern (format "vertico-indexed-insert-%s" n)) () ,(format "Insert candidate %s in minibuffer." n) (interactive) (let ((vertico--index ,n)) (funcall-interactively 'vertico-insert)))) (dotimes (n 10) - (eval `(define-choose ,n)) - (eval `(define-insert ,n)) + (eval `(define-vertico-choose ,n)) + (eval `(define-vertico-insert ,n)) (define-key vertico-map (kbd (format "C-%s" n)) (intern (format "vertico-indexed-choose-%s" n))) (define-key vertico-map (kbd (format "M-%s" n)) (intern (format "vertico-indexed-insert-%s" n)))) (vertico-indexed-mode 1)) -- cgit 1.4.1-2-gfad0