]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/tab-bar.el (tab-bar-tab-post-select-functions): New hook (bug#69093).
authorJuri Linkov <juri@linkov.net>
Tue, 5 Mar 2024 17:14:28 +0000 (19:14 +0200)
committerEshel Yaron <me@eshelyaron.com>
Wed, 6 Mar 2024 11:36:31 +0000 (12:36 +0100)
(tab-bar-select-tab): Call tab-bar-tab-post-select-functions at the end.

(cherry picked from commit 3cb06145070ff5d4a220f1144434f1ba6c1976f7)

etc/NEWS
lisp/tab-bar.el

index fdd78b4e58b6136c3db82e8eb3f9e12e174e3a4a..b731737fb9d95e76f741d0228510ae9b437c51d1 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -260,10 +260,14 @@ selected or deselected at the end of executing the current command.
 
 ** Tab Bars and Tab Lines
 
+---
 *** New user option 'tab-bar-tab-name-format-functions'.
 It can be used to add, remove and reorder functions that change
 the appearance of every tab on the tab bar.
 
+---
+*** New hook 'tab-bar-tab-post-select-functions'.
+
 +++
 ** New optional argument for modifying directory-local variables.
 The commands 'add-dir-local-variable', 'delete-dir-local-variable' and
index 3e1d8278b04b1ced87f0a573f27303d5c0867c5c..61efa332e0b73bb774b6f971fac3e25f3abe2ddf 100644 (file)
@@ -1385,6 +1385,14 @@ inherits the current tab's `explicit-name' parameter."
                              tabs))))
 
 \f
+(defcustom tab-bar-tab-post-select-functions nil
+  "List of functions to call after selecting a tab.
+Two arguments are supplied: the previous tab that was selected before,
+and the newly selected tab."
+  :type '(repeat function)
+  :group 'tab-bar
+  :version "30.1")
+
 (defvar tab-bar-minibuffer-restore-tab nil
   "Tab number for `tab-bar-minibuffer-restore-tab'.")
 
@@ -1499,7 +1507,10 @@ Negative TAB-NUMBER counts tabs from the end of the tab bar."
               (tab-bar--current-tab-make (nth to-index tabs)))
 
         (unless tab-bar-mode
-          (message "Selected tab '%s'" (alist-get 'name to-tab))))
+          (message "Selected tab '%s'" (alist-get 'name to-tab)))
+
+        (run-hook-with-args 'tab-bar-tab-post-select-functions
+                            from-tab to-tab))
 
       (force-mode-line-update))))