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#63967: 28.2; switch-to-buffer in normal window fails if minibuffer window is active Date: Sat, 10 Jun 2023 19:42:04 +0000 Message-ID: References: <83o7lo28e6.fsf@gnu.org> <83fs701uts.fsf@gnu.org> <83a5x81m33.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="23766"; mail-complaints-to="usenet@ciao.gmane.io" Cc: al@petrofsky.org, rudalics@gmx.at, Eli Zaretskii , 63967@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 10 21:43:18 2023 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 1q84UY-000667-Gw for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 10 Jun 2023 21:43:18 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q84UM-0004sL-8C; Sat, 10 Jun 2023 15:43:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q84UJ-0004sB-4F for bug-gnu-emacs@gnu.org; Sat, 10 Jun 2023 15:43:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q84UI-000895-S1 for bug-gnu-emacs@gnu.org; Sat, 10 Jun 2023 15:43:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q84UI-000620-7t for bug-gnu-emacs@gnu.org; Sat, 10 Jun 2023 15:43: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: Sat, 10 Jun 2023 19:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63967 X-GNU-PR-Package: emacs Original-Received: via spool by 63967-submit@debbugs.gnu.org id=B63967.168642613823134 (code B ref 63967); Sat, 10 Jun 2023 19:43:02 +0000 Original-Received: (at 63967) by debbugs.gnu.org; 10 Jun 2023 19:42:18 +0000 Original-Received: from localhost ([127.0.0.1]:36352 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q84TZ-000614-PX for submit@debbugs.gnu.org; Sat, 10 Jun 2023 15:42:18 -0400 Original-Received: from mx3.muc.de ([193.149.48.5]:21475) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q84TU-00060m-8H for 63967@debbugs.gnu.org; Sat, 10 Jun 2023 15:42:16 -0400 Original-Received: (qmail 74841 invoked by uid 3782); 10 Jun 2023 21:42:05 +0200 Original-Received: from acm.muc.de (p4fe1580b.dip0.t-ipconnect.de [79.225.88.11]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 10 Jun 2023 21:42:05 +0200 Original-Received: (qmail 9940 invoked by uid 1000); 10 Jun 2023 19:42:04 -0000 Content-Disposition: inline In-Reply-To: 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:263235 Archived-At: Hello, Stefan. On Sat, Jun 10, 2023 at 11:49:43 -0400, Stefan Monnier wrote: > Hi Alan, > Could you explain why/when we need to call `Fset_frame_selected_window` > in the code below: > > static void > > minibuffer_unwind (void) > > { > > struct frame *f; > > struct window *w; > > Lisp_Object window; > > Lisp_Object entry; > > > > if (NILP (exp_MB_frame)) return; /* "Can't happen." */ > > f = XFRAME (exp_MB_frame); > > window = f->minibuffer_window; > > w = XWINDOW (window); > > if (FRAME_LIVE_P (f)) > > { > > /* minibuf_window = sf->minibuffer_window; */ > > if (!NILP (w->prev_buffers)) > > { > > entry = Fcar (w->prev_buffers); > > w->prev_buffers = Fcdr (w->prev_buffers); > > set_window_buffer (window, Fcar (entry), 0, 0); > > Fset_window_start (window, Fcar (Fcdr (entry)), Qnil); > > Fset_window_point (window, Fcar (Fcdr (Fcdr (entry)))); > > /* set-window-configuration may/will have unselected the > > mini-window as the selected window. Restore it. */ > > Fset_frame_selected_window (exp_MB_frame, window, Qnil); <<<<<<<<< > > } > > else > > set_window_buffer (window, nth_minibuffer (0), 0, 0); > > } > > } > I understand why we do the `set_window_buffer` and set its start and > point, but I can't see why we'd need to select the mini-window: > presumably if it needed to be (re)selected that should have been handled > by the window-config save&restore, no? There was a problem with the restoring of the window configuration selecting a window other than the minibuffer; that is in circumstances where the minibuffer window should have ended up being selected. Fset_window_configuration seems to be the troublesome function in this scenario. As well as setting the window configuration, it also selects a window. Perhaps we should modify the minibuffer code to note which window should be current after the completion or abortion of the minibuffer read action. > Stefan -- Alan Mackenzie (Nuremberg, Germany).