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

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

[nongnu] elpa/multiple-cursors 06a2985 362/434: * mc-mark-more.el (mc/ma


From: ELPA Syncer
Subject: [nongnu] elpa/multiple-cursors 06a2985 362/434: * mc-mark-more.el (mc/mark-all-in-region-regexp): Don't infloop when regexp matches empty string
Date: Sat, 7 Aug 2021 09:21:00 -0400 (EDT)

branch: elpa/multiple-cursors
commit 06a2985db00663567f44c6b53bed6cb8b5d7a4ca
Author: Nicolas Richard <youngfrog@members.fsf.org>
Commit: Nicolas Richard <youngfrog@members.fsf.org>

    * mc-mark-more.el (mc/mark-all-in-region-regexp): Don't infloop when regexp 
matches empty string
---
 mc-mark-more.el | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/mc-mark-more.el b/mc-mark-more.el
index 02a67f4..ab72a82 100644
--- a/mc-mark-more.el
+++ b/mc-mark-more.el
@@ -347,7 +347,7 @@ With zero ARG, skip the last one and mark next."
 
 ;;;###autoload
 (defun mc/mark-all-in-region-regexp (beg end)
-  "Find and mark all the parts in the region matching the given regexp"
+  "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))
@@ -356,9 +356,17 @@ With zero ARG, skip the last one and mark next."
       (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 ((lastmatch))
+          (while (and (< (point) end) ; can happen because of (forward-char)
+                      (search-forward-regexp search end t))
+            (push-mark (match-beginning 0))
+            (mc/create-fake-cursor-at-point)
+            (setq lastmatch (point))
+            (when (= (point) (match-beginning 0))
+              (forward-char)))
+          (when lastmatch (goto-char lastmatch)))
+        (when (> (mc/num-cursors) 0)
+          (goto-char (match-end 0)))
         (let ((first (mc/furthest-cursor-before-point)))
           (if (not first)
               (error "Search failed for %S" search)



reply via email to

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