* 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.
This commit is contained in:
parent
ef5744a988
commit
c1ce9fa7f2
1 changed files with 7 additions and 2 deletions
|
@ -2964,13 +2964,18 @@ This finishes the change group by reverting all of its changes."
|
||||||
;; the body of `atomic-change-group' all changes can be undone.
|
;; the body of `atomic-change-group' all changes can be undone.
|
||||||
(widen)
|
(widen)
|
||||||
(let ((old-car (car-safe elt))
|
(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))
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
(progn
|
(progn
|
||||||
;; Temporarily truncate the undo log at ELT.
|
;; Temporarily truncate the undo log at ELT.
|
||||||
(when (consp elt)
|
(when (consp elt)
|
||||||
(setcar elt nil) (setcdr elt nil))
|
(setcar elt nil) (setcdr elt nil))
|
||||||
(unless (eq last-command 'undo) (undo-start))
|
|
||||||
;; Make sure there's no confusion.
|
;; Make sure there's no confusion.
|
||||||
(when (and (consp elt) (not (eq elt (last pending-undo-list))))
|
(when (and (consp elt) (not (eq elt (last pending-undo-list))))
|
||||||
(error "Undoing to some unrelated state"))
|
(error "Undoing to some unrelated state"))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue