From: Eli Zaretskii Date: Mon, 16 Aug 2021 17:11:33 +0000 (+0300) Subject: Fix recent documentation additions X-Git-Tag: emacs-28.0.90~1478 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f0ef1e971d200940f5ebf1d50707112df659da8e;p=emacs.git Fix recent documentation additions * doc/lispref/searching.texi (Search and Replace): Document the new functions by @defun. --- diff --git a/doc/lispref/searching.texi b/doc/lispref/searching.texi index fe47e7ccf57..4d5ae3cb437 100644 --- a/doc/lispref/searching.texi +++ b/doc/lispref/searching.texi @@ -2553,21 +2553,31 @@ using @code{re-search-forward} and @code{replace-match}, like this: @xref{Replacing Match,, Replacing the Text that Matched}, for a description of @code{replace-match}. -@findex replace-regexp-in-region - If it's more convenient, you can also use the -@code{replace-regexp-in-region}, which does something similar to the -loop above, but is optionally delimited to a specific region (and -doesn't change point). Furthermore, it does the searches -case-sensitively, and performs the replacements without changing case -in the replacement. + It may be more convenient to limit the replacements to a specific +region. The function @code{replace-regexp-in-region} does that. + +@defun replace-regexp-in-region regexp replacement &optional start end +This function replaces all the occurrences of @var{regexp} with +@var{replacement} in the region of buffer text between @var{start} and +@var{end}; @var{start} defaults to position of point, and @var{end} +defaults to the last accessible position of the buffer. The search +for @var{regexp} is case-sensitive, and @var{replacement} is inserted +without changing its letter-case. The @var{replacement} string can +use the same special elements starting with @samp{\} as +@code{replace-match} does. The function returns the number of +replaced occurrences, or @code{nil} if @var{regexp} is not found. The +function preserves the position of point. @example (replace-regexp-in-region "foo[ \t]+bar" "foobar") @end example +@end defun -@findex replace-string-in-region - There's also @code{replace-string-in-region}, which works along the -same lines, but searches for literal strings instead. +@defun replace-string-in-region string replacement &optional start end + This function works similarly to @code{replace-regexp-in-region}, +but searches for, and replaces, literal @var{string}s instead of +regular expressions. +@end defun Emacs also has special functions for replacing matches in a string.