From: Juri Linkov Date: Mon, 19 Aug 2024 16:56:31 +0000 (+0300) Subject: * lisp/tab-bar.el: Improve tab-bar-auto-width-predicate-default (bug#71883). X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c1b41a7a8f2bccb3bb2dcbaea1571f174e706d93;p=emacs.git * 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. (cherry picked from commit 60da504cf7ca2c95ab4e3bea10875271b15a5a45) --- diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index eb80e2c95fb..0eb00ec9e90 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -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.