From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.devel Subject: Clarify `pcase' `rx' pattern doc Date: Wed, 13 Jun 2018 05:52:01 +0200 Message-ID: <87fu1rqr6m.fsf@web.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1528861856 11591 195.159.176.226 (13 Jun 2018 03:50:56 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 13 Jun 2018 03:50:56 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Philipp Stephani To: Emacs Development Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jun 13 05:50:52 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fSwo7-0002u0-K7 for ged-emacs-devel@m.gmane.org; Wed, 13 Jun 2018 05:50:51 +0200 Original-Received: from localhost ([::1]:59667 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSwqE-0003d9-Aa for ged-emacs-devel@m.gmane.org; Tue, 12 Jun 2018 23:53:02 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38148) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSwpO-0003bZ-7U for emacs-devel@gnu.org; Tue, 12 Jun 2018 23:52:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fSwpL-0005hE-53 for emacs-devel@gnu.org; Tue, 12 Jun 2018 23:52:10 -0400 Original-Received: from mout.web.de ([212.227.15.14]:39359) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fSwpK-0005gl-OP for emacs-devel@gnu.org; Tue, 12 Jun 2018 23:52:07 -0400 Original-Received: from drachen.dragon ([188.110.196.170]) by smtp.web.de (mrweb002 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MDPUT-1fS94m321F-00Gu8x; Wed, 13 Jun 2018 05:52:01 +0200 X-Provags-ID: V03:K1:JgTBZviws23Q+dw6qEMLOrr1BYnhvlI9efaQwN+qrzMBu3OwkiY lr3Lu/sCJSA8eMn6n2MmknOwSTiAKeZm2iC41kYdIeL33fzZt08L+dp5dnAMXB88A7Yxk0C OwQSPFU+lv6qZKMO652+0cQ0F4l2uGxGbHdNVCdsm9LUQc7cYglQVrY5/BHbxKxTEpYaPbS IY/IAKP1KetG+os2OYM7Q== X-UI-Out-Filterresults: notjunk:1;V01:K0:9UjTMFJhJLU=:vuLCf3yrJV12Mlw3lG0HlI EAWUcOSUuESsi7RBTEXuxJItfvdwBRp6lqbCid/6dqAHp5Jmbvj9JL6cnOZrpBDMGLJYwyI/6 W/hvEgzEeUdw99quOMdXFWVbxthTjcoAenwNLgSi2Hh9XaoC04+t1M4D0uqB/TQSQdmGd1+SI sajLgBjQcKwl66o6Via2vVW1nPpxJkc3/zMxNM3/Y5cMaV2e2NqWShsnqoizb1KXnEV19YkfR c3a7mxTvUfHBnnnMuQQEajP81AC8Cxa80U87sKEQVyizbk60OiXl6CW9Uo2BuciW4hsc14K/d su6E5SUOzJVBgfCoAOQhR4ZXAWhx9pCOcN1BEv16oUCUOvYK3jjPaiCs1uHuIXCdgs26i8PLz WCoXmowodtgXbwMDUlaw5BBFWv0qNlNCjNcDN+Z1O3dY2LSZEhy+P+GjZAMgFSIwnd0SEDfFq YOs7/uLYYrfNsdD8Zxnf+x4W0J58DcZ+6dN1bfZWveVuk2LWzoERrmFr/qsGD7Nd+hCaGfRe+ eo2ko4iEJDiiboH5xJlaEeWMWKdYPCzfVnb0hZ0h6HOSXdvV3Cnalkmzf3JZsenu7V8GuM8bc QgHddhAT3tHuic8yR8ZoWvl731Sjg19I4g7OwR0AxY9jFyQ/g5dQAg0tf6oCg79Y3T+1BYKLX H7Ns/JZ/gvRLQk/qlSTYl53YaukIzt0w/PKMjQuTTHERE6zGaUqUnJya+C/D0jw5ErSnnSWjb HnN0fdw/GX/0onmdtPFfk4y6FDflW02+FepiO0DagWNOlafyE0CjAY5gfVATbSRMxRpeitVa X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.15.14 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:226279 Archived-At: --=-=-= Content-Type: text/plain 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? --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Clarify-pcase-rx-pattern-documentation.patch >From 0d56315ad2470e127f5f0b464872216e7ceb6caa Mon Sep 17 00:00:00 2001 From: Michael Heerdegen 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 --=-=-= Content-Type: text/plain Thanks, Michael. --=-=-=--