1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Prevent the selected window being a dead mini-window when switching frames

This fixes bug #48249 and also a situation where, with recursive minibuffers
enabled and minibuffer-follows-selected-frame t, switching frames when a
minibuffer was open would leave the mini-window selected on the old frame.

* lisp/window.el (record-window-buffer): Add extra parameter DO-MINIBUF, and
amend the code such that minibuffers only get processed when that parameter is
non-nil.

* src/minibuf.c (zip_minibuffer_stacks, read_minibuf): Call
Qrecord_window_buffer with the new argument set to Qt.
(move_minibuffers_onto_frame): Set the selected window on the old frame when
this would otherwise remain the mini-window.
This commit is contained in:
Alan Mackenzie 2021-05-08 12:10:00 +00:00
parent fdeb1a3dc7
commit f608b4b93c
2 changed files with 21 additions and 11 deletions

View file

@ -4361,9 +4361,12 @@ This may be a useful alternative binding for \\[delete-other-windows]
;; The following function is called by `set-window-buffer' _before_ it
;; replaces the buffer of the argument window with the new buffer.
(defun record-window-buffer (&optional window)
(defun record-window-buffer (&optional window do-minibuf)
"Record WINDOW's buffer.
WINDOW must be a live window and defaults to the selected one."
WINDOW must be a live window and defaults to the selected one.
If WINDOW is a minibuffer, it will only be recorded if DO-MINIBUF
is non-nil."
(let* ((window (window-normalize-window window t))
(buffer (window-buffer window))
(entry (assq buffer (window-prev-buffers window))))
@ -4371,14 +4374,13 @@ WINDOW must be a live window and defaults to the selected one."
;; `switch-to-prev-buffer' and `switch-to-next-buffer'.
(set-window-next-buffers window nil)
(when entry
;; Remove all entries for BUFFER from WINDOW's previous buffers.
(set-window-prev-buffers
window (assq-delete-all buffer (window-prev-buffers window))))
;; Don't record insignificant buffers.
(when (or (not (eq (aref (buffer-name buffer) 0) ?\s))
(minibufferp buffer))
(and do-minibuf (minibufferp buffer)))
(when entry
;; Remove all entries for BUFFER from WINDOW's previous buffers.
(set-window-prev-buffers
window (assq-delete-all buffer (window-prev-buffers window))))
;; Add an entry for buffer to WINDOW's previous buffers.
(with-current-buffer buffer
(let ((start (window-start window))