diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index 2604955224..82f3ca2385 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -334,6 +334,18 @@ tab-bar-tab-name-function :group 'tab-bar :version "27.1") +(defcustom tab-bar-tab-name-format-function nil + "Function to format a tab name. +Function get one argument, the tab name, and should return +the formatted tab name." + :type 'function + :initialize 'custom-initialize-default + :set (lambda (sym val) + (set-default sym val) + (force-mode-line-update)) + :group 'tab-bar + :version "28.1") + (defun tab-bar-tab-name-current () "Generate tab name from the buffer of the selected window." (buffer-name (window-buffer (minibuffer-selected-window)))) @@ -433,8 +445,9 @@ tab-bar-make-keymap-1 ((eq (car tab) 'current-tab) `((current-tab menu-item - ,(propertize (concat (if tab-bar-tab-hints (format "%d " i) "") - (alist-get 'name tab) + ,(propertize (concat (funcall (or tab-bar-tab-name-format-function 'identity) + (concat (if tab-bar-tab-hints (format "%d " i) "") + (alist-get 'name tab))) (or (and tab-bar-close-button-show (not (eq tab-bar-close-button-show 'non-selected)) @@ -445,8 +458,9 @@ tab-bar-make-keymap-1 (t `((,(intern (format "tab-%i" i)) menu-item - ,(propertize (concat (if tab-bar-tab-hints (format "%d " i) "") - (alist-get 'name tab) + ,(propertize (concat (funcall (or tab-bar-tab-name-format-function 'identity) + (concat (if tab-bar-tab-hints (format "%d " i) "") + (alist-get 'name tab))) (or (and tab-bar-close-button-show (not (eq tab-bar-close-button-show 'selected))