Function: mc/add-fake-cursor-to-undo-list

mc/add-fake-cursor-to-undo-list is a macro defined in multiple-cursors-core.el.

Signature

(mc/add-fake-cursor-to-undo-list &rest FORMS)

Documentation

Make sure point is in the right place when undoing

Source Code

;; Defined in /nix/store/5q7a78ihkz25lf4xmxaa9m7b2ym63m36-emacs-packages-deps/share/emacs/site-lisp/elpa/multiple-cursors-20260419.931/multiple-cursors-core.el
(defmacro mc/add-fake-cursor-to-undo-list (&rest forms)
  "Make sure point is in the right place when undoing"
  (let ((uc (make-symbol "undo-cleaner")))
    `(let ((,uc (cons 'apply (cons 'deactivate-cursor-after-undo (list id)))))
       (setq buffer-undo-list (cons ,uc buffer-undo-list))
       ,@forms
       (if (eq ,uc (car buffer-undo-list)) ;; if nothing has been added to the undo-list
           (setq buffer-undo-list (cdr buffer-undo-list)) ;; then pop the cleaner right off again
         (setq buffer-undo-list ;; otherwise add a function to activate this cursor
               (cons (cons 'apply (cons 'activate-cursor-for-undo (list id))) buffer-undo-list))))))