]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/subr.el (string-replace): Add dashes to arg names (bug#50644)
authorJuri Linkov <juri@linkov.net>
Sat, 18 Sep 2021 18:42:17 +0000 (21:42 +0300)
committerJuri Linkov <juri@linkov.net>
Sat, 18 Sep 2021 18:43:18 +0000 (21:43 +0300)
* lisp/net/tramp-compat.el (tramp-compat-string-replace): Idem.
* doc/lispref/searching.texi (Search and Replace): Idem.

doc/lispref/searching.texi
lisp/net/tramp-compat.el
lisp/subr.el

index 68061f0b09f40ebddd6d2f8aa84cd6aae1bc2bf0..0dcf3889a59058b1a2a46e01b3802927cdbc3cff 100644 (file)
@@ -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
index 125f82592f4a7ad759b3fcbdd1ebfe7f975affd7..e6f1d9df70fe4f41bd3c5f7ef0c12387b68774c6 100644 (file)
@@ -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
index a2266b1d5761cde8ecbdfe3e24de6e77216124c7..c2cfc18bd7a65dd864afad4df28cc9c51019bc4a 100644 (file)
@@ -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