From 6e469709c550ba18d9d5a34f6bb89908472f0eb2 Mon Sep 17 00:00:00 2001 From: Alan Mackenzie Date: Thu, 19 Nov 2020 10:31:50 +0000 Subject: [PATCH] In attempted recursive minibuffer use, display error message in correct frame This was problematic when minibuffer-follows-selected-frame was non-nil. Introduce a new parameter DONT-SET-FRAME to set-window-configuration. * doc/lispref/windows.texi (Window Configurations): Describe the new &optional parameter to set-window-configuration. * etc/NEWS (Lisp Changes): Note the new parameter to set-window-configuration. * src/keyboard.c (read_char_help_form_unwind): Add a new Qnil argument to the call of Fset_window_configuration. * src/minibuf.c (read_minibuf): Cons up a Qt with the window configuration in the argument to record_unwind_protect for the window configuration (twice). * src/window.c (Fset_window_configuration): Add the new &optional parameter and document it in the doc string. At the final do_switch_frame operation, restore the original frame when DONT-SET-FRAME is non-nil. (restore_window_configuration): Handle the new parameter when the supplied argument is a cons. --- doc/lispref/windows.texi | 7 +++++-- etc/NEWS | 45 +++++----------------------------------- src/keyboard.c | 2 +- src/minibuf.c | 5 +++-- src/window.c | 21 ++++++++++++++----- 5 files changed, 30 insertions(+), 50 deletions(-) diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi index 5ec23a9c876..2d092e1842a 100644 --- a/doc/lispref/windows.texi +++ b/doc/lispref/windows.texi @@ -5869,13 +5869,16 @@ which window parameters (if any) are saved by this function. @xref{Window Parameters}. @end defun -@defun set-window-configuration configuration +@defun set-window-configuration configuration &optional dont-set-frame This function restores the configuration of windows and buffers as specified by @var{configuration}, for the frame that @var{configuration} was created for, regardless of whether that frame is selected or not. The argument @var{configuration} must be a value that was previously returned by @code{current-window-configuration} -for that frame. +for that frame. Normally the function also selects the frame which is +recorded in the configuration, but if @var{dont-set-frame} is +non-@code{nil}, it leaves selected the frame which was current at the +start of the function. If the frame from which @var{configuration} was saved is dead, all this function does is to restore the value of the variable diff --git a/etc/NEWS b/etc/NEWS index 9f39851b4a5..ee9f484be35 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -203,12 +203,6 @@ This command would previously not redefine values defined by these forms, but this command has now been changed to work more like 'eval-defun', and reset the values as specified. ---- -** New user options 'copy-region-blink-delay' and 'delete-pair-blink-delay'. -'copy-region-blink-delay' specifies a delay to indicate the region -copied by 'kill-ring-save'. 'delete-pair-blink-delay' specifies -a delay to show a paired character to delete. - +++ ** New command 'undo-redo'. It undoes previous undo commands, but doesn't record itself as an @@ -441,11 +435,6 @@ their 'default-directory' under VC. *** New command 'vc-dir-root' uses the root directory without asking. ---- -*** New face 'log-view-commit-body'. -This is used when expanding commit messages from 'vc-print-root-log' -and similar commands. - --- *** The responsible VC backend is now the most specific one. 'vc-responsible-backend' loops over the backends in @@ -669,13 +658,6 @@ to the search string. --- *** New input method 'compose' based on X Multi_key sequences. ---- -*** New input method 'iso-transl' with the same keys as 'C-x 8'. -After selecting it as a transient input method with 'C-u C-x \ -iso-transl RET', it supports the same key sequences as 'C-x 8', -so e.g. like 'C-x 8 [' inserts a left single quotation mark, -'C-x \ [' does the same. - --- *** Improved language transliteration in Malayalam input methods. Added a new Mozhi scheme. The inapplicable ITRANS scheme is now @@ -1142,13 +1124,6 @@ project's root directory, respectively. +++ *** New user option 'project-list-file'. -** xref - ---- -*** Prefix arg of 'xref-goto-xref' quits the *xref* buffer. -So typing 'C-u RET' in the *xref* buffer quits its window -before navigating to the selected location. - ** json.el --- @@ -1265,11 +1240,6 @@ and the result is not truncated in any way. *** The '/' operator now has higher precedence in (La)TeX input mode. It no longer has lower precedence than '+' and '-'. ---- -*** Calc now marks its windows dedicated. -The new user option 'calc-make-windows-dedicated' controls this. It -is t by default; set to nil to get back the old behavior. - ** term-mode --- @@ -1346,11 +1316,6 @@ visited errors, so you can have an overview what errors were already visited. If 'tab-always-indent' is 'complete', this new user option can be used to further tweak whether to complete or indent. ---- -*** 'dired-query' now uses 'read-char-from-minibuffer'. -Using it instead of 'read-char-choice' allows using 'C-x o' -to switch to the help window displayed after typing 'C-h'. - --- *** 'zap-up-to-char' now uses 'read-char-from-minibuffer'. This allows navigating through the history of characters that have @@ -1758,6 +1723,11 @@ ledit.el, lmenu.el, lucid.el and old-whitespace.el. * Lisp Changes in Emacs 28.1 ++++ +** 'set-window-configuration' now takes an optional 'dont-set-frame' +parameter which, when non-nil, instructs the function not to select +the frame recorded in the configuration. + +++ ** 'define-globalized-minor-mode' now takes a ':predicate' parameter. This can be used to control which major modes the minor mode should be @@ -1999,11 +1969,6 @@ image API via 'M-x report-emacs-bug'. --- ** The user option 'make-pointer-invisible' is now honored on macOS. --- -** On macOS, 's-' and 's-' are now bound to -'move-beginning-of-line' and 'move-end-of-line' respectively. The commands -to select previous/next frame are still bound to 's-~' and 's-`'. - ---------------------------------------------------------------------- This file is part of GNU Emacs. diff --git a/src/keyboard.c b/src/keyboard.c index 49a0a8bd236..1579c007ecf 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -2122,7 +2122,7 @@ read_char_help_form_unwind (void) Lisp_Object window_config = XCAR (help_form_saved_window_configs); help_form_saved_window_configs = XCDR (help_form_saved_window_configs); if (!NILP (window_config)) - Fset_window_configuration (window_config); + Fset_window_configuration (window_config, Qnil); } #define STOP_POLLING \ diff --git a/src/minibuf.c b/src/minibuf.c index c4adca15365..464e3018f7d 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -501,14 +501,15 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, record_unwind_protect_void (choose_minibuf_frame); record_unwind_protect (restore_window_configuration, - Fcurrent_window_configuration (Qnil)); + Fcons (Qt, Fcurrent_window_configuration (Qnil))); /* If the minibuffer window is on a different frame, save that frame's configuration too. */ mini_frame = WINDOW_FRAME (XWINDOW (minibuf_window)); if (!EQ (mini_frame, selected_frame)) record_unwind_protect (restore_window_configuration, - Fcurrent_window_configuration (mini_frame)); + Fcons (Qt, + Fcurrent_window_configuration (mini_frame))); /* If the minibuffer is on an iconified or invisible frame, make it visible now. */ diff --git a/src/window.c b/src/window.c index a6de34f3db6..6cd3122b43b 100644 --- a/src/window.c +++ b/src/window.c @@ -6824,19 +6824,25 @@ DEFUN ("window-configuration-frame", Fwindow_configuration_frame, Swindow_config } DEFUN ("set-window-configuration", Fset_window_configuration, - Sset_window_configuration, 1, 1, 0, + Sset_window_configuration, 1, 2, 0, doc: /* Set the configuration of windows and buffers as specified by CONFIGURATION. CONFIGURATION must be a value previously returned by `current-window-configuration' (which see). + +Normally, this function selects the frame of the CONFIGURATION, but if +DONT-SET-FRAME is non-nil, it leaves selected the frame which was +current at the start of the function. + If CONFIGURATION was made from a frame that is now deleted, only frame-independent values can be restored. In this case, the return value is nil. Otherwise the value is t. */) - (Lisp_Object configuration) + (Lisp_Object configuration, Lisp_Object dont_set_frame) { register struct save_window_data *data; struct Lisp_Vector *saved_windows; Lisp_Object new_current_buffer; Lisp_Object frame; + Lisp_Object old_frame = selected_frame; struct frame *f; ptrdiff_t old_point = -1; USE_SAFE_ALLOCA; @@ -7153,7 +7159,10 @@ the return value is nil. Otherwise the value is t. */) select_window above totally superfluous; it still sets f's selected window. */ if (FRAME_LIVE_P (XFRAME (data->selected_frame))) - do_switch_frame (data->selected_frame, 0, 0, Qnil); + do_switch_frame (NILP (dont_set_frame) + ? data->selected_frame + : old_frame + , 0, 0, Qnil); } FRAME_WINDOW_CHANGE (f) = true; @@ -7187,11 +7196,13 @@ the return value is nil. Otherwise the value is t. */) return FRAME_LIVE_P (f) ? Qt : Qnil; } - void restore_window_configuration (Lisp_Object configuration) { - Fset_window_configuration (configuration); + if (CONSP (configuration)) + Fset_window_configuration (XCDR (configuration), XCAR (configuration)); + else + Fset_window_configuration (configuration, Qnil); } -- 2.39.5