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

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

[elpa] externals/bufferlo d74f2c1ece 21/37: Add bufferlo-remove-non-excl


From: ELPA Syncer
Subject: [elpa] externals/bufferlo d74f2c1ece 21/37: Add bufferlo-remove-non-exclusive-buffers
Date: Sun, 5 Nov 2023 09:57:33 -0500 (EST)

branch: externals/bufferlo
commit d74f2c1ecef177e0d5fd5e9d9cf2b103beaa26b3
Author: Florian Rommel <mail@florommel.de>
Commit: Florian Rommel <mail@florommel.de>

    Add bufferlo-remove-non-exclusive-buffers
---
 README.org  |  2 ++
 bufferlo.el | 17 +++++++++++++----
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/README.org b/README.org
index 0256ede30a..80ab85f1a2 100644
--- a/README.org
+++ b/README.org
@@ -60,6 +60,8 @@ Bufferlo provides functions to manage the local buffer lists:
   Clear the frame/tab's buffer list.
 - ~bufferlo-remove~:
   Remove a buffer from the frame/tab's buffer list.
+- ~bufferlo-remove-non-exclusive-buffers~
+  Remove all buffers from the local list that are not exclusive to this 
frame/tab.
 - ~bufferlo-bury~:
   Bury and remove the current buffer from the frame/tab's buffer list.
 - ~bufferlo-kill-buffers~:
diff --git a/bufferlo.el b/bufferlo.el
index bf1c6112d0..3494cbcea1 100644
--- a/bufferlo.el
+++ b/bufferlo.el
@@ -357,6 +357,13 @@ If FRAME is nil, use the current frame."
       (switch-to-prev-buffer nil 'bury)))
     nil))
 
+(defun bufferlo-remove-non-exclusive-buffers ()
+  "Remove all buffers from the frame/tab's buffer list that are not exclusively
+attached to this frame/tab."
+  (interactive)
+  (dolist (buffer (bufferlo--get-exclusive-buffers nil t))
+    (bufferlo-remove buffer)))
+
 (defun bufferlo-bury (&optional buffer-or-name)
   "Bury and remove the buffer specified by BUFFER-OR-NAME from the local list.
 If `bufferlo-include-buried-buffers' is set to `nil' then this has the same
@@ -395,13 +402,15 @@ If EXCLUDE-FRAME is a frame, exclude the local buffer 
list of this frame."
                 (not (memq b (bufferlo--get-captured-buffers))))
               (buffer-list)))
 
-(defun bufferlo--get-exclusive-buffers (&optional frame)
+(defun bufferlo--get-exclusive-buffers (&optional frame invert)
   "Get all buffers that are exclusive for this frame and tab.
-If frame is nil, use the current frame."
+If FRAME is nil, use the current frame.
+If INVERT is non-nil, return the non-exclusive buffer instead."
   (let ((other-bufs (bufferlo--get-captured-buffers (or frame 
(selected-frame))))
         (this-bufs (bufferlo--current-buffers frame)))
-    (seq-filter (lambda (b)
-                  (not (memq b other-bufs)))
+    (seq-filter (if invert
+                    (lambda (b) (memq b other-bufs))
+                  (lambda (b) (not (memq b other-bufs))))
                 this-bufs)))
 
 (defun bufferlo-kill-buffers (&optional killall frame)



reply via email to

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