aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2020-03-12 10:01:54 -0400
committerStefan Monnier2020-03-12 10:01:54 -0400
commitc1ce9fa7f2b1d88637e8d8f03f08d8ddd2ff9e4a (patch)
tree832e787a40ded8840643397446873d6357e4ea34
parentef5744a988f299c1b8b4726ee0d5bf9c1c1074f5 (diff)
downloademacs-c1ce9fa7f2b1d88637e8d8f03f08d8ddd2ff9e4a.tar.gz
emacs-c1ce9fa7f2b1d88637e8d8f03f08d8ddd2ff9e4a.zip
* 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.
-rw-r--r--lisp/subr.el9
1 files changed, 7 insertions, 2 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index 5b94343e499..a744cfddfd4 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2964,13 +2964,18 @@ This finishes the change group by reverting all of its changes."
2964 ;; the body of `atomic-change-group' all changes can be undone. 2964 ;; the body of `atomic-change-group' all changes can be undone.
2965 (widen) 2965 (widen)
2966 (let ((old-car (car-safe elt)) 2966 (let ((old-car (car-safe elt))
2967 (old-cdr (cdr-safe elt))) 2967 (old-cdr (cdr-safe elt))
2968 ;; Use `pending-undo-list' temporarily since `undo-more' needs
2969 ;; it, but restore it afterwards so as not to mess with an
2970 ;; ongoing sequence of `undo's.
2971 (pending-undo-list
2972 ;; Use `buffer-undo-list' unconditionally (bug#39680).
2973 buffer-undo-list))
2968 (unwind-protect 2974 (unwind-protect
2969 (progn 2975 (progn
2970 ;; Temporarily truncate the undo log at ELT. 2976 ;; Temporarily truncate the undo log at ELT.
2971 (when (consp elt) 2977 (when (consp elt)
2972 (setcar elt nil) (setcdr elt nil)) 2978 (setcar elt nil) (setcdr elt nil))
2973 (unless (eq last-command 'undo) (undo-start))
2974 ;; Make sure there's no confusion. 2979 ;; Make sure there's no confusion.
2975 (when (and (consp elt) (not (eq elt (last pending-undo-list)))) 2980 (when (and (consp elt) (not (eq elt (last pending-undo-list))))
2976 (error "Undoing to some unrelated state")) 2981 (error "Undoing to some unrelated state"))