[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vertico d3d4d4fcbe: vertico-multiform: Unify vertico-co
From: |
ELPA Syncer |
Subject: |
[elpa] externals/vertico d3d4d4fcbe: vertico-multiform: Unify vertico-command/category-modes/settings |
Date: |
Sun, 2 Jan 2022 16:57:46 -0500 (EST) |
branch: externals/vertico
commit d3d4d4fcbe73e3b2270e339e9c95fc701de79eb0
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
vertico-multiform: Unify vertico-command/category-modes/settings
The configuration gets more concise and the configuration for
one command/category is kept at a single place.
---
README.org | 44 ++++++++++++--------------
extensions/vertico-multiform.el | 69 +++++++++++++++++------------------------
2 files changed, 48 insertions(+), 65 deletions(-)
diff --git a/README.org b/README.org
index 1baf96262e..c2a3c33bd7 100644
--- a/README.org
+++ b/README.org
@@ -286,14 +286,14 @@ problem!
;; Configure the display per command.
;; Use a buffer with indices for imenu
;; and a flat (Ido-like) menu for M-x.
- (setq vertico-multiform-command-modes
+ (setq vertico-multiform-commands
'((consult-imenu buffer indexed)
(execute-extended-command flat)))
;; Configure the display per completion category.
;; Use the grid display for files and a buffer
;; for the consult-grep commands.
- (setq vertico-multiform-category-modes
+ (setq vertico-multiform-categories
'((file grid)
(consult-grep buffer)))
#+end_src
@@ -305,18 +305,18 @@ calling convention of a mode, i.e., it takes a single
argument, which is either
#+begin_src emacs-lisp
;; Configure `consult-outline' as a scaled down TOC in a separate buffer
- (setq vertico-multiform-command-modes
+ (setq vertico-multiform-commands
`((consult-outline buffer ,(lambda (_) (text-scale-set -1)))))
#+end_src
-Furthermore you can tune buffer-local settings per command (or category).
+Furthermore you can tune buffer-local settings per command or category.
#+begin_src emacs-lisp
;; Change the default sorting function
- (setq vertico-multiform-command-settings
+ (setq vertico-multiform-commands
'((describe-symbol (vertico-sort-function . vertico-sort-alpha))))
- (setq vertico-multiform-category-settings
+ (setq vertico-multiform-categories
'((symbol (vertico-sort-function . vertico-sort-alpha))
(file (vertico-sort-function . sort-directories-first))))
@@ -327,19 +327,6 @@ Furthermore you can tune buffer-local settings per command
(or category).
(seq-remove (lambda (x) (string-suffix-p "/" x)) files)))
#+end_src
-As another example, the following code uses ~vertico-flat~ and ~vertico-cycle~
to
-emulate ~(ido-mode 'buffer)~, i.e. Ido when it is enabled only for completion
of
-buffer names. ~vertico-cycle~ set to ~t~ is necessary here to prevent
completion
-candidates from disappearing when they scroll off-screen to the left.
-
-#+begin_src emacs-lisp
- (setq vertico-multiform-category-modes
- '((buffer flat)))
-
- (setq vertico-multiform-category-settings
- '((buffer (vertico-cycle . t))))
-#+end_src
-
Combining these features allows us to fine-tune the completion display even
more
by adjusting the ~vertico-buffer-display-action~. We can for example reuse the
current window for commands of the ~consult-grep~ category (~consult-grep~,
@@ -349,19 +336,26 @@ in exactly this window. Nevertheless this snippet
demonstrates the flexibility
of the configuration system.
#+begin_src emacs-lisp
- ;; Configure the display action
- (setq vertico-multiform-category-settings
+ ;; Configure the buffer display and the buffer display action
+ (setq vertico-multiform-categories
'((consult-grep
+ buffer
(vertico-buffer-display-action . (display-buffer-same-window)))))
- ;; Configure the buffer display
- (setq vertico-multiform-category-modes
- '((consult-grep buffer)))
-
;; Disable preview for consult-grep commands
(consult-customize consult-ripgrep consult-git-grep consult-grep
:preview-key nil)
#+end_src
+As another example, the following code uses ~vertico-flat~ and ~vertico-cycle~
to
+emulate ~(ido-mode 'buffer)~, i.e., Ido when it is enabled only for completion
of
+buffer names. ~vertico-cycle~ set to ~t~ is necessary here to prevent
completion
+candidates from disappearing when they scroll off-screen to the left.
+
+#+begin_src emacs-lisp
+ (setq vertico-multiform-categories
+ '((buffer flat (vertico-cycle . t))))
+#+end_src
+
* Complementary packages
:properties:
:custom_id: complementary-packages
diff --git a/extensions/vertico-multiform.el b/extensions/vertico-multiform.el
index 6cf92abdfe..d7ec6fb131 100644
--- a/extensions/vertico-multiform.el
+++ b/extensions/vertico-multiform.el
@@ -34,12 +34,12 @@
;;
;; Example:
;;
-;; (setq vertico-multiform-command-modes
+;; (setq vertico-multiform-commands
;; '((consult-line buffer)
;; (consult-imenu reverse buffer)
;; (execute-extended-command flat)))
;;
-;; (setq vertico-multiform-category-modes
+;; (setq vertico-multiform-categories
;; '((file buffer grid)))
;;
;; (vertico-multiform-mode)
@@ -56,31 +56,19 @@
(eval-when-compile
(require 'cl-lib))
-(defcustom vertico-multiform-command-modes nil
- "Alist of commands/regexps and list of modes to turn on per command.
-Takes precedence over `vertico-multiform-category-modes'."
+(defcustom vertico-multiform-commands nil
+ "Alist of commands/regexps and list of settings to turn on per command.
+A setting can either be a mode symbol, a function or a cons cell of variable
+name and variable value. Takes precedence over `vertico-multiform-categories'."
:group 'vertico
- :type '(alist :key-type (choice symbol regexp) :value-type (repeat symbol)))
+ :type '(alist :key-type (choice symbol regexp) :value-type (repeat sexp)))
-(defcustom vertico-multiform-category-modes nil
- "Alist of categories/regexps and list of modes to turn on per category.
-Has lower precedence than `vertico-multiform-command-modes'."
+(defcustom vertico-multiform-categories nil
+ "Alist of categories/regexps and list of settings to turn on per category.
+A setting can either be a mode symbol, a function or a cons cell of variable
+name and value. Has lower precedence than `vertico-multiform-commands'."
:group 'vertico
- :type '(alist :key-type (choice symbol regexp) :value-type (repeat symbol)))
-
-(defcustom vertico-multiform-command-settings nil
- "Alist of commands/regexps and alist of variables to set per command.
-Takes precedence over `vertico-multiform-category-settings'."
- :group 'vertico
- :type '(alist :key-type (choice symbol regexp)
- :value-type (alist :key-type symbol :value-type sexp)))
-
-(defcustom vertico-multiform-category-settings nil
- "Alist of categories/regexps and alist of variables to set per category.
-Has lower precedence than `vertico-multiform-command-settings'."
- :group 'vertico
- :type '(alist :key-type (choice symbol regexp)
- :value-type (alist :key-type symbol :value-type sexp)))
+ :type '(alist :key-type (choice symbol regexp) :value-type (repeat sexp)))
(defvar vertico-multiform--stack nil)
@@ -121,13 +109,14 @@ The keys in LIST can be symbols or regexps."
(vertico-multiform--toggle -1)
(pop vertico-multiform--stack))))
(add-hook 'minibuffer-exit-hook exit)
- (dolist (x (cdr (or (vertico-multiform--lookup this-command
vertico-multiform-command-settings)
- (and cat (vertico-multiform--lookup cat
vertico-multiform-category-settings)))))
- (set (make-local-variable (car x)) (cdr x)))
- (dolist (x (cdr (or (vertico-multiform--lookup this-command
vertico-multiform-command-modes)
- (and cat (vertico-multiform--lookup cat
vertico-multiform-category-modes)))))
- (let ((sym (and (symbolp x) (intern-soft (format "vertico-%s-mode" x)))))
- (push (if (and sym (fboundp sym)) sym x) modes)))
+ (dolist (x (cdr (or (vertico-multiform--lookup this-command
vertico-multiform-commands)
+ (and cat (vertico-multiform--lookup cat
vertico-multiform-categories)))))
+ (pcase x
+ ((or (pred functionp) (pred symbolp))
+ (let ((sym (and (symbolp x) (intern-soft (format "vertico-%s-mode"
x)))))
+ (push (if (and sym (fboundp sym)) sym x) modes)))
+ (`(,k . ,v) (set (make-local-variable k) v))
+ (_ (error "Invalid multiform setting %S" x))))
(push modes vertico-multiform--stack)
(vertico-multiform--toggle 1)
(vertico--setup)))
@@ -150,7 +139,7 @@ APP is the original function call."
(advice-add #'vertico--advice :override #'vertico-multiform--advice)
(advice-remove #'vertico--advice #'vertico-multiform--advice)))
-(defun vertico-multiform--disable-temporarily (mode)
+(defun vertico-multiform--temporary-disable (mode)
"Disable MODE temporarily in minibuffer."
(unless (minibufferp)
(user-error "`%s' must be called inside the minibuffer" this-command))
@@ -161,29 +150,29 @@ APP is the original function call."
(setf (car vertico-multiform--stack)
(remove mode (car vertico-multiform--stack)))))
-(defun vertico-multiform--enable-temporarily (mode)
+(defun vertico-multiform--temporary-enable (mode)
"Enable MODE temporarily in minibuffer."
(unless (and (boundp mode) (symbol-value mode))
(funcall mode 1)
(push mode (car vertico-multiform--stack))))
-(defun vertico-multiform--toggle-temporarily (mode)
+(defun vertico-multiform--temporary-toggle (mode)
"Toggle MODE temporarily in minibuffer."
(if (and (boundp mode) (symbol-value mode))
- (vertico-multiform--disable-temporarily mode)
- (vertico-multiform--enable-temporarily mode)))
+ (vertico-multiform--temporary-disable mode)
+ (vertico-multiform--temporary-enable mode)))
(defun vertico-multiform-grid ()
"Toggle the grid display."
(interactive)
- (vertico-multiform--disable-temporarily 'vertico-flat-mode)
- (vertico-multiform--toggle-temporarily 'vertico-grid-mode))
+ (vertico-multiform--temporary-disable 'vertico-flat-mode)
+ (vertico-multiform--temporary-toggle 'vertico-grid-mode))
(defun vertico-multiform-flat ()
"Toggle the flat display."
(interactive)
- (vertico-multiform--disable-temporarily 'vertico-grid-mode)
- (vertico-multiform--toggle-temporarily 'vertico-flat-mode))
+ (vertico-multiform--temporary-disable 'vertico-grid-mode)
+ (vertico-multiform--temporary-toggle 'vertico-flat-mode))
(provide 'vertico-multiform)
;;; vertico-multiform.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/vertico d3d4d4fcbe: vertico-multiform: Unify vertico-command/category-modes/settings,
ELPA Syncer <=