From: shipmints Date: Thu, 30 Jan 2025 17:57:00 +0000 (-0500) Subject: Add new variable tab-bar-format-tab-help-text-function X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d967e9d0ad7097fdc51b44b40d1ef215cd93f464;p=emacs.git Add new variable tab-bar-format-tab-help-text-function * lisp/tab-bar.el (tab-bar--format-tab): Add new variable 'tab-bar-format-tab-help-text-function' and a default function 'tab-bar-format-tab-help-text-default'. 'tab-bar--format-tab' respects this new variable when producing a tab's help text, normally shown in the echo area or via tooltips (bug#75950). (cherry picked from commit f45a776fe3c9160c49fdf21a96d37d2ed780836c) --- diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index ee22be5ae67..7f35476482d 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -992,6 +992,17 @@ You can hide these buttons by customizing `tab-bar-format' and removing menu-item ,tab-bar-forward-button tab-bar-history-forward :help "Click to go forward in tab history")))) +(defun tab-bar-format-tab-help-text-default (tab _i) + (alist-get 'name tab)) + +(defvar tab-bar-format-tab-help-text-function #'tab-bar-format-tab-help-text-default + "Function to produce help text for tabs displayed in the tab bar. +This function should accept two arguments: the tab, and the one-based +tab's number. + +The function should produce a string, which may be propertized. By +default, use function `tab-bar-format-tab-help-text-default.") + (defun tab-bar--format-tab (tab i) "Format TAB using its index I and return the result as a keymap." (append @@ -1002,13 +1013,13 @@ You can hide these buttons by customizing `tab-bar-format' and removing menu-item ,(funcall tab-bar-tab-name-format-function tab i) ignore - :help ,(alist-get 'name tab)))) + :help ,(funcall tab-bar-format-tab-help-text-function tab i)))) (t `((,(intern (format "tab-%i" i)) menu-item ,(funcall tab-bar-tab-name-format-function tab i) ,(alist-get 'binding tab) - :help ,(alist-get 'name tab))))) + :help ,(funcall tab-bar-format-tab-help-text-function tab i))))) (when (alist-get 'close-binding tab) `((,(if (eq (car tab) 'current-tab) 'C-current-tab (intern (format "C-tab-%i" i)))