* bug#60073: 30.0.50; [PATCH] Tab bar group format not applied to current
@ 2022-12-14 20:16 Gabriel
2022-12-15 15:04 ` Gabriel
2022-12-15 18:05 ` Juri Linkov
0 siblings, 2 replies; 4+ messages in thread
From: Gabriel @ 2022-12-14 20:16 UTC (permalink / raw)
To: 60073
[-- Attachment #1: Type: text/plain, Size: 1145 bytes --]
Description:
The user option 'tab-bar-tab-group-format-function' is not applied to
current group tab, only to other group tabs. I suspect this is not
intentional and could be fixed by the attached patch.
Steps:
1) emacs -Q (master "42c757913a4c6acc07f8904df7def6b720bb23b4")
2) Enable tab bar and create some tabs and groups:
(progn
(tab-bar-mode 1)
(tab-bar-change-tab-group "group1")
(tab-new)
(tab-bar-change-tab-group "group2")
(tab-new)
(tab-bar-change-tab-group "group2")
(tab-new)
(tab-bar-change-tab-group "group3"))
3) Set a custom function to format group tabs:
(progn
(defun my-tab-bar-group-format (tab i)
(format "<%s (%s)>"
(funcall tab-bar-tab-group-function tab)
i))
(setopt tab-bar-format '(tab-bar-format-tabs-groups)
tab-bar-tab-group-format-function 'my-tab-bar-group-format))
4) Change tabs a couple of times with 'C-x t o' ('tab-next')
Result: The 'tab-bar-tab-group-format-function' is not applied to format
the current group tab, only to other group tabs. See attach patch for a
proposed fix. If this behavior is intentional, I propose to update the
doc string.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-incorrect-format-of-current-tab-bar-group.patch --]
[-- Type: text/x-diff, Size: 996 bytes --]
From da2025d524da5b76e4f2bc81d51899d9b798888c Mon Sep 17 00:00:00 2001
From: Gabriel do Nascimento Ribeiro <gabriel376@hotmail.com>
Date: Wed, 14 Dec 2022 17:10:28 -0300
Subject: [PATCH 1/1] Fix incorrect format of current tab bar group
* lisp/tab-bar.el (tab-bar--format-tab-group): Make proper use of
'tab-bar--format-tab-group' to format the current tab bar 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 162e63fe23..65e424080d 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -882,7 +882,7 @@ tab-bar--format-tab-group
`((,(intern (format "group-%i" i))
menu-item
,(if current-p
- (propertize (funcall tab-bar-tab-group-function tab)
+ (propertize (funcall tab-bar-tab-group-format-function tab i)
'face 'tab-bar-tab-group-current)
(funcall tab-bar-tab-group-format-function tab i))
,(if current-p 'ignore
--
2.34.1
[-- Attachment #3: Type: text/plain, Size: 13 bytes --]
---
Gabriel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#60073: 30.0.50; [PATCH] Tab bar group format not applied to current
2022-12-14 20:16 bug#60073: 30.0.50; [PATCH] Tab bar group format not applied to current Gabriel
@ 2022-12-15 15:04 ` Gabriel
2022-12-15 18:04 ` Juri Linkov
2022-12-15 18:05 ` Juri Linkov
1 sibling, 1 reply; 4+ messages in thread
From: Gabriel @ 2022-12-15 15:04 UTC (permalink / raw)
To: 60073
[-- Attachment #1: Type: text/plain, Size: 282 bytes --]
Here is a new patch that also updates the function
'tab-bar-tab-group-format-default'. There are no breaking or functional
changes in how the tab-bar behaves today.
With this patch, the 'tab-bar-tab-group-format-function' behaves
similarly to 'tab-bar-tab-name-format-function'.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Make-tab-bar-tab-group-format-function-also-handle-c.patch --]
[-- Type: text/x-diff, Size: 2615 bytes --]
From 832e6ca6a5ce314e37a840356828c50adb94ebf4 Mon Sep 17 00:00:00 2001
From: Gabriel do Nascimento Ribeiro <gabriel376@hotmail.com>
Date: Thu, 15 Dec 2022 11:58:30 -0300
Subject: [PATCH 1/1] Make tab-bar-tab-group-format-function also handle
current group
* lisp/tab-bar.el (tab-bar--format-tab-group): Call
'tab-bar-tab-group-format-default' to format current group tab.
(tab-bar-tab-group-format-default): Update function to also handle
current group tab.
---
lisp/tab-bar.el | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 162e63fe23..1f25ee6d7e 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -844,8 +844,9 @@ tab-bar-tab-group-default
(defcustom tab-bar-tab-group-format-function #'tab-bar-tab-group-format-default
"Function to format a tab group name.
-Function gets two arguments, a tab with a group name and its number,
-and should return the formatted tab group name to display in the tab bar."
+Function gets three arguments, a tab with a group name, its
+number and an optional t when the tab is current, and should
+return the formatted tab group name to display in the tab bar."
:type 'function
:initialize 'custom-initialize-default
:set (lambda (sym val)
@@ -854,11 +855,13 @@ tab-bar-tab-group-format-function
:group 'tab-bar
:version "28.1")
-(defun tab-bar-tab-group-format-default (tab i)
- (propertize
- (concat (if tab-bar-tab-hints (format "%d " i) "")
- (funcall tab-bar-tab-group-function tab))
- 'face 'tab-bar-tab-group-inactive))
+(defun tab-bar-tab-group-format-default (tab i &optional current-p)
+ (let ((name (concat (if tab-bar-tab-hints (format "%d " i) "")
+ (funcall tab-bar-tab-group-function tab)))
+ (face (if current-p
+ 'tab-bar-tab-group-current
+ 'tab-bar-tab-group-inactive)))
+ (propertize name 'face face)))
(defcustom tab-bar-tab-group-face-function #'tab-bar-tab-group-face-default
"Function to define a tab group face.
@@ -881,10 +884,7 @@ tab-bar--format-tab-group
`((,(intern (format "sep-%i" i)) menu-item ,(tab-bar-separator) ignore))
`((,(intern (format "group-%i" i))
menu-item
- ,(if current-p
- (propertize (funcall tab-bar-tab-group-function tab)
- 'face 'tab-bar-tab-group-current)
- (funcall tab-bar-tab-group-format-function tab i))
+ ,(funcall tab-bar-tab-group-format-function tab i current-p)
,(if current-p 'ignore
(or
(alist-get 'binding tab)
--
2.34.1
[-- Attachment #3: Type: text/plain, Size: 13 bytes --]
---
Gabriel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#60073: 30.0.50; [PATCH] Tab bar group format not applied to current
2022-12-15 15:04 ` Gabriel
@ 2022-12-15 18:04 ` Juri Linkov
0 siblings, 0 replies; 4+ messages in thread
From: Juri Linkov @ 2022-12-15 18:04 UTC (permalink / raw)
To: Gabriel; +Cc: 60073
close 60073 29.0.60
thanks
> Here is a new patch that also updates the function
> 'tab-bar-tab-group-format-default'.
Thanks, pushed.
> There are no breaking or functional changes in how the tab-bar behaves
> today.
It's a breaking change because we can't use a new call with three
arguments to call the function that might be customized by users with
two arguments. So I added a safety net.
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#60073: 30.0.50; [PATCH] Tab bar group format not applied to current
2022-12-14 20:16 bug#60073: 30.0.50; [PATCH] Tab bar group format not applied to current Gabriel
2022-12-15 15:04 ` Gabriel
@ 2022-12-15 18:05 ` Juri Linkov
1 sibling, 0 replies; 4+ messages in thread
From: Juri Linkov @ 2022-12-15 18:05 UTC (permalink / raw)
To: Gabriel; +Cc: 60073
> Result: The 'tab-bar-tab-group-format-function' is not applied to format
> the current group tab, only to other group tabs. See attach patch for a
> proposed fix. If this behavior is intentional, I propose to update the
> doc string.
Indeed, this behavior was intentional because when tab-bar-tab-hints is non-nil
then the number is already displayed on the current tab, so the group tab
doesn't duplicate the same number.
But you are right that tab-bar-tab-group-format-function should be called
even for the current tab.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-12-15 18:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-14 20:16 bug#60073: 30.0.50; [PATCH] Tab bar group format not applied to current Gabriel
2022-12-15 15:04 ` Gabriel
2022-12-15 18:04 ` Juri Linkov
2022-12-15 18:05 ` Juri Linkov
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).