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#58343: 29.0.50; ELisp code run in "inconsitent" selected-window state Date: Wed, 12 Oct 2022 19:13:51 +0000 Message-ID: References: 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="37284"; mail-complaints-to="usenet@ciao.gmane.io" Cc: acm@muc.de, 58343@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Oct 12 21:14:16 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 1oihBI-0009S7-Ao for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 12 Oct 2022 21:14:16 +0200 Original-Received: from localhost ([::1]:46644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oihBH-0003Qd-2h for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 12 Oct 2022 15:14:15 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60482) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oihB7-0003Oa-R2 for bug-gnu-emacs@gnu.org; Wed, 12 Oct 2022 15:14:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:59377) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oihB3-00013o-OX for bug-gnu-emacs@gnu.org; Wed, 12 Oct 2022 15:14:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oihB3-0000HV-KE for bug-gnu-emacs@gnu.org; Wed, 12 Oct 2022 15:14:01 -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, 12 Oct 2022 19:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58343 X-GNU-PR-Package: emacs Original-Received: via spool by 58343-submit@debbugs.gnu.org id=B58343.16656020401066 (code B ref 58343); Wed, 12 Oct 2022 19:14:01 +0000 Original-Received: (at 58343) by debbugs.gnu.org; 12 Oct 2022 19:14:00 +0000 Original-Received: from localhost ([127.0.0.1]:58455 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oihB2-0000H7-01 for submit@debbugs.gnu.org; Wed, 12 Oct 2022 15:14:00 -0400 Original-Received: from mx3.muc.de ([193.149.48.5]:59816) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oihB0-0000Gv-VH for 58343@debbugs.gnu.org; Wed, 12 Oct 2022 15:13:59 -0400 Original-Received: (qmail 7959 invoked by uid 3782); 12 Oct 2022 21:13:52 +0200 Original-Received: from acm.muc.de (p4fe15af2.dip0.t-ipconnect.de [79.225.90.242]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Wed, 12 Oct 2022 21:13:51 +0200 Original-Received: (qmail 12590 invoked by uid 1000); 12 Oct 2022 19:13:51 -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" Xref: news.gmane.io gmane.emacs.bugs:245247 Archived-At: Hello, Stefan. On Wed, Oct 12, 2022 at 14:35:33 -0400, Stefan Monnier wrote: > Hi Alan, > > One minor problem I see at the moment is that the call to > > move_minibuffers_onto_frame wasn't moved together with the surrounding > > code. With its current calling convention, it needs to be called > > _after_ selected_frame has been set, because it uses selected_frame. > Aha! > > Is there any reason this function call was left where it was? > I was afraid that swapping `move_minibuffers_onto_frame` and > if (EQ (f->selected_window, f->minibuffer_window) > /* The following test might fail if the mini-window contains a > non-active minibuffer. */ > && NILP (Fminibufferp (XWINDOW (f->minibuffer_window)->contents, Qt))) > { > Lisp_Object w = call1 (Qget_mru_window, frame); > if (WINDOW_LIVE_P (w)) /* W can be nil in minibuffer-only frames. */ > Fset_frame_selected_window (frame, w, Qnil); > } > would not result in the same final result, e.g. because the name > "move_minibuffers_onto_frame" suggests it might change the result of > `XWINDOW (f->minibuffer_window)->contents`. Yes, I suppose you're right. > > Or could it just be moved, too? Otherwise, its calling convention > > will need to be adapted. > The patch below refrains from moving it and passes it the to-be-selected > frame as argument instead. Yes. That's a better solution than moving the function call around, particularly given that there're are only two calls to it, both in frame.c. Just one small thing: the name sf is a bad name for a Lisp_Object - there's a de facto convention in minibuf.c and frame.c that f, sf, and of, etc are struct *frame's, and selected_frame, frame, etc., are Lisp_Object's which are frames. In fact sf is used as a struct *frame elsewhere in minibuf.c. Let me guess - originally this sf was a struct *frame, but got changed to a Lisp_Object when it became clear that it was needed to set MB_frame with. ;-) > Stefan [ .... ] -- Alan Mackenzie (Nuremberg, Germany).