From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gregory Heytings Newsgroups: gmane.emacs.bugs Subject: bug#60467: 30.0.50; primitive-undo: Changes to be undone by function different from announced Date: Tue, 03 Jan 2023 16:33:09 +0000 Message-ID: References: <87o7ri74qv.fsf@localhost> <9bc9c69ac20a37ded741@heytings.org> <9bc9c69ac282c0148962@heytings.org> <87h6x9mgdv.fsf@localhost> <838rij23by.fsf@gnu.org> <83zgazznau.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27984"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 60467@debbugs.gnu.org, Alan Mackenzie , Eli Zaretskii , yantar92@posteo.net To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jan 03 17:34:37 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 1pCkFJ-0006yZ-1l for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 03 Jan 2023 17:34:37 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pCkF3-0002wD-Hp; Tue, 03 Jan 2023 11:34:21 -0500 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 1pCkEr-0002u4-MR for bug-gnu-emacs@gnu.org; Tue, 03 Jan 2023 11:34:18 -0500 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 1pCkEk-0003v8-0I for bug-gnu-emacs@gnu.org; Tue, 03 Jan 2023 11:34:09 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pCkEj-0002P4-O3 for bug-gnu-emacs@gnu.org; Tue, 03 Jan 2023 11:34:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Gregory Heytings Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 03 Jan 2023 16:34:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60467 X-GNU-PR-Package: emacs Original-Received: via spool by 60467-submit@debbugs.gnu.org id=B60467.16727635989186 (code B ref 60467); Tue, 03 Jan 2023 16:34:01 +0000 Original-Received: (at 60467) by debbugs.gnu.org; 3 Jan 2023 16:33:18 +0000 Original-Received: from localhost ([127.0.0.1]:46557 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pCkE1-0002O6-Id for submit@debbugs.gnu.org; Tue, 03 Jan 2023 11:33:17 -0500 Original-Received: from heytings.org ([95.142.160.155]:57354) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pCkDv-0002Nr-AV for 60467@debbugs.gnu.org; Tue, 03 Jan 2023 11:33:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org; s=20220101; t=1672763590; bh=3KcKv5P+OqUO868K9b4zMQmWUS+37K7Kgh5LNMm5tDw=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:From; b=LwYWg39NPNYk2jcoGnMG8k/ekbymaZYnt15X3EjPv24MTSgK5U18Oy8omoLvCQ1kg FI8R+wNBnL5o5GUv2RYI7i5i+XLkbr6LK2wcZydfV3Z3aOZ1gbRUSuTXkQZVXPnlGD UGc83P9xT5WyAePZBigSWuSGsdjvmoh+vn38CU5jnR6vEShYI7ID/JipIpjga1bI3n 703oVfjmWi/1xiPdZGHh2jkGArhJvNzU3DrG8WW+Mg3lKseKdiM/dWdZFIbrd4PIzb 73j2FI0nqwRnRzyx0QHReFvhZTcndaqdp8qTCddoKD/dwe4bNUcmvgoshqBn9ecgo8 KDgmU8q2fmcAg== In-Reply-To: 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:252421 Archived-At: >> I don't even understand what this is supposed to do. > > Yet you happily threw it away :-( > Because there are no such precautions elsewhere in the code, and the comment above ("In case garbage collection has removed OLD-BUL") does not explain what its purpose is. A few lines below, old-bul is used without such a precaution. Of course, if it has a purpose, it's okay to keep it. >> By definition, garbage collection cannot collect something that is >> still referred to. > > `garbage-collect` does a bit more than collect garbage. It also > truncates undo lists among other things. > Aha. So this means that garbage-collect could be called between (funcall body) and the (while ...) loop two lines below, and could have removed elements that were added to buffer-undo-list by (funcall body), right? If so, that's what the comment should have said. >> This one is just plain wrong. It assumes that buffer-undo-list is >> non-nil initially. > > AFAICT it warns when the GC's truncation has thrown stuff away (in which > case there's a good chance the `apply` element we're building is > incorrect). > Given what you write above, that's probably what it meant to do indeed. But it also warns when buffer-undo-list is initially nil, such as with the recipe of this bug report. If adding such a warning is useful, we should check whether old-bul was initially non-nil. >> Yes. The current code apparently meant to skip these entries, but it >> does not work at all. Replacing a broken code that does not work with >> a clean(er) code that does work seems the right thing. > > FWIW, I don't see what's cleaner about the new code. > It took me a half hour to figure out what the original code was doing with this 'ap-elt' to which 'buffer-undo-list' is added, and subsequenty modified by the loop below, which does not refer to buffer-undo-list, and which also updates 'old-bul' in an unclear way. I'm biased of course, but I think I would have understood the code in my patch much easier: it does one thing (adding the new undo element) after the other (building the list included in that undo element).