From: Michael Heerdegen <michael_heerdegen@web.de>
To: Emacs Development <emacs-devel@gnu.org>
Cc: Philipp Stephani <phst@google.com>
Subject: Clarify `pcase' `rx' pattern doc
Date: Wed, 13 Jun 2018 05:52:01 +0200 [thread overview]
Message-ID: <87fu1rqr6m.fsf@web.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 271 bytes --]
Hello,
I had problems to understand the documentation of the `pcase' `rx'
pattern defined in "rx.el", though I'm familiar with (and user of) both
pcase and rx. So I looked at the code and tried to tweak the docstring.
(I also removed the EXPVAL reference.)
Opinions?
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Clarify-pcase-rx-pattern-documentation.patch --]
[-- Type: text/x-diff, Size: 2158 bytes --]
From 0d56315ad2470e127f5f0b464872216e7ceb6caa Mon Sep 17 00:00:00 2001
From: Michael Heerdegen <michael_heerdegen@web.de>
Date: Wed, 13 Jun 2018 01:42:34 +0200
Subject: [PATCH] Clarify `pcase' `rx' pattern documentation
---
lisp/emacs-lisp/rx.el | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el
index 85e74f28ef..643ee6949d 100644
--- a/lisp/emacs-lisp/rx.el
+++ b/lisp/emacs-lisp/rx.el
@@ -1183,24 +1183,25 @@ rx
(pcase-defmacro rx (&rest regexps)
- "Build a `pcase' pattern matching `rx' regexps.
-The REGEXPS are interpreted as by `rx'. The pattern matches if
-the regular expression so constructed matches EXPVAL, as if
-by `string-match'.
+ "`pcase' pattern matching strings using `rx' REGEXPS.
+The REGEXPS are interpreted as by `rx'. The pattern matches any
+string matched by the regular expression so constructed, as if by
+`string-match'.
In addition to the usual `rx' constructs, REGEXPS can contain the
following constructs:
- (let VAR FORM...) creates a new explicitly numbered submatch
- that matches FORM and binds the match to
- VAR.
- (backref VAR) creates a backreference to the submatch
- introduced by a previous (let VAR ...)
- construct.
+ (let VAR REGEXPS...) creates a new explicitly numbered
+ submatch that matches the `rx' REGEXPS
+ and binds the match to VAR.
+ (backref VAR-OR-NBR) creates a backreference to the submatch
+ introduced by a previous (let VAR ...)
+ construct; VAR-OR-NBR is either a symbol
+ VAR or a submatch number. It matches the
+ exact previous submatch.
The VARs are associated with explicitly numbered submatches
-starting from 1. Multiple occurrences of the same VAR refer to
-the same submatch.
+starting from 1.
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
--
2.17.1
[-- Attachment #3: Type: text/plain, Size: 21 bytes --]
Thanks,
Michael.
next reply other threads:[~2018-06-13 3:52 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-13 3:52 Michael Heerdegen [this message]
2018-06-13 5:43 ` Clarify `pcase' `rx' pattern doc Michael Heerdegen
2018-06-13 7:33 ` Andreas Schwab
2018-06-13 7:59 ` Michael Heerdegen
2018-06-13 8:18 ` Michael Heerdegen
2018-06-13 12:29 ` Yuri Khan
2018-06-18 12:34 ` Michael Heerdegen
2018-06-18 14:11 ` Stefan Monnier
2018-06-18 14:58 ` Michael Heerdegen
2018-06-18 16:56 ` Eli Zaretskii
2018-06-18 17:22 ` Michael Heerdegen
2018-06-18 17:55 ` Eli Zaretskii
2018-06-21 11:13 ` Michael Heerdegen
2018-06-21 14:48 ` Eli Zaretskii
2018-06-21 15:13 ` Michael Heerdegen
2018-06-23 13:35 ` Eli Zaretskii
2018-07-06 17:57 ` Michael Heerdegen
2018-07-07 6:53 ` Eli Zaretskii
2018-07-07 13:36 ` Michael Heerdegen
2018-07-07 13:57 ` Eli Zaretskii
2018-07-07 14:35 ` Michael Heerdegen
2018-07-20 8:45 ` Eli Zaretskii
2018-07-20 22:56 ` Michael Heerdegen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87fu1rqr6m.fsf@web.de \
--to=michael_heerdegen@web.de \
--cc=emacs-devel@gnu.org \
--cc=phst@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.