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

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

[elpa] externals/hyperbole 9f9b106 35/51: hypb:replace-match-string): Re


From: Stefan Monnier
Subject: [elpa] externals/hyperbole 9f9b106 35/51: hypb:replace-match-string): Replace with replace-regexp-in-string
Date: Sun, 12 Jul 2020 18:10:16 -0400 (EDT)

branch: externals/hyperbole
commit 9f9b1066602ccb5fc1d565ffa75d2b04381d16cb
Author: Bob Weiner <rsw@gnu.org>
Commit: Bob Weiner <rsw@gnu.org>

    hypb:replace-match-string): Replace with replace-regexp-in-string
---
 hypb.el | 38 +-------------------------------------
 1 file changed, 1 insertion(+), 37 deletions(-)

diff --git a/hypb.el b/hypb.el
index 131ea32..26a1893 100644
--- a/hypb.el
+++ b/hypb.el
@@ -533,43 +533,7 @@ that returns a replacement string."
   (unless (or (stringp newtext) (functionp newtext))
     (error "(hypb:replace-match-string): 3rd arg must be a string or function: 
%s"
           newtext))
-  (let ((rtn-str "")
-       (start 0)
-       (special)
-       match prev-start)
-    (while (setq match (string-match regexp str start))
-      (setq prev-start start
-           start (match-end 0)
-           rtn-str
-           (concat
-             rtn-str
-             (substring str prev-start match)
-             (cond ((functionp newtext)
-                    (hypb:replace-match-string
-                     regexp (substring str match start)
-                     (funcall newtext str) literal))
-                   (literal newtext)
-                   (t (mapconcat
-                        (lambda (c)
-                          (cond (special
-                                 (setq special nil)
-                                 (cond ((eq c ?\\) "\\")
-                                       ((eq c ?&)
-                                        (match-string 0 str))
-                                       ((and (>= c ?0) (<= c ?9))
-                                        (if (> c (+ ?0 (length
-                                                        (match-data))))
-                                            ;; Invalid match num
-                                            (error 
"(hypb:replace-match-string) Invalid match num: %c" c)
-                                          (setq c (- c ?0))
-                                          (match-string c str)))
-                                       (t (char-to-string c))))
-                            ((eq c ?\\)
-                             (setq special t)
-                             nil)
-                            (t (char-to-string c))))
-                        newtext ""))))))
-    (concat rtn-str (substring str start))))
+  (replace-regexp-in-string regexp newtext str nil literal))
 
 (defun hypb:return-process-output (program &optional infile &rest args)
   "Return as a string the output from external PROGRAM with INFILE for input.



reply via email to

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