branch: master
commit 456e575facc25b6d4bbeefb7f82ba4a0a85c361c
Author: Andrew Whatson <[email protected]>
Commit: Oleh Krehel <[email protected]>
Don't bury killed buffers after counsel-switch-buffer
It's possible for a killed buffer to remain on buffer-list, causing
bury-buffer to error while restoring the original buffer-list.
Fixes #1959
---
counsel.el | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/counsel.el b/counsel.el
index 6aa0cba..1a6ab5b 100644
--- a/counsel.el
+++ b/counsel.el
@@ -5080,8 +5080,10 @@ When ARG is non-nil, ignore NoDisplay property in
*.desktop files."
(defun counsel--switch-buffer-unwind ()
"Clear temporary file buffers and restore `buffer-list'.
The buffers are those opened during a session of `counsel-switch-buffer'."
- (mapc 'kill-buffer counsel--switch-buffer-temporary-buffers)
- (mapc 'bury-buffer counsel--switch-buffer-previous-buffers)
+ (mapc #'kill-buffer counsel--switch-buffer-temporary-buffers)
+ (mapc #'bury-buffer (cl-remove-if-not
+ #'buffer-live-p
+ counsel--switch-buffer-previous-buffers))
(setq counsel--switch-buffer-temporary-buffers nil
counsel--switch-buffer-previous-buffers nil))