From: Alan Mackenzie <acm@muc.de>
To: martin rudalics <rudalics@gmx.at>
Cc: Andrii Kolomoiets <andreyk.mad@gmail.com>,
emacs-devel@gnu.org, enometh@meer.net,
Stefan Monnier <monnier@iro.umontreal.ca>,
Gregory Heytings <ghe@sdf.org>, Eli Zaretskii <eliz@gnu.org>
Subject: Re: Stop frames stealing eachothers' minibuffers!
Date: Sun, 10 Jan 2021 00:53:36 +0000 [thread overview]
Message-ID: <X/pQEJzrr+ygUTQi@ACM> (raw)
In-Reply-To: <2d91b8cb-0206-32f0-a577-f243fb534aec@gmx.at>
[-- Attachment #1: Type: text/plain, Size: 5982 bytes --]
Hello, Martin.
On Thu, Jan 07, 2021 at 19:26:02 +0100, martin rudalics wrote:
> > Actualy, I don't think it's as ugly as all that.
> > select-frame-set-input-focus is an extremely coherent function; it does
> > one thing and does it well, i.e. switch frames. Maybe it's a pity that
> > it's a Lisp function rather than a C function, but it is as it is.
> It does call 'raise-frame' something people with 'focus-follows-mouse' t
> (not 'auto-raise') might not want here. And it may have to move the
> mouse cursor according to the 'mouse-autoselect-window' and
> 'focus-follows-mouse' policies. Most window managers don't handle the
> latter well (IIRC only the otherwise abominable mutter and KDE could do
> it approximately). And the former wants the selected window to be set
> up well before calling 'select-frame-set-input-focus'.
It is nevertheless the standard function to call to move focus to a
different frame. If there are problems with focus-follows-mouse, they
should surely be fixed in frame.el as a separate problem.
> > I've been trying to think through the bit about redirect-frame-focus.
> > It's difficult. Are you aware of any particular scenarios where it might
> > go wrong with select-frame-set-input-focus? Or is it more a general
> > concern, possibly from past experience? For example if the source frame
> > has focus redirected to a MB-only frame, and s-f-s-i-focus is called,
> > should that redirected focus be undone? I'm a little confused about the
> > difference between a MB-only frame being the selected frame, and it being
> > the focus frame of a different "normal" frame.
> I already had to revert one change because I got that wrong. It's again
> mostly about using 'focus-follows-mouse' t with a standalone minibuffer
> frame and I've never been able to understand how people manage that when
> the normal frame practically completely covers the minibuffer frame.
> But sooner or later this point will get moot because with Wayland people
> will be no more able to put a standalone minibuffer frame wherever they
> want to.
OK. My gut feeling is just to ignore this potential problem at the
moment.
> >> We're right in hell's kitchen here.
> > I've actually implemented the above, on a trial basis. It was actually
> > surprisingly easy. The C-g bit was just 9 extra lines (plus comments) in
> > internal_catch (eval.c), and another small function in minibuf.c.
> > You say "hell's kitchen". Again, is this on general principles,
> Just gut feeling.
OK. I can understand that. ;-)
> > or can
> > you see some specific problems which might crop up? My feeling is that
> > this way of dealing with "not the innermost minibuffer" is simple, and
> > possibly as good as we're going to get.
My intention at the moment is to commit my current state of work. I'm
attaching the patch.
Here's a commit message to go with it:
Fix incompleteness in the implementation of minibuffer-follows-selected-frame
In particular, add a new value to the variable, and fix several bugs apparent
with the implementation up till now.
* doc/emacs/mini.texi (Basic Minibuffer): Add a description of the new
non-nil, non-t value of minibuffer-follows-selected-frame.
* doc/emacs/trouble.texi (Quitting): Add a description of how C-g handles
recursive minibuffers when typed in one which isn't the most nested.
* doc/lispref/minibuf.texi (Intro to Minibuffers): Add an @dfn for "active
minibuffer".
(Minibuffer Commands): Document that exit-minibuffer throws an error when not
invoked from the innermost Minibuffer.
(Recursive Mini): Amend the description of the visibility of outer level
minibuffers.
(Minibuffer Misc): In the description of the minibuffer hooks, replace "the
minibuffer" with "a minibuffer".
* etc/NEWS (Entry announcing minibuffer-follows-selected-frame): Add a
description of the new non-nil, non-t value.
* lisp/cus-start.el (top level): make the customize entry for
minibuffer-follows-selected-frame a choice between three entries.
* lisp/minibuffer.el (exit-minibuffer): throw an error when we're not in the
most nested minibuffer.
* lisp/window.el (window-deletable-p): return the symbol `frame' when (amongst
other things) minibuffer-follows-selected-frame is t.
* src/eval.c (internal_catch): Add a mechanism to (throw 'exit t) repeatedly
when the throw currently being processed doesn't terminate the current
minibuffer.
* src/lisp.h (this_minibuffer_depth): New extern declaration
(minibuf_level): extern declaration moved here from window.h.
* src/minibuf.c (minibuffer_follows_frame, minibuf_stays_put)
(minibuf_moves_frame_when_opened): New and amended functions to query the
value of minibuffer-follows-selected-frame.
(choose_minibuf_frame): check (minibuf > 1) in place of (minibufer > 0) at a
particular place. At another place, check that an alleged frame is so and is
live. Before selecting a non-miniwindow on a different frame, ensure it
really is a different frame.
(move_minibuffer_onto_frame): Stack up all recursive minibuffers on the target
frame. Check the minibuf_window isn't in the old frame before setting that
frame's miniwindow to an inactive minibuffer.
(Finnermost_minibuffer_p): New primitive.
(this_minibuffer_depth): New function.
(read_minibuf): Record the calling frame in a variable, and switch back to it
after the recursive edit has terminated normally, using
select-frame-set-input-focus. Stack up all the recursive minibuffers on the
miniwindow where a new minibuffer is being opened. After the recursive edit,
switch the selected window away from the expired minibuffer's window.
(nth_minibuffer): New function.
(minibuffer-follows-selected-frame): Change from a DEFVAR_BOOL to a
DEFVAR_LISP.
* src/window.c (decode_next_window_args): Set *minibuf to w's mini-window's
content when that content is a minibuffer.
* src/window.h (minibuf_level) Declaration moved from here to lisp.h.
> martin
--
Alan Mackenzie (Nuremberg, Germany).
[-- Attachment #2: diff.20210109c.diff --]
[-- Type: text/plain, Size: 21714 bytes --]
diff --git a/doc/emacs/mini.texi b/doc/emacs/mini.texi
index c7c8fb30ac..f81e64bdf9 100644
--- a/doc/emacs/mini.texi
+++ b/doc/emacs/mini.texi
@@ -76,9 +76,13 @@ Basic Minibuffer
the user option @code{minibuffer-follows-selected-frame} to
@code{nil}, then the minibuffer stays in the frame where you opened
it, and you must switch back to that frame in order to complete (or
-abort) the current command. Note that the effect of the command, when
-you finally finish using the minibuffer, always takes place in the
-frame where you first opened it.
+abort) the current command. If you set that option to a value which
+is neither @code{nil} nor @code{t}, the minibuffer moves frame only
+after a recursive minibuffer has been opened in the current command
+(@pxref{Recursive Mini,,, elisp}). This option is mainly to retain
+(approximately) the behavior prior to Emacs 28.1. Note that the
+effect of the command, when you finally finish using the minibuffer,
+always takes place in the frame where you first opened it.
@node Minibuffer File
@section Minibuffers for File Names
diff --git a/doc/emacs/trouble.texi b/doc/emacs/trouble.texi
index 4da3d4a3e8..13f03814fd 100644
--- a/doc/emacs/trouble.texi
+++ b/doc/emacs/trouble.texi
@@ -57,6 +57,13 @@ Quitting
successive @kbd{C-g} characters to get out of a search.
@xref{Incremental Search}, for details.
+ If you type @kbd{C-g} in a minibuffer, this quits the command that
+opened that minibuffer, closing it. If that minibuffer is not the
+most recently opened one (which can happen when
+@code{minibuffer-follows-selected-frame} is @code{nil} (@pxref{Basic
+Minibuffer})), @kbd{C-g} closes the more recently opened ones,
+quitting their associated commands.
+
On MS-DOS, the character @kbd{C-@key{Break}} serves as a quit character
like @kbd{C-g}. The reason is that it is not feasible, on MS-DOS, to
recognize @kbd{C-g} while a command is running, between interactions
diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi
index f0036f0ccf..da7c22eb9c 100644
--- a/doc/lispref/minibuf.texi
+++ b/doc/lispref/minibuf.texi
@@ -82,10 +82,12 @@ Intro to Minibuffers
incrementing the number at the end of the name. (The names begin with
a space so that they won't show up in normal buffer lists.) Of
several recursive minibuffers, the innermost (or most recently
-entered) is the active minibuffer. We usually call this @emph{the}
-minibuffer. You can permit or forbid recursive minibuffers by setting
-the variable @code{enable-recursive-minibuffers}, or by putting
-properties of that name on command symbols (@xref{Recursive Mini}.)
+entered) is the @dfn{active minibuffer}--it is the one you can
+terminate by typing @key{RET} (@code{exit-minibuffer}) in. We usually
+call this @emph{the} minibuffer. You can permit or forbid recursive
+minibuffers by setting the variable
+@code{enable-recursive-minibuffers}, or by putting properties of that
+name on command symbols (@xref{Recursive Mini}.)
Like other buffers, a minibuffer uses a local keymap
(@pxref{Keymaps}) to specify special key bindings. The function that
@@ -348,7 +350,7 @@ Text from Minibuffer
@item @key{RET}
@code{exit-minibuffer}
-@item @kbd{M-<}
+@item @key{M-<}
@code{minibuffer-beginning-of-buffer}
@item @kbd{C-g}
@@ -2380,7 +2382,8 @@ Minibuffer Commands
@deffn Command exit-minibuffer
This command exits the active minibuffer. It is normally bound to
-keys in minibuffer local keymaps.
+keys in minibuffer local keymaps. The command throws an error if the
+current buffer is not the active minibuffer.
@end deffn
@deffn Command self-insert-and-exit
@@ -2594,8 +2597,11 @@ Recursive Mini
If this variable is non-@code{nil}, you can invoke commands (such as
@code{find-file}) that use minibuffers even while the minibuffer is
active. Such invocation produces a recursive editing level for a new
-minibuffer. The outer-level minibuffer is invisible while you are
-editing the inner one.
+minibuffer. By default, the outer-level minibuffer is invisible while
+you are editing the inner one. If you have
+@code{minibuffer-follows-selected-frame} set to @code{nil}, you can
+have minibuffers visible on several frames at the same time.
+@xref{Basic Minibuffer,,, emacs}.
If this variable is @code{nil}, you cannot invoke minibuffer commands
when the minibuffer is active, not even if you switch to another window
@@ -2623,7 +2629,7 @@ Minibuffer Misc
@end defun
@defvar minibuffer-setup-hook
-This is a normal hook that is run whenever the minibuffer is entered.
+This is a normal hook that is run whenever a minibuffer is entered.
@xref{Hooks}.
@end defvar
@@ -2641,7 +2647,7 @@ Minibuffer Misc
@end defmac
@defvar minibuffer-exit-hook
-This is a normal hook that is run whenever the minibuffer is exited.
+This is a normal hook that is run whenever a minibuffer is exited.
@xref{Hooks}.
@end defvar
diff --git a/etc/NEWS b/etc/NEWS
index eaaf9bfb0e..8c0c809231 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -102,12 +102,13 @@ effect should be negligible in the vast majority of cases anyway.
By default, when you switch to another frame, an active minibuffer now
moves to the newly selected frame. Nevertheless, the effect of what
you type in the minibuffer happens in the frame where the minibuffer
-was first activated, even if it moved to another frame. An
-alternative behavior is available by customizing
-'minibuffer-follows-selected-frame' to nil. Here, the minibuffer
-stays in the frame where you first opened it, and you must switch back
-to this frame to continue or abort its command. The old, somewhat
-unsystematic behavior, which mixed these two is no longer available.
+was first activated. An alternative behavior is available by
+customizing 'minibuffer-follows-selected-frame' to nil. Here, the
+minibuffer stays in the frame where you first opened it, and you must
+switch back to this frame to continue or abort its command. The old
+behavior, which mixed these two, can be approximated by customizing
+'minibuffer-follows-selected-frame' to a value which is neither nil
+nor t.
+++
** New system for displaying documentation for groups of functions.
diff --git a/lisp/cus-start.el b/lisp/cus-start.el
index 85dd14f628..0293d34d1c 100644
--- a/lisp/cus-start.el
+++ b/lisp/cus-start.el
@@ -394,7 +394,11 @@ minibuffer-prompt-properties--setter
;; (directory :format "%v"))))
(load-prefer-newer lisp boolean "24.4")
;; minibuf.c
- (minibuffer-follows-selected-frame minibuffer boolean "28.1")
+ (minibuffer-follows-selected-frame
+ minibuffer (choice (const :tag "Always" t)
+ (const :tag "When used" hybrid)
+ (const :tag "Never" nil))
+ "28.1")
(enable-recursive-minibuffers minibuffer boolean)
(history-length minibuffer
(choice (const :tag "Infinite" t) integer)
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 556f5d3a56..cbdd4a90f1 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -2125,8 +2125,10 @@ exit-minibuffer
;; A better solution would be to make deactivate-mark buffer-local
;; (or to turn it into a list of buffers, ...), but in the mean time,
;; this should do the trick in most cases.
- (setq deactivate-mark nil)
- (throw 'exit nil))
+ (when (innermost-minibuffer-p)
+ (setq deactivate-mark nil)
+ (throw 'exit nil))
+ (error "%s" "Not in most nested minibuffer"))
(defun self-insert-and-exit ()
"Terminate minibuffer input."
diff --git a/lisp/window.el b/lisp/window.el
index 38be778906..a6cdd4dec2 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -4116,7 +4116,10 @@ window-deletable-p
frame))
(throw 'other t))))
(let ((minibuf (active-minibuffer-window)))
- (and minibuf (eq frame (window-frame minibuf)))))
+ (and minibuf (eq frame (window-frame minibuf))
+ (not (eq (default-toplevel-value
+ minibuffer-follows-selected-frame)
+ t)))))
'frame))
((window-minibuffer-p window)
;; If WINDOW is the minibuffer window of a non-minibuffer-only
diff --git a/src/eval.c b/src/eval.c
index 706aafdf50..5bf3faebc8 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1167,9 +1167,18 @@ Lisp_Object
internal_catch (Lisp_Object tag,
Lisp_Object (*func) (Lisp_Object), Lisp_Object arg)
{
+ /* MINIBUFFER_QUIT_LEVEL is to handle quitting from nested minibuffers by
+ throwing t to tag `exit'.
+ Value -1 means there is no (throw 'exit t) in progress;
+ 0 means the `throw' wasn't done from an active minibuffer;
+ N > 0 means the `throw' was done from the minibuffer at level N. */
+ static EMACS_INT minibuffer_quit_level = -1;
/* This structure is made part of the chain `catchlist'. */
struct handler *c = push_handler (tag, CATCHER);
+ if (EQ (tag, Qexit))
+ minibuffer_quit_level = -1;
+
/* Call FUNC. */
if (! sys_setjmp (c->jmp))
{
@@ -1183,6 +1192,23 @@ internal_catch (Lisp_Object tag,
Lisp_Object val = handlerlist->val;
clobbered_eassert (handlerlist == c);
handlerlist = handlerlist->next;
+ if (EQ (tag, Qexit) && EQ (val, Qt))
+ /* If we've thrown t to tag `exit' from within a minibuffer, we
+ exit all minibuffers more deeply nested than the current
+ one. */
+ {
+ EMACS_INT mini_depth = this_minibuffer_depth (Qnil);
+ if (mini_depth && mini_depth != minibuffer_quit_level)
+ {
+ if (minibuffer_quit_level == -1)
+ minibuffer_quit_level = mini_depth;
+ if (minibuffer_quit_level
+ && (minibuf_level > minibuffer_quit_level))
+ Fthrow (Qexit, Qt);
+ }
+ else
+ minibuffer_quit_level = -1;
+ }
return val;
}
}
diff --git a/src/lisp.h b/src/lisp.h
index d139df9342..86be25852a 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4346,6 +4346,8 @@ extern Lisp_Object Vminibuffer_list;
extern Lisp_Object last_minibuf_string;
extern void move_minibuffer_onto_frame (void);
extern bool is_minibuffer (EMACS_INT, Lisp_Object);
+extern EMACS_INT this_minibuffer_depth (Lisp_Object);
+extern EMACS_INT minibuf_level;
extern Lisp_Object get_minibuffer (EMACS_INT);
extern void init_minibuf_once (void);
extern void syms_of_minibuf (void);
diff --git a/src/minibuf.c b/src/minibuf.c
index 5ee440f662..758377532e 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -63,9 +63,30 @@ static Lisp_Object minibuf_prompt;
static ptrdiff_t minibuf_prompt_width;
+static Lisp_Object nth_minibuffer (EMACS_INT depth);
+
\f
+/* Return TRUE when a frame switch causes a minibuffer on the old
+ frame to move onto the new one. */
static bool
minibuf_follows_frame (void)
+{
+ return EQ (Fdefault_toplevel_value (Qminibuffer_follows_selected_frame),
+ Qt);
+}
+
+/* Return TRUE when a minibuffer always remains on the frame where it
+ was first invoked. */
+static bool
+minibuf_stays_put (void)
+{
+ return NILP (Fdefault_toplevel_value (Qminibuffer_follows_selected_frame));
+}
+
+/* Return TRUE when opening a (recursive) minibuffer causes
+ minibuffers on other frames to move to the selected frame. */
+static bool
+minibuf_moves_frame_when_opened (void)
{
return !NILP (Fdefault_toplevel_value (Qminibuffer_follows_selected_frame));
}
@@ -90,7 +111,7 @@ choose_minibuf_frame (void)
minibuf_window = sf->minibuffer_window;
/* If we've still got another minibuffer open, use its mini-window
instead. */
- if (minibuf_level && !minibuf_follows_frame ())
+ if (minibuf_level > 1 && minibuf_stays_put ())
{
Lisp_Object buffer = get_minibuffer (minibuf_level);
Lisp_Object tail, frame;
@@ -105,26 +126,40 @@ choose_minibuf_frame (void)
}
}
- if (minibuf_follows_frame ())
+ if (minibuf_moves_frame_when_opened ()
+ && FRAMEP (selected_frame)
+ && FRAME_LIVE_P (XFRAME (selected_frame)))
/* Make sure no other frame has a minibuffer as its selected window,
because the text would not be displayed in it, and that would be
confusing. Only allow the selected frame to do this,
and that only if the minibuffer is active. */
- {
- Lisp_Object tail, frame;
-
- FOR_EACH_FRAME (tail, frame)
- if (MINI_WINDOW_P (XWINDOW (FRAME_SELECTED_WINDOW (XFRAME (frame))))
- && !(EQ (frame, selected_frame)
- && minibuf_level > 0))
- Fset_frame_selected_window (frame, Fframe_first_window (frame),
- Qnil);
- }
+ {
+ Lisp_Object tail, frame;
+ struct frame *of;
+
+ FOR_EACH_FRAME (tail, frame)
+ if (!EQ (frame, selected_frame)
+ && minibuf_level > 1
+ /* The frame's minibuffer can be on a different frame. */
+ && XWINDOW ((of = XFRAME (frame))->minibuffer_window)->frame
+ != selected_frame)
+ {
+ if (MINI_WINDOW_P (XWINDOW (FRAME_SELECTED_WINDOW (of))))
+ Fset_frame_selected_window (frame, Fframe_first_window (frame),
+ Qnil);
+
+ if (!EQ (XWINDOW (of->minibuffer_window)->contents,
+ nth_minibuffer (0)))
+ set_window_buffer (of->minibuffer_window,
+ nth_minibuffer (0), 0, 0);
+ }
+ }
}
-/* If `minibuffer_follows_selected_frame' and we have a minibuffer, move it
- from its current frame to the selected frame. This function is
- intended to be called from `do_switch_frame' in frame.c. */
+/* If `minibuffer_follows_selected_frame' is t and we have a
+ minibuffer, move it from its current frame to the selected frame.
+ This function is intended to be called from `do_switch_frame' in
+ frame.c. */
void move_minibuffer_onto_frame (void)
{
if (!minibuf_level)
@@ -135,14 +170,18 @@ void move_minibuffer_onto_frame (void)
&& FRAME_LIVE_P (XFRAME (selected_frame))
&& !EQ (minibuf_window, XFRAME (selected_frame)->minibuffer_window))
{
+ EMACS_INT i;
struct frame *sf = XFRAME (selected_frame);
Lisp_Object old_frame = XWINDOW (minibuf_window)->frame;
struct frame *of = XFRAME (old_frame);
- Lisp_Object buffer = XWINDOW (minibuf_window)->contents;
- set_window_buffer (sf->minibuffer_window, buffer, 0, 0);
+ /* Stack up all the (recursively) open minibuffers on the selected
+ mini_window. */
+ for (i = 1; i <= minibuf_level; i++)
+ set_window_buffer (sf->minibuffer_window, nth_minibuffer (i), 0, 0);
minibuf_window = sf->minibuffer_window;
- set_window_buffer (of->minibuffer_window, get_minibuffer (0), 0, 0);
+ if (of != sf)
+ set_window_buffer (of->minibuffer_window, get_minibuffer (0), 0, 0);
}
}
@@ -336,6 +375,39 @@ return t only if BUFFER is an active minibuffer. */)
? Qt : Qnil;
}
+DEFUN ("innermost-minibuffer-p", Finnermost_minibuffer_p,
+ Sinnermost_minibuffer_p, 0, 1, 0,
+ doc: /* Return t if BUFFER is the most nested active minibuffer.
+No argument or nil as argument means use the current buffer as BUFFER. */)
+ (Lisp_Object buffer)
+{
+ if (NILP (buffer))
+ buffer = Fcurrent_buffer ();
+ return EQ (buffer, (Fcar (Fnthcdr (make_fixnum (minibuf_level),
+ Vminibuffer_list))))
+ ? Qt
+ : Qnil;
+}
+
+/* Return the nesting depth of the active minibuffer BUFFER, or 0 if
+ BUFFER isn't such a thing. If BUFFER is nil, this means use the current
+ buffer. */
+EMACS_INT
+this_minibuffer_depth (Lisp_Object buffer)
+{
+ EMACS_INT i;
+ Lisp_Object bufs;
+
+ if (NILP (buffer))
+ buffer = Fcurrent_buffer ();
+ for (i = 1, bufs = Fcdr (Vminibuffer_list);
+ i <= minibuf_level;
+ i++, bufs = Fcdr (bufs))
+ if (EQ (Fcar (bufs), buffer))
+ return i;
+ return 0;
+}
+
DEFUN ("minibuffer-prompt-end", Fminibuffer_prompt_end,
Sminibuffer_prompt_end, 0, 0, 0,
doc: /* Return the buffer position of the end of the minibuffer prompt.
@@ -411,6 +483,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
Lisp_Object val;
ptrdiff_t count = SPECPDL_INDEX ();
Lisp_Object mini_frame, ambient_dir, minibuffer, input_method;
+ Lisp_Object calling_frame = selected_frame;
Lisp_Object enable_multibyte;
EMACS_INT pos = 0;
/* String to add to the history. */
@@ -648,6 +721,17 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
}
}
+ if (minibuf_moves_frame_when_opened ())
+ {
+ EMACS_INT i;
+
+ /* Stack up all the (recursively) open minibuffers on the selected
+ mini_window. */
+ for (i = 1; i < minibuf_level; i++)
+ set_window_buffer (XFRAME (mini_frame)->minibuffer_window,
+ nth_minibuffer (i), 0, 0);
+ }
+
/* Display this minibuffer in the proper window. */
/* Use set_window_buffer instead of Fset_window_buffer (see
discussion of bug#11984, bug#12025, bug#12026). */
@@ -729,6 +813,20 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
recursive_edit_1 ();
+ /* We've exited the recursive edit without an error, so switch the
+ current window away from the expired minibuffer window. */
+ {
+ Lisp_Object prev = Fprevious_window (minibuf_window, Qnil, Qnil);
+ /* PREV can be on a different frame when we have a minibuffer only
+ frame, the other frame's minibuffer window is MINIBUF_WINDOW,
+ and its "focus window" is also MINIBUF_WINDOW. */
+ while (!EQ (prev, minibuf_window)
+ && !EQ (selected_frame, WINDOW_FRAME (XWINDOW (prev))))
+ prev = Fprevious_window (prev, Qnil, Qnil);
+ if (!EQ (prev, minibuf_window))
+ Fset_frame_selected_window (selected_frame, prev, Qnil);
+ }
+
/* If cursor is on the minibuffer line,
show the user we have exited by putting it in column 0. */
if (XWINDOW (minibuf_window)->cursor.vpos >= 0
@@ -767,6 +865,12 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
in set-window-configuration. */
unbind_to (count, Qnil);
+ /* Switch the frame back to the calling frame. */
+ if (!EQ (selected_frame, calling_frame)
+ && FRAMEP (calling_frame)
+ && FRAME_LIVE_P (XFRAME (calling_frame)))
+ call2 (intern ("select-frame-set-input-focus"), calling_frame, Qnil);
+
/* Add the value to the appropriate history list, if any. This is
done after the previous buffer has been made current again, in
case the history variable is buffer-local. */
@@ -790,6 +894,14 @@ is_minibuffer (EMACS_INT depth, Lisp_Object buf)
&& EQ (Fcar (tail), buf);
}
+/* Return the DEPTHth minibuffer, or nil if such does not yet exist. */
+static Lisp_Object
+nth_minibuffer (EMACS_INT depth)
+{
+ Lisp_Object tail = Fnthcdr (make_fixnum (depth), Vminibuffer_list);
+ return XCAR (tail);
+}
+
/* Return a buffer to be used as the minibuffer at depth `depth'.
depth = 0 is the lowest allowed argument, and that is the value
used for nonrecursive minibuffer invocations. */
@@ -2032,13 +2144,15 @@ For example, `eval-expression' uses this. */);
The function is called with the arguments passed to `read-buffer'. */);
Vread_buffer_function = Qnil;
- DEFVAR_BOOL ("minibuffer-follows-selected-frame", minibuffer_follows_selected_frame,
- doc: /* Non-nil means the active minibuffer always displays on the selected frame.
+ DEFVAR_LISP ("minibuffer-follows-selected-frame", minibuffer_follows_selected_frame,
+ doc: /* t means the active minibuffer always displays on the selected frame.
Nil means that a minibuffer will appear only in the frame which created it.
+Any other value means the minibuffer will move onto another frame, but
+only when the user starts using a minibuffer there.
Any buffer local or dynamic binding of this variable is ignored. Only the
default top level value is used. */);
- minibuffer_follows_selected_frame = 1;
+ minibuffer_follows_selected_frame = Qt;
DEFVAR_BOOL ("read-buffer-completion-ignore-case",
read_buffer_completion_ignore_case,
@@ -2196,6 +2310,7 @@ uses to hide passwords. */);
defsubr (&Sminibuffer_prompt);
defsubr (&Sminibufferp);
+ defsubr (&Sinnermost_minibuffer_p);
defsubr (&Sminibuffer_prompt_end);
defsubr (&Sminibuffer_contents);
defsubr (&Sminibuffer_contents_no_properties);
diff --git a/src/window.c b/src/window.c
index 5e78aa400b..fe3a93f7ac 100644
--- a/src/window.c
+++ b/src/window.c
@@ -2663,12 +2663,15 @@ static void
decode_next_window_args (Lisp_Object *window, Lisp_Object *minibuf, Lisp_Object *all_frames)
{
struct window *w = decode_live_window (*window);
+ Lisp_Object miniwin = XFRAME (w->frame)->minibuffer_window;
XSETWINDOW (*window, w);
/* MINIBUF nil may or may not include minibuffers. Decide if it
does. */
if (NILP (*minibuf))
- *minibuf = minibuf_level ? minibuf_window : Qlambda;
+ *minibuf = this_minibuffer_depth (XWINDOW (miniwin)->contents)
+ ? miniwin
+ : Qlambda;
else if (!EQ (*minibuf, Qt))
*minibuf = Qlambda;
diff --git a/src/window.h b/src/window.h
index 332cb3091f..79eb44e7a3 100644
--- a/src/window.h
+++ b/src/window.h
@@ -1124,10 +1124,6 @@ extern Lisp_Object echo_area_window;
extern EMACS_INT command_loop_level;
-/* Depth in minibuffer invocations. */
-
-extern EMACS_INT minibuf_level;
-
/* Non-zero if we should redraw the mode lines on the next redisplay.
Usually set to a unique small integer so we can track the main causes of
full redisplays in `redisplay--mode-lines-cause'. */
next prev parent reply other threads:[~2021-01-10 0:53 UTC|newest]
Thread overview: 259+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-13 19:02 Stop frames stealing eachothers' minibuffers! Alan Mackenzie
2020-10-13 19:20 ` Eli Zaretskii
2020-10-13 19:51 ` Alan Mackenzie
2020-10-13 20:25 ` Gregory Heytings via Emacs development discussions.
2020-10-13 20:44 ` Alan Mackenzie
2020-10-13 21:02 ` Drew Adams
2020-10-14 14:34 ` Eli Zaretskii
2020-10-14 16:02 ` Alan Mackenzie
2020-10-14 16:14 ` Eli Zaretskii
2020-10-14 16:35 ` Alan Mackenzie
2020-10-14 17:05 ` Eli Zaretskii
2020-10-14 18:45 ` Alan Mackenzie
2020-10-14 18:58 ` Eli Zaretskii
2020-10-14 19:49 ` Alan Mackenzie
2020-10-15 13:44 ` Eli Zaretskii
2020-10-15 18:01 ` Alan Mackenzie
2020-10-15 18:18 ` Eli Zaretskii
2020-10-21 15:19 ` Alan Mackenzie
2020-10-21 16:49 ` Drew Adams
2020-10-21 19:13 ` Alan Mackenzie
2020-10-21 18:32 ` Stefan Monnier
2020-10-21 19:38 ` Alan Mackenzie
2020-10-21 20:04 ` Alan Mackenzie
2020-10-22 16:14 ` Eli Zaretskii
2020-10-23 20:42 ` C-x o is moving between frames. [Was: Stop frames stealing eachothers' minibuffers!] Alan Mackenzie
2020-10-23 20:55 ` Stefan Monnier
2020-10-24 7:26 ` Eli Zaretskii
2020-10-24 15:44 ` Alan Mackenzie
2020-10-24 18:40 ` Stefan Monnier
2020-10-24 19:29 ` Alan Mackenzie
2020-10-30 22:09 ` Stop frames stealing eachothers' minibuffers! Alan Mackenzie
2020-10-31 7:25 ` Eli Zaretskii
2020-10-31 16:14 ` Alan Mackenzie
2020-10-31 16:45 ` Eli Zaretskii
2020-10-31 19:44 ` Alan Mackenzie
2020-10-31 20:00 ` Eli Zaretskii
2020-10-31 20:39 ` Alan Mackenzie
2020-11-01 18:35 ` Eli Zaretskii
2020-11-01 19:53 ` Alan Mackenzie
2020-11-01 20:52 ` Non-nested minibuffers (was: Stop frames stealing eachothers' minibuffers!) Stefan Monnier
2020-11-02 17:19 ` Stop frames stealing eachothers' minibuffers! Eli Zaretskii
2020-11-02 18:51 ` Alan Mackenzie
2020-11-02 19:19 ` Eli Zaretskii
2020-11-03 21:08 ` Alan Mackenzie
2020-11-04 16:47 ` Eli Zaretskii
2020-11-04 17:39 ` Alan Mackenzie
2020-11-09 15:09 ` Madhu
2020-11-09 20:34 ` Andrii Kolomoiets
2020-11-10 3:25 ` Eli Zaretskii
2020-11-10 8:08 ` Andrii Kolomoiets
2020-11-10 8:52 ` Eli Zaretskii
2020-11-10 13:21 ` Stefan Monnier
2020-11-10 17:27 ` Andrii Kolomoiets
2020-11-10 18:26 ` Eli Zaretskii
2020-11-10 22:43 ` Andrii Kolomoiets
2020-11-11 15:38 ` Eli Zaretskii
2020-11-10 19:57 ` Stefan Monnier
2020-11-10 22:54 ` Andrii Kolomoiets
2020-11-10 23:18 ` Stefan Monnier
2020-11-11 7:47 ` Andrii Kolomoiets
2020-11-11 16:07 ` Eli Zaretskii
2020-11-11 20:37 ` Alan Mackenzie
2020-11-14 13:36 ` Eli Zaretskii
2020-11-14 17:12 ` Eli Zaretskii
2020-11-14 18:48 ` Alan Mackenzie
2020-11-14 19:11 ` Eli Zaretskii
2020-11-14 19:24 ` martin rudalics
2020-11-14 21:37 ` Alan Mackenzie
2020-11-15 8:48 ` martin rudalics
2020-11-19 10:40 ` Alan Mackenzie
2020-11-19 11:40 ` Andrii Kolomoiets
2020-11-19 13:30 ` Alan Mackenzie
2020-11-20 18:47 ` martin rudalics
2020-11-20 21:00 ` Alan Mackenzie
2020-11-20 21:36 ` Stefan Monnier
2020-11-21 9:02 ` martin rudalics
2020-11-21 10:27 ` Alan Mackenzie
2020-11-21 11:55 ` martin rudalics
2020-11-21 12:45 ` Alan Mackenzie
2020-11-21 15:53 ` martin rudalics
2020-11-22 10:59 ` Alan Mackenzie
2020-11-22 15:13 ` Stefan Monnier
2020-11-22 17:11 ` Alan Mackenzie
2020-11-22 19:58 ` Stefan Monnier
2020-11-22 17:57 ` martin rudalics
2020-11-22 18:38 ` Alan Mackenzie
2020-11-23 9:10 ` martin rudalics
2020-11-23 13:36 ` Alan Mackenzie
2020-11-23 14:22 ` martin rudalics
2020-11-23 16:07 ` Alan Mackenzie
2020-11-23 18:08 ` martin rudalics
2020-11-23 20:16 ` Andrii Kolomoiets
2020-11-24 8:46 ` martin rudalics
2020-11-23 20:22 ` Gregory Heytings via Emacs development discussions.
2020-11-23 20:26 ` Andrii Kolomoiets
2020-11-24 8:47 ` martin rudalics
2020-11-24 8:46 ` martin rudalics
2020-11-24 10:25 ` martin rudalics
2020-11-24 11:37 ` Gregory Heytings via Emacs development discussions.
2020-11-24 19:24 ` martin rudalics
2020-11-25 9:25 ` martin rudalics
2020-11-25 21:09 ` Alan Mackenzie
2020-11-25 21:31 ` Gregory Heytings via Emacs development discussions.
2020-11-25 21:54 ` Alan Mackenzie
2020-11-25 22:23 ` Gregory Heytings via Emacs development discussions.
2020-11-27 10:02 ` Alan Mackenzie
2020-11-27 10:36 ` Gregory Heytings via Emacs development discussions.
2020-11-27 10:47 ` Gregory Heytings via Emacs development discussions.
2020-11-27 11:20 ` Alan Mackenzie
2020-11-27 12:03 ` Gregory Heytings via Emacs development discussions.
2020-11-27 11:14 ` Alan Mackenzie
2020-11-27 12:03 ` Gregory Heytings via Emacs development discussions.
2020-11-27 15:42 ` martin rudalics
2020-11-27 15:54 ` Gregory Heytings via Emacs development discussions.
2020-11-27 17:14 ` martin rudalics
2020-11-27 17:43 ` Gregory Heytings via Emacs development discussions.
2020-11-27 18:08 ` martin rudalics
2020-11-27 20:02 ` Gregory Heytings via Emacs development discussions.
2020-11-27 18:50 ` Eli Zaretskii
2020-11-26 15:44 ` martin rudalics
2020-11-26 20:32 ` Gregory Heytings via Emacs development discussions.
2020-11-27 7:33 ` Gregory Heytings via Emacs development discussions.
2020-11-27 9:34 ` martin rudalics
2020-11-27 10:06 ` Gregory Heytings via Emacs development discussions.
2020-11-27 10:36 ` martin rudalics
2020-11-27 10:43 ` Gregory Heytings via Emacs development discussions.
2020-11-27 15:41 ` martin rudalics
2020-11-27 16:19 ` Gregory Heytings via Emacs development discussions.
2020-11-27 17:14 ` martin rudalics
2020-11-27 18:01 ` Gregory Heytings via Emacs development discussions.
2020-11-27 18:35 ` martin rudalics
2020-11-27 20:05 ` Gregory Heytings via Emacs development discussions.
2020-11-28 10:45 ` Alan Mackenzie
2020-11-28 15:35 ` Alan Mackenzie
2020-11-28 17:02 ` Stefan Monnier
2020-11-28 20:59 ` Gregory Heytings via Emacs development discussions.
2020-11-28 21:10 ` Stefan Monnier
2020-11-28 22:01 ` Gregory Heytings via Emacs development discussions.
2020-11-28 22:10 ` Stefan Monnier
2020-11-28 22:38 ` Gregory Heytings via Emacs development discussions.
2020-11-29 18:15 ` Alan Mackenzie
2020-11-27 10:13 ` Alan Mackenzie
2020-11-27 10:36 ` martin rudalics
2020-11-27 11:30 ` Alan Mackenzie
2020-11-27 12:29 ` Eli Zaretskii
2020-11-27 13:43 ` Gregory Heytings via Emacs development discussions.
2020-11-27 14:09 ` Stefan Monnier
2020-11-27 15:03 ` Eli Zaretskii
2020-11-27 22:00 ` Alan Mackenzie
2020-11-27 15:42 ` martin rudalics
2021-01-03 18:10 ` Alan Mackenzie
2021-01-03 18:24 ` martin rudalics
2021-01-03 18:42 ` Alan Mackenzie
2021-01-03 20:08 ` martin rudalics
2021-01-03 20:43 ` Alan Mackenzie
2021-01-04 9:20 ` martin rudalics
2021-01-05 18:07 ` Alan Mackenzie
2021-01-05 18:53 ` martin rudalics
2021-01-07 17:36 ` Alan Mackenzie
2021-01-07 18:08 ` Drew Adams
2021-01-07 18:26 ` martin rudalics
2021-01-10 0:53 ` Alan Mackenzie [this message]
2021-01-10 1:34 ` Stefan Monnier
2021-01-10 16:03 ` Alan Mackenzie
2021-01-10 16:04 ` martin rudalics
2021-01-10 17:18 ` Alan Mackenzie
2021-01-10 17:30 ` Stefan Monnier
2021-01-10 17:49 ` martin rudalics
2021-01-10 18:25 ` Alan Mackenzie
2021-01-10 19:05 ` martin rudalics
2021-01-06 0:14 ` Gregory Heytings via Emacs development discussions.
2021-01-06 0:48 ` Stefan Monnier
2021-01-06 9:40 ` Gregory Heytings via Emacs development discussions.
2021-01-06 15:52 ` Stefan Monnier
2021-01-07 7:52 ` Richard Stallman
2021-01-07 14:33 ` Eli Zaretskii
2021-01-07 13:27 ` Alan Mackenzie
2021-01-07 23:34 ` Gregory Heytings via Emacs development discussions.
2020-11-26 15:43 ` martin rudalics
2020-11-27 11:53 ` Alan Mackenzie
2020-11-24 12:59 ` Andrii Kolomoiets
2020-11-24 19:24 ` martin rudalics
2020-11-21 17:19 ` Stefan Monnier
2020-11-21 18:08 ` martin rudalics
2020-11-11 8:28 ` martin rudalics
2020-11-11 18:47 ` Drew Adams
2020-11-11 19:10 ` martin rudalics
2020-11-10 16:45 ` Drew Adams
2020-11-10 19:51 ` Stefan Monnier
2020-11-10 20:08 ` Eli Zaretskii
2020-11-10 20:12 ` Drew Adams
2020-10-14 20:17 ` Gregory Heytings via Emacs development discussions.
2020-10-14 17:07 ` Gregory Heytings via Emacs development discussions.
2020-10-13 20:51 ` Andreas Schwab
2020-10-13 21:02 ` Gregory Heytings via Emacs development discussions.
2020-10-13 22:22 ` Stefan Monnier
2020-10-13 22:28 ` Stefan Monnier
2020-10-14 14:47 ` Eli Zaretskii
2020-10-14 17:22 ` Stefan Monnier
2020-10-14 17:32 ` Gregory Heytings via Emacs development discussions.
2020-10-14 17:47 ` Eli Zaretskii
2020-10-15 1:43 ` Stefan Monnier
2020-10-14 17:43 ` Eli Zaretskii
2020-10-15 1:42 ` Stefan Monnier
2020-10-13 19:22 ` Gregory Heytings via Emacs development discussions.
2020-10-13 22:25 ` Stefan Monnier
[not found] <<20201031194419.GC5887@ACM>
[not found] ` <<834kmago8m.fsf@gnu.org>
[not found] ` <<20201031203914.GD5887@ACM>
[not found] ` <<835z6ogc1h.fsf@gnu.org>
[not found] ` <<20201101195313.GA6190@ACM>
[not found] ` <<83sg9rd6cp.fsf@gnu.org>
[not found] ` <<20201102185147.GC7297@ACM>
[not found] ` <<83mtzzd0s3.fsf@gnu.org>
[not found] ` <<20201103210853.GA21923@ACM>
[not found] ` <<83ft5pax2p.fsf@gnu.org>
[not found] ` <<20201104173954.GA14535@ACM>
[not found] ` <<m31rh2pnws.fsf@leonis4.robolove.meer.net>
[not found] ` <<m28sbas208.fsf@gmail.com>
[not found] ` <<83v9ed3nbw.fsf@gnu.org>
[not found] ` <<m21rh1prap.fsf@gmail.com>
[not found] ` <<CF5D4DFC-5288-4D2C-AF4A-A7D1B267CAFF@gnu.org>
[not found] ` <<44261efc-da8d-44f2-9a9a-200d1683b313@default>
[not found] ` <<jwvzh3pvvmi.fsf-monnier+emacs@gnu.org>
[not found] ` <<83imad0yb3.fsf@gnu.org>
2020-11-10 20:17 ` Drew Adams
-- strict thread matches above, loose matches on Subject: below --
2021-02-03 15:20 jakanakaevangeli
2021-02-06 15:52 ` Alan Mackenzie
2021-02-06 23:25 jakanakaevangeli
2021-02-07 12:55 ` Alan Mackenzie
2021-02-07 16:44 ` jakanakaevangeli
2021-02-07 20:26 ` Alan Mackenzie
2021-02-08 12:53 ` jakanakaevangeli
2021-02-11 11:44 ` Alan Mackenzie
2021-02-11 14:29 ` Stefan Monnier
2021-02-12 9:48 ` Alan Mackenzie
2021-03-13 18:23 ` Alan Mackenzie
2021-03-13 19:39 ` Stefan Monnier
2021-03-13 20:24 ` Alan Mackenzie
2021-03-13 20:52 ` Stefan Monnier
2021-03-14 18:26 ` Alan Mackenzie
2021-03-14 18:48 ` Eli Zaretskii
2021-03-14 20:32 ` Stefan Monnier
2021-03-13 20:53 ` jakanakaevangeli
2021-03-14 19:17 ` Alan Mackenzie
2021-03-14 21:23 ` Miha Rihtaršič
2021-03-17 19:32 ` Alan Mackenzie
2021-03-17 19:55 ` Eli Zaretskii
2021-03-17 20:19 ` Eli Zaretskii
2021-03-18 11:27 ` Alan Mackenzie
2021-03-18 11:46 ` Eli Zaretskii
2021-03-18 15:51 ` martin rudalics
2021-03-18 16:58 ` Alan Mackenzie
2021-03-18 18:44 ` Eli Zaretskii
2021-03-19 11:40 ` Alan Mackenzie
2021-03-19 12:33 ` Eli Zaretskii
2021-03-19 15:35 ` Alan Mackenzie
2021-03-19 15:59 ` Eli Zaretskii
2021-03-20 10:28 ` Alan Mackenzie
2021-03-20 10:49 ` Eli Zaretskii
2021-03-20 12:24 ` Alan Mackenzie
2021-03-20 12:49 ` Miha Rihtaršič
2021-03-20 13:59 ` Stefan Monnier
2021-03-21 10:30 ` Alan Mackenzie
2021-03-21 10:38 ` Eli Zaretskii
2021-03-21 10:40 ` Eli Zaretskii
2021-03-21 14:49 ` Alan Mackenzie
2021-03-21 15:00 ` Stefan Monnier
2021-03-21 15:43 ` Eli Zaretskii
2021-03-21 16:17 ` Michael Welsh Duggan
2021-03-21 16:37 ` Alan Mackenzie
2021-03-20 12:50 ` Eli Zaretskii
2021-03-20 13:51 ` Alan Mackenzie
2021-03-20 13:55 ` Stefan Monnier
2021-03-20 14:01 ` Eli Zaretskii
2021-03-20 14:12 ` Alan Mackenzie
2021-03-21 15:44 ` Miha Rihtaršič
2021-03-21 17:03 ` Alan Mackenzie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=X/pQEJzrr+ygUTQi@ACM \
--to=acm@muc.de \
--cc=andreyk.mad@gmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=enometh@meer.net \
--cc=ghe@sdf.org \
--cc=monnier@iro.umontreal.ca \
--cc=rudalics@gmx.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.