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: Mon, 15 Jul 2024 22:12:46 -0700 Message-ID: <87a5ihgii9.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> 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="26393"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Adam Porter , 71883@debbugs.gnu.org, Ship Mints To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jul 16 23:01:27 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 1sTpIc-0006ig-35 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 16 Jul 2024 23:01:26 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTpIE-0002Fx-4A; Tue, 16 Jul 2024 17:01:02 -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 1sTpIB-0002Fk-Mf for bug-gnu-emacs@gnu.org; Tue, 16 Jul 2024 17:01:00 -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 1sTpIB-0001DW-Ca for bug-gnu-emacs@gnu.org; Tue, 16 Jul 2024 17:00:59 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sTpIE-0003o2-2r for bug-gnu-emacs@gnu.org; Tue, 16 Jul 2024 17:01: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: Tue, 16 Jul 2024 21:01: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.172116361914567 (code B ref 71883); Tue, 16 Jul 2024 21:01:02 +0000 Original-Received: (at 71883) by debbugs.gnu.org; 16 Jul 2024 21:00:19 +0000 Original-Received: from localhost ([127.0.0.1]:34505 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sTpHW-0003mt-L5 for submit@debbugs.gnu.org; Tue, 16 Jul 2024 17:00:19 -0400 Original-Received: from out-176.mta1.migadu.com ([95.215.58.176]:16065) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sTpHT-0003mf-Pq for 71883@debbugs.gnu.org; Tue, 16 Jul 2024 17:00:17 -0400 X-Envelope-To: juri@linkov.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1721163605; 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=L8C7L4Kisd1qXinJjyCHOwhzHKdiAiPnKBMBh9Zldvs=; b=kdSDCC9pU1zbtWwncm2ACSMLhir9yrEg8oyWSFIJ0v9zgRVHBNmfM5icmGSgJy7e5K40f4 LXl0Io3btTzyN2ycHvrGHmxN+DBerY1hBpVV06Q3CBGJZapj5ZZnB376lC05D6rikufHnH HW+C/tSVXqfg5kdQdwlJBgewhFa/YWQ= X-Envelope-To: adam@alphapapa.net X-Envelope-To: 71883@debbugs.gnu.org X-Envelope-To: shipmints@gmail.com X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. In-Reply-To: <86o77dox54.fsf@mail.linkov.net> (Juri Linkov's message of "Thu, 04 Jul 2024 20:57:23 +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:288894 Archived-At: --=-=-= Content-Type: text/plain Juri Linkov writes: > Let's see what Joseph and Stephane think. Please see the attached patches, where the first three commits are intended to be applied to the emacs-30 branch, and the final commit removes the obsolete `tab-bar-auto-width-faces' on master. Does this change warrant a NEWS entry? 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 ca66acf2a4ded69e07a796d3feb1906072c20e6c 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 on Emacs 31 or later. --- lisp/tab-bar.el | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index 66fb9490ce8..86259f36df5 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,10 @@ 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 (if (version<= "31" emacs-version) + (run-hook-with-args-until-success 'tab-bar-auto-width-functions item) + (memq (get-text-property 0 'face (nth 2 item)) + tab-bar-auto-width-faces)) (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 89c7c43219569df5d78a3677aeff7f5e20d83330 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 86259f36df5..853f487743d 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-Remove-obsolete-tab-bar-auto-width-faces.patch >From fa939a20ad4752bdf6d591b09ec69e14981aa714 Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Mon, 15 Jul 2024 22:07:22 -0700 Subject: [PATCH 4/4] Remove obsolete tab-bar-auto-width-faces * lisp/tab-bar.el (tab-bar-auto-width-faces): Remove. (tab-bar-auto-width): Only run tab-bar-auto-width-functions. --- lisp/tab-bar.el | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index 853f487743d..57ea78414bc 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -1216,13 +1216,6 @@ 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 - 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 @@ -1263,10 +1256,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 (if (version<= "31" emacs-version) - (run-hook-with-args-until-success 'tab-bar-auto-width-functions item) - (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 --=-=-=--