aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2023-07-05 20:20:48 +0300
committerJuri Linkov2023-07-05 20:20:48 +0300
commit1dc2d5441e3d7d202ca9d842b73f165a1b2ed42e (patch)
tree653e4781d8cea7d1fbfa9c9f38fb47232f2bc3a3
parent26f31fe3b584d6c1846a2b5d68d0655e1e4d5145 (diff)
downloademacs-1dc2d5441e3d7d202ca9d842b73f165a1b2ed42e.tar.gz
emacs-1dc2d5441e3d7d202ca9d842b73f165a1b2ed42e.zip
* 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).
-rw-r--r--lisp/tab-bar.el18
1 files changed, 18 insertions, 0 deletions
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."
1253 tabs)))) 1253 tabs))))
1254 1254
1255 1255
1256(defvar tab-bar-minibuffer-restore-tab nil
1257 "Tab number for `tab-bar-minibuffer-restore-tab'.")
1258
1259(defun tab-bar-minibuffer-restore-tab ()
1260 "Switch back to the tab where the minibuffer was activated.
1261This is necessary to prepare the same window configuration where
1262original windows were saved and will be restored. This function
1263is used only when `read-minibuffer-restore-windows' is non-nil."
1264 (when (and read-minibuffer-restore-windows
1265 tab-bar-minibuffer-restore-tab)
1266 (tab-bar-select-tab tab-bar-minibuffer-restore-tab)
1267 (setq tab-bar-minibuffer-restore-tab nil)))
1268
1256(defun tab-bar-select-tab (&optional tab-number) 1269(defun tab-bar-select-tab (&optional tab-number)
1257 "Switch to the tab by its absolute position TAB-NUMBER in the tab bar. 1270 "Switch to the tab by its absolute position TAB-NUMBER in the tab bar.
1258When this command is bound to a numeric key (with a key prefix or modifier key 1271When 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."
1278 (to-index (1- (max 1 (min to-number (length tabs))))) 1291 (to-index (1- (max 1 (min to-number (length tabs)))))
1279 (minibuffer-was-active (minibuffer-window-active-p (selected-window)))) 1292 (minibuffer-was-active (minibuffer-window-active-p (selected-window))))
1280 1293
1294 (when (and read-minibuffer-restore-windows minibuffer-was-active
1295 (not tab-bar-minibuffer-restore-tab))
1296 (setq tab-bar-minibuffer-restore-tab (1+ from-index))
1297 (add-hook 'minibuffer-exit-hook 'tab-bar-minibuffer-restore-tab))
1298
1281 (unless (eq from-index to-index) 1299 (unless (eq from-index to-index)
1282 (let* ((from-tab (tab-bar--tab)) 1300 (let* ((from-tab (tab-bar--tab))
1283 (to-tab (nth to-index tabs)) 1301 (to-tab (nth to-index tabs))