From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Braun =?UTF-8?Q?G=C3=A1bor?= Newsgroups: gmane.emacs.bugs Subject: bug#34405: 26.1; patch for cancel-change-group to work after undo Date: Tue, 12 Nov 2019 18:05:48 +0100 Message-ID: <3538177.LDI8N28pS7@gabor> References: <1631063.cd5q6Ms6ql@gabor> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="122705"; mail-complaints-to="usenet@blaine.gmane.org" To: 34405@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Nov 12 18:07:21 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iUZdQ-000Vm2-Bh for geb-bug-gnu-emacs@m.gmane.org; Tue, 12 Nov 2019 18:07:20 +0100 Original-Received: from localhost ([::1]:37934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUZdO-0002Df-W7 for geb-bug-gnu-emacs@m.gmane.org; Tue, 12 Nov 2019 12:07:19 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58260) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUZd9-00020a-Rk for bug-gnu-emacs@gnu.org; Tue, 12 Nov 2019 12:07:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iUZd8-00062L-PE for bug-gnu-emacs@gnu.org; Tue, 12 Nov 2019 12:07:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49483) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iUZd8-00062G-LY for bug-gnu-emacs@gnu.org; Tue, 12 Nov 2019 12:07:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iUZd8-0004pa-D9 for bug-gnu-emacs@gnu.org; Tue, 12 Nov 2019 12:07:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <1631063.cd5q6Ms6ql@gabor> Resent-From: Braun =?UTF-8?Q?G=C3=A1bor?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 12 Nov 2019 17:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34405 X-GNU-PR-Package: emacs Original-Received: via spool by 34405-submit@debbugs.gnu.org id=B34405.157357837618514 (code B ref 34405); Tue, 12 Nov 2019 17:07:02 +0000 Original-Received: (at 34405) by debbugs.gnu.org; 12 Nov 2019 17:06:16 +0000 Original-Received: from localhost ([127.0.0.1]:58304 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iUZcO-0004oX-Bb for submit@debbugs.gnu.org; Tue, 12 Nov 2019 12:06:16 -0500 Original-Received: from mail-wr1-f49.google.com ([209.85.221.49]:44741) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iUZcL-0004oJ-9W for 34405@debbugs.gnu.org; Tue, 12 Nov 2019 12:06:15 -0500 Original-Received: by mail-wr1-f49.google.com with SMTP id f2so19339399wrs.11 for <34405@debbugs.gnu.org>; Tue, 12 Nov 2019 09:06:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=g52RBFYXfRuGS/Yi4qag2OnU2aYwt+f/O0LPFqgfeis=; b=Ca+AN6ernkFmsX+rZ7EK7ZW5mfHndQH3xeEKN8cNZXwBuccaVREQsQaJA9OFDXBHdU WPn+7gON/nH+V3GKVYAUCjIIQl6YZ/AmPPjr6e2K1d28PfB7iarIiaW6ThS+VBoProNc 1+mgbnCtTXx+35to7LPuVQE2pAPGVlkGLshdTfQSgEfEqDFFIwR+VRKk54Jp7KkSW0Q9 LjAnvLzWpVR1YySqMMXNyGcQydE8pfpYDeQ5923xUZVH8r+QxgLVxVhvu1wxMtpr29oq YPKPrH1Fb4LtcAXtlZ1SqzuhAIYgMYfwZ5ROEt482DpSfRCmXb3qHS1z3QSJrgAqBVAo z9RQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=g52RBFYXfRuGS/Yi4qag2OnU2aYwt+f/O0LPFqgfeis=; b=I2zpqj1J2lRUmHrN8StWwVrchOdE6lKoW/LHMy92CrSBVqrfhMcuPtzSFkbGwVZNps 39HSNudBnAJvkymv3VKBp0fjIM0+Vz6Z2kGfUHnQeaPchZys0F90NMM5cgkKB8V6WCZA 51ENnCMgMFcVKaauNckFYiaQWjQcxSFTq0Pojm4Td2rZOKGu//1HEyUCaChx5xlkDQZg yYLioGjzMZf49WX1uVGeBYT9Nx3ZdOgE+PSLsGXYnRqnpETcu0gl1woK5F7oU3FmyCiD oHeFsjo+X2sh/bS4kTRKSVGNrOghY41+gH/iO/Lykvp3NSmsGeVhAp3C1kWrwSeW0G9o gfww== X-Gm-Message-State: APjAAAUpQziSKjJbhK6+5I9Le2swcojMlOdppC/F5LuljX5PFISZuWrt bWA37txbrZdSo97JIUG8/uLSLsB3 X-Google-Smtp-Source: APXvYqyWw+f3lKUgeRhUYm1j5k6ABLs19+C9LdrFXK4qS5B5NlyG8NSp4okBx9SmLPm0cV6aAQLq3w== X-Received: by 2002:adf:ce05:: with SMTP id p5mr15772095wrn.48.1573578367133; Tue, 12 Nov 2019 09:06:07 -0800 (PST) Original-Received: from gabor.localnet (254C4FA9.nat.pool.telekom.hu. [37.76.79.169]) by smtp.gmail.com with ESMTPSA id v8sm28122654wra.79.2019.11.12.09.06.05 for <34405@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Nov 2019 09:06:06 -0800 (PST) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:171463 Archived-At: Hi, Please consider the following fix to the problem, patching function=20 cancel-change-group. In the original implementation, the only form depending on whether the=20 last command was an undo is the line (unless (eq last-command 'undo) (undo-start)) which sets pending-undo-list to buffer-undo-list, when the last command=20 was not an undo. When it was, then pending-undo-list probably contains=20 the pending undo entries from a buffer state before the start of the=20 change group, which are obviously irrelevant for cancelling the change=20 group. The fix below is to use buffer-undo-list instead of pending-undo-list, essentially inlining the call to undo-more for this change. =20 As a side effect, the value of pending-undo-list will no longer be=20 changed by cancel-change-group (unless something in the undo log changes=20 it), but as far as I see, it doesn't matter, as its value is useful only=20 directly after an undo command. =2D-- lisp/subr.el +++ lisp/subr.el @@ -2669,14 +2669,17 @@ (progn ;; Temporarily truncate the undo log at ELT. (when (consp elt) =2D (setcar elt nil) (setcdr elt nil)) =2D (unless (eq last-command 'undo) (undo-start)) =2D ;; Make sure there's no confusion. =2D (when (and (consp elt) (not (eq elt (last pending-undo- list)))) =2D (error "Undoing to some unrelated state")) + (setcar elt nil) (setcdr elt nil) + ;; Make sure there's no confusion. + (unless (eq elt (last buffer-undo-list)) + (error "Undoing to some unrelated state"))) ;; Undo it all. (save-excursion =2D (while (listp pending-undo-list) (undo-more 1))) + (let ((undo-in-progress t)) + (while buffer-undo-list + ;; Undo one step, removing it from undo log. + (setq buffer-undo-list + (primitive-undo 1 buffer-undo-list))))) ;; Revert the undo info to what it was when we grabbed ;; the state. (setq buffer-undo-list elt)) Best wishes, G=C3=A1bor