From 9bcb7326860ed8b234f8ffd8bceae866b968ff39 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Tue, 21 Dec 2021 21:11:30 +0200 Subject: [PATCH] * lisp/window.el (quit-restore-window): Select previously selected window. After deleting the dedicated window, such as a window with *Completions* buffer, select the previously selected window, like most of other 'cond' branches do in this function (bug#52491). --- lisp/window.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lisp/window.el b/lisp/window.el index d12232641e3..ce1e6098748 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -5167,7 +5167,10 @@ nil means to not handle the buffer in a particular way. This (cond ;; First try to delete dedicated windows that are not side windows. ((and dedicated (not (eq dedicated 'side)) - (window--delete window 'dedicated (eq bury-or-kill 'kill)))) + (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)))) ((and (not prev-buffer) (eq (nth 1 quit-restore) 'tab) (eq (nth 3 quit-restore) buffer))