:version "31.1"
:group 'windows)
-(defun window--quit-restore-select-window (window)
+(defun window--quit-restore-select-window (window &optional frame)
"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)))
+ ;; If WINDOW is not on the selected frame, don't switch to
+ ;; another frame.
+ (unless (and (eq frame (selected-frame))
+ (not (eq frame (window-frame window))))
+ (setq frame (window-frame window))
+ (set-frame-selected-window frame window)
+ (select-frame-set-input-focus frame))))
(defun quit-restore-window (&optional window bury-or-kill)
"Quit WINDOW and deal with its buffer.
(unless (eq (car buf) buffer)
(throw 'prev-buffer (car buf))))))
(dedicated (window-dedicated-p window))
+ (frame (window-frame window))
quad entry reset-prev)
(cond
;; First try to delete dedicated windows that are not side windows.
(window--delete
window 'dedicated (memq bury-or-kill '(kill killing))))
;; If the previously selected window is still alive, select it.
- (window--quit-restore-select-window quit-restore-2))
+ (window--quit-restore-select-window quit-restore-2 frame))
((and (not prev-buffer)
(or (memq (nth 1 quit-restore) '(frame tab))
(and (eq (nth 1 quit-restore) 'window)
;; Delete WINDOW if possible.
(window--delete window nil (eq bury-or-kill 'kill)))
;; If the previously selected window is still alive, select it.
- (window--quit-restore-select-window quit-restore-2))
+ (window--quit-restore-select-window quit-restore-2 frame))
((and (or (and quit-restore-window-no-switch (not prev-buffer))
;; Ignore first of the previous buffers if
;; 'quit-restore-window-no-switch' says so.
(window--delete
window nil (memq bury-or-kill '(kill killing))))
;; If the previously selected window is still alive, select it.
- (window--quit-restore-select-window quit-restore-2))
+ (window--quit-restore-select-window quit-restore-2 frame))
((or (and (listp (setq quad (nth 1 quit-restore-prev)))
(buffer-live-p (car quad))
(eq (nth 3 quit-restore-prev) buffer)
(should (eq (length (window-list)) 2))
(should (equal (buffer-name) "*info*"))
(quit-window)
- ;; 'quit-window' unexpectedly selects the original frame,
- ;; so move back to the created frame
- (select-frame (car (frame-list)))
(should (eq (length (window-list)) 1))
(should (eq (length (frame-list)) 2))
(should (equal (buffer-name) "*Messages*"))
(should (eq (length (frame-list)) 2))
;; Delete the created frame afterwards because with tty frames
;; the output of 'message' is bound to the original frame
- (delete-frame))
+ (delete-frame (car (frame-list))))
;; 2.1. 'quit-restore-window' should close the tab
;; from initial window (bug#59862)