unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: martin rudalics <rudalics@gmx.at>
Cc: 48674@debbugs.gnu.org, "Iris García" <iris.garcia.desebastian@gmail.com>
Subject: bug#48674: Frames and minibuffer bug
Date: Thu, 27 May 2021 10:34:36 +0000	[thread overview]
Message-ID: <YK91vK/0eW629D/E@ACM> (raw)
In-Reply-To: <1911d1b0-ed9f-7359-b28c-fbaef27df8f3@gmx.at>

Hello, Iris and Martin.

Iris, thanks for taking the trouble to report this bug, and thanks even
more for cutting the test case down to the absolute minimum, making the
bug easier to diagnose.

On Wed, May 26, 2021 at 19:45:11 +0200, martin rudalics wrote:
> merge 48674 48675
> quit

> Thanks for the report.  I've just tried to merge this with the following
> one.

>  > 4. M-x (The bug appears, it is not possible to write in the minibuffer)

> The crucial part is the

>    (dolist (frame (frame-list))
>      (with-selected-frame frame

> setting the cursor is not necessary to reproduce it.  Since the bug does
> not appear with Emacs 27, this could be due to Alan's minibuffer window
> changes.

Sort of, almost.

What is happening is that the with-selected-frame invocation is
selecting (temporarily) a different frame from the minibuffer's frame.
This has the (intended) side effect of making the MB no longer selected
in that frame.  When the MB's frame becomes selected again, nothing
makes the mini-window the selected window.  This needs fixing.

I think it likely that this bug could be triggered in Emacs 27 by
putting something into minibuffer-setup-hook that selects a different
window in the MB's frame, though I haven't tried this.

>  > Note:
>  > As soon as the new frame is destroyed, it is possible again to write in the
>  > minibuffer.

> Right but as soon as I make another frame and type M-x I get

> completing-read-default: Command attempted to use minibuffer while in minibuffer

> so I'm at the same time in the active minibuffer and a normal buffer.

Yes.  I think the following patch should fix the trouble.  Iris, could
you please apply the patch (in directory ..../emacs/src) and rebuild
your Emacs-28, then try it out on your real lisp source code.  Should
you want any help with the patching or building, feel free to send me
private email.  Then please confirm that the problem is fixed, or tell
us what's still not working.  Thanks!

Martin, that Qt in the Fselect_window call (the NORECORD argument) -
would it be perhaps be better as Qnil?


diff --git a/src/minibuf.c b/src/minibuf.c
index cffb7fe787..3468643a7e 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -893,6 +893,11 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
 
   run_hook (Qminibuffer_setup_hook);
 
+  /* If the above hook has made the mini-window no longer the selected
+     window, restore it.  */
+  if (!EQ (selected_window, minibuf_window))
+    Fselect_window (minibuf_window , Qt);
+
   /* Don't allow the user to undo past this point.  */
   bset_undo_list (current_buffer, Qnil);
 


> martin

-- 
Alan Mackenzie (Nuremberg, Germany).





  reply	other threads:[~2021-05-27 10:34 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-26 11:23 bug#48674: Frames and minibuffer bug Iris García
2021-05-26 17:45 ` martin rudalics
2021-05-27 10:34   ` Alan Mackenzie [this message]
2021-05-27 16:33     ` martin rudalics
2021-05-27 19:56       ` Iris García
2021-05-28  8:25         ` martin rudalics
2021-05-28  9:34           ` Iris García
2021-05-28  9:51             ` martin rudalics
2021-05-31 16:36         ` Alan Mackenzie
2021-06-01 11:29           ` Iris García
2021-05-27 20:01       ` Alan Mackenzie
2021-05-28  8:26         ` martin rudalics
2021-05-28 17:15           ` Alan Mackenzie
2021-05-28 20:14             ` Alan Mackenzie
2021-05-29  9:20               ` martin rudalics
2021-05-29 13:10                 ` Alan Mackenzie
2021-05-29 15:12                   ` martin rudalics
2021-05-29 15:24                     ` Eli Zaretskii
2021-05-29 17:00                     ` Alan Mackenzie
2021-05-30 13:58                       ` Alan Mackenzie
2021-05-31  7:55                         ` martin rudalics

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YK91vK/0eW629D/E@ACM \
    --to=acm@muc.de \
    --cc=48674@debbugs.gnu.org \
    --cc=iris.garcia.desebastian@gmail.com \
    --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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).