From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs 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 Organization: LINKOV.NET Message-ID: <86r0cb7l58.fsf@mail.linkov.net> References: <87le2kaloz.fsf@breatheoutbreathe.in> <861q4ce1yb.fsf@mail.linkov.net> <877ce3damx.fsf@breatheoutbreathe.in> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37583"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) Cc: 71883@debbugs.gnu.org, Adam Porter , Ship Mints To: Joseph Turner Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jul 02 19:40:49 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sOhUn-0009bV-Pd for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 02 Jul 2024 19:40:49 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sOhUK-0003QM-Cq; Tue, 02 Jul 2024 13:40:20 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sOhU1-0003MY-5H for bug-gnu-emacs@gnu.org; Tue, 02 Jul 2024 13:40:07 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOhU0-0003MK-T7 for bug-gnu-emacs@gnu.org; Tue, 02 Jul 2024 13:40:00 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sOhU2-00054w-3i for bug-gnu-emacs@gnu.org; Tue, 02 Jul 2024 13:40:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 02 Jul 2024 17:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71883 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 71883-submit@debbugs.gnu.org id=B71883.171994194519448 (code B ref 71883); Tue, 02 Jul 2024 17:40:02 +0000 Original-Received: (at 71883) by debbugs.gnu.org; 2 Jul 2024 17:39:05 +0000 Original-Received: from localhost ([127.0.0.1]:37628 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sOhT7-00053a-5C for submit@debbugs.gnu.org; Tue, 02 Jul 2024 13:39:05 -0400 Original-Received: from relay4-d.mail.gandi.net ([217.70.183.196]:35487) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sOhT4-000532-KX for 71883@debbugs.gnu.org; Tue, 02 Jul 2024 13:39:03 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 7AE9FE0002; Tue, 2 Jul 2024 17:38:50 +0000 (UTC) In-Reply-To: <877ce3damx.fsf@breatheoutbreathe.in> (Joseph Turner's message of "Tue, 02 Jul 2024 09:25:10 -0700") X-GND-Sasl: juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:288292 Archived-At: >> 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