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 (bug#60073).
This commit is contained in:
Gabriel do Nascimento Ribeiro 2022-12-15 11:58:30 -03:00 committed by Juri Linkov
parent 367022f316
commit b211a63455

View file

@ -844,8 +844,9 @@ Function gets one argument: a tab."
(defcustom tab-bar-tab-group-format-function #'tab-bar-tab-group-format-default (defcustom tab-bar-tab-group-format-function #'tab-bar-tab-group-format-default
"Function to format a tab group name. "Function to format a tab group name.
Function gets two arguments, a tab with a group name and its number, Function gets three arguments, a tab with a group name, its
and should return the formatted tab group name to display in the tab bar." 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 :type 'function
:initialize 'custom-initialize-default :initialize 'custom-initialize-default
:set (lambda (sym val) :set (lambda (sym val)
@ -854,11 +855,13 @@ and should return the formatted tab group name to display in the tab bar."
:group 'tab-bar :group 'tab-bar
:version "28.1") :version "28.1")
(defun tab-bar-tab-group-format-default (tab i) (defun tab-bar-tab-group-format-default (tab i &optional current-p)
(propertize (let ((name (concat (if tab-bar-tab-hints (format "%d " i) "")
(concat (if tab-bar-tab-hints (format "%d " i) "") (funcall tab-bar-tab-group-function tab)))
(funcall tab-bar-tab-group-function tab)) (face (if current-p
'face 'tab-bar-tab-group-inactive)) '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 (defcustom tab-bar-tab-group-face-function #'tab-bar-tab-group-face-default
"Function to define a tab group face. "Function to define a tab group face.
@ -881,10 +884,7 @@ when the tab is current. Return the result as a keymap."
`((,(intern (format "sep-%i" i)) menu-item ,(tab-bar-separator) ignore)) `((,(intern (format "sep-%i" i)) menu-item ,(tab-bar-separator) ignore))
`((,(intern (format "group-%i" i)) `((,(intern (format "group-%i" i))
menu-item menu-item
,(if current-p ,(funcall tab-bar-tab-group-format-function tab i 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))
,(if current-p 'ignore ,(if current-p 'ignore
(or (or
(alist-get 'binding tab) (alist-get 'binding tab)