aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConstantine Vetoshev <gepardcv@gmail.com>2020-04-13 18:31:25 -0700
committerConstantine Vetoshev <gepardcv@gmail.com>2020-04-13 18:31:25 -0700
commit02758a546280a5b96f21cc25721b287afa493804 (patch)
tree4300697e0d963919250452ba6c3635408583224e
parent67e1d33101885c1ab3dc1b76e17c0a8e32b1a077 (diff)
Refactor ignore buffer handling.
-rw-r--r--perspective.el25
1 files changed, 17 insertions, 8 deletions
diff --git a/perspective.el b/perspective.el
index 0a3ab1d..3586f71 100644
--- a/perspective.el
+++ b/perspective.el
@@ -149,9 +149,23 @@ After BODY is evaluated, frame parameters are reset to their original values."
(window-configuration (current-window-configuration))
(point-marker (point-marker)))
+(defun persp--make-ignore-buffer-rx ()
+ (defvar ido-ignore-buffers)
+ (when ido-ignore-buffers
+ ;; convert a list of regexps to one
+ (rx-to-string (append (list 'or)
+ (mapcar (lambda (rx) `(regexp ,rx))
+ ido-ignore-buffers)))))
+
(defmacro persp-current-buffers ()
- "Return a list of all buffers in the current perspective."
- `(persp-buffers (persp-curr)))
+ "Return a list of all live buffers in the current perspective."
+ `(let ((ignore-rx (persp--make-ignore-buffer-rx)))
+ (cl-loop for buf in (persp-buffers (persp-curr))
+ if (and (buffer-live-p buf)
+ (if ignore-rx
+ (not (string-match-p ignore-rx (buffer-name buf)))
+ t))
+ collect buf)))
(defun persp-is-current-buffer (buf)
"Return T if BUF is in the current perspective."
@@ -1124,14 +1138,9 @@ PERSP-SET-IDO-BUFFERS)."
(interactive "P")
(unless (featurep 'bs)
(user-error "bs not loaded"))
- (defvar ido-ignore-buffers)
(defvar bs-configurations)
(declare-function bs--show-with-configuration "bs.el")
- (let* ((ignore-rx (when ido-ignore-buffers
- ;; convert a list of regexps to one
- (rx-to-string (append (list 'or)
- (mapcar (lambda (rx) `(regexp ,rx))
- ido-ignore-buffers)))))
+ (let* ((ignore-rx (persp--make-ignore-buffer-rx))
(bs-configurations (append bs-configurations
(list `("perspective" nil nil
,ignore-rx persp-buffer-filter nil))