Function: evil-with-undo
evil-with-undo is a macro defined in evil-common.el.
Signature
(evil-with-undo &rest BODY)
Documentation
Execute BODY with enabled undo.
If undo is disabled in the current buffer, the undo information
is stored in evil-temporary-undo instead of buffer-undo-list.
Source Code
;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-common.el
(defmacro evil-with-undo (&rest body)
"Execute BODY with enabled undo.
If undo is disabled in the current buffer, the undo information
is stored in `evil-temporary-undo' instead of `buffer-undo-list'."
(declare (indent defun) (debug t))
(let ((undo-list (make-symbol "undo-list")))
`(let ((,undo-list buffer-undo-list)
(evil-undo-system evil-undo-system))
(when (eq ,undo-list t) (setq buffer-undo-list nil
evil-undo-system nil))
(unwind-protect
(progn ,@body)
;; ensure any new undo changes we've accumulated start with
;; exactly one undo boundary marker, i.e. nil
(when (car-safe buffer-undo-list) (push nil buffer-undo-list))
(if (eq ,undo-list t)
;; undo is disabled, so store undo information in
;; evil-temporary-undo
(setq evil-temporary-undo buffer-undo-list
buffer-undo-list t)
(setq evil-temporary-undo nil))))))