[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master baf331e 3/3: Rename replace-in-string to string-replace
From: |
Lars Ingebrigtsen |
Subject: |
master baf331e 3/3: Rename replace-in-string to string-replace |
Date: |
Sat, 26 Sep 2020 18:25:02 -0400 (EDT) |
branch: master
commit baf331e40c08155082e255372d7cc3c9d63aa3c8
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Rename replace-in-string to string-replace
* doc/lispref/searching.texi (Search and Replace): Update.
* lisp/bindings.el (mode-line-position): Update callers.
* lisp/subr.el (string-replace): Rename from replace-in-string
since that clashes with XEmacs' replace-in-string which is
equivalent to the Emacs replace-regexp-in-string (bug#43598).
---
doc/lispref/searching.texi | 2 +-
etc/NEWS | 2 +-
lisp/bindings.el | 4 ++--
lisp/subr.el | 2 +-
test/lisp/subr-tests.el | 26 +++++++++++++-------------
5 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/doc/lispref/searching.texi b/doc/lispref/searching.texi
index a217c6e..451283b 100644
--- a/doc/lispref/searching.texi
+++ b/doc/lispref/searching.texi
@@ -2566,7 +2566,7 @@ replacement string. The match data at this point are the
result
of matching @var{regexp} against a substring of @var{string}.
@end defun
-@defun replace-in-string fromstring tostring instring
+@defun string-replace fromstring tostring instring
This function copies @var{instring} and replaces any occurrences of
@var{fromstring} with @var{tostring}.
@end defun
diff --git a/etc/NEWS b/etc/NEWS
index 9cd35593..0cbbae4 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1455,7 +1455,7 @@ return status is non-zero.
'process-lines-handling-status' has also
been added, and takes a callback to handle the return status.
+++
-*** New function 'replace-in-string'.
+*** New function 'string-replace'.
This function works along the line of 'replace-regexp-in-string', but
matching on strings instead of regexps, and does not change the global
match state.
diff --git a/lisp/bindings.el b/lisp/bindings.el
index f31c6cc..3930f5b 100644
--- a/lisp/bindings.el
+++ b/lisp/bindings.el
@@ -493,7 +493,7 @@ mouse-1: Display Line and Column Mode Menu")))
,@mode-line-position--column-line-properties))
(10
(:propertize
- (:eval (replace-in-string
+ (:eval (string-replace
"%c" "%C" (car mode-line-position-column-line-format)))
,@mode-line-position--column-line-properties)))
(6
@@ -508,7 +508,7 @@ mouse-1: Display Line and Column Mode Menu")))
(,@mode-line-position--column-line-properties)))
(6
(:propertize
- (:eval (replace-in-string
+ (:eval (string-replace
"%c" "%C" (car mode-line-position-column-format)))
,@mode-line-position--column-line-properties))))))
"Mode line construct for displaying the position in the buffer.
diff --git a/lisp/subr.el b/lisp/subr.el
index 357eae0..6f164ae 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -4429,7 +4429,7 @@ Unless optional argument INPLACE is non-nil, return a new
string."
(aset newstr i tochar)))
newstr))
-(defun replace-in-string (fromstring tostring instring)
+(defun string-replace (fromstring tostring instring)
"Replace FROMSTRING with TOSTRING in INSTRING each time it occurs."
(declare (pure t))
(when (equal fromstring "")
diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el
index 505408f..a3e9c42 100644
--- a/test/lisp/subr-tests.el
+++ b/test/lisp/subr-tests.el
@@ -440,33 +440,33 @@ See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=19350.";
(should-error (ignore-error foo
(read ""))))
-(ert-deftest replace-in-string ()
- (should (equal (replace-in-string "foo" "bar" "zot")
+(ert-deftest string-replace ()
+ (should (equal (string-replace "foo" "bar" "zot")
"zot"))
- (should (equal (replace-in-string "foo" "bar" "foozot")
+ (should (equal (string-replace "foo" "bar" "foozot")
"barzot"))
- (should (equal (replace-in-string "foo" "bar" "barfoozot")
+ (should (equal (string-replace "foo" "bar" "barfoozot")
"barbarzot"))
- (should (equal (replace-in-string "zot" "bar" "barfoozot")
+ (should (equal (string-replace "zot" "bar" "barfoozot")
"barfoobar"))
- (should (equal (replace-in-string "z" "bar" "barfoozot")
+ (should (equal (string-replace "z" "bar" "barfoozot")
"barfoobarot"))
- (should (equal (replace-in-string "zot" "bar" "zat")
+ (should (equal (string-replace "zot" "bar" "zat")
"zat"))
- (should (equal (replace-in-string "azot" "bar" "zat")
+ (should (equal (string-replace "azot" "bar" "zat")
"zat"))
- (should (equal (replace-in-string "azot" "bar" "azot")
+ (should (equal (string-replace "azot" "bar" "azot")
"bar"))
- (should (equal (replace-in-string "azot" "bar" "foozotbar")
+ (should (equal (string-replace "azot" "bar" "foozotbar")
"foozotbar"))
- (should (equal (replace-in-string "\377" "x" "a\377b")
+ (should (equal (string-replace "\377" "x" "a\377b")
"axb"))
- (should (equal (replace-in-string "\377" "x" "a\377ø")
+ (should (equal (string-replace "\377" "x" "a\377ø")
"axø"))
- (should-error (replace-in-string "" "x" "abc")))
+ (should-error (string-replace "" "x" "abc")))
(provide 'subr-tests)
;;; subr-tests.el ends here