[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vertico 2b320ef1af 1/3: vertico-buffer: Ensure that dis
From: |
ELPA Syncer |
Subject: |
[elpa] externals/vertico 2b320ef1af 1/3: vertico-buffer: Ensure that display-buffer-same-window works |
Date: |
Thu, 30 Dec 2021 01:57:59 -0500 (EST) |
branch: externals/vertico
commit 2b320ef1af8991f513da7adcd80e4c4706c05b5e
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
vertico-buffer: Ensure that display-buffer-same-window works
See the report by @gcv in https://github.com/minad/vertico/issues/149
---
README.org | 15 +++++----------
extensions/vertico-buffer.el | 7 +++++--
2 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/README.org b/README.org
index 774611c1b4..97643df5dd 100644
--- a/README.org
+++ b/README.org
@@ -330,21 +330,16 @@ Furthermore you can tune buffer-local settings per
command (or category).
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~,
-~consult-git-grep~ and ~consult-ripgrep~). We have to define a display action
-function, which uses the ~minibuffer-selected-window~. Note that this
-configuration is incompatible with Consult preview, since the previewed buffer
-is usually shown in exactly this window. Nevertheless this snippet demonstrates
-the flexibility of the configuration system.
+~consult-git-grep~ and ~consult-ripgrep~). Note that this configuration is
+incompatible with Consult preview, since the previewed buffer is usually shown
+in exactly this window. Nevertheless this snippet demonstrates the flexibility
+of the configuration system.
#+begin_src emacs-lisp
- (defun display-buffer-in-selected (buffer alist)
- "Show the buffer in the latest selected window, before the minibuffer
started."
- (window--display-buffer buffer (minibuffer-selected-window) 'reuse alist))
-
;; Configure the display action
(setq vertico-multiform-category-settings
'((consult-grep
- (vertico-display-buffer-action . (display-buffer-in-selected)))))
+ (vertico-buffer-display-action . (display-buffer-same-window)))))
;; Configure the buffer display
(setq vertico-multiform-category-modes
diff --git a/extensions/vertico-buffer.el b/extensions/vertico-buffer.el
index 2473ed4c65..39c28d68c5 100644
--- a/extensions/vertico-buffer.el
+++ b/extensions/vertico-buffer.el
@@ -92,8 +92,11 @@
(defun vertico-buffer--setup ()
"Setup minibuffer overlay, which pushes the minibuffer content down."
(add-hook 'pre-redisplay-functions 'vertico-buffer--redisplay nil 'local)
- (let ((temp (generate-new-buffer "*vertico*")))
- (setq vertico-buffer--window (display-buffer temp
vertico-buffer-display-action))
+ (let ((action vertico-buffer-display-action)
+ (temp (generate-new-buffer "*vertico*")))
+ (setq vertico-buffer--window
+ ;; Temporarily select the original window such that
`display-buffer-same-window' works.
+ (with-minibuffer-selected-window (display-buffer temp action)))
(set-window-buffer vertico-buffer--window (current-buffer))
(kill-buffer temp))
(let ((sym (make-symbol "vertico-buffer--destroy"))