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

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

[nongnu] elpa/anzu 8a1eb22317 174/288: Merge pull request #42 from syohe


From: ELPA Syncer
Subject: [nongnu] elpa/anzu 8a1eb22317 174/288: Merge pull request #42 from syohex/fix-replace-command-bug
Date: Thu, 6 Jan 2022 03:58:50 -0500 (EST)

branch: elpa/anzu
commit 8a1eb22317a45594b21039c6085c71f5f031c5f7
Merge: b723c16507 dcae136088
Author: Syohei YOSHIDA <syohex@gmail.com>
Commit: Syohei YOSHIDA <syohex@gmail.com>

    Merge pull request #42 from syohex/fix-replace-command-bug
    
    Fix displaying current replaced point
---
 anzu.el | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/anzu.el b/anzu.el
index 3c9c2498fe..a92067557b 100644
--- a/anzu.el
+++ b/anzu.el
@@ -350,7 +350,6 @@
                     (forward-char 1)))
                 (when (and (>= beg overlay-beg) (<= end overlay-end) (not 
finish))
                   (cl-incf overlayed)
-                  (anzu--set-marker beg buf)
                   (anzu--add-overlay beg end))))
             (setq anzu--cached-count count)
             overlayed))))))
@@ -615,7 +614,7 @@
 
 (defsubst anzu--current-replaced-index (curpoint)
   (cl-loop for m in anzu--replaced-markers
-           for i = 1 then (+ i 1)
+           for i = 1 then (1+ i)
            for pos = (marker-position m)
            when (= pos curpoint)
            return i))
@@ -627,6 +626,14 @@
         (force-mode-line-update)
         (setq anzu--current-position (or index 1))))))
 
+(defun anzu--set-replaced-markers (from beg end use-regexp)
+  (save-excursion
+    (goto-char beg)
+    (cl-loop with curbuf = (current-buffer)
+             with search-func = (if use-regexp 're-search-forward 
'search-forward)
+             while (funcall search-func from end t)
+             do (anzu--set-marker (match-beginning 0) curbuf))))
+
 (cl-defun anzu--query-replace-common (use-regexp &key at-cursor thing 
prefix-arg (query t))
   (anzu--cons-mode-line 'replace-query)
   (let* ((use-region (use-region-p))
@@ -654,6 +661,7 @@
                      (anzu--query-replace-read-to
                       from prompt beg end use-regexp overlay-limit))))
           (anzu--clear-overlays curbuf beg end)
+          (anzu--set-replaced-markers from beg end use-regexp)
           (setq anzu--state 'replace anzu--current-position 0
                 anzu--replaced-markers (reverse anzu--replaced-markers)
                 clear-overlay t)
@@ -668,6 +676,7 @@
           (anzu--clear-overlays curbuf beg end))
         (when (zerop anzu--current-position)
           (goto-char orig-point))
+        (anzu--cleanup-markers)
         (anzu--reset-mode-line)
         (force-mode-line-update)))))
 



reply via email to

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