diff options
| author | Eli Zaretskii | 2018-07-20 11:44:36 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2018-07-20 11:44:36 +0300 |
| commit | 3e722980df9d4a705394c843a2a5e051e9c682b6 (patch) | |
| tree | cb97b4cded9f504a7bcfe0e94f87b9ddc82b0c5f | |
| parent | ba9b9bb4accda749be5a3803569ef1dc2de6919a (diff) | |
| download | emacs-3e722980df9d4a705394c843a2a5e051e9c682b6.tar.gz emacs-3e722980df9d4a705394c843a2a5e051e9c682b6.zip | |
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.
| -rw-r--r-- | lisp/emacs-lisp/rx.el | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el index 30bb129e8f2..5fa0eaf194f 100644 --- a/lisp/emacs-lisp/rx.el +++ b/lisp/emacs-lisp/rx.el | |||
| @@ -1181,24 +1181,28 @@ enclosed in `(and ...)'. | |||
| 1181 | 1181 | ||
| 1182 | 1182 | ||
| 1183 | (pcase-defmacro rx (&rest regexps) | 1183 | (pcase-defmacro rx (&rest regexps) |
| 1184 | "Build a `pcase' pattern matching `rx' regexps. | 1184 | "Build a `pcase' pattern matching `rx' REGEXPS in sexp form. |
| 1185 | The REGEXPS are interpreted as by `rx'. The pattern matches if | 1185 | The REGEXPS are interpreted as in `rx'. The pattern matches any |
| 1186 | the regular expression so constructed matches EXPVAL, as if | 1186 | string that is a match for the regular expression so constructed, |
| 1187 | by `string-match'. | 1187 | as if by `string-match'. |
| 1188 | 1188 | ||
| 1189 | In addition to the usual `rx' constructs, REGEXPS can contain the | 1189 | In addition to the usual `rx' constructs, REGEXPS can contain the |
| 1190 | following constructs: | 1190 | following constructs: |
| 1191 | 1191 | ||
| 1192 | (let VAR FORM...) creates a new explicitly numbered submatch | 1192 | (let REF SEXP...) creates a new explicitly named reference to |
| 1193 | that matches FORM and binds the match to | 1193 | a submatch that matches regular expressions |
| 1194 | VAR. | 1194 | SEXP, and binds the match to REF. |
| 1195 | (backref VAR) creates a backreference to the submatch | 1195 | (backref REF) creates a backreference to the submatch |
| 1196 | introduced by a previous (let VAR ...) | 1196 | introduced by a previous (let REF ...) |
| 1197 | construct. | 1197 | construct. REF can be the same symbol |
| 1198 | 1198 | in the first argument of the corresponding | |
| 1199 | The VARs are associated with explicitly numbered submatches | 1199 | (let REF ...) construct, or it can be a |
| 1200 | starting from 1. Multiple occurrences of the same VAR refer to | 1200 | submatch number. It matches the referenced |
| 1201 | the same submatch. | 1201 | submatch. |
| 1202 | |||
| 1203 | The REFs are associated with explicitly named submatches starting | ||
| 1204 | from 1. Multiple occurrences of the same REF refer to the same | ||
| 1205 | submatch. | ||
| 1202 | 1206 | ||
| 1203 | If a case matches, the match data is modified as usual so you can | 1207 | If a case matches, the match data is modified as usual so you can |
| 1204 | use it in the case body, but you still have to pass the correct | 1208 | use it in the case body, but you still have to pass the correct |