Make tab-bar-tab-group-format-function backwards-compatible (bug#60073)
* lisp/tab-bar.el (tab-bar--format-tab-group): Add condition-case with wrong-number-of-arguments for backwards-compatibility. (tab-bar-tab-group-format-default): Simplify.
This commit is contained in:
parent
b211a63455
commit
6e2923d80f
1 changed files with 17 additions and 10 deletions
|
@ -844,9 +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 three arguments, a tab with a group name, its
|
Function gets three arguments, a tab with a group name, its number, and
|
||||||
number and an optional t when the tab is current, and should
|
an optional value that is non-nil when the tab is from the current group.
|
||||||
return the formatted tab group name to display in the tab bar."
|
It 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)
|
||||||
|
@ -856,12 +856,10 @@ return the formatted tab group name to display in the tab bar."
|
||||||
:version "28.1")
|
:version "28.1")
|
||||||
|
|
||||||
(defun tab-bar-tab-group-format-default (tab i &optional current-p)
|
(defun tab-bar-tab-group-format-default (tab i &optional current-p)
|
||||||
(let ((name (concat (if tab-bar-tab-hints (format "%d " i) "")
|
(propertize
|
||||||
(funcall tab-bar-tab-group-function tab)))
|
(concat (if (and tab-bar-tab-hints (not current-p)) (format "%d " i) "")
|
||||||
(face (if current-p
|
(funcall tab-bar-tab-group-function tab))
|
||||||
'tab-bar-tab-group-current
|
'face (if current-p 'tab-bar-tab-group-current 'tab-bar-tab-group-inactive)))
|
||||||
'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.
|
||||||
|
@ -884,7 +882,16 @@ 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
|
||||||
,(funcall tab-bar-tab-group-format-function tab i current-p)
|
,(if current-p
|
||||||
|
(condition-case nil
|
||||||
|
(funcall tab-bar-tab-group-format-function tab i current-p)
|
||||||
|
;; We used to define tab-bar-tab-group-format-function as
|
||||||
|
;; taking two arguments but after adding the third argument
|
||||||
|
;; we need to provide backwards-compatibility.
|
||||||
|
(wrong-number-of-arguments
|
||||||
|
(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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue