mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-03 10:31:37 -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:
parent
fdeb1a3dc7
commit
f608b4b93c
2 changed files with 21 additions and 11 deletions
|
|
@ -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)
|
||||
|
||||
;; Don't record insignificant buffers.
|
||||
(when (or (not (eq (aref (buffer-name buffer) 0) ?\s))
|
||||
(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))))
|
||||
|
||||
;; Don't record insignificant buffers.
|
||||
(when (or (not (eq (aref (buffer-name buffer) 0) ?\s))
|
||||
(minibufferp buffer))
|
||||
;; Add an entry for buffer to WINDOW's previous buffers.
|
||||
(with-current-buffer buffer
|
||||
(let ((start (window-start window))
|
||||
|
|
|
|||
|
|
@ -163,9 +163,9 @@ zip_minibuffer_stacks (Lisp_Object dest_window, Lisp_Object source_window)
|
|||
}
|
||||
|
||||
if (live_minibuffer_p (dw->contents))
|
||||
call1 (Qrecord_window_buffer, dest_window);
|
||||
call2 (Qrecord_window_buffer, dest_window, Qt);
|
||||
if (live_minibuffer_p (sw->contents))
|
||||
call1 (Qrecord_window_buffer, source_window);
|
||||
call2 (Qrecord_window_buffer, source_window, Qt);
|
||||
|
||||
acc = merge_c (dw->prev_buffers, sw->prev_buffers, minibuffer_ent_greater);
|
||||
|
||||
|
|
@ -204,6 +204,14 @@ move_minibuffers_onto_frame (struct frame *of, bool for_deletion)
|
|||
zip_minibuffer_stacks (f->minibuffer_window, of->minibuffer_window);
|
||||
if (for_deletion && XFRAME (MB_frame) != of)
|
||||
MB_frame = selected_frame;
|
||||
if (!for_deletion
|
||||
&& MINI_WINDOW_P (XWINDOW (FRAME_SELECTED_WINDOW (of))))
|
||||
{
|
||||
Lisp_Object old_frame;
|
||||
XSETFRAME (old_frame, of);
|
||||
Fset_frame_selected_window (old_frame,
|
||||
Fframe_first_window (old_frame), Qnil);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -672,7 +680,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
|
|||
}
|
||||
MB_frame = XWINDOW (XFRAME (selected_frame)->minibuffer_window)->frame;
|
||||
if (live_minibuffer_p (XWINDOW (minibuf_window)->contents))
|
||||
call1 (Qrecord_window_buffer, minibuf_window);
|
||||
call2 (Qrecord_window_buffer, minibuf_window, Qt);
|
||||
|
||||
record_unwind_protect_void (minibuffer_unwind);
|
||||
record_unwind_protect (restore_window_configuration,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue