Function: org-with-undo-amalgamate

org-with-undo-amalgamate is a macro defined in org-compat.el.

Signature

(org-with-undo-amalgamate &rest BODY)

Documentation

Like progn but perform BODY with amalgamated undo barriers.

This allows multiple operations to be undone in a single step. When undo is disabled this behaves like progn.

Source Code

;; Defined in ~/.emacs.d/elpa/org-9.8.2/org-compat.el
(if (fboundp 'with-undo-amalgamate)
    (defalias 'org-with-undo-amalgamate 'with-undo-amalgamate)
  ;; Copied from Emacs source.
  (defmacro org-with-undo-amalgamate (&rest body)
    "Like `progn' but perform BODY with amalgamated undo barriers.

This allows multiple operations to be undone in a single step.
When undo is disabled this behaves like `progn'."
    (declare (indent 0) (debug t))
    (let ((handle (make-symbol "--change-group-handle--")))
      `(let ((,handle (prepare-change-group))
             ;; Don't truncate any undo data in the middle of this,
             ;; otherwise Emacs might truncate part of the resulting
             ;; undo step: we want to mimic the behavior we'd get if the
             ;; undo-boundaries were never added in the first place.
             (undo-outer-limit nil)
             (undo-limit most-positive-fixnum)
             (undo-strong-limit most-positive-fixnum))
         (unwind-protect
             (progn
               (activate-change-group ,handle)
               ,@body)
           (progn
             (accept-change-group ,handle)
             (undo-amalgamate-change-group ,handle)))))))