aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorStefan Monnier2020-03-12 10:03:14 -0400
committerStefan Monnier2020-03-12 10:03:14 -0400
commitf253ff7b780c68bd4d1d12a978a1215af1971320 (patch)
tree5a465c49b4d6afafd3685e79040f528cbfe3171c /lisp
parent4c3c175a63823d851c7e9326f4f70c81b9c0110e (diff)
downloademacs-f253ff7b780c68bd4d1d12a978a1215af1971320.tar.gz
emacs-f253ff7b780c68bd4d1d12a978a1215af1971320.zip
* lisp/subr.el (cancel-change-group): Undo accidental change
Diffstat (limited to 'lisp')
-rw-r--r--lisp/subr.el13
1 files changed, 3 insertions, 10 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index 359f51c0d0c..9c80c06a127 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2987,14 +2987,13 @@ This finishes the change group by reverting all of its changes."
2987 ;; the body of `atomic-change-group' all changes can be undone. 2987 ;; the body of `atomic-change-group' all changes can be undone.
2988 (widen) 2988 (widen)
2989 (let ((old-car (car-safe elt)) 2989 (let ((old-car (car-safe elt))
2990 (old-cdr (cdr-safe elt)) 2990 (old-cdr (cdr-safe elt)))
2991 (start-pul pending-undo-list))
2992 (unwind-protect 2991 (unwind-protect
2993 (progn 2992 (progn
2994 ;; Temporarily truncate the undo log at ELT. 2993 ;; Temporarily truncate the undo log at ELT.
2995 (when (consp elt) 2994 (when (consp elt)
2996 (setcar elt nil) (setcdr elt nil)) 2995 (setcar elt nil) (setcdr elt nil))
2997 (setq pending-undo-list buffer-undo-list) 2996 (unless (eq last-command 'undo) (undo-start))
2998 ;; Make sure there's no confusion. 2997 ;; Make sure there's no confusion.
2999 (when (and (consp elt) (not (eq elt (last pending-undo-list)))) 2998 (when (and (consp elt) (not (eq elt (last pending-undo-list))))
3000 (error "Undoing to some unrelated state")) 2999 (error "Undoing to some unrelated state"))
@@ -3007,13 +3006,7 @@ This finishes the change group by reverting all of its changes."
3007 ;; Reset the modified cons cell ELT to its original content. 3006 ;; Reset the modified cons cell ELT to its original content.
3008 (when (consp elt) 3007 (when (consp elt)
3009 (setcar elt old-car) 3008 (setcar elt old-car)
3010 (setcdr elt old-cdr))) 3009 (setcdr elt old-cdr))))))))
3011 ;; Let's not break a sequence of undos just because we
3012 ;; tried to make a change and then undid it: preserve
3013 ;; the original `pending-undo-list' if it's still valid.
3014 (if (eq (undo--last-change-was-undo-p buffer-undo-list)
3015 start-pul)
3016 (setq pending-undo-list start-pul)))))))
3017 3010
3018;;;; Display-related functions. 3011;;;; Display-related functions.
3019 3012