]> git.eshelyaron.com Git - emacs.git/commitdiff
Add new variable tab-bar-format-tab-help-text-function
authorshipmints <shipmints@gmail.com>
Thu, 30 Jan 2025 17:57:00 +0000 (12:57 -0500)
committerEshel Yaron <me@eshelyaron.com>
Mon, 3 Feb 2025 11:11:30 +0000 (12:11 +0100)
* 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)

lisp/tab-bar.el

index ee22be5ae67b56c5e11124ce467ca8b2904b3524..7f35476482dc6f646f4469a94f9bda767b83f398 100644 (file)
@@ -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)))