[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 6e2923d80f 2/2: Make tab-bar-tab-group-format-function backward
From: |
Juri Linkov |
Subject: |
emacs-29 6e2923d80f 2/2: Make tab-bar-tab-group-format-function backwards-compatible (bug#60073) |
Date: |
Thu, 15 Dec 2022 13:04:04 -0500 (EST) |
branch: emacs-29
commit 6e2923d80f822e6da470860f51ba13bcad10d0a3
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>
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.
---
lisp/tab-bar.el | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 1f25ee6d7e..1baa857e9e 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)