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: Edebug corrupting point in buffers. Date: Tue, 1 Nov 2022 20:53:47 +0000 Message-ID: References: <83iljydh7e.fsf@gnu.org> <838rkud9d5.fsf@gnu.org> <83v8nybnuk.fsf@gnu.org> <83pme6bls8.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="13428"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Nov 01 21:55:00 2022 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 1opyHk-0003I0-0h for ged-emacs-devel@m.gmane-mx.org; Tue, 01 Nov 2022 21:55:00 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1opyGo-0002CC-Pj; Tue, 01 Nov 2022 16:54:02 -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 1opyGn-0002BG-Ct for emacs-devel@gnu.org; Tue, 01 Nov 2022 16:54:01 -0400 Original-Received: from mx3.muc.de ([193.149.48.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1opyGj-0007Il-TK for emacs-devel@gnu.org; Tue, 01 Nov 2022 16:54:01 -0400 Original-Received: (qmail 680 invoked by uid 3782); 1 Nov 2022 21:53:48 +0100 Original-Received: from acm.muc.de (p4fe15c46.dip0.t-ipconnect.de [79.225.92.70]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Tue, 01 Nov 2022 21:53:48 +0100 Original-Received: (qmail 10103 invoked by uid 1000); 1 Nov 2022 20:53:47 -0000 Content-Disposition: inline In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.5; envelope-from=acm@muc.de; helo=mx3.muc.de 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=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: "Emacs-devel" Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:298980 Archived-At: Hello, Stefan. On Tue, Nov 01, 2022 at 15:47:45 -0400, Stefan Monnier wrote: > > Why does set-window-configuration overwrite the buffer-points? The > > window configuration does not contain them. The code just assumes that > > the buffer-point should be set to the window point. Of course, we have > > a race condition if a buffer is displayed in several windows. So this > > would appear to be a bug, the root cause of the bug in this thread. > This suggests the patch below, right? > I note that this only changes the buffer-point for `current-buffer`, not > for all the buffers displayed in the window-config, right? Not quite. It changes the buffer-point for every buffer except the "current buffer". > There's still a "race condition", of course. > > Maybe set-window-configuration should be amended not to write the > > buffer-points? That might cause problems in other areas, though. The > > window configuration is one of the few areas where the documentation is > > poor enough that you need to read the C source to find out what it's > > really doing. > Yup. We could start by providing some way to tell > `set-window-configuration` not to change buffer-points (and use that in > Edebug)? This way we fix the problem for Edebug without risking > changes elsewhere? An &optional parameter, you mean? I'd thought of that, but it feels ugly. > We can try and run out own Emacs with the patch installed, to see if we > notice any regression. Indeed, yes. I count 89 occurrences of '(set-window-configuration' in our Lisp sources. That's not really a comfortable number to check by looking at the code. :-( > If we do, that might help us understand what we should do. If we > don't, maybe it's hint that it was really just a bug. It feels like a bug for the reasons already given, and the fact that the "current buffer"'s buffer-point is spared. If there's something wrong with overwriting that buffer's buffer-point, why is it OK for all the other buffers in windows in the window-configuration? I'm going to try out your patch and see if it, by itself, fixes the bug, now that I've got a reproducible test case. <...later...> I've tried it, and the patch doesn't fix the bug. :-( Something else is clearly overwriting the buffer-point. > Stefan > diff --git a/src/window.c b/src/window.c > index b858d145415..382d3cbdc6a 100644 > --- a/src/window.c > +++ b/src/window.c > @@ -7270,12 +7270,6 @@ DEFUN ("set-window-configuration", Fset_window_configuration, > set_marker_restricted (w->start, p->start, w->contents); > set_marker_restricted (w->pointm, p->pointm, w->contents); > set_marker_restricted (w->old_pointm, p->old_pointm, w->contents); > - /* As documented in Fcurrent_window_configuration, don't > - restore the location of point in the buffer which was > - current when the window configuration was recorded. */ > - if (!EQ (p->buffer, new_current_buffer) > - && XBUFFER (p->buffer) == current_buffer) > - Fgoto_char (w->pointm); > } > else if (BUFFERP (w->contents) && BUFFER_LIVE_P (XBUFFER (w->contents))) > /* Keep window's old buffer; make sure the markers are real. */ -- Alan Mackenzie (Nuremberg, Germany).