From 51583a0f9f75950933a342a09ea3d317a528581e Mon Sep 17 00:00:00 2001 From: martin rudalics Date: Wed, 4 Aug 2021 08:48:18 +0200 Subject: [PATCH] Add new user option 'read-minibuffer-restore-windows' * doc/lispref/minibuf.texi (Text from Minibuffer): Document it (bug#45072). * lisp/cus-start.el (standard): Add. * src/minibuf.c (syms_of_minibuf): New variable 'read-minibuffer-restore-windows'. --- doc/lispref/minibuf.texi | 12 ++++++++++++ etc/NEWS | 3 +++ lisp/cus-start.el | 1 + src/minibuf.c | 18 +++++++++++++++--- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi index 196dd990767..d54c654562f 100644 --- a/doc/lispref/minibuf.texi +++ b/doc/lispref/minibuf.texi @@ -469,6 +469,18 @@ If @var{default} is a non-@code{nil} list, the first element of the list is used in the prompt. @end defun +@defvar read-minibuffer-restore-windows +If this option is non-@code{nil} (the default), getting input from the +minibuffer will restore, on exit, the window configurations of the frame +where the minibuffer was entered from and, if it is different, the frame +that owns the minibuffer window. This means that if, for example, a +user splits a window while getting input from the minibuffer on the same +frame, that split will be undone when exiting the minibuffer. + +If this option is @code{nil}, no such restorations are done. Hence, the +window split mentioned above will persist after exiting the minibuffer. +@end defvar + @node Object from Minibuffer @section Reading Lisp Objects with the Minibuffer @cindex minibuffer input, reading lisp objects diff --git a/etc/NEWS b/etc/NEWS index 86aeea69ca1..18cca8b4ab3 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -178,6 +178,9 @@ behavior, which mixed these two, can be approximated by customizing 'minibuffer-follows-selected-frame' to a value which is neither nil nor t. ++++ +** New user option 'read-minibuffer-restore-windows'. + +++ ** New system for displaying documentation for groups of functions. This can either be used by saying 'M-x shortdoc-display-group' and diff --git a/lisp/cus-start.el b/lisp/cus-start.el index 7df70d704ef..27b98f2d809 100644 --- a/lisp/cus-start.el +++ b/lisp/cus-start.el @@ -431,6 +431,7 @@ Leaving \"Default\" unchecked is equivalent with specifying a default of "21.1" :set minibuffer-prompt-properties--setter) (minibuffer-auto-raise minibuffer boolean) + (read-minibuffer-restore-windows boolean "28.1") ;; options property set at end (read-buffer-function minibuffer (choice (const nil) diff --git a/src/minibuf.c b/src/minibuf.c index 0f4349e70b8..3ee0dca5e05 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -689,12 +689,15 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, call1 (Qpush_window_buffer_onto_prev, minibuf_window); record_unwind_protect_void (minibuffer_unwind); - record_unwind_protect (restore_window_configuration, - list3 (Fcurrent_window_configuration (Qnil), Qt, Qt)); + if (read_minibuffer_restore_windows) + record_unwind_protect (restore_window_configuration, + list3 (Fcurrent_window_configuration (Qnil), + Qt, Qt)); /* If the minibuffer window is on a different frame, save that frame's configuration too. */ - if (!EQ (mini_frame, selected_frame)) + if (read_minibuffer_restore_windows && + !EQ (mini_frame, selected_frame)) record_unwind_protect (restore_window_configuration, list3 (Fcurrent_window_configuration (mini_frame), Qnil, Qt)); @@ -2527,6 +2530,15 @@ for instance when running a headless Emacs server. Functions like instead. */); inhibit_interaction = 0; + DEFVAR_BOOL ("read-minibuffer-restore-windows", read_minibuffer_restore_windows, + doc: /* Non-nil means restore window configurations on exit from minibuffer. +If this is non-nil (the default), reading input with the minibuffer will +restore, on exit, the window configurations of the frame where the +minibuffer was entered from and, if it is different, the frame that owns +the associated minibuffer window. If this is nil, no such restorations +are done. */); + read_minibuffer_restore_windows = true; + defsubr (&Sactive_minibuffer_window); defsubr (&Sset_minibuffer_window); defsubr (&Sread_from_minibuffer); -- 2.39.2