about summary refs log tree commit diff stats
path: root/.emacs.d/lisp/init-completion.el
diff options
context:
space:
mode:
authorDavid Morgan <djm_uk@protonmail.com>2024-10-02 13:07:25 +0100
committerDavid Morgan <djm_uk@protonmail.com>2024-10-02 13:07:25 +0100
commitd7578c0df016fe8f797e260208e10742ec84aeae (patch)
treed7a2e5ac29ed16d3ca555b38262dde8d008bc6c4 /.emacs.d/lisp/init-completion.el
parent3e09f18ef9ce7ea46878109a9c0fd1bbb5334bf5 (diff)
downloaddotfiles-d7578c0df016fe8f797e260208e10742ec84aeae.tar.gz
Use corfu-indexed without tab/enter
Diffstat (limited to '.emacs.d/lisp/init-completion.el')
-rw-r--r--.emacs.d/lisp/init-completion.el20
1 files changed, 19 insertions, 1 deletions
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