From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#56305: 29.0.50; 'yes-or-no-p' deselects minibuffer frame Date: Wed, 6 Jul 2022 17:04:40 +0000 Message-ID: References: <83bku69nn2.fsf@gnu.org> <83iloc8yzs.fsf@gnu.org> <83h73w8f7i.fsf@gnu.org> <83zghn7ckd.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4637"; mail-complaints-to="usenet@ciao.gmane.io" Cc: rudalics@gmx.at, 56305@debbugs.gnu.org, monnier@iro.umontreal.ca, acm@muc.de To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jul 06 19:05:13 2022 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 1o98Se-0000wK-Gh for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 06 Jul 2022 19:05:12 +0200 Original-Received: from localhost ([::1]:36338 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o98Sc-00065G-UA for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 06 Jul 2022 13:05:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52574) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o98SV-00063c-4I for bug-gnu-emacs@gnu.org; Wed, 06 Jul 2022 13:05:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:32855) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o98SU-0007D2-Re for bug-gnu-emacs@gnu.org; Wed, 06 Jul 2022 13:05:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o98SU-0006WA-Lu for bug-gnu-emacs@gnu.org; Wed, 06 Jul 2022 13:05:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 06 Jul 2022 17:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56305 X-GNU-PR-Package: emacs Original-Received: via spool by 56305-submit@debbugs.gnu.org id=B56305.165712709025031 (code B ref 56305); Wed, 06 Jul 2022 17:05:02 +0000 Original-Received: (at 56305) by debbugs.gnu.org; 6 Jul 2022 17:04:50 +0000 Original-Received: from localhost ([127.0.0.1]:54985 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o98SH-0006Ve-MW for submit@debbugs.gnu.org; Wed, 06 Jul 2022 13:04:50 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:34694 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1o98SG-0006VN-0W for 56305@debbugs.gnu.org; Wed, 06 Jul 2022 13:04:48 -0400 Original-Received: (qmail 14992 invoked by uid 3782); 6 Jul 2022 17:04:41 -0000 Original-Received: from acm.muc.de (p4fe15bd4.dip0.t-ipconnect.de [79.225.91.212]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Wed, 06 Jul 2022 19:04:41 +0200 Original-Received: (qmail 8010 invoked by uid 1000); 6 Jul 2022 17:04:40 -0000 Content-Disposition: inline In-Reply-To: <83zghn7ckd.fsf@gnu.org> X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de 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:236276 Archived-At: Hello, Eli, Martin and Stefan. On Tue, Jul 05, 2022 at 19:24:02 +0300, Eli Zaretskii wrote: > > Date: Tue, 5 Jul 2022 15:59:00 +0000 > > Cc: rudalics@gmx.at, monnier@iro.umontreal.ca, 56305@debbugs.gnu.org > > From: Alan Mackenzie > > > > After typing C-x C-c, rather than exiting, this particular Emacs > > > > prompts: > > > > "Active processes exist; kill them and exit anyway? (yes or no) " > > > > on MBF and it opens a window *Process List* on NF. > > > Sounds right to me: the frame where Emacs presents some important > > > information has focus. If you think this is wrong, please tell why. > > Well, I don't have a firm opinion on this, but yes-or-no-p is an active > > function, here. We always leave the minibuffer as the selected window > > for this function, certainly when we've a normal minibuffer in the frame. > > Why should it be different when we've got a minibuffer-only frame? > > Also, the mechanism by which NF gets the focus in the bug scenario > > appears to be random. When the focus starts out in NF and we do C-x C-c, > > the focus moves to MBF. This is inconsistent. > > The place where the randomness takes effect is the > > Fredirect_frame_focus (gfocus, frame); > > in do_switch_frame I drew attention to yesterday. > Do you have a suggestion for a change there to improve the behavior? I do now. I think we should expunge the entire section of code. I've spent several hours trying to make sense of it, and failed. The code section is 30 years old, and Jim Blandy's comment (from 1992) suggests that the code was inserted to enable movement between frames using other-window. That code was written a few months before the new function other-window was first committed. The #ifdef 0 made its appearance in 1993, it being written by Karl Heuer. My feeling is that the code section became redundant in the early 1990s, immediately after the introduction of other-frame, but lived on since nobody could be sure it wasn't needed. As I said, I don't understand the code section, and my Emacs appears to run OK without it. I think we should get rid of it. Alternatively, if somebody else can see a purpose for it, maybe we could amend it to leave that purpose intact and solve Martin's bug #56305 at the same time. Here's the patch (based on master) I propose should be committed, possibly experimentally. Comments would we welcome: diff --git a/src/frame.c b/src/frame.c index c21461d49f..f9e4b2a0e2 100644 --- a/src/frame.c +++ b/src/frame.c @@ -1477,59 +1477,6 @@ do_switch_frame (Lisp_Object frame, int track, int for_deletion, Lisp_Object nor else if (f == sf) return frame; - /* If a frame's focus has been redirected toward the currently - selected frame, we should change the redirection to point to the - newly selected frame. This means that if the focus is redirected - from a minibufferless frame to a surrogate minibuffer frame, we - can use `other-window' to switch between all the frames using - that minibuffer frame, and the focus redirection will follow us - around. */ -#if 0 - /* This is too greedy; it causes inappropriate focus redirection - that's hard to get rid of. */ - if (track) - { - Lisp_Object tail; - - for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) - { - Lisp_Object focus; - - if (!FRAMEP (XCAR (tail))) - emacs_abort (); - - focus = FRAME_FOCUS_FRAME (XFRAME (XCAR (tail))); - - if (FRAMEP (focus) && XFRAME (focus) == SELECTED_FRAME ()) - Fredirect_frame_focus (XCAR (tail), frame); - } - } -#else /* ! 0 */ - /* Instead, apply it only to the frame we're pointing to. */ -#ifdef HAVE_WINDOW_SYSTEM - if (track && FRAME_WINDOW_P (f) && FRAME_TERMINAL (f)->get_focus_frame) - { - Lisp_Object focus, gfocus; - - gfocus = FRAME_TERMINAL (f)->get_focus_frame (f); - if (FRAMEP (gfocus)) - { - focus = FRAME_FOCUS_FRAME (XFRAME (gfocus)); - if (FRAMEP (focus) && XFRAME (focus) == SELECTED_FRAME ()) - /* Redirect frame focus also when FRAME has its minibuffer - window on the selected frame (see Bug#24500). - - Don't do that: It causes redirection problem with a - separate minibuffer frame (Bug#24803) and problems - when updating the cursor on such frames. - || (NILP (focus) - && EQ (FRAME_MINIBUF_WINDOW (f), sf->selected_window))) */ - Fredirect_frame_focus (gfocus, frame); - } - } -#endif /* HAVE_X_WINDOWS */ -#endif /* ! 0 */ - if (!for_deletion && FRAME_HAS_MINIBUF_P (sf)) resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf)), 1); -- Alan Mackenzie (Nuremberg, Germany).