From: Martin Rudalics Date: Sat, 14 May 2022 07:19:57 +0000 (+0200) Subject: 2022-05-14 Martin Rudalics X-Git-Tag: emacs-29.0.90~1910^2~701 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=88e0e034eff81194b775fd3d1e7cbd28eeb610f6;p=emacs.git 2022-05-14 Martin Rudalics * lisp/window.el (quit-restore-select-window): New function. (quit-restore-window): Call 'quit-restore-select-window' to avoid selecting inactive minibuffer window (Bug#55403). --- diff --git a/lisp/window.el b/lisp/window.el index 0787e6390cf..e378652e283 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -5142,6 +5142,14 @@ all window-local buffer lists." :version "27.1" :group 'windows) +(defun quit-restore-select-window (window) + "Select WINDOW after having quit another one. +Do not select an inactive minibuffer window." + (when (and (window-live-p window) + (or (not (window-minibuffer-p window)) + (minibuffer-window-active-p window))) + (select-window window))) + (defun quit-restore-window (&optional window bury-or-kill) "Quit WINDOW and deal with its buffer. WINDOW must be a live window and defaults to the selected one. @@ -5191,15 +5199,13 @@ nil means to not handle the buffer in a particular way. This ((and dedicated (not (eq dedicated 'side)) (window--delete window 'dedicated (eq bury-or-kill 'kill))) ;; If the previously selected window is still alive, select it. - (when (window-live-p (nth 2 quit-restore)) - (select-window (nth 2 quit-restore)))) + (quit-restore-select-window (nth 2 quit-restore))) ((and (not prev-buffer) (eq (nth 1 quit-restore) 'tab) (eq (nth 3 quit-restore) buffer)) (tab-bar-close-tab) ;; If the previously selected window is still alive, select it. - (when (window-live-p (nth 2 quit-restore)) - (select-window (nth 2 quit-restore)))) + (quit-restore-select-window (nth 2 quit-restore))) ((and (not prev-buffer) (or (eq (nth 1 quit-restore) 'frame) (and (eq (nth 1 quit-restore) 'window) @@ -5211,8 +5217,7 @@ nil means to not handle the buffer in a particular way. This ;; Delete WINDOW if possible. (window--delete window nil (eq bury-or-kill 'kill))) ;; If the previously selected window is still alive, select it. - (when (window-live-p (nth 2 quit-restore)) - (select-window (nth 2 quit-restore)))) + (quit-restore-select-window (nth 2 quit-restore))) ((and (listp (setq quad (nth 1 quit-restore))) (buffer-live-p (car quad)) (eq (nth 3 quit-restore) buffer)) @@ -5256,8 +5261,8 @@ nil means to not handle the buffer in a particular way. This ;; Reset the quit-restore parameter. (set-window-parameter window 'quit-restore nil) ;; Select old window. - (when (window-live-p (nth 2 quit-restore)) - (select-window (nth 2 quit-restore)))) + ;; If the previously selected window is still alive, select it. + (quit-restore-select-window (nth 2 quit-restore))) (t ;; Show some other buffer in WINDOW and reset the quit-restore ;; parameter. @@ -5270,8 +5275,8 @@ nil means to not handle the buffer in a particular way. This (when (eq dedicated 'side) (set-window-dedicated-p window 'side)) (window--delete window nil (eq bury-or-kill 'kill)) - (when (window-live-p (nth 2 quit-restore)) - (select-window (nth 2 quit-restore)))))) + ;; If the previously selected window is still alive, select it. + (quit-restore-select-window (nth 2 quit-restore))))) ;; Deal with the buffer. (cond