[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 1dc2d5441e3: * lisp/tab-bar.el: Restore the original tab where mi
From: |
Juri Linkov |
Subject: |
master 1dc2d5441e3: * lisp/tab-bar.el: Restore the original tab where minibuffer was activated. |
Date: |
Wed, 5 Jul 2023 13:21:28 -0400 (EDT) |
branch: master
commit 1dc2d5441e3d7d202ca9d842b73f165a1b2ed42e
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>
* lisp/tab-bar.el: Restore the original tab where minibuffer was activated.
(tab-bar-minibuffer-restore-tab): New variable and function.
(tab-bar-select-tab): Use them (bug#64373).
---
lisp/tab-bar.el | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 87ca80ce00a..234e7e5d14d 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -1253,6 +1253,19 @@ inherits the current tab's `explicit-name' parameter."
tabs))))
+(defvar tab-bar-minibuffer-restore-tab nil
+ "Tab number for `tab-bar-minibuffer-restore-tab'.")
+
+(defun tab-bar-minibuffer-restore-tab ()
+ "Switch back to the tab where the minibuffer was activated.
+This is necessary to prepare the same window configuration where
+original windows were saved and will be restored. This function
+is used only when `read-minibuffer-restore-windows' is non-nil."
+ (when (and read-minibuffer-restore-windows
+ tab-bar-minibuffer-restore-tab)
+ (tab-bar-select-tab tab-bar-minibuffer-restore-tab)
+ (setq tab-bar-minibuffer-restore-tab nil)))
+
(defun tab-bar-select-tab (&optional tab-number)
"Switch to the tab by its absolute position TAB-NUMBER in the tab bar.
When this command is bound to a numeric key (with a key prefix or modifier key
@@ -1278,6 +1291,11 @@ Negative TAB-NUMBER counts tabs from the end of the tab
bar."
(to-index (1- (max 1 (min to-number (length tabs)))))
(minibuffer-was-active (minibuffer-window-active-p
(selected-window))))
+ (when (and read-minibuffer-restore-windows minibuffer-was-active
+ (not tab-bar-minibuffer-restore-tab))
+ (setq tab-bar-minibuffer-restore-tab (1+ from-index))
+ (add-hook 'minibuffer-exit-hook 'tab-bar-minibuffer-restore-tab))
+
(unless (eq from-index to-index)
(let* ((from-tab (tab-bar--tab))
(to-tab (nth to-index tabs))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 1dc2d5441e3: * lisp/tab-bar.el: Restore the original tab where minibuffer was activated.,
Juri Linkov <=