bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#71883: [PATCH] Fix tab-bar-auto-width with customized tab-bar-tab-fa


From: Juri Linkov
Subject: bug#71883: [PATCH] Fix tab-bar-auto-width with customized tab-bar-tab-face-function
Date: Tue, 02 Jul 2024 20:34:43 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu)

>> If not, then what about allowing tab-bar-auto-width-faces to have
>> the value t that means that all tabs should be resized regardless of
>> what faces they have.
>
> Would you be willing to send a patch with this idea?

Probably this is not needed after implementing a variable with
a predicate function, since it could be set to 'always' to return t.

Then activities.el could set this to a function that checks for a symbol.

>>> In the proposed patch, instead of checking each tab's face, we check
>>> that the symbol at the start of each tab keymap matches
>>>
>>> (rx bos (or "current-tab" "tab-" "group-"))
>>
>>> -(defvar tab-bar-auto-width-faces
>>> -  '( tab-bar-tab tab-bar-tab-inactive
>>> -     tab-bar-tab-ungrouped
>>> -     tab-bar-tab-group-inactive)
>>> -  "Resize tabs only with these faces.")
>>
>> Sorry, we can't remove the existing variable to not break user
>> configs.
>
> You're right.

But we could deprecate tab-bar-auto-width-faces in Emacs 30,
and in Emacs 31 replace it with a function that matches a symbol name
like in your patch.  Then users will have time to get the function into use.

>>> @@ -1250,8 +1244,8 @@ tab-bar-auto-width
>>> -        (if (memq (get-text-property 0 'face (nth 2 item))
>>> -                  tab-bar-auto-width-faces)
>>> +        (if (string-match-p "\\`\\(?:current-tab\\|\\(?:group\\|tab\\)-\\)"
>>> +                            (symbol-name (nth 0 item)))
>>
>> Matching the symbol name with the hard-coded regexp doesn't look right.
>> Maybe better to add a new variable that contains a predicate function?
>> When it returns t then resize.
>
> What would be passed to the predicate function?

I think only 'item' should be passed to the function,
there is no other useful information here.

Then in Emacs 30 this function could check for a face name
in (nth 2 item), and in Emacs 31 a symbol name in (nth 0 item).

But only if a symbol name covers all cases currently supported
by the face name.  Let's see with the face->symbol mapping:

  tab-bar-tab -> current-tab
  tab-bar-tab-inactive -> tab-N
  tab-bar-tab-ungrouped -> tab-N, unfortunately there is no separate symbol
  tab-bar-tab-group-inactive -> group-N
  tab-bar-tab-group-current -> there is no current-group, but this could be 
added:

diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index edec6543a82..66fb9490ce8 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -1044,7 +1044,7 @@ tab-bar--format-tab-group
 when the tab is current.  Return the result as a keymap."
   (append
    `((,(intern (format "sep-%i" i)) menu-item ,(tab-bar-separator) ignore))
-   `((,(intern (format "group-%i" i))
+   `((,(intern (if current-p "current-group" (format "group-%i" i)))
       menu-item
       ,(if current-p
            (condition-case nil





reply via email to

[Prev in Thread] Current Thread [Next in Thread]