unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Joseph Turner <joseph@breatheoutbreathe.in>
Cc: 71883@debbugs.gnu.org, Adam Porter <adam@alphapapa.net>,
	Ship Mints <shipmints@gmail.com>
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	[thread overview]
Message-ID: <86r0cb7l58.fsf@mail.linkov.net> (raw)
In-Reply-To: <877ce3damx.fsf@breatheoutbreathe.in> (Joseph Turner's message of "Tue, 02 Jul 2024 09:25:10 -0700")

>> 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	other threads:[~2024-07-02 17:34 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-01 20:42 bug#71883: [PATCH] Fix tab-bar-auto-width with customized tab-bar-tab-face-function Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-02  6:55 ` Juri Linkov
2024-07-02 13:42   ` Ship Mints
2024-07-02 16:25   ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-02 17:34     ` Juri Linkov [this message]
2024-07-02 23:10       ` Adam Porter
2024-07-03  6:27         ` Juri Linkov
2024-07-03 19:50           ` Adam Porter
2024-07-04 17:57             ` Juri Linkov
2024-07-04 21:11               ` Ship Mints
2024-07-16  5:12               ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-17 11:18                 ` Eli Zaretskii
2024-07-19  6:42                   ` Juri Linkov
2024-07-25 18:11                     ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-25 18:18                       ` Juri Linkov
2024-07-25 18:52                         ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-25 19:09                       ` Eli Zaretskii
2024-07-25 23:00                         ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-06  6:59                           ` Juri Linkov
2024-08-09 12:15                             ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-09 12:25                             ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-19 16:57                               ` Juri Linkov
2024-08-20  1:49                                 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-20  6:40                                   ` Juri Linkov
2024-08-20  7:11                                     ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86r0cb7l58.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=71883@debbugs.gnu.org \
    --cc=adam@alphapapa.net \
    --cc=joseph@breatheoutbreathe.in \
    --cc=shipmints@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).