GNU bug report logs - #48674
Frames and minibuffer bug

Previous Next

Package: emacs;

Reported by: Iris García <iris.garcia.desebastian <at> gmail.com>

Date: Wed, 26 May 2021 14:42:04 UTC

Severity: normal

Merged with 48675

Found in version 28.0.50

Done: Alan Mackenzie <acm <at> muc.de>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Iris García <iris.garcia.desebastian <at> gmail.com>
To: martin rudalics <rudalics <at> gmx.at>
Cc: 48674 <at> debbugs.gnu.org, Alan Mackenzie <acm <at> muc.de>
Subject: bug#48674: Frames and minibuffer bug
Date: Thu, 27 May 2021 19:56:03 +0000
[Message part 1 (text/plain, inline)]
Hi Martin,

I forgot to include you in my last mail where I said:

I think I have found the new issue (it is related to the former one), my
> code this time was the following:
>
> (defvar box-cursor t)
>
> (defun test/set-cursor()
>   "Set cursor in all frames depending on the active state."
>   (interactive)
>   (dolist (frame (frame-list))
>     (with-selected-frame frame
>       (if box-cursor
>           (progn
>             (modify-frame-parameters
>              frame (list (cons 'cursor-type 'box)))
>             (modify-frame-parameters
>              frame (list (cons 'cursor-color "#00A9FE"))))
>         (progn
>           (modify-frame-parameters
>            frame (list (cons 'cursor-type 'hbar)))
>           (modify-frame-parameters
>            frame (list (cons 'cursor-color "green")))
>           )))))
>
> (defun test/enter-minibuffer()
>   (setq box-cursor nil)
>   (test/set-cursor))
>
> (defun test/exit-minibuffer()
>   (setq box-cursor t)
>   (test/set-cursor))
>
>
> (add-hook 'window-state-change-hook #'test/enter-minibuffer)
> (add-hook 'window-state-change-hook #'test/exit-minibuffer)
>
> (server-start)
> (make-frame
>
> The only difference is the add-hook, this time using
> window-state-change-hook instead of minibuffer-...
> This leads to the same bug.
>
> Regards,
>
> Iris.
>

On Thu, 27 May 2021 at 16:33, martin rudalics <rudalics <at> gmx.at> wrote:

>  > 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.
>
> Does this mean that the
>
>    Fselect_window (f->selected_window, norecord);
>
> in do_switch_frame fails?  If so, why?  Do we anywhere violate the
>
>    (eq (selected-window) (frame-selected-window (selected-frame)))
>
> invariant?  That might be fatal.  Both, `with-selected-frame' and
> `with-selected-window', should leave no traces behind.
>
>  > 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);
>  > +
>
> Are we sure that we want to disallow a function on
> `minibuffer-setup-hook' to change the selected window?  With Emacs 27
>
>
> (defun foo ()
>    (select-window (frame-first-window)))
>
> (add-hook 'minibuffer-setup-hook 'foo)
>
>
> works without any problems here.
>
> The NORECORD argument is important only if you need it - so far, the
> previous buffers of the minibuffer window were largely ignored.
>
> martin
>
>
[Message part 2 (text/html, inline)]

This bug report was last modified 3 years and 355 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.