Split macro mc/for-each-fake-cursor into a function returning all the cursor overlays and a macro to loop over this list.

This commit is contained in:
Marco Baringer 2012-10-10 13:38:47 +02:00
parent 80ebdbb35b
commit 324d9354b5

View File

@ -49,12 +49,16 @@
(setq buffer-undo-list ;; otherwise add a function to activate this cursor (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))))) (cons (cons 'apply (cons 'activate-cursor-for-undo (list id))) buffer-undo-list)))))
(defun mc/all-fake-cursors (&optional start end)
(remove-if-not (lambda (overlay)
(mc/fake-cursor-p overlay))
(overlays-in (or start (point-min))
(or end (point-max)))))
(defmacro mc/for-each-fake-cursor (&rest forms) (defmacro mc/for-each-fake-cursor (&rest forms)
"Runs the body for each fake cursor, bound to the name cursor" "Runs the body for each fake cursor, bound to the name cursor"
`(mapc #'(lambda (cursor) `(mapc #'(lambda (cursor) ,@forms)
(when (mc/fake-cursor-p cursor) (mc/all-fake-cursors)))
,@forms))
(overlays-in (point-min) (point-max))))
(defmacro mc/save-excursion (&rest forms) (defmacro mc/save-excursion (&rest forms)
"Saves and restores all the state that multiple-cursors cares about." "Saves and restores all the state that multiple-cursors cares about."