diff options
| author | Matthew White <mehw.is.me@inventati.org> | 2021-07-30 23:22:47 +0000 |
|---|---|---|
| committer | Matthew White <mehw.is.me@inventati.org> | 2021-10-20 23:01:53 +0200 |
| commit | 6f10a7a879e0e3d9c62d1363d615520fd47efcb9 (patch) | |
| tree | e4cc1550bbbd611aeafaff69c1133f69778ca139 | |
| parent | 6aa369c1ea7694b1dd5a4e1d9cb5f64564e04234 (diff) | |
persp-get-buffers: get a perspective's list of buffers
New utility function to return a perspective's list of buffers for a
specific frame or for the selected one. As argument, accepts a name
or a proper perspective data, if nil or if not given, default to the
current perspective. If a frame is nil or not given, default to the
selected frame.
| -rw-r--r-- | CHANGELOG.md | 5 | ||||
| -rw-r--r-- | perspective.el | 19 |
2 files changed, 24 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 71dbab9..bb46797 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - `persp-test-with-persp`: verify that a `*scratch* (NAME)` buffer exists before killing it. +### Added + +- `persp-get-buffers`: get any perspective's list of buffers. + + ### Fixed - Added a workaround for potential problems caused by recursive minibuffer use. diff --git a/perspective.el b/perspective.el index cc7be51..85f37e5 100644 --- a/perspective.el +++ b/perspective.el @@ -933,6 +933,25 @@ copied across frames." (let ((persp (gethash name (perspectives-hash)))) (if persp (cl-return-from persp-all-get (persp-buffers persp)))))))) +(defun persp-get-buffers (&optional persp-or-name frame) + "Return the list of PERSP-OR-NAME buffers in FRAME. +If PERSP-OR-NAME isn't given or nil use the current perspective. +If FRAME isn't nil, fetch PERSP-OR-NAME in FRAME, otherwise stay +in the selected frame. + +Uses `persp-current-buffers' as backhand. + +See also `persp-all-get' to get buffers from all frames." + (let ((name (if (stringp persp-or-name) + persp-or-name + (persp-name (or persp-or-name (persp-curr))))) + buffers) + (with-selected-frame (or frame (selected-frame)) + (when (member name (persp-names)) + (with-perspective name + (setq buffers (persp-current-buffers))))) + buffers)) + (defun persp-read-buffer (prompt &optional def require-match predicate) "A replacement for the built-in `read-buffer', meant to be used with `read-buffer-function'. Return the name of the buffer selected, only selecting from buffers |
