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.devel Subject: Re: Stop frames stealing eachothers' minibuffers! Date: Sat, 14 Nov 2020 21:37:38 +0000 Message-ID: <20201114213738.GB8992@ACM> References: <835z6b27xm.fsf@gnu.org> <20201111203716.GA19003@ACM> <83v9e8ukk4.fsf@gnu.org> <837dqnvp53.fsf@gnu.org> <20201114184858.GA8992@ACM> 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="1614"; mail-complaints-to="usenet@ciao.gmane.io" Cc: enometh@meer.net, monnier@iro.umontreal.ca, andreyk.mad@gmail.com, emacs-devel@gnu.org To: martin rudalics , Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Nov 14 22:38:28 2020 Return-path: Envelope-to: ged-emacs-devel@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 1ke3Fc-0000IQ-7k for ged-emacs-devel@m.gmane-mx.org; Sat, 14 Nov 2020 22:38:28 +0100 Original-Received: from localhost ([::1]:49046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ke3Fb-0007WQ-Aj for ged-emacs-devel@m.gmane-mx.org; Sat, 14 Nov 2020 16:38:27 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45152) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ke3Ew-00073W-04 for emacs-devel@gnu.org; Sat, 14 Nov 2020 16:37:46 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:10947 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.90_1) (envelope-from ) id 1ke3Es-000097-Jt for emacs-devel@gnu.org; Sat, 14 Nov 2020 16:37:45 -0500 Original-Received: (qmail 66988 invoked by uid 3782); 14 Nov 2020 21:37:40 -0000 Original-Received: from acm.muc.de (p2e5d5492.dip0.t-ipconnect.de [46.93.84.146]) by localhost.muc.de (tmda-ofmipd) with ESMTP; Sat, 14 Nov 2020 22:37:39 +0100 Original-Received: (qmail 17294 invoked by uid 1000); 14 Nov 2020 21:37:38 -0000 Content-Disposition: inline In-Reply-To: X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.1; envelope-from=acm@muc.de; helo=mail.muc.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/14 16:37:40 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:259185 Archived-At: Hello, Martin and Eli. On Sat, Nov 14, 2020 at 20:24:32 +0100, martin rudalics wrote: > > Arguably, Fset_window_configuration selecting the pertinent frame is a > > bug in the specification of that function - one should be able to restore > > a frame's configuration without selecting the frame as well. However, > > backwards compatibility, and all that.... > You'd first have to get rid of the two select_window calls which select > the frame whose configuration gets restored. Fset_window_configuration > is a PITA. Actually, I just put in a do_switch_frame back to the frame which was the selected one at the beginning of the function. But I agree with you about Fset_window_configuration. Anyway, here's a provisional patch. I realise that my amendment to the doc string of Fset_window_configuration is poor, but it's too late to fix it tonight. ;-( I also realise I'll need to amend the Elisp manual and NEWS, but also not tonight. The patch seems to fix the bug (the one about a "recursive" C-x b displaying its error message in the wrong frame). Comments are welcome. diff --git a/src/keyboard.c b/src/keyboard.c index 49a0a8bd23..1579c007ec 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -2122,7 +2122,7 @@ read_char_help_form_unwind (void) Lisp_Object window_config = XCAR (help_form_saved_window_configs); help_form_saved_window_configs = XCDR (help_form_saved_window_configs); if (!NILP (window_config)) - Fset_window_configuration (window_config); + Fset_window_configuration (window_config, Qnil); } #define STOP_POLLING \ diff --git a/src/minibuf.c b/src/minibuf.c index 8c19559b08..acb633c583 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -501,14 +501,15 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, record_unwind_protect_void (choose_minibuf_frame); record_unwind_protect (restore_window_configuration, - Fcurrent_window_configuration (Qnil)); + Fcons (Qt, Fcurrent_window_configuration (Qnil))); /* If the minibuffer window is on a different frame, save that frame's configuration too. */ mini_frame = WINDOW_FRAME (XWINDOW (minibuf_window)); if (!EQ (mini_frame, selected_frame)) record_unwind_protect (restore_window_configuration, - Fcurrent_window_configuration (mini_frame)); + Fcons (Qt, + Fcurrent_window_configuration (mini_frame))); /* If the minibuffer is on an iconified or invisible frame, make it visible now. */ diff --git a/src/window.c b/src/window.c index a6de34f3db..3187720f89 100644 --- a/src/window.c +++ b/src/window.c @@ -6824,19 +6826,24 @@ DEFUN ("window-configuration-frame", Fwindow_configuration_frame, Swindow_config } DEFUN ("set-window-configuration", Fset_window_configuration, - Sset_window_configuration, 1, 1, 0, + Sset_window_configuration, 1, 2, 0, doc: /* Set the configuration of windows and buffers as specified by CONFIGURATION. CONFIGURATION must be a value previously returned by `current-window-configuration' (which see). + +Normally, the original frame of CONFIGURATION gets selected, but if DONT-SET-FRAME is +non-nil, the frame selected at the beginning of this function remains selected. + If CONFIGURATION was made from a frame that is now deleted, only frame-independent values can be restored. In this case, the return value is nil. Otherwise the value is t. */) - (Lisp_Object configuration) + (Lisp_Object configuration, Lisp_Object dont_set_frame) { register struct save_window_data *data; struct Lisp_Vector *saved_windows; Lisp_Object new_current_buffer; Lisp_Object frame; + Lisp_Object old_frame = selected_frame; struct frame *f; ptrdiff_t old_point = -1; USE_SAFE_ALLOCA; @@ -7153,7 +7160,10 @@ the return value is nil. Otherwise the value is t. */) select_window above totally superfluous; it still sets f's selected window. */ if (FRAME_LIVE_P (XFRAME (data->selected_frame))) - do_switch_frame (data->selected_frame, 0, 0, Qnil); + do_switch_frame (NILP (dont_set_frame) + ? data->selected_frame + : old_frame + , 0, 0, Qnil); } FRAME_WINDOW_CHANGE (f) = true; @@ -7191,7 +7201,10 @@ the return value is nil. Otherwise the value is t. */) void restore_window_configuration (Lisp_Object configuration) { - Fset_window_configuration (configuration); + if (CONSP (configuration)) + Fset_window_configuration (XCDR (configuration), XCAR (configuration)); + else + Fset_window_configuration (configuration, Qnil); } > martin -- Alan Mackenzie (Nuremberg, Germany).