branch: externals/bufferlo
commit a8204c88c28436893d6a4c2b1e314bcd533ae789
Author: Stéphane Marks <[email protected]>
Commit: Flo Rommel <[email protected]>
Handle nil 'buffer-list frame-parameter in buffer predicates
This addresses the situation where there are no bufferlo local
buffers and the user has not yet actively selected a buffer
window. For the sake of completness, both the bufferlo frame
parameter 'buffer-predicate function and
'switch-to-prev-buffer-skip-p' function now treat a passed
buffer as local when 'buffer-list is nil.
---
bufferlo.el | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/bufferlo.el b/bufferlo.el
index f275f52bce..7f8afd79e3 100644
--- a/bufferlo.el
+++ b/bufferlo.el
@@ -1361,9 +1361,14 @@ before calling OLDFN with ARGS. See
`bufferlo--clear-buffer-lists'."
;; (funcall skip window buffer bury-or-kill)
(defun bufferlo--switch-to-prev-buffer-skip-p (_window buffer _bury-or-kill)
"Restrict BUFFER to the current tab's locals for buffer switching.
-Affects `switch-to-prev-buffer' and `switch-to-next-buffer'.
-Includes hidden buffers."
- (not (bufferlo-local-buffer-p buffer nil (tab-bar--current-tab-index) t)))
+Return non-nil if `switch-to-prev-buffer' (and and
+`switch-to-next-buffer') should skip BUFFER. Includes hidden buffers.
+
+If the frame parameter \\='buffer-list is nil, hence it has no local
+buffers, do not skip."
+ (if (frame-parameter nil 'buffer-list)
+ (not (bufferlo-local-buffer-p buffer nil (tab-bar--current-tab-index) t))
+ nil))
(defvar bufferlo--switch-to-prev-buffer-skip-orig)
@@ -1378,8 +1383,13 @@ Includes hidden buffers."
(defun bufferlo--buffer-predicate (buffer)
"Return whether BUFFER is local to the current frame/tab.
-Includes hidden buffers."
- (bufferlo-local-buffer-p buffer nil nil t))
+Includes hidden buffers.
+
+If the frame parameter \\='buffer-list is nil, hence it has no local
+buffers, treat BUFFER as local."
+ (if (frame-parameter nil 'buffer-list)
+ (bufferlo-local-buffer-p buffer nil nil t)
+ t))
(defun bufferlo--set-buffer-predicate (frame)
"Set the buffer predicate of FRAME to `bufferlo--buffer-predicate'."