[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/bufferlo 0b5a339d55 2/4: Add bufferlo-isolate-project
|
From: |
ELPA Syncer |
|
Subject: |
[elpa] externals/bufferlo 0b5a339d55 2/4: Add bufferlo-isolate-project |
|
Date: |
Fri, 10 Nov 2023 18:57:28 -0500 (EST) |
branch: externals/bufferlo
commit 0b5a339d55279cc11877ecd00435793be4b2ce89
Author: Florian Rommel <mail@florommel.de>
Commit: Florian Rommel <mail@florommel.de>
Add bufferlo-isolate-project
---
README.org | 2 ++
bufferlo.el | 19 +++++++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/README.org b/README.org
index bc2f52f47f..951339ebf8 100644
--- a/README.org
+++ b/README.org
@@ -75,6 +75,8 @@ Bufferlo provides functions to manage the local buffer lists:
Delete the frame and kill all its local buffers.
- ~bufferlo-tab-close-kill-buffers~:
Close the tab and kill all its local buffers.
+- ~bufferlo-isolate-project~:
+ Isolate a project in the frame or tab.
** Consult Integration
diff --git a/bufferlo.el b/bufferlo.el
index 07c19ad949..83499d04b4 100644
--- a/bufferlo.el
+++ b/bufferlo.el
@@ -500,6 +500,25 @@ The optional parameter KILLALL is passed to
`bufferlo-kill-buffers'"
(bufferlo-kill-buffers killall)
(tab-bar-close-tab))
+(defun bufferlo-isolate-project (&optional file-buffers-only)
+ "Isolate a project in the frame or tab.
+Remove all buffers that do not belong to the current project from
+the local buffer list. When FILE-BUFFERS-ONLY is non-nil or the
+prefix argument is given, remove only buffers that visit a file.
+Buffers matching `bufferlo-include-buffer-filters' are not removed."
+ (interactive "P")
+ (let ((curr-project (project-current))
+ (include (bufferlo--merge-regexp-list
+ (append '("a^") bufferlo-include-buffer-filters))))
+ (if curr-project
+ (dolist (buffer (bufferlo-buffer-list))
+ (when (and (not (string-match-p include (buffer-name buffer)))
+ (not (equal curr-project
+ (with-current-buffer buffer
(project-current))))
+ (or (not file-buffers-only) (buffer-file-name buffer)))
+ (bufferlo-remove buffer)))
+ (message "Current buffer is not part of a project"))))
+
(defun bufferlo-switch-to-buffer (buffer &optional norecord force-same-window)
"Display the BUFFER in the selected window.
Completion includes only local buffers.