diff options
author | David Morgan <djm_uk@protonmail.com> | 2022-11-03 16:44:41 +0000 |
---|---|---|
committer | David Morgan <djm_uk@protonmail.com> | 2022-11-03 16:44:41 +0000 |
commit | 4fd6e8d437ca5f4b19b3db75d4993e1336e9d7e1 (patch) | |
tree | 55b22246c0499f71d35cd1a597333e4a781597c5 /.emacs.d/lisp/init-minibuffer.el | |
parent | 9ce6b2962229b880f1a2c42ab01adef97bbb8da7 (diff) | |
download | dotfiles-4fd6e8d437ca5f4b19b3db75d4993e1336e9d7e1.tar.gz |
Improve vertico-indexed code
Diffstat (limited to '.emacs.d/lisp/init-minibuffer.el')
-rw-r--r-- | .emacs.d/lisp/init-minibuffer.el | 56 |
1 files changed, 9 insertions, 47 deletions
diff --git a/.emacs.d/lisp/init-minibuffer.el b/.emacs.d/lisp/init-minibuffer.el index 7507421..e62c12f 100644 --- a/.emacs.d/lisp/init-minibuffer.el +++ b/.emacs.d/lisp/init-minibuffer.el @@ -151,62 +151,24 @@ DEFS is a plist associating completion categories to commands." (add-to-list 'savehist-additional-variables 'vertico-repeat-history)) (use-extension vertico vertico-indexed - ;; TODO why doesn't bind-key/define-key work in the macro - :bind (:map vertico-map - ("C-0" . vertico-indexed-choose-0) - ("C-1" . vertico-indexed-choose-1) - ("C-2" . vertico-indexed-choose-2) - ("C-3" . vertico-indexed-choose-3) - ("C-4" . vertico-indexed-choose-4) - ("C-5" . vertico-indexed-choose-5) - ("C-6" . vertico-indexed-choose-6) - ("C-7" . vertico-indexed-choose-7) - ("C-8" . vertico-indexed-choose-8) - ("C-9" . vertico-indexed-choose-9) - ("M-0" . vertico-indexed-insert-0) - ("M-1" . vertico-indexed-insert-1) - ("M-2" . vertico-indexed-insert-2) - ("M-3" . vertico-indexed-insert-3) - ("M-4" . vertico-indexed-insert-4) - ("M-5" . vertico-indexed-insert-5) - ("M-6" . vertico-indexed-insert-6) - ("M-7" . vertico-indexed-insert-7) - ("M-8" . vertico-indexed-insert-8) - ("M-9" . vertico-indexed-insert-9)) :config - (defmacro def-choose (n) + (defmacro define-choose (n) `(defun ,(intern (format "vertico-indexed-choose-%s" n)) () - ,(message "Exit minibuffer with candidate %s." n) + ,(format "Exit minibuffer with candidate %s." n) (interactive) (let ((current-prefix-arg ,n)) (funcall-interactively 'vertico-exit)))) - (defmacro def-insert (n) + (defmacro define-insert (n) `(defun ,(intern (format "vertico-indexed-insert-%s" n)) () - ,(message "Insert candidate %s in minibuffer." n) + ,(format "Insert candidate %s in minibuffer." n) (interactive) (let ((current-prefix-arg ,n)) (funcall-interactively 'vertico-insert)))) - ;; TODO why doens't this work in dotimes - (def-choose 0) - (def-choose 1) - (def-choose 2) - (def-choose 3) - (def-choose 4) - (def-choose 5) - (def-choose 6) - (def-choose 7) - (def-choose 8) - (def-choose 9) - (def-insert 0) - (def-insert 1) - (def-insert 2) - (def-insert 3) - (def-insert 4) - (def-insert 5) - (def-insert 6) - (def-insert 7) - (def-insert 8) - (def-insert 9) + (dotimes (n 10) + (eval `(define-choose ,n)) + (eval `(define-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)) (use-extension vertico vertico-quick |