[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-27 c1ce9fa: * lisp/subr.el (cancel-change-group): Fix bug#39680

From: Stefan Monnier
Subject: emacs-27 c1ce9fa: * lisp/subr.el (cancel-change-group): Fix bug#39680
Date: Thu, 12 Mar 2020 10:02:01 -0400 (EDT)

branch: emacs-27
commit c1ce9fa7f2b1d88637e8d8f03f08d8ddd2ff9e4a
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>

    * lisp/subr.el (cancel-change-group): Fix bug#39680
    Don't re-use an existing `pending-undo-list` even if (eq last-command 'undo)
    since there might have been changes to the buffer since that `undo` command
    and the `pending-undo-list` can hence be invalid for the current
    buffer contents.
 lisp/subr.el | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lisp/subr.el b/lisp/subr.el
index 5b94343..a744cfd 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2964,13 +2964,18 @@ This finishes the change group by reverting all of its 
        ;; the body of `atomic-change-group' all changes can be undone.
        (let ((old-car (car-safe elt))
-             (old-cdr (cdr-safe elt)))
+             (old-cdr (cdr-safe elt))
+             ;; Use `pending-undo-list' temporarily since `undo-more' needs
+             ;; it, but restore it afterwards so as not to mess with an
+             ;; ongoing sequence of `undo's.
+             (pending-undo-list
+              ;; Use `buffer-undo-list' unconditionally (bug#39680).
+              buffer-undo-list))
                 ;; Temporarily truncate the undo log at ELT.
                 (when (consp elt)
                   (setcar elt nil) (setcdr elt nil))
-                (unless (eq last-command 'undo) (undo-start))
                 ;; Make sure there's no confusion.
                 (when (and (consp elt) (not (eq elt (last pending-undo-list))))
                   (error "Undoing to some unrelated state"))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]