branch: externals/vertico commit c9157759a015ac32cb299c18c84c6d5fb34e0aa1 Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
Add vertico-resize instead of reusing resize-mini-windows This allows to configure the plain minibuffer (read-from-minibuffer) separately from the Vertico minibuffer (completing-read). --- README.org | 6 +++--- vertico.el | 12 ++++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/README.org b/README.org index 69f2fc0..8f5b4dd 100644 --- a/README.org +++ b/README.org @@ -50,6 +50,9 @@ Here is an example configuration: :init (vertico-mode) + ;; Grow and shrink the Vertico minibuffer + ;; (setq vertico-resize t) + ;; Optionally enable cycling for `vertico-next' and `vertico-previous'. ;; (setq vertico-cycle t) ) @@ -76,9 +79,6 @@ Here is an example configuration: (cons (concat "[CRM] " (car args)) (cdr args))) (advice-add #'completing-read-multiple :filter-args #'crm-indicator) - ;; Grow and shrink minibuffer - ;;(setq resize-mini-windows t) - ;; Do not allow the cursor in the minibuffer prompt (setq minibuffer-prompt-properties '(read-only t cursor-intangible t face minibuffer-prompt)) diff --git a/vertico.el b/vertico.el index 83e3e48..2b402df 100644 --- a/vertico.el +++ b/vertico.el @@ -58,6 +58,11 @@ "Maximal number of candidates to show." :type 'integer) +(defcustom vertico-resize resize-mini-windows + "How to resize the Vertico minibuffer window. +See `resize-mini-windows' for documentation." + :type '(choice (const nil) (const t) (const grow-only))) + (defcustom vertico-cycle nil "Enable cycling for `vertico-next' and `vertico-previous'." :type 'boolean) @@ -463,13 +468,12 @@ (defun vertico--resize-window (height) "Resize active minibuffer window to HEIGHT." (unless (frame-root-window-p (active-minibuffer-window)) - (let* ((resize (default-value 'resize-mini-windows)) - (window-resize-pixelwise t) + (let* ((window-resize-pixelwise t) (dp (- (max (cdr (window-text-pixel-size)) - (* (default-line-height) (1+ (if resize height vertico-count)))) + (* (default-line-height) (1+ (if vertico-resize height vertico-count)))) (window-pixel-height)))) (when (and (or (/= height 0) (< dp 0)) - (or (> dp 0) (eq resize t))) + (or (> dp 0) (eq vertico-resize t))) (window-resize nil dp nil nil 'pixelwise))))) (defun vertico--display-count ()