emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/consult 48f7aa4378 1/2: consult--buffer-preview: Explic


From: ELPA Syncer
Subject: [elpa] externals/consult 48f7aa4378 1/2: consult--buffer-preview: Explicitly save and restore buffer list (Fix #354, #779)
Date: Thu, 30 Mar 2023 06:57:31 -0400 (EDT)

branch: externals/consult
commit 48f7aa43788286f1413e42672c237270899a4d62
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    consult--buffer-preview: Explicitly save and restore buffer list (Fix #354, 
#779)
---
 consult.el | 38 ++++++++++++++++++++++++--------------
 1 file changed, 24 insertions(+), 14 deletions(-)

diff --git a/consult.el b/consult.el
index 7587cec079..0f498aadc1 100644
--- a/consult.el
+++ b/consult.el
@@ -4393,21 +4393,31 @@ AS is a conversion function."
 
 (defun consult--buffer-preview ()
   "Buffer preview function."
-  (let ((orig-buf (current-buffer)) other-win)
+  (let ((orig-buf (current-buffer))
+        (orig-prev (copy-sequence (window-prev-buffers)))
+        (orig-next (copy-sequence (window-next-buffers)))
+        other-win)
     (lambda (action cand)
-      (when (eq action 'preview)
-        (when (and (eq consult--buffer-display #'switch-to-buffer-other-window)
-                   (not other-win))
-          (switch-to-buffer-other-window orig-buf)
-          (setq other-win (selected-window)))
-        (let ((win (or other-win (selected-window))))
-          (when (window-live-p win)
-            (with-selected-window win
-              (cond
-               ((and cand (get-buffer cand))
-                (switch-to-buffer cand 'norecord))
-               ((buffer-live-p orig-buf)
-                (switch-to-buffer orig-buf 'norecord))))))))))
+      (pcase action
+        ('exit
+         (set-window-prev-buffers other-win orig-prev)
+         (set-window-next-buffers other-win orig-next))
+        ('preview
+         (when (and (eq consult--buffer-display 
#'switch-to-buffer-other-window)
+                    (not other-win))
+           (switch-to-buffer-other-window orig-buf)
+           (setq other-win (selected-window)))
+         (let ((win (or other-win (selected-window))))
+           (when (window-live-p win)
+             (with-selected-window win
+               (unless (or orig-prev orig-next)
+                 (setq orig-prev (copy-sequence (window-prev-buffers))
+                       orig-next (copy-sequence (window-next-buffers))))
+               (cond
+                ((and cand (get-buffer cand))
+                 (switch-to-buffer cand 'norecord))
+                ((buffer-live-p orig-buf)
+                 (switch-to-buffer orig-buf 'norecord)))))))))))
 
 (defun consult--buffer-action (buffer &optional norecord)
   "Switch to BUFFER via `consult--buffer-display' function.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]