mirror of
https://github.com/magnars/multiple-cursors.el.git
synced 2025-10-13 21:03:05 +00:00
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:
parent
80ebdbb35b
commit
324d9354b5
@ -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."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user