diff --git a/lisp/window.el b/lisp/window.el index d12232641e..0db2dcbb90 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -5171,10 +5171,7 @@ quit-restore-window ((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)))) + (tab-bar-close-tab)) ((and (not prev-buffer) (or (eq (nth 1 quit-restore) 'frame) (and (eq (nth 1 quit-restore) 'window) @@ -5184,10 +5181,7 @@ quit-restore-window (not (eq window (frame-root-window window))))) (eq (nth 3 quit-restore) buffer) ;; 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)))) + (window--delete window nil (eq bury-or-kill 'kill)))) ((and (listp (setq quad (nth 1 quit-restore))) (buffer-live-p (car quad)) (eq (nth 3 quit-restore) buffer)) @@ -5229,10 +5223,7 @@ quit-restore-window (set-window-prev-buffers window (append (window-prev-buffers window) (list entry)))) ;; 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)))) + (set-window-parameter window 'quit-restore nil)) (t ;; Show some other buffer in WINDOW and reset the quit-restore ;; parameter. @@ -5244,9 +5235,11 @@ quit-restore-window (if (switch-to-prev-buffer window bury-or-kill) (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)))))) + (window--delete window nil (eq bury-or-kill 'kill))))) + + ;; When the previously selected window is still live, select it. + (when (window-live-p (nth 2 quit-restore)) + (select-window (nth 2 quit-restore))) ;; Deal with the buffer. (cond