Function: mc/for-each-cursor-ordered

mc/for-each-cursor-ordered is a macro defined in multiple-cursors-core.el.

Signature

(mc/for-each-cursor-ordered &rest FORMS)

Documentation

Runs the body for each cursor, fake and real, bound to the name cursor

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/for-each-cursor-ordered (&rest forms)
  "Runs the body for each cursor, fake and real, bound to the name cursor"
  (let ((rci (make-symbol "real-cursor-id")))
    `(let ((,rci (overlay-get (mc/create-fake-cursor-at-point) 'mc-id)))
       (mapc #'(lambda (cursor)
                 (when (mc/fake-cursor-p cursor)
                   ,@forms))
             (sort (overlays-in (point-min) (point-max)) #'mc--compare-by-overlay-start))
       (mc/pop-state-from-overlay (mc/cursor-with-id ,rci)))))