branch: externals/cape
commit 383fab93cbba6ef0a6a389b1a0e01f88a3d7e2d5
Author: Daniel Mendler <m...@daniel-mendler.de>
Commit: Daniel Mendler <m...@daniel-mendler.de>

    cape--buffer-list: Simplify behavior in the minibuffer
---
 cape.el | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/cape.el b/cape.el
index 9720270f0e..acb5e46e8e 100644
--- a/cape.el
+++ b/cape.el
@@ -135,15 +135,13 @@ The buffers are scanned for completion candidates by 
`cape-line'."
 
 (defun cape--buffer-list (pred)
   "Return list of buffers satisfying PRED."
-  (let ((cur (current-buffer)))
-    (cons cur
-          (if (minibufferp)
-              (cl-loop for win in (window-list)
-                       for buf = (window-buffer win)
-                       unless (eq buf cur) collect buf)
-            (cl-loop for buf in (buffer-list)
-                     if (and (not (eq buf cur)) (funcall pred buf))
-                     collect buf)))))
+  (let* ((cur (current-buffer))
+         (orig (and (minibufferp) (window-buffer 
(minibuffer-selected-window))))
+         (list (cl-loop for buf in (buffer-list)
+                        if (and (not (eq buf cur)) (not (eq buf orig))
+                                (funcall pred buf))
+                        collect buf)))
+    `(,cur ,@(and orig (list orig)) ,@list)))
 
 (defun cape-same-mode-buffers ()
   "Return buffers with same major mode as current buffer."

Reply via email to