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 16:00:10 -0700 Message-ID: <87a5i5dqmd.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> <87ikwttk96.fsf@breatheoutbreathe.in> <861q3h47ci.fsf@gnu.org> 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="16055"; mail-complaints-to="usenet@ciao.gmane.io" Cc: adam@alphapapa.net, 71883@debbugs.gnu.org, shipmints@gmail.com, juri@linkov.net To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 26 01:01: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 1sX7Se-000439-MU for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 26 Jul 2024 01:01:24 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sX7SC-0002TJ-F4; Thu, 25 Jul 2024 19:00:56 -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 1sX7SA-0002Sg-UW for bug-gnu-emacs@gnu.org; Thu, 25 Jul 2024 19:00: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 1sX7SA-0004EF-MU for bug-gnu-emacs@gnu.org; Thu, 25 Jul 2024 19:00:54 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sX7SH-0005Iy-UR for bug-gnu-emacs@gnu.org; Thu, 25 Jul 2024 19:01:01 -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 23:01:01 +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.172194843320344 (code B ref 71883); Thu, 25 Jul 2024 23:01:01 +0000 Original-Received: (at 71883) by debbugs.gnu.org; 25 Jul 2024 23:00:33 +0000 Original-Received: from localhost ([127.0.0.1]:37991 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sX7Ro-0005I4-LS for submit@debbugs.gnu.org; Thu, 25 Jul 2024 19:00:33 -0400 Original-Received: from out-186.mta1.migadu.com ([95.215.58.186]:42402) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sX7Rl-0005Hn-F6 for 71883@debbugs.gnu.org; Thu, 25 Jul 2024 19:00:31 -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=1721948415; 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=/r9DxQ/1Hxrb8Vnp4P7O+1lL4NScZgeGWOK8ikfBM3A=; b=OnqFSATczQc9R2c9AX/Do2BtOMD0vgVxu8zl4/kn+LG/HOFVdVEOpgeDGfBcPptsJVqzdc XANiYNDrAQcU37r4GDXGgxzK/6LVA3SUdAq1AjzmaYOMKkcYd844/AWckK2S2gKw+0COFm hHnuuVh0khMPcXDlCoWaDEl4VZXfHHg= In-Reply-To: <861q3h47ci.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 25 Jul 2024 22:09:01 +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:289341 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: Joseph Turner >> Cc: Eli Zaretskii , adam@alphapapa.net, >> 71883@debbugs.gnu.org, shipmints@gmail.com >> Date: Thu, 25 Jul 2024 11:11:01 -0700 >> >> +** 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 first line should be a single complete sentence. Thanks! See patches. --=-=-= 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 7e63ee64297e1f8fdb161654d17516bfdb6eb527 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..078573dd654 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 auto-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 --=-=-=--