emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/multiple-cursors 324d935 157/434: Split macro mc/for-each-


From: ELPA Syncer
Subject: [nongnu] elpa/multiple-cursors 324d935 157/434: Split macro mc/for-each-fake-cursor into a function returning all the cursor overlays and a macro to loop over this list.
Date: Sat, 7 Aug 2021 09:20:16 -0400 (EDT)

branch: elpa/multiple-cursors
commit 324d9354b5bba9f354dde16717f74e8420db72e6
Author: Marco Baringer <mb@bese.it>
Commit: Marco Baringer <mb@bese.it>

    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."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]