From bb43055ef08049fa3a1694b7769adbade762c17d Mon Sep 17 00:00:00 2001 From: Phil Sainty Date: Thu, 1 Jan 2026 21:28:59 +1300 Subject: [PATCH] Support the `reusable-frames' value 0 for `display-buffer-in-tab' * lisp/tab-bar.el (tab-bar--reusable-frames): Implement support for the `reusable-frames' value 0, for better consistency with other buffer display actions. (bug#80092) --- doc/lispref/windows.texi | 2 ++ lisp/tab-bar.el | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi index dd0d925ed7e..09d58c17c01 100644 --- a/doc/lispref/windows.texi +++ b/doc/lispref/windows.texi @@ -3580,6 +3580,8 @@ which already displays the buffer. The possible values of means consider all existing frames. @item @code{visible} means consider all visible frames. +@item 0 +means consider all frames on the current terminal. @item A frame means consider that frame only. @item Any other non-@code{nil} value diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index 5c63de5e39f..f9df4110757 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -2865,9 +2865,20 @@ with those specified by the selected window configuration." (defun tab-bar--reusable-frames (all-frames) + "Process the `reusable-frames' buffer display action alist entry. +Return a frame list. Used with the `display-buffer-in-tab' action." (cond ((eq all-frames t) (frame-list)) ((eq all-frames 'visible) (visible-frame-list)) + ;; The standard behavior for a `reusable-frames' value of 0 is implemented in + ;; candidate_window_p() in window.c, and we have to go via `window-list-1' to + ;; utilize this. We list the selected frame first. + ((eq all-frames 0) (let (frames) + (dolist (w (window-list-1 nil nil 0)) + (let ((f (window-frame w))) + (unless (memq f frames) + (push f frames)))) + (nreverse frames))) ((framep all-frames) (list all-frames)) (t (list (selected-frame))))) @@ -2883,6 +2894,9 @@ The optional argument ALL-FRAMES specifies the frames to consider: - `visible' means consider all tabs on all visible frames. +- 0 (the number zero) means consider all tabs on all visible and + iconified frames. + - A frame means consider all tabs on that frame only. - Any other value of ALL-FRAMES means consider all tabs on the @@ -2941,6 +2955,7 @@ displays BUFFER. The possible values of `reusable-frames' are: t -- all existing frames; `visible' -- all visible frames; + 0 -- all frames on the current terminal; A frame -- that frame only; Any other non-nil value -- the selected frame; nil -- do not search any frames (equivalent to omitting the entry).