From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Iris =?UTF-8?Q?Garc=C3=ADa?= Newsgroups: gmane.emacs.bugs Subject: bug#48674: Frames and minibuffer bug Date: Thu, 27 May 2021 19:56:03 +0000 Message-ID: References: <1911d1b0-ed9f-7359-b28c-fbaef27df8f3@gmx.at> <1e21b121-91c1-cbe9-d9ae-24915f163ae5@gmx.at> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000006ef69205c3552641" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34923"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 48674@debbugs.gnu.org, Alan Mackenzie To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu May 27 21:57:09 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lmM7x-0008tK-F7 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 27 May 2021 21:57:09 +0200 Original-Received: from localhost ([::1]:50966 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lmM7w-0001H3-Dd for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 27 May 2021 15:57:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60434) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lmM7p-0001Gf-RE for bug-gnu-emacs@gnu.org; Thu, 27 May 2021 15:57:01 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41299) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lmM7p-0006GG-JQ for bug-gnu-emacs@gnu.org; Thu, 27 May 2021 15:57:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lmM7p-0001Lg-Hn for bug-gnu-emacs@gnu.org; Thu, 27 May 2021 15:57:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Iris =?UTF-8?Q?Garc=C3=ADa?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 27 May 2021 19:57:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48674 X-GNU-PR-Package: emacs Original-Received: via spool by 48674-submit@debbugs.gnu.org id=B48674.16221453765131 (code B ref 48674); Thu, 27 May 2021 19:57:01 +0000 Original-Received: (at 48674) by debbugs.gnu.org; 27 May 2021 19:56:16 +0000 Original-Received: from localhost ([127.0.0.1]:52845 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lmM76-0001Kh-0d for submit@debbugs.gnu.org; Thu, 27 May 2021 15:56:16 -0400 Original-Received: from mail-ed1-f48.google.com ([209.85.208.48]:37652) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lmM74-0001KS-0W for 48674@debbugs.gnu.org; Thu, 27 May 2021 15:56:14 -0400 Original-Received: by mail-ed1-f48.google.com with SMTP id g7so2227259edm.4 for <48674@debbugs.gnu.org>; Thu, 27 May 2021 12:56:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4goG+eWSRWxvrQy6OclfQlG/oTmSNFp0erpEOgV8X/Q=; b=TOV6bpFR3mq0XpIPHvQDnzGc+QFpvrsZsXmzuyHxb5A0ocJMCKG1IrDCi7irHL6FZ/ T1AxI/CdSwsQgNRzfjVLa0JY7pAKed+WeHKtQhRx0hWdxAu+lJTjhC+FCyuSLIJ6hI6N BBouB3LtBh90PfISwi/WxWmm8lftviYAh5Zezk+bFPf7pMFAy5rAoZSp/GqReF1J5idx Xoppg4ARVeObJdqDvVuxUshGWjC3eJy10cpqA8LyVJf3CFKJi4KSsqLWkVEdhZ7yKfM7 YPYiOyGQua32mOYdhWv7/u5nuK3frC/xUQbFJvuHQ4O3FrZjMM3Ow9B6+08gEqB8hUyV 7UNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4goG+eWSRWxvrQy6OclfQlG/oTmSNFp0erpEOgV8X/Q=; b=qiHLS/6Vx/1DztiZHt2XTdd7DLeoGQGRt+fiTuoqiJ4Qng/4Zh3rnBXmpMDh6iHd2U VqK1fCyzhiioCT+am5PhSYrtSwbrIVKXUPSasTv+QvplpgasHVPuWazRpKRDi33EX+c2 o2K/n7oZx0pFaa+5koyIeRLrJCB4lEv8LLGGnWaAqVO71zOu+vY82a3LXimXRYIl6BXf 3dKtGjBkVCHZvRdLOMeWfHjfK3rELLjtYyDAs5EsLW+h7HI/rqITUhCW9Bvaye64WGeE 0nLtI85fvTe+DDGULW6X/2tVQO0fR0I05OE+pSVP0mjolzwbgOQ+IkBBsc0i0PjeLXzu oltw== X-Gm-Message-State: AOAM5319arz5pQrit+xlsHqKUEtjc7Kbjq7WTPqjqAp0iLrBO81NEuys LD/Y6yhuQP6elOo8ZKXHxdQPl0tn0RkKsXoxqi4= X-Google-Smtp-Source: ABdhPJwTELI94QrUlxPDxn2nt8WqqZko5MPs5sosn5EKGGlIFOnY0NIkMZIjeqfKPJ4d9arucp3b02Bi0pJxAnRDLV4= X-Received: by 2002:a05:6402:50cd:: with SMTP id h13mr6110691edb.111.1622145367994; Thu, 27 May 2021 12:56:07 -0700 (PDT) In-Reply-To: <1e21b121-91c1-cbe9-d9ae-24915f163ae5@gmx.at> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:207395 Archived-At: --0000000000006ef69205c3552641 Content-Type: text/plain; charset="UTF-8" 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 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 > > --0000000000006ef69205c3552641 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Martin,

I forgot to inclu= de you in my last mail where I said:

I think I have found the new iss= ue (it is related to the former one), my code this time was the following:<= /div>

(defvar box-cursor t)

(defun test/set-curso= r()
=C2=A0 "Set cursor in all frames depending on the active state.= "
=C2=A0 (interactive)
=C2=A0 (dolist (= frame (frame-list))
=C2=A0 =C2=A0 (with-selected-frame frame
= =C2=A0 =C2=A0 =C2=A0 (if box-cursor
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (= progn
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (modify-frame-parameters=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0frame (list (cons '= cursor-type 'box)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (modif= y-frame-parameters
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0frame= (list (cons 'cursor-color "#00A9FE"))))
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 (progn
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (modify-frame-param= eters
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0frame (list (cons 'cu= rsor-type 'hbar)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (modify-frame-= parameters
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0frame (list (cons &#= 39;cursor-color "green")))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = )))))

(defun test/enter-minibuffer()
=C2=A0 (setq box-cursor nil)=
=C2=A0 (test/set-cursor))

(defun test/exit-minibuffer()
=C2= =A0 (setq box-cursor t)
=C2=A0 (test/set-cursor))


(add-hook &= #39;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-...
Th= is leads to the same bug.

Regards,

<= /div>
Iris.

On Thu, 27 May 2021 at 16:33, marti= n rudalics <rudalics@gmx.at> w= rote:
=C2=A0>= What is happening is that the with-selected-frame invocation is
=C2=A0> selecting (temporarily) a different frame from the minibuffer= 9;s frame.
=C2=A0> This has the (intended) side effect of making the MB no longer s= elected
=C2=A0> in that frame.=C2=A0 When the MB's frame becomes selected ag= ain, nothing
=C2=A0> makes the mini-window the selected window.=C2=A0 This needs fixi= ng.

Does this mean that the

=C2=A0 =C2=A0Fselect_window (f->selected_window, norecord);

in do_switch_frame fails?=C2=A0 If so, why?=C2=A0 Do we anywhere violate th= e

=C2=A0 =C2=A0(eq (selected-window) (frame-selected-window (selected-frame))= )

invariant?=C2=A0 That might be fatal.=C2=A0 Both, `with-selected-frame'= and
`with-selected-window', should leave no traces behind.

=C2=A0> Martin, that Qt in the Fselect_window call (the NORECORD argumen= t) -
=C2=A0> would it be perhaps be better as Qnil?
=C2=A0>
=C2=A0>
=C2=A0> diff --git a/src/minibuf.c b/src/minibuf.c
=C2=A0> index cffb7fe787..3468643a7e 100644
=C2=A0> --- a/src/minibuf.c
=C2=A0> +++ b/src/minibuf.c
=C2=A0> @@ -893,6 +893,11 @@ read_minibuf (Lisp_Object map, Lisp_Object = initial, Lisp_Object prompt,
=C2=A0>
=C2=A0>=C2=A0 =C2=A0 =C2=A0run_hook (Qminibuffer_setup_hook);
=C2=A0>
=C2=A0> +=C2=A0 /* If the above hook has made the mini-window no longer = the selected
=C2=A0> +=C2=A0 =C2=A0 =C2=A0window, restore it.=C2=A0 */
=C2=A0> +=C2=A0 if (!EQ (selected_window, minibuf_window))
=C2=A0> +=C2=A0 =C2=A0 Fselect_window (minibuf_window , Qt);
=C2=A0> +

Are we sure that we want to disallow a function on
`minibuffer-setup-hook' to change the selected window?=C2=A0 With Emacs= 27


(defun foo ()
=C2=A0 =C2=A0(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

--0000000000006ef69205c3552641--