From: Joseph Turner via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Juri Linkov <juri@linkov.net>
Cc: Adam Porter <adam@alphapapa.net>,
71883@debbugs.gnu.org, Ship Mints <shipmints@gmail.com>
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 [thread overview]
Message-ID: <87a5ihgii9.fsf@breatheoutbreathe.in> (raw)
In-Reply-To: <86o77dox54.fsf@mail.linkov.net> (Juri Linkov's message of "Thu, 04 Jul 2024 20:57:23 +0300")
[-- Attachment #1: Type: text/plain, Size: 336 bytes --]
Juri Linkov <juri@linkov.net> 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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Use-current-group-symbol-for-current-tab-group-item.patch --]
[-- Type: text/x-diff, Size: 858 bytes --]
From 050a574bcab371ee87b1ed6c15e6431a3c2ed4d8 Mon Sep 17 00:00:00 2001
From: Juri Linkov <juri@linkov.net>
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-Add-abnormal-hook-to-determine-which-tabs-to-auto-wi.patch --]
[-- Type: text/x-diff, Size: 2219 bytes --]
From ca66acf2a4ded69e07a796d3feb1906072c20e6c Mon Sep 17 00:00:00 2001
From: Joseph Turner <joseph@breatheoutbreathe.in>
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0003-Mark-tab-bar-auto-width-faces-obsolete.patch --]
[-- Type: text/x-diff, Size: 853 bytes --]
From 89c7c43219569df5d78a3677aeff7f5e20d83330 Mon Sep 17 00:00:00 2001
From: Joseph Turner <joseph@breatheoutbreathe.in>
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #5: 0004-Remove-obsolete-tab-bar-auto-width-faces.patch --]
[-- Type: text/x-diff, Size: 1820 bytes --]
From fa939a20ad4752bdf6d591b09ec69e14981aa714 Mon Sep 17 00:00:00 2001
From: Joseph Turner <joseph@breatheoutbreathe.in>
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
next prev parent reply other threads:[~2024-07-16 5:12 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
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 [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a5ihgii9.fsf@breatheoutbreathe.in \
--to=bug-gnu-emacs@gnu.org \
--cc=71883@debbugs.gnu.org \
--cc=adam@alphapapa.net \
--cc=joseph@breatheoutbreathe.in \
--cc=juri@linkov.net \
--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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.