branch: externals/vertico commit bb4e01d302c7ab0749c2e18497c155b0b942fc76 Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
vertico-multiform-mode: Add vertico-multiform-map --- CHANGELOG.org | 1 + README.org | 29 ++++++++++++++--------------- extensions/vertico-flat.el | 9 ++++----- extensions/vertico-grid.el | 9 ++++----- extensions/vertico-multiform.el | 33 ++++++++++++++++++++++----------- extensions/vertico-reverse.el | 12 ++++++------ extensions/vertico-unobtrusive.el | 15 +++++++-------- 7 files changed, 58 insertions(+), 50 deletions(-) diff --git a/CHANGELOG.org b/CHANGELOG.org index 9bc73c289e..37db1fd52b 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -8,6 +8,7 @@ - =vertico-directory-up= moves up even if point is not located directly after /. - Use =cl-defgeneric= internally as mechanism to allow extensions to override functionality, e.g., the candidate formatting and display. +- =vertico-multiform-mode=: Add =vertico-multiform-map= with default key bindings. * Version 1.0 (2022-12-22) diff --git a/README.org b/README.org index cf50ba7dfb..ae2ad01574 100644 --- a/README.org +++ b/README.org @@ -300,21 +300,20 @@ problem. (consult-grep buffer))) #+end_src -Temporary toggling between the different display modes is possible. Bind the -following commands: - -#+begin_src emacs-lisp - (keymap-set vertico-map "M-V" #'vertico-multiform-vertical) - (keymap-set vertico-map "M-G" #'vertico-multiform-grid) - (keymap-set vertico-map "M-F" #'vertico-multiform-flat) - (keymap-set vertico-map "M-R" #'vertico-multiform-reverse) - (keymap-set vertico-map "M-U" #'vertico-multiform-unobtrusive) -#+end_src - -You can use your own functions or even lambdas to configure the completion -behavior per command or per completion category. The function must have the -calling convention of a mode, i.e., it takes a single argument, which is either -1 to turn on the mode and -1 to turn off the mode. +Temporary toggling between the different display modes is possible. The +following commands are bound by default in the =vertico-multiform-map=. You can of +course change these bindings if you like. + +- =M-V= -> ~vertico-multiform-vertical~ +- =M-G= -> ~vertico-multiform-grid~ +- =M-F= -> ~vertico-multiform-flat~ +- =M-R= -> ~vertico-multiform-reverse~ +- =M-U= -> ~vertico-multiform-unobtrusive~ + +For special configuration you can use your own functions or even lambdas to +configure the completion behavior per command or per completion category. +Functions must have the calling convention of a mode, i.e., take a single +argument, which is either 1 to turn on the mode and -1 to turn off the mode. #+begin_src emacs-lisp ;; Configure `consult-outline' as a scaled down TOC in a separate buffer diff --git a/extensions/vertico-flat.el b/extensions/vertico-flat.el index 594b533dd5..b151e120f2 100644 --- a/extensions/vertico-flat.el +++ b/extensions/vertico-flat.el @@ -28,11 +28,10 @@ ;; This package is a Vertico extension providing a horizontal display. ;; -;; The mode can be enabled globally or via `vertico-multiform-mode' per -;; command or completion category. Alternatively the flat display can be -;; toggled temporarily if `vertico-multiform-mode' is enabled: -;; -;; (keymap-set vertico-map "M-F" #'vertico-multiform-flat) +;; The mode can be enabled globally or via `vertico-multiform-mode' +;; per command or completion category. Alternatively the flat display +;; can be toggled temporarily with M-F if `vertico-multiform-mode' is +;; enabled. ;; ;; The flat display can be made to look like `ido-mode' by setting ;; `vertico-cycle' to t. See also the `vertico-flat-format' diff --git a/extensions/vertico-grid.el b/extensions/vertico-grid.el index a4a95d9b12..74216a1b6f 100644 --- a/extensions/vertico-grid.el +++ b/extensions/vertico-grid.el @@ -28,11 +28,10 @@ ;; This package is a Vertico extension providing a grid display. ;; -;; The mode can be enabled globally or via `vertico-multiform-mode' per -;; command or completion category. Alternatively the grid display can be -;; toggled temporarily if `vertico-multiform-mode' is enabled: -;; -;; (keymap-set vertico-map "M-G" #'vertico-multiform-grid) +;; The mode can be enabled globally or via `vertico-multiform-mode' +;; per command or completion category. Alternatively the grid display +;; can be toggled temporarily with M-G if `vertico-multiform-mode' is +;; enabled. ;;; Code: diff --git a/extensions/vertico-multiform.el b/extensions/vertico-multiform.el index 9705df604d..c17e7d2206 100644 --- a/extensions/vertico-multiform.el +++ b/extensions/vertico-multiform.el @@ -28,9 +28,9 @@ ;; This package is a Vertico extension for fine tuning the Vertico ;; display and other minibuffer modes per command or completion -;; category. For some commands you may want to use the `vertico-buffer' -;; display and for completion categories like file you prefer the -;; `vertico-grid-mode'. +;; category. For some commands you may want to use the +;; `vertico-buffer' display and for completion categories like file +;; you prefer the `vertico-grid-mode'. ;; ;; Example: ;; @@ -46,14 +46,14 @@ ;; ;; (vertico-multiform-mode) ;; -;; Temporary toggling between the different display modes is -;; possible. Bind the following commands: +;; Temporary toggling between the different display modes is possible. +;; The following keys are bound in the `vertico-multiform-map'. ;; -;; (keymap-set vertico-map "M-V" #'vertico-multiform-vertical) -;; (keymap-set vertico-map "M-G" #'vertico-multiform-grid) -;; (keymap-set vertico-map "M-F" #'vertico-multiform-flat) -;; (keymap-set vertico-map "M-R" #'vertico-multiform-reverse) -;; (keymap-set vertico-map "M-U" #'vertico-multiform-unobtrusive) +;; M-V -> `vertico-multiform-vertical' +;; M-G -> `vertico-multiform-grid' +;; M-F -> `vertico-multiform-flat' +;; M-R -> `vertico-multiform-reverse' +;; M-U -> `vertico-multiform-unobtrusive' ;; ;;; Code: @@ -135,6 +135,14 @@ The keys in LIST can be symbols or regexps." (vertico-multiform--toggle 1) (vertico--setup))) +(defvar-keymap vertico-multiform-map + :doc "Additional keymap activated in multiform mode." + "M-V" 'vertico-multiform-vertical + "M-G" 'vertico-multiform-grid + "M-F" 'vertico-multiform-flat + "M-R" 'vertico-multiform-reverse + "M-U" 'vertico-multiform-unobtrusive) + ;;;###autoload (define-minor-mode vertico-multiform-mode "Configure Vertico in various forms per command." @@ -143,7 +151,10 @@ The keys in LIST can be symbols or regexps." (warn "vertico-multiform must not be toggled from recursive minibuffers")) (when vertico-multiform--stack (warn "vertico-multiform state is inconsistent") - (setq vertico-multiform--stack nil))) + (setq vertico-multiform--stack nil)) + (if vertico-multiform-mode + (add-to-list 'minor-mode-map-alist `(vertico--input . ,vertico-multiform-map)) + (setq minor-mode-map-alist (delete `(vertico--input . ,vertico-multiform-map) minor-mode-map-alist)))) (cl-defmethod vertico--advice (&context (vertico-multiform-mode (eql t)) &rest app) (unwind-protect diff --git a/extensions/vertico-reverse.el b/extensions/vertico-reverse.el index eee2ff6b5f..2924b0c2ff 100644 --- a/extensions/vertico-reverse.el +++ b/extensions/vertico-reverse.el @@ -26,13 +26,13 @@ ;;; Commentary: -;; This package is a Vertico extension, which reverses the list of candidates. +;; This package is a Vertico extension, which reverses the list of +;; candidates. ;; -;; The mode can be enabled globally or via `vertico-multiform-mode' per -;; command or completion category. Alternatively the reverse display can be -;; toggled temporarily if `vertico-multiform-mode' is enabled: -;; -;; (keymap-set vertico-map "M-R" #'vertico-multiform-reverse) +;; The mode can be enabled globally or via `vertico-multiform-mode' +;; per command or completion category. Alternatively the reverse +;; display can be toggled temporarily with M-R if +;; `vertico-multiform-mode' is enabled. ;;; Code: diff --git a/extensions/vertico-unobtrusive.el b/extensions/vertico-unobtrusive.el index 91c437850f..a49db48290 100644 --- a/extensions/vertico-unobtrusive.el +++ b/extensions/vertico-unobtrusive.el @@ -26,15 +26,14 @@ ;;; Commentary: -;; This package is a Vertico extension providing a unobtrusive display. -;; The unobtrusive display only shows the topmost candidate and nothing -;; else, it is a simple derivative of `vertico-flat-mode'. +;; This package is a Vertico extension providing a unobtrusive +;; display. The unobtrusive display only shows the topmost candidate +;; and nothing else, it is a simple derivative of `vertico-flat-mode'. ;; -;; The mode can be enabled globally or via `vertico-multiform-mode' per -;; command or completion category. Alternatively the unobtrusive display -;; can be toggled temporarily if `vertico-multiform-mode' is enabled: -;; -;; (keymap-set vertico-map "M-U" #'vertico-multiform-unobtrusive) +;; The mode can be enabled globally or via `vertico-multiform-mode' +;; per command or completion category. Alternatively the unobtrusive +;; display can be toggled temporarily with M-U if +;; `vertico-multiform-mode' is enabled. ;;; Code: