1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-24 10:38:38 +00:00

Improve documentation of 'pcase-defmacro rx'

* lisp/emacs-lisp/rx.el (rx): Clarify and improve the doc string.
For the details, see the discussion starting at
http://lists.gnu.org/archive/html/emacs-devel/2018-06/msg00399.html.
This commit is contained in:
Eli Zaretskii 2018-07-20 11:44:36 +03:00
parent ba9b9bb4ac
commit 3e722980df

View File

@ -1181,24 +1181,28 @@ enclosed in `(and ...)'.
(pcase-defmacro rx (&rest regexps) (pcase-defmacro rx (&rest regexps)
"Build a `pcase' pattern matching `rx' regexps. "Build a `pcase' pattern matching `rx' REGEXPS in sexp form.
The REGEXPS are interpreted as by `rx'. The pattern matches if The REGEXPS are interpreted as in `rx'. The pattern matches any
the regular expression so constructed matches EXPVAL, as if string that is a match for the regular expression so constructed,
by `string-match'. as if by `string-match'.
In addition to the usual `rx' constructs, REGEXPS can contain the In addition to the usual `rx' constructs, REGEXPS can contain the
following constructs: following constructs:
(let VAR FORM...) creates a new explicitly numbered submatch (let REF SEXP...) creates a new explicitly named reference to
that matches FORM and binds the match to a submatch that matches regular expressions
VAR. SEXP, and binds the match to REF.
(backref VAR) creates a backreference to the submatch (backref REF) creates a backreference to the submatch
introduced by a previous (let VAR ...) introduced by a previous (let REF ...)
construct. construct. REF can be the same symbol
in the first argument of the corresponding
(let REF ...) construct, or it can be a
submatch number. It matches the referenced
submatch.
The VARs are associated with explicitly numbered submatches The REFs are associated with explicitly named submatches starting
starting from 1. Multiple occurrences of the same VAR refer to from 1. Multiple occurrences of the same REF refer to the same
the same submatch. submatch.
If a case matches, the match data is modified as usual so you can If a case matches, the match data is modified as usual so you can
use it in the case body, but you still have to pass the correct use it in the case body, but you still have to pass the correct