Add more ways to exclude buffers in tab-line-mode. (Bug#78988)

* etc/NEWS: Announce changes.
* lisp/tab-line.el (tab-line-exclude-buffer): New user option.
(tab-line-mode--turn-on): Update conditions.
This commit is contained in:
Elías Gabriel Pérez 2025-07-10 16:40:34 -06:00 committed by Juri Linkov
parent 15570b7b95
commit 6053a7f1a4
2 changed files with 35 additions and 1 deletions

View file

@ -412,6 +412,12 @@ on the tab line to a different position.
*** New command 'tab-line-close-other-tabs'. *** New command 'tab-line-close-other-tabs'.
It is bound to the tab's context menu item "Close other tabs". It is bound to the tab's context menu item "Close other tabs".
---
*** New user option 'tab-line-exclude-buffers'.
This user option controls where 'tab-line-mode' should not be enabled in
a buffer. The value must be a condition which is passed to
'buffer-match-p'.
** Project ** Project
--- ---

View file

@ -1245,11 +1245,38 @@ button, so you could have one more buffer shown on the tab line."
'(completion-list-mode) '(completion-list-mode)
"List of major modes for which the tab-line display is not enabled. "List of major modes for which the tab-line display is not enabled.
Buffers under any of these major modes will not show the tab line in Buffers under any of these major modes will not show the tab line in
their windows, even if `global-tab-line-mode' is enabled." their windows, even if `global-tab-line-mode' is enabled.
See also `tab-line-exclude-buffers', for exclude buffers."
:type '(repeat symbol) :type '(repeat symbol)
:group 'tab-line :group 'tab-line
:version "27.1") :version "27.1")
(defcustom tab-line-exclude-buffers nil
"Whether tab-line should not be enabled in a buffer.
The value must be a condition which is passed to `buffer-match-p' (which
see).
You can include multiple conditions, for example:
To exclude multiple modes and buffer names:
\='(or \"\\*eshell\\*\"
(derived-mode completion-list-mode
eshell-mode
term-mode
...)
...)
If the condition yields a non-nil value, tab line will not be enabled in
those buffers.
See also `tab-line-exclude-modes', for only exclude major modes."
:type '(buffer-predicate :tag "Predicate for `buffer-match-p'")
:safe #'booleanp
:group 'tab-line
:version "31.1")
;;;###autoload ;;;###autoload
(defvar-local tab-line-exclude nil) (defvar-local tab-line-exclude nil)
@ -1263,6 +1290,7 @@ of `tab-line-exclude', are exempt from `tab-line-mode'."
(unless (or (minibufferp) (unless (or (minibufferp)
(string-match-p "\\` " (buffer-name)) (string-match-p "\\` " (buffer-name))
(memq major-mode tab-line-exclude-modes) (memq major-mode tab-line-exclude-modes)
(buffer-match-p tab-line-exclude-buffers (buffer-name))
(get major-mode 'tab-line-exclude) (get major-mode 'tab-line-exclude)
(buffer-local-value 'tab-line-exclude (current-buffer))) (buffer-local-value 'tab-line-exclude (current-buffer)))
(tab-line-mode 1))) (tab-line-mode 1)))