[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Stop frames stealing eachothers' minibuffers!
From: |
Alan Mackenzie |
Subject: |
Re: Stop frames stealing eachothers' minibuffers! |
Date: |
Sat, 14 Nov 2020 21:37:38 +0000 |
Hello, Martin and Eli.
On Sat, Nov 14, 2020 at 20:24:32 +0100, martin rudalics wrote:
> > Arguably, Fset_window_configuration selecting the pertinent frame is a
> > bug in the specification of that function - one should be able to restore
> > a frame's configuration without selecting the frame as well. However,
> > backwards compatibility, and all that....
> You'd first have to get rid of the two select_window calls which select
> the frame whose configuration gets restored. Fset_window_configuration
> is a PITA.
Actually, I just put in a do_switch_frame back to the frame which was
the selected one at the beginning of the function.
But I agree with you about Fset_window_configuration.
Anyway, here's a provisional patch. I realise that my amendment to the
doc string of Fset_window_configuration is poor, but it's too late to
fix it tonight. ;-( I also realise I'll need to amend the Elisp manual
and NEWS, but also not tonight.
The patch seems to fix the bug (the one about a "recursive" C-x b
displaying its error message in the wrong frame).
Comments are welcome.
diff --git a/src/keyboard.c b/src/keyboard.c
index 49a0a8bd23..1579c007ec 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 8c19559b08..acb633c583 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 a6de34f3db..3187720f89 100644
--- a/src/window.c
+++ b/src/window.c
@@ -6824,19 +6826,24 @@ 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, the original frame of CONFIGURATION gets selected, but if
DONT-SET-FRAME is
+non-nil, the frame selected at the beginning of this function remains selected.
+
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 +7160,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;
@@ -7191,7 +7201,10 @@ the return value is nil. Otherwise the value is t. */)
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);
}
> martin
--
Alan Mackenzie (Nuremberg, Germany).
- Re: Stop frames stealing eachothers' minibuffers!, (continued)
- Re: Stop frames stealing eachothers' minibuffers!, Andrii Kolomoiets, 2020/11/10
- Re: Stop frames stealing eachothers' minibuffers!, Stefan Monnier, 2020/11/10
- Re: Stop frames stealing eachothers' minibuffers!, Andrii Kolomoiets, 2020/11/11
- Re: Stop frames stealing eachothers' minibuffers!, Eli Zaretskii, 2020/11/11
- Re: Stop frames stealing eachothers' minibuffers!, Alan Mackenzie, 2020/11/11
- Re: Stop frames stealing eachothers' minibuffers!, Eli Zaretskii, 2020/11/14
- Re: Stop frames stealing eachothers' minibuffers!, Eli Zaretskii, 2020/11/14
- Re: Stop frames stealing eachothers' minibuffers!, Alan Mackenzie, 2020/11/14
- Re: Stop frames stealing eachothers' minibuffers!, Eli Zaretskii, 2020/11/14
- Re: Stop frames stealing eachothers' minibuffers!, martin rudalics, 2020/11/14
- Re: Stop frames stealing eachothers' minibuffers!,
Alan Mackenzie <=
- Re: Stop frames stealing eachothers' minibuffers!, martin rudalics, 2020/11/15
- Re: Stop frames stealing eachothers' minibuffers!, Alan Mackenzie, 2020/11/19
- Re: Stop frames stealing eachothers' minibuffers!, Andrii Kolomoiets, 2020/11/19
- Re: Stop frames stealing eachothers' minibuffers!, Alan Mackenzie, 2020/11/19
- Re: Stop frames stealing eachothers' minibuffers!, martin rudalics, 2020/11/20
- Re: Stop frames stealing eachothers' minibuffers!, Alan Mackenzie, 2020/11/20
- Re: Stop frames stealing eachothers' minibuffers!, Stefan Monnier, 2020/11/20
- Re: Stop frames stealing eachothers' minibuffers!, martin rudalics, 2020/11/21
- Re: Stop frames stealing eachothers' minibuffers!, Alan Mackenzie, 2020/11/21
- Re: Stop frames stealing eachothers' minibuffers!, martin rudalics, 2020/11/21