summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorJuri Linkov <juri@linkov.net>2022-12-15 20:03:24 +0200
committerJuri Linkov <juri@linkov.net>2022-12-15 20:03:24 +0200
commit6e2923d80f822e6da470860f51ba13bcad10d0a3 (patch)
tree9b400cfc366182c62344c5e8969572b9decc0ff6 /lisp
parentb211a63455cad72f4883ef1494502633f8ac19be (diff)
downloademacs-6e2923d80f822e6da470860f51ba13bcad10d0a3.tar.gz
emacs-6e2923d80f822e6da470860f51ba13bcad10d0a3.tar.bz2
emacs-6e2923d80f822e6da470860f51ba13bcad10d0a3.zip
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.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/tab-bar.el27
1 files changed, 17 insertions, 10 deletions
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 1f25ee6d7e4..1baa857e9e9 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -844,9 +844,9 @@ Function gets one argument: a tab."
(defcustom tab-bar-tab-group-format-function #'tab-bar-tab-group-format-default
"Function to format a tab group name.
-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."
+Function gets three arguments, a tab with a group name, its number, and
+an optional value that is non-nil when the tab is from the current group.
+It should return the formatted tab group name to display in the tab bar."
:type 'function
:initialize 'custom-initialize-default
:set (lambda (sym val)
@@ -856,12 +856,10 @@ return the formatted tab group name to display in the tab bar."
:version "28.1")
(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)))
+ (propertize
+ (concat (if (and tab-bar-tab-hints (not current-p)) (format "%d " i) "")
+ (funcall tab-bar-tab-group-function tab))
+ 'face (if current-p 'tab-bar-tab-group-current 'tab-bar-tab-group-inactive)))
(defcustom tab-bar-tab-group-face-function #'tab-bar-tab-group-face-default
"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 "group-%i" i))
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
(or
(alist-get 'binding tab)