emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs-25 38f4b8e: Clarify the documentation of back-refere


From: Eli Zaretskii
Subject: [Emacs-diffs] emacs-25 38f4b8e: Clarify the documentation of back-references in replacements
Date: Sat, 2 Jul 2016 15:04:40 +0000 (UTC)

branch: emacs-25
commit 38f4b8ea615025e7996754fd72449be91c38d448
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Clarify the documentation of back-references in replacements
    
    * doc/emacs/search.texi (Regexp Replace): Clarify that \D starts
    with \1, not \0.
    
    * lisp/replace.el (query-replace-regexp)
    (query-replace-regexp-eval, replace-regexp): Doc fix (Bug#23884)
---
 doc/emacs/search.texi |   12 ++++++------
 lisp/replace.el       |   17 ++++++++++-------
 2 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/doc/emacs/search.texi b/doc/emacs/search.texi
index d841934..b41214d 100644
--- a/doc/emacs/search.texi
+++ b/doc/emacs/search.texi
@@ -1356,12 +1356,12 @@ Replace every match for @var{regexp} with 
@var{newstring}.
 it can refer to all or part of what is matched by the @var{regexp}.
 @samp{\&} in @var{newstring} stands for the entire match being
 replaced.  @address@hidden in @var{newstring}, where @var{d} is a
-digit, stands for whatever matched the @var{d}th parenthesized
-grouping in @var{regexp}.  (This is called a ``back reference''.)
address@hidden refers to the count of replacements already made in this
-command, as a decimal number.  In the first replacement, @samp{\#}
-stands for @samp{0}; in the second, for @samp{1}; and so on.  For
-example,
+digit starting from 1, stands for whatever matched the @var{d}th
+parenthesized grouping in @var{regexp}.  (This is called a ``back
+reference''.)  @samp{\#} refers to the count of replacements already
+made in this command, as a decimal number.  In the first replacement,
address@hidden stands for @samp{0}; in the second, for @samp{1}; and so on.
+For example,
 
 @example
 M-x replace-regexp @key{RET} c[ad]+r @key{RET} \&-safe @key{RET}
diff --git a/lisp/replace.el b/lisp/replace.el
index fe90062..eb5e0cf 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -391,9 +391,10 @@ replace backward.
 
 Fourth and fifth arg START and END specify the region to operate on.
 
-In TO-STRING, `\\&' stands for whatever matched the whole of REGEXP,
-and `\\=\\N' (where N is a digit) stands for
-whatever what matched the Nth `\\(...\\)' in REGEXP.
+In TO-STRING, `\\&' or `\\0' stands for whatever matched the whole of
+REGEXP, and `\\=\\N' (where N is a digit) stands for whatever matched
+the Nth `\\(...\\)' (1-based) in REGEXP.  The `\\(...\\)' groups are
+counted from 1.
 `\\?' lets you edit the replacement text in the minibuffer
 at the given position for each replacement.
 
@@ -451,7 +452,9 @@ If the result of TO-EXPR is not a string, it is converted 
to one using
 
 For convenience, when entering TO-EXPR interactively, you can use `\\&' or
 `\\0' to stand for whatever matched the whole of REGEXP, and `\\N' (where
-N is a digit) to stand for whatever matched the Nth `\\(...\\)' in REGEXP.
+N is a digit) to stand for whatever matched the Nth `\\(...\\)' (1-based)
+in REGEXP.
+
 Use `\\#&' or `\\#N' if you want a number instead of a string.
 In interactive use, `\\#' in itself stands for `replace-count'.
 
@@ -635,9 +638,9 @@ replace backward.
 
 Fourth and fifth arg START and END specify the region to operate on.
 
-In TO-STRING, `\\&' stands for whatever matched the whole of REGEXP,
-and `\\=\\N' (where N is a digit) stands for
-whatever what matched the Nth `\\(...\\)' in REGEXP.
+In TO-STRING, `\\&' or `\\0' stands for whatever matched the whole of
+REGEXP, and `\\=\\N' (where N is a digit) stands for
+whatever matched the Nth `\\(...\\)' (1-based) in REGEXP.
 `\\?' lets you edit the replacement text in the minibuffer
 at the given position for each replacement.
 



reply via email to

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