From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Joseph Turner via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#71883: [PATCH] Fix tab-bar-auto-width with customized tab-bar-tab-face-function Date: Thu, 25 Jul 2024 11:11:01 -0700 Message-ID: <87ikwttk96.fsf@breatheoutbreathe.in> References: <87le2kaloz.fsf@breatheoutbreathe.in> <861q4ce1yb.fsf@mail.linkov.net> <877ce3damx.fsf@breatheoutbreathe.in> <86r0cb7l58.fsf@mail.linkov.net> <5aff3095-087f-493d-9251-8048b51280f9@alphapapa.net> <86msmzc7ne.fsf@mail.linkov.net> <86o77dox54.fsf@mail.linkov.net> <87a5ihgii9.fsf@breatheoutbreathe.in> <86jzhkgtb7.fsf@gnu.org> <865xt1lw66.fsf@mail.linkov.net> Reply-To: Joseph Turner Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12966"; mail-complaints-to="usenet@ciao.gmane.io" Cc: adam@alphapapa.net, 71883@debbugs.gnu.org, Eli Zaretskii , shipmints@gmail.com To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jul 25 20:12:24 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 1sX2wv-0003A6-Sh for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 25 Jul 2024 20:12:21 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sX2wX-0004sg-Jr; Thu, 25 Jul 2024 14:11:57 -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 1sX2wV-0004sP-CQ for bug-gnu-emacs@gnu.org; Thu, 25 Jul 2024 14:11:55 -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 1sX2wV-0008MU-2s for bug-gnu-emacs@gnu.org; Thu, 25 Jul 2024 14:11:55 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sX2wc-0003Ab-CW for bug-gnu-emacs@gnu.org; Thu, 25 Jul 2024 14:12:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Joseph Turner Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 25 Jul 2024 18:12: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.172193108612138 (code B ref 71883); Thu, 25 Jul 2024 18:12:02 +0000 Original-Received: (at 71883) by debbugs.gnu.org; 25 Jul 2024 18:11:26 +0000 Original-Received: from localhost ([127.0.0.1]:37732 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sX2w1-00039g-Gr for submit@debbugs.gnu.org; Thu, 25 Jul 2024 14:11:26 -0400 Original-Received: from out-180.mta0.migadu.com ([91.218.175.180]:53708) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sX2vy-00039M-QJ for 71883@debbugs.gnu.org; Thu, 25 Jul 2024 14:11:23 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1721931066; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=In/odr5Si9AYIzXF2UV+4B9Lty/pURJxo6cTA8XQZQg=; b=Z/cDTyZKHK5NkM3jhz8S9P49lf+imPKtEsGloxHzD5Kn9Cyai3AWZh4J5xnTPMGmy/2d9V f4Mgf3c4xQ3PH6yYXEAxKIGycQZiCRI1tocd0kRI40mATZhTP/R9AiRcTij7ee+6YGmMVP BFL8Sj8cv2j0rZxVlpNY03y5IASk7PE= In-Reply-To: <865xt1lw66.fsf@mail.linkov.net> (Juri Linkov's message of "Fri, 19 Jul 2024 09:42:41 +0300") X-Migadu-Flow: FLOW_OUT 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:289325 Archived-At: --=-=-= Content-Type: text/plain Juri Linkov writes: >> I'm not sure I understand why they need to be installed on emacs-30. >> Is this a regression in Emacs 29 or Emacs 30? What bad things will >> happen if we install the changes on master instead> No regression. > Replacing hard-coded logic with customizable variable > for external packages like activities.el is needed > as soon as possible on emacs-30 because hard-coded logic > hinders the use of packages. > > However, there is no hurry to change the default behavior > to match a symbol name instead of checking face names. > Therefore I think better to move the existing code > > (memq (get-text-property 0 'face (nth 2 item)) tab-bar-auto-width-faces) > > to the new predicate function on emacs-30. Then activities.el > can change it to another function that matches a symbol. > > Then on master the default body on the new predicate > could be replaced from checking the face to match a symbol. > Also changes in tab-bar--format-tab-group should be on master as well. Much as I'd like to use these changes asap, I think this patchset should go entirely on master. I see these changes as adding functionality (making tab-bar tabs more extensible) rather than bug fixes. >>> Does this change warrant a NEWS entry? >> >> Yes, since you are adding a hook variable. Obsolescence of a variable >> also requires a NEWS entry. Please see attached patches. Thanks! Joseph --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Use-current-group-symbol-for-current-tab-group-item.patch >From 050a574bcab371ee87b1ed6c15e6431a3c2ed4d8 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Mon, 15 Jul 2024 21:23:39 -0700 Subject: [PATCH 1/4] Use current-group symbol for current tab group item * lisp/tab-bar.el (tab-bar--format-tab-group): --- lisp/tab-bar.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- 2.41.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-Add-abnormal-hook-to-determine-which-tabs-to-auto-wi.patch >From f85b67595b91f90fdd96231d18b73edcf96c30be Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Mon, 15 Jul 2024 21:55:35 -0700 Subject: [PATCH 2/4] Add abnormal hook to determine which tabs to auto-widen * lisp/tab-bar.el (tab-bar-auto-width-predicate-default): Default value for tab-bar-auto-width-functions. (tab-bar-auto-width-functions): New abnormal hook. (tab-bar-auto-width): Run new abnormal hook until success instead of comparing text properties. --- lisp/tab-bar.el | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index 66fb9490ce8..9ad59339aa1 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -1222,6 +1222,18 @@ tab-bar-auto-width-faces tab-bar-tab-group-inactive) "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)))) + +(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. +If any of these functions returns non-nil for a given tab ITEM, that +tab's width will be auto-sized.") + (defvar tab-bar--auto-width-hash nil "Memoization table for `tab-bar-auto-width'.") @@ -1250,8 +1262,7 @@ tab-bar-auto-width (width 0)) ;; resize tab names to this width (dolist (item items) (when (and (eq (nth 1 item) 'menu-item) (stringp (nth 2 item))) - (if (memq (get-text-property 0 'face (nth 2 item)) - tab-bar-auto-width-faces) + (if (run-hook-with-args-until-success 'tab-bar-auto-width-functions item) (push item tabs) (unless (eq (nth 0 item) 'align-right) (setq non-tabs (concat non-tabs (nth 2 item))))))) -- 2.41.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0003-Mark-tab-bar-auto-width-faces-obsolete.patch >From f4419f46ab96476537fe377baf5950bb8ef22b83 Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Mon, 15 Jul 2024 22:05:40 -0700 Subject: [PATCH 3/4] Mark tab-bar-auto-width-faces obsolete * lisp/tab-bar.el: (tab-bar-auto-width-faces) Obsolete on >=30. --- lisp/tab-bar.el | 1 + 1 file changed, 1 insertion(+) diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index 9ad59339aa1..503df82539d 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -1216,6 +1216,7 @@ tab-bar-auto-width-min 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.") +(make-obsolete-variable 'tab-bar-auto-width-faces 'tab-bar-auto-width-functions "30") (defvar tab-bar-auto-width-faces '( tab-bar-tab tab-bar-tab-inactive tab-bar-tab-ungrouped -- 2.41.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0004-etc-NEWS-Announce-tab-bar-auto-width-functions.patch >From 1d677b03e1ebb38b8287adf1a6cc4fe5ab4712b2 Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Thu, 25 Jul 2024 10:58:38 -0700 Subject: [PATCH 4/4] ; * etc/NEWS: Announce tab-bar-auto-width-functions --- etc/NEWS | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/etc/NEWS b/etc/NEWS index 5c08bc7550f..300b79c50b2 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -30,6 +30,14 @@ applies, and please also update docstrings as needed. * Changes in Emacs 31.1 +** Tab Bars and Tab Lines + +*** New abnormal hook 'tab-bar-auto-width-functions'. This hook +allows you to control which tab-bar tabs are automatically resized. + +*** The 'tab-bar-auto-width-faces' variable is now obsolete. +Use 'tab-bar-auto-width-functions' instead. + * Editing Changes in Emacs 31.1 -- 2.41.0 --=-=-=--