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

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

[nongnu] elpa/multiple-cursors da2a9ab 298/434: Add mc/mark-all-in-regio


From: ELPA Syncer
Subject: [nongnu] elpa/multiple-cursors da2a9ab 298/434: Add mc/mark-all-in-region-regexp
Date: Sat, 7 Aug 2021 09:20:46 -0400 (EDT)

branch: elpa/multiple-cursors
commit da2a9abfd84045701048e0b2e28c5e1e8430531b
Author: Magnar Sveen <magnars@gmail.com>
Commit: Magnar Sveen <magnars@gmail.com>

    Add mc/mark-all-in-region-regexp
    
    Thanks to Gabriel Antonioli :-)
---
 mc-mark-more.el | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/mc-mark-more.el b/mc-mark-more.el
index ef4b877..45a87fc 100644
--- a/mc-mark-more.el
+++ b/mc-mark-more.el
@@ -292,6 +292,28 @@ With zero ARG, skip the last one and mark next."
             (multiple-cursors-mode 1)
           (multiple-cursors-mode 0))))))
 
+;;;###autoload
+(defun mc/mark-all-in-region-regexp (beg end)
+  "Find and mark all the parts in the region matching the given regexp"
+  (interactive "r")
+  (let ((search (read-regexp "Mark regexp in region: "))
+        (case-fold-search nil))
+    (if (string= search "")
+        (message "Mark aborted")
+      (progn
+        (mc/remove-fake-cursors)
+        (goto-char beg)
+        (while (search-forward-regexp search end t)
+          (push-mark (match-beginning 0))
+          (mc/create-fake-cursor-at-point))
+        (let ((first (mc/furthest-cursor-before-point)))
+          (if (not first)
+              (error "Search failed for %S" search)
+            (mc/pop-state-from-overlay first)))
+        (if (> (mc/num-cursors) 1)
+            (multiple-cursors-mode 1)
+          (multiple-cursors-mode 0))))))
+
 (when (not (fboundp 'set-temporary-overlay-map))
   ;; Backport this function from newer emacs versions
   (defun set-temporary-overlay-map (map &optional keep-pred)



reply via email to

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