[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 815c4dc0e07 1/3: Add abnormal hook tab-bar-post-undo-close-tab-fu
From: |
Juri Linkov |
Subject: |
master 815c4dc0e07 1/3: Add abnormal hook tab-bar-post-undo-close-tab-functions |
Date: |
Thu, 30 Jan 2025 13:38:00 -0500 (EST) |
branch: master
commit 815c4dc0e07cfae5398c6145a4b4887b7fa64f42
Author: shipmints <shipmints@gmail.com>
Commit: Juri Linkov <juri@linkov.net>
Add abnormal hook tab-bar-post-undo-close-tab-functions
* lisp/tab-bar.el (tab-bar-undo-close-tab):
Add new abnormal hook tab-bar-post-undo-close-tab-functions (bug#75919).
---
etc/NEWS | 7 +++++++
lisp/tab-bar.el | 9 +++++++++
2 files changed, 16 insertions(+)
diff --git a/etc/NEWS b/etc/NEWS
index 09507adecb8..2f1057a1307 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -238,6 +238,13 @@ latter throws an error when the argument FRAME cannot be
deleted.
*** New abnormal hook 'tab-bar-auto-width-functions'.
This hook allows you to control which tab-bar tabs are auto-resized.
+---
+*** New abnormal hook 'tab-bar-post-undo-close-tab-functions'.
+This hook allows you to operate on a reopened tab.
+
+This is useful when you define custom tab parameters that may need
+adjustment when a tab is restored, and avoids advice.
+
** Project
---
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index b570949bfec..f220ee768ae 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -2185,6 +2185,13 @@ happens interactively)."
(unless tab-bar-mode
(message "Deleted all other tabs")))))
+(defcustom tab-bar-post-undo-close-tab-functions nil
+ "List of functions to call after a closed tab is restored.
+Each function is called with one argument: the tab that has been restored."
+ :type '(repeat function)
+ :group 'tab-bar
+ :version "31.1")
+
(defun tab-bar-undo-close-tab ()
"Restore the most recently closed tab."
(interactive)
@@ -2208,6 +2215,8 @@ happens interactively)."
;; `pushnew' handles the head of tabs but not frame-parameter
(tab-bar-tabs-set tabs))
(tab-bar-select-tab (1+ index)))
+ (run-hook-with-args 'tab-bar-post-undo-close-tab-functions
+ tab)
(tab-bar--update-tab-bar-lines))
(message "No more closed tabs to undo")))