From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Philipp Stephani Newsgroups: gmane.emacs.bugs Subject: bug#27659: 26.0.50; Add string-matched-text: string-match + match-string Date: Sun, 23 Jul 2017 20:41:36 +0000 Message-ID: References: <87fue2rxm1.fsf@calancha-pc> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="001a1140faba7be2880555022058" X-Trace: blaine.gmane.org 1500842537 28178 195.159.176.226 (23 Jul 2017 20:42:17 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 23 Jul 2017 20:42:17 +0000 (UTC) Cc: 27659@debbugs.gnu.org, Michael Heerdegen To: Stefan Monnier , Tino Calancha Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jul 23 22:42:12 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1dZNhY-0006nb-Vh for geb-bug-gnu-emacs@m.gmane.org; Sun, 23 Jul 2017 22:42:09 +0200 Original-Received: from localhost ([::1]:51527 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZNhd-0004aW-1R for geb-bug-gnu-emacs@m.gmane.org; Sun, 23 Jul 2017 16:42:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60959) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZNhX-0004aR-Bs for bug-gnu-emacs@gnu.org; Sun, 23 Jul 2017 16:42:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZNhT-00063H-5a for bug-gnu-emacs@gnu.org; Sun, 23 Jul 2017 16:42:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:50978) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dZNhT-000639-0u for bug-gnu-emacs@gnu.org; Sun, 23 Jul 2017 16:42:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dZNhS-0005EQ-Gz for bug-gnu-emacs@gnu.org; Sun, 23 Jul 2017 16:42:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Philipp Stephani Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 23 Jul 2017 20:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27659 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: wontfix Original-Received: via spool by 27659-submit@debbugs.gnu.org id=B27659.150084251620093 (code B ref 27659); Sun, 23 Jul 2017 20:42:02 +0000 Original-Received: (at 27659) by debbugs.gnu.org; 23 Jul 2017 20:41:56 +0000 Original-Received: from localhost ([127.0.0.1]:53655 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dZNhL-0005E1-Lr for submit@debbugs.gnu.org; Sun, 23 Jul 2017 16:41:55 -0400 Original-Received: from mail-oi0-f52.google.com ([209.85.218.52]:35973) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dZNhJ-0005Do-Ge for 27659@debbugs.gnu.org; Sun, 23 Jul 2017 16:41:54 -0400 Original-Received: by mail-oi0-f52.google.com with SMTP id g131so11566892oic.3 for <27659@debbugs.gnu.org>; Sun, 23 Jul 2017 13:41:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mTWkdZnz3m9kM1cTLaW/IBh1J3HGJzSqhwp9fv6SkZg=; b=E3cZzLqXYGTa8X3LSdcyNJoA2aDp2jkEfYuZqYbSOsN5gnxumETSmB6RHd2kM/p4DY 2cw0L6ce86S2rVyl62qAKHnBAzTLW9G+/WsRBHpQLvaRdf/yGc0rp6N0JrgSCJmD028d KQxD/5gj3j6SOiIPD3tT82eZvBvymJhzCQ7mvedktlwF0e9FXkdGcVIkgYul/71rjTet +OoKQijWGWndSfhFfbjiaJGozuAyylAf4JQw5C8SdNPCFG18yfR5Cs/Q1raYJkqhTCZ0 09jmClBnSOuWVRpTrqSAF1JF6f4Ft0y1D9VlJFHqan+Pk2sPGBUsOITXgOe23qIGniHF ZfoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mTWkdZnz3m9kM1cTLaW/IBh1J3HGJzSqhwp9fv6SkZg=; b=OQURottqq6t5udHEEEIBFeY/n8mJWHtpInS/03MZQZ38bG00Rnk4eo7w35u5QtRuhl 2pJ7DHXSI9BGx1IhJIgw0TQTLyUyVlipC7adnmGCrt0wkDL9E5jTHGvv6zCOwWdypi0C nq9lr5C4L6kpRDD7keSkG320nxdvD9QEfVxkmh7yltotqqWycxk9BW8509NxIQ82wQBK wVn5/HmnpXRklbbCPvMTAo48kRN3ryKTFlPAtR5duQWDJfGGEoLBU+r3jwDfxGnfURJB x4jwp5Y8gM1yhN7Dm7+kZeHh+0y7AqlNNyljzEdlzUthIK6cRVaozwSe6UwCFbrE/4nb GJww== X-Gm-Message-State: AIVw1130wE/LSecYMEsBTU7/vxMMOYWA0Fix+JUrWae49FHIDb5g4zQ1 OPtru4xxX8HiK2MvPaHpwkPoeB9Ezw== X-Received: by 10.202.104.38 with SMTP id d38mr4237864oic.53.1500842506836; Sun, 23 Jul 2017 13:41:46 -0700 (PDT) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:134894 Archived-At: --001a1140faba7be2880555022058 Content-Type: text/plain; charset="UTF-8" Stefan Monnier schrieb am Fr., 21. Juli 2017 um 15:34 Uhr: > >> This looks useful, but I think it would be even better to add it > >> as a pcase macro to be composable (see attached patch). > > Hey, very nice. Please add it to rx.el. > [ But please change `backref-var` to just `backref` (you can distinguish > the two based on the type of the argument, I think). I guess one > could also argue that you could similarly rename the `let` to > `group-n`. ] > Pushed as ad4eff3b905dbc32e2d38bfec1e4f93eceec288d. I've renamed backref-var to backref as you suggested, but left `let' because I think that feature is important enough to deserve a short, common name. > > > Although, i must admit i am not fluent in `rx' syntaxis, i find your idea > > very nice. > > If you prefer the standard/cryptic regexp syntax, I posted a similar > thingy in the past (see below). > > This lets you do > > (pcase "foo-123" > ((re-match "[[:alpha:]]+-\\(?num:[0-9]+\\)") > num)) > => "123" > > Maybe I should install it in pcase.el? > > > Sure! I'd suggest to change the syntax to be compatible with other languages: \(?[0-9]+\) or \(?'abc'[0-9+\) (Perl and .NET) \(?P[0-9]+\) (Python) These languages also have syntax for named backreferences, though that's less important. --001a1140faba7be2880555022058 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


Stefan= Monnier <monnier@iro.umontr= eal.ca> schrieb am Fr., 21. Juli 2017 um 15:34=C2=A0Uhr:
>> This looks useful, but I think it wou= ld be even better to add it
>> as a pcase macro to be composable (see attached patch).=C2=A0

Hey, very nice.=C2=A0 Please add it to rx.el.
[ But please change `backref-var` to just `backref` (you can distinguish =C2=A0 the two based on the type of the argument, I think).=C2=A0 I guess o= ne
=C2=A0 could also argue that you could similarly rename the `let` to
=C2=A0 `group-n`.=C2=A0 ]


Pushed as ad4eff3b905dbc32e2d38bfec1e4f93eceec288d. I've renamed back= ref-var to backref as you suggested, but left `let' because I think tha= t feature is important enough to deserve a short, common name.
=C2=A0

> Although, i must admit i am not fluent in `rx' syntaxis, i find yo= ur idea
> very nice.

If you prefer the standard/cryptic regexp syntax, I posted a similar
thingy in the past (see below).

This lets you do

=C2=A0 =C2=A0 (pcase "foo-123"
=C2=A0 =C2=A0 =C2=A0 ((re-match "[[:alpha:]]+-\\(?num:[0-9]+\\)")=
=C2=A0 =C2=A0 =C2=A0 =C2=A0num))
=C2=A0 =C2=A0 =3D> "123"

Maybe I should install it in pcase.el?



Sure! I'd suggest to change the sy= ntax to be compatible with other languages:

\(?<= ;abc>[0-9]+\) or \(?'abc'[0-9+\) (Perl and .NET)
\(?P&= lt;abc>[0-9]+\) (Python)

These languages also h= ave syntax for named backreferences, though that's less important.=C2= =A0
--001a1140faba7be2880555022058--