* lisp/tab-bar.el: Improve tab-bar-auto-width-predicate-default (bug#71883).

(tab-bar--auto-width-faces-default): New variable with the
value from the default value of tab-bar-auto-width-faces.
(tab-bar-auto-width-faces): Set the default value to
tab-bar--auto-width-faces-default.
(tab-bar-auto-width-predicate-default): For backwards-compatibility
use the old logic of checking tab-bar-auto-width-faces when its value
was changed.  Otherwise, check for a symbol, but remove "current-group"
from the list of symbols.
This commit is contained in:
Juri Linkov 2024-08-19 19:56:31 +03:00
parent 9ed761a793
commit 60da504cf7

View file

@ -1238,18 +1238,24 @@ which see.
It's not recommended to change this value since with larger values, the
tab bar might wrap to the second line when it shouldn't.")
(defvar tab-bar-auto-width-faces
(defconst tab-bar--auto-width-faces-default
'( tab-bar-tab tab-bar-tab-inactive
tab-bar-tab-ungrouped
tab-bar-tab-group-inactive)
tab-bar-tab-group-inactive))
(defvar tab-bar-auto-width-faces
tab-bar--auto-width-faces-default
"Resize tabs only with these faces.")
(defun tab-bar-auto-width-predicate-default (item)
"Accepts tab ITEM and returns non-nil for tabs and tab groups."
(string-match-p
;; (rx bos (or "current-tab" "current-group" "tab-" "group-"))
"\\`\\(?:current-\\(?:group\\|tab\\)\\|\\(?:group\\|tab\\)-\\)"
(symbol-name (nth 0 item))))
(if (eq tab-bar-auto-width-faces tab-bar--auto-width-faces-default)
(string-match-p
;; (rx bos (or "current-tab" "tab-" "group-"))
"\\`\\(?:current-tab\\|\\(?:group\\|tab\\)-\\)"
(symbol-name (nth 0 item)))
(memq (get-text-property 0 'face (nth 2 item))
tab-bar-auto-width-faces)))
(defvar tab-bar-auto-width-functions '(tab-bar-auto-width-predicate-default)
"List of functions for `tab-bar-auto-width' to call with a tab ITEM.