]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/tab-bar.el: Improve tab-bar-auto-width-predicate-default (bug#71883).
authorJuri Linkov <juri@linkov.net>
Mon, 19 Aug 2024 16:56:31 +0000 (19:56 +0300)
committerEshel Yaron <me@eshelyaron.com>
Tue, 20 Aug 2024 14:12:44 +0000 (16:12 +0200)
(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)

lisp/tab-bar.el

index eb80e2c95fb64ab365893d9a53e777740ab4cbeb..0eb00ec9e9049f71da64d20b4a8c2f5e9b569c29 100644 (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.