Subject: Re: bug#71883: [PATCH] Fix tab-bar-auto-width with customized tab-bar-tab-face-function

From: Ship Mints <[email-masked]>
Date: Tue, 2 Jul 2024 09:42:42 -0400

I like both ideas. Supporting t seems idiomatic. `activities' could add its
face to the list, or a user in her configuration via documentation.

On Tue, Jul 2, 2024 at 2:59 AM Juri Linkov <[email-masked]> wrote:

> > The function tab-bar-auto-width determines which tabs to automatically
> > resize based on the face applied to each tab's text.  If the face is one
> > of tab-bar-auto-width-faces, then the tab gets resized.  However, if
> > either tab-bar-tab-face-function or tab-bar-tab-group-face-function is
> > set to a function which does not apply one of tab-bar-auto-width-faces,
> > then the tabs which have a different face are not auto resized.
> >
> > A real-world example of this issue is in activities.el:
> >
> > https://github.com/alphapapa/activities.el/issues/76
>
> Thanks for the request.
>
> Maybe activities.el could add its face to tab-bar-auto-width-faces?
>
> 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.
>
> > 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.
>
> > @@ -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.
>