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

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

[elpa] master 15e2c88 051/399: Restore buffer-list after counsel-switch-


From: Oleh Krehel
Subject: [elpa] master 15e2c88 051/399: Restore buffer-list after counsel-switch-buffers
Date: Sat, 20 Jul 2019 14:56:47 -0400 (EDT)

branch: master
commit 15e2c8869c99045125a691f5c647ec4a7cdbf287
Author: Andrew Whatson <address@hidden>
Commit: Oleh Krehel <address@hidden>

    Restore buffer-list after counsel-switch-buffers
    
    Previewing the buffers calls `switch-to-buffer` without the NORECORD
    flag, so the buffer-list is modified (previewed buffers are bumped up
    the list).  This change keeps a backup of buffer-list and restores it
    during unwind.
    
    Fixes #1954
---
 counsel.el | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/counsel.el b/counsel.el
index 4f471a6..4deceb6 100644
--- a/counsel.el
+++ b/counsel.el
@@ -5052,14 +5052,20 @@ When ARG is non-nil, ignore NoDisplay property in 
*.desktop files."
 (defvar counsel--switch-buffer-temporary-buffers nil
   "Internal.")
 
+(defvar counsel--switch-buffer-previous-buffers nil
+  "Internal.")
+
 (defun counsel--switch-buffer-unwind ()
-  "Clear temporary file buffers.
+  "Clear temporary file buffers and restore `buffer-list'.
 The buffers are those opened during a session of `counsel-switch-buffer'."
-  (while counsel--switch-buffer-temporary-buffers
-    (let ((buf (pop counsel--switch-buffer-temporary-buffers)))
-      (kill-buffer buf))))
+  (mapc 'kill-buffer counsel--switch-buffer-temporary-buffers)
+  (mapc 'bury-buffer counsel--switch-buffer-previous-buffers)
+  (setq counsel--switch-buffer-temporary-buffers nil
+        counsel--switch-buffer-previous-buffers nil))
 
 (defun counsel--switch-buffer-update-fn ()
+  (unless counsel--switch-buffer-previous-buffers
+    (setq counsel--switch-buffer-previous-buffers (buffer-list)))
   (let ((current (ivy-state-current ivy-last)))
     ;; This check is necessary, otherwise typing into the completion
     ;; would create empty buffers.



reply via email to

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