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

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

[elpa] externals/m-buffer e4ec4daa87 027/115: replace-match now returns


From: ELPA Syncer
Subject: [elpa] externals/m-buffer e4ec4daa87 027/115: replace-match now returns marker to the end of the replacements.
Date: Tue, 19 Jul 2022 15:58:46 -0400 (EDT)

branch: externals/m-buffer
commit e4ec4daa8743bf05bd8aee5fbd8eef9cd55546a4
Author: Phillip Lord <phillip.lord@newcastle.ac.uk>
Commit: Phillip Lord <phillip.lord@newcastle.ac.uk>

    replace-match now returns marker to the end of the replacements.
---
 m-buffer.el           |  6 ++++--
 test/m-buffer-test.el | 10 ++++++++++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/m-buffer.el b/m-buffer.el
index 9b22bc4a68..d5a687f802 100644
--- a/m-buffer.el
+++ b/m-buffer.el
@@ -318,7 +318,8 @@ See also `m-buffer-nil-markers'"
 
 (defun m-buffer-replace-match (match-data replacement &optional subexp)
   "Given a list of MATCH-DATA, replace with REPLACEMENT.
-SUBEXP should be a number indicating the regexp group to replace."
+SUBEXP should be a number indicating the regexp group to replace.
+Returns a list of markers to the end of the replacement."
   (-map
    (lambda (match)
      (with-current-buffer
@@ -327,7 +328,8 @@ SUBEXP should be a number indicating the regexp group to 
replace."
          (set-match-data match)
          (replace-match
           replacement nil nil nil
-          (or subexp 0)))))
+          (or subexp 0))
+         (point-marker))))
    match-data))
 
 (defun m-buffer-match-string (match-data &optional subexp)
diff --git a/test/m-buffer-test.el b/test/m-buffer-test.el
index df4e7661b7..92b34e8d08 100644
--- a/test/m-buffer-test.el
+++ b/test/m-buffer-test.el
@@ -154,6 +154,16 @@
 
 
 (ert-deftest replace-matches ()
+  (should
+   (equal
+    '(6 16 26)
+    (m-buffer-wtb-of-file
+     "match-data.txt"
+     (m-buffer-marker-to-pos
+      (m-buffer-replace-match
+       (m-buffer-match-data
+        (current-buffer) "^one$") "three")))))
+
   (should
    (equal
     "three\ntwo\nthree\ntwo\nthree\ntwo\n"



reply via email to

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