emacs-diffs
[Top][All Lists]
Advanced

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

master 4b3dc7a: * lisp/subr.el (string-replace): Add dashes to arg names


From: Juri Linkov
Subject: master 4b3dc7a: * lisp/subr.el (string-replace): Add dashes to arg names (bug#50644)
Date: Sat, 18 Sep 2021 14:44:15 -0400 (EDT)

branch: master
commit 4b3dc7a139c426bad52d3aa145b4868c9b44a325
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>

    * lisp/subr.el (string-replace): Add dashes to arg names (bug#50644)
    
    * lisp/net/tramp-compat.el (tramp-compat-string-replace): Idem.
    * doc/lispref/searching.texi (Search and Replace): Idem.
---
 doc/lispref/searching.texi |  6 +++---
 lisp/net/tramp-compat.el   |  4 ++--
 lisp/subr.el               | 20 ++++++++++----------
 3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/doc/lispref/searching.texi b/doc/lispref/searching.texi
index 68061f0..0dcf388 100644
--- a/doc/lispref/searching.texi
+++ b/doc/lispref/searching.texi
@@ -2620,9 +2620,9 @@ replacement string.  The match data at this point are the 
result
 of matching @var{regexp} against a substring of @var{string}.
 @end defun
 
-@defun string-replace fromstring tostring instring
-This function replaces all occurrences of @var{fromstring} with
-@var{tostring} in @var{instring} and returns the result.  It may
+@defun string-replace from-string to-string in-string
+This function replaces all occurrences of @var{from-string} with
+@var{to-string} in @var{in-string} and returns the result.  It may
 return one of its arguments unchanged, a constant string or a new
 string.  Case is significant, and text properties are ignored.
 @end defun
diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el
index 125f825..e6f1d9d 100644
--- a/lisp/net/tramp-compat.el
+++ b/lisp/net/tramp-compat.el
@@ -359,10 +359,10 @@ CONDITION can also be a list of error conditions."
 (defalias 'tramp-compat-string-replace
   (if (fboundp 'string-replace)
       #'string-replace
-    (lambda (fromstring tostring instring)
+    (lambda (from-string to-string in-string)
       (let ((case-fold-search nil))
         (replace-regexp-in-string
-         (regexp-quote fromstring) tostring instring t t)))))
+         (regexp-quote from-string) to-string in-string t t)))))
 
 ;; Function `string-search' is new in Emacs 28.1.
 (defalias 'tramp-compat-string-search
diff --git a/lisp/subr.el b/lisp/subr.el
index a2266b1..c2cfc18 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -4937,25 +4937,25 @@ Unless optional argument INPLACE is non-nil, return a 
new string."
          (aset newstr i tochar)))
     newstr))
 
-(defun string-replace (fromstring tostring instring)
-  "Replace FROMSTRING with TOSTRING in INSTRING each time it occurs."
+(defun string-replace (from-string to-string in-string)
+  "Replace FROM-STRING with TO-STRING in IN-STRING each time it occurs."
   (declare (pure t) (side-effect-free t))
-  (when (equal fromstring "")
+  (when (equal from-string "")
     (signal 'wrong-length-argument '(0)))
   (let ((start 0)
         (result nil)
         pos)
-    (while (setq pos (string-search fromstring instring start))
+    (while (setq pos (string-search from-string in-string start))
       (unless (= start pos)
-        (push (substring instring start pos) result))
-      (push tostring result)
-      (setq start (+ pos (length fromstring))))
+        (push (substring in-string start pos) result))
+      (push to-string result)
+      (setq start (+ pos (length from-string))))
     (if (null result)
         ;; No replacements were done, so just return the original string.
-        instring
+        in-string
       ;; Get any remaining bit.
-      (unless (= start (length instring))
-        (push (substring instring start) result))
+      (unless (= start (length in-string))
+        (push (substring in-string start) result))
       (apply #'concat (nreverse result)))))
 
 (defun replace-regexp-in-string (regexp rep string &optional



reply via email to

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