branch: elpa/multiple-cursors
commit 324d9354b5bba9f354dde16717f74e8420db72e6
Author: Marco Baringer <[email protected]>
Commit: Marco Baringer <[email protected]>
Split macro mc/for-each-fake-cursor into a function returning all the
cursor overlays and a macro to loop over this list.
---
multiple-cursors-core.el | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/multiple-cursors-core.el b/multiple-cursors-core.el
index 387f7ea..b2576e9 100644
--- a/multiple-cursors-core.el
+++ b/multiple-cursors-core.el
@@ -49,12 +49,16 @@
(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)))))
+(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)
"Runs the body for each fake cursor, bound to the name cursor"
- `(mapc #'(lambda (cursor)
- (when (mc/fake-cursor-p cursor)
- ,@forms))
- (overlays-in (point-min) (point-max))))
+ `(mapc #'(lambda (cursor) ,@forms)
+ (mc/all-fake-cursors)))
(defmacro mc/save-excursion (&rest forms)
"Saves and restores all the state that multiple-cursors cares about."