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: Thu, 20 Jul 2017 19:51:22 +0000 Message-ID: References: <87fue2rxm1.fsf@calancha-pc> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="001a113d2cd85bce3f0554c513c1" X-Trace: blaine.gmane.org 1500580337 27337 195.159.176.226 (20 Jul 2017 19:52:17 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 20 Jul 2017 19:52:17 +0000 (UTC) To: Tino Calancha , 27659@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jul 20 21:52:13 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 1dYHUW-0006g3-Ji for geb-bug-gnu-emacs@m.gmane.org; Thu, 20 Jul 2017 21:52:08 +0200 Original-Received: from localhost ([::1]:39743 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dYHUc-0001C9-8x for geb-bug-gnu-emacs@m.gmane.org; Thu, 20 Jul 2017 15:52:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33593) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dYHUT-0001Bz-Et for bug-gnu-emacs@gnu.org; Thu, 20 Jul 2017 15:52:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dYHUQ-0006AT-S1 for bug-gnu-emacs@gnu.org; Thu, 20 Jul 2017 15:52:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:47364) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dYHUQ-0006AK-MF for bug-gnu-emacs@gnu.org; Thu, 20 Jul 2017 15:52:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dYHUQ-0006O8-Ct for bug-gnu-emacs@gnu.org; Thu, 20 Jul 2017 15:52: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: Thu, 20 Jul 2017 19:52: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.150058030124520 (code B ref 27659); Thu, 20 Jul 2017 19:52:02 +0000 Original-Received: (at 27659) by debbugs.gnu.org; 20 Jul 2017 19:51:41 +0000 Original-Received: from localhost ([127.0.0.1]:50041 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dYHU5-0006NL-Dt for submit@debbugs.gnu.org; Thu, 20 Jul 2017 15:51:41 -0400 Original-Received: from mail-oi0-f49.google.com ([209.85.218.49]:34674) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dYHU3-0006Mz-Di for 27659@debbugs.gnu.org; Thu, 20 Jul 2017 15:51:39 -0400 Original-Received: by mail-oi0-f49.google.com with SMTP id q4so35956231oif.1 for <27659@debbugs.gnu.org>; Thu, 20 Jul 2017 12:51:39 -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; bh=9gcmaRozXFRZLn7B3nawsG88rV4E5dTb/854Uvshk7E=; b=q7YgLoeDgN/PaYJxdbw/Gke9ypnoyGqsqJZOW9Fbt4IeMCpF7hMjNWx5FgHc8RXfeZ ACrXIxyQR5+QOwgTTC/68T6KjvDykn4pZmvJIESYjH8cknpt16lr28nX/SSwhekJhKnn X2tXcRZC6Telc4Uga66fUtTAO3pZvi/be80auXKL1NG8L1mdSrYheSoixDJcE4kt2p5o vx142Am9mxr64esezLfx3ALwRXjV9oEL+O4m6fqTsVObRvDViInb0rDwz4s6WWSURky8 COxvnUkGFHT36k/fPTpZjDcVZ9q9bsZjG0E7rBlDmxK2hUkJLdTTxTrxY+b0kekfckXu jNLA== 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; bh=9gcmaRozXFRZLn7B3nawsG88rV4E5dTb/854Uvshk7E=; b=NxmXlo4FnBeFWCDcmGEH9DfscXB0QWQlEBNTybod/8+6j2lD4+lf1IVPKq4jx7Cnxw 9sYT7c+9vHH3nHIiD5wJdoc354nw8xro7zG3/S1jf9AIduBRevRRCFKygRWC/x47HuPY gT4OhvQZxXEXUq36tv8haDEzujxYj2AA3oNq7FnDmJ1P+jauvp0JXS3GMtEh6DH9aOAN XOT8KEpnXAV5CQ3EjjbYqlidW9eUgXPKqMeKigFCAOC7db12sPeX3fBl094A5AzzoIJY PRTtwz3fAuykiYu9UGrZOWp6VEkUCicLxw7DWIy4/kiCtSb7kFYU6Lkqdp4m7Y92XT7U pV3A== X-Gm-Message-State: AIVw112qHurecZTa1pa1TP+SCwCRCZlm0O4kmCYhSS6CjCjjD72U1lbh v0OJMnBUst6ErWRb5xLGcDctss/UCw== X-Received: by 10.202.82.76 with SMTP id g73mr299516oib.315.1500580293616; Thu, 20 Jul 2017 12:51:33 -0700 (PDT) In-Reply-To: <87fue2rxm1.fsf@calancha-pc> 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:134797 Archived-At: --001a113d2cd85bce3f0554c513c1 Content-Type: multipart/alternative; boundary="001a113d2cd85bce3a0554c513bf" --001a113d2cd85bce3a0554c513bf Content-Type: text/plain; charset="UTF-8" Tino Calancha schrieb am Mi., 12. Juli 2017 um 08:16 Uhr: > Severity: wishlist > > Just wondering if the following is of any interest: > > (defun string-matched-text (regexp string num &optional start) > "" > (when (string-match regexp string start) > (match-string num string))) > > Then, > > (let ((str "foo-123")) > (when (string-match "[[:alpha:]]+-\\([0-9]+\\)" str) > (match-string 1 str))) > => "123" > > is equivalent to: > (string-matched-text "[[:alpha:]]+-\\([0-9]+\\)" "foo-123" 1) > => "123" > This looks useful, but I think it would be even better to add it as a pcase macro to be composable (see attached patch). --001a113d2cd85bce3a0554c513bf Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


Tino C= alancha <tino.calancha@gmail.= com> schrieb am Mi., 12. Juli 2017 um 08:16=C2=A0Uhr:
Severity: wishlist

Just wondering if the following is of any interest:

(defun string-matched-text (regexp string num &optional start)
=C2=A0 ""
=C2=A0 (when (string-match regexp string start)
=C2=A0 =C2=A0 (match-string num string)))

Then,

(let ((str "foo-123"))
=C2=A0 (when (string-match "[[:alpha:]]+-\\([0-9]+\\)" str)
=C2=A0 =C2=A0 (match-string 1 str)))
=3D> "123"

is equivalent to:
(string-matched-text "[[:alpha:]]+-\\([0-9]+\\)" "foo-123&qu= ot; 1)
=3D> "123"

This looks useful, but I think it would be= even better to add it as a pcase macro to be composable (see attached patc= h).=C2=A0
--001a113d2cd85bce3a0554c513bf-- --001a113d2cd85bce3f0554c513c1 Content-Type: text/plain; charset="US-ASCII"; name="0001-Add-rx-pattern-for-pcase.txt" Content-Disposition: attachment; filename="0001-Add-rx-pattern-for-pcase.txt" Content-Transfer-Encoding: base64 Content-ID: <15d618df26a31b9c1721> X-Attachment-Id: 15d618df26a31b9c1721 RnJvbSBiOTVmNzQ3Nzg4N2EyODMxMzRhMTkwMjFiOGQyMWVlNDY2ZDQ1N2MzIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBQaGlsaXBwIFN0ZXBoYW5pIDxwaHN0QGdvb2dsZS5jb20+CkRh dGU6IFRodSwgMjAgSnVsIDIwMTcgMjE6MzY6MTggKzAyMDAKU3ViamVjdDogW1BBVENIXSBBZGQg J3J4JyBwYXR0ZXJuIGZvciBwY2FzZS4KCiogbGlzcC9lbWFjcy1saXNwL3BjYXNlLmVsIChyeCk6 IE5ldyBwY2FzZSBtYWNyby4KKiB0ZXN0L2xpc3AvZW1hY3MtbGlzcC9wY2FzZS10ZXN0cy5lbCAo cGNhc2UtdGVzdHMtcngpOiBBZGQgdW5pdCB0ZXN0LgotLS0KIGV0Yy9ORVdTICAgICAgICAgICAg ICAgICAgICAgICAgICAgIHwgIDMgKysrCiBsaXNwL2VtYWNzLWxpc3AvcGNhc2UuZWwgICAgICAg ICAgICB8IDQ3ICsrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysKIHRlc3QvbGlz cC9lbWFjcy1saXNwL3BjYXNlLXRlc3RzLmVsIHwgIDkgKysrKysrKwogMyBmaWxlcyBjaGFuZ2Vk LCA1OSBpbnNlcnRpb25zKCspCgpkaWZmIC0tZ2l0IGEvZXRjL05FV1MgYi9ldGMvTkVXUwppbmRl eCA5NTRmZTBkNTQ3Li5hMTZkYjdmNGUwIDEwMDY0NAotLS0gYS9ldGMvTkVXUworKysgYi9ldGMv TkVXUwpAQCAtMTUyMSw2ICsxNTIxLDkgQEAgbWFudWFsLgogKiogJ3RjbC1hdXRvLWZpbGwtbW9k ZScgaXMgbm93IGRlY2xhcmVkIG9ic29sZXRlLiAgSXRzIG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GZyb20gMS4gIE11bHRpcGxlIG9j Y3VycmVuY2VzIG9mIHRoZSBzYW1lIFZBUiByZWZlciB0bwordGhlIHNhbWUgc3VibWF0Y2guIgor ICAobGV0KiAoKHZhcnMgKCkpCisgICAgICAgICAocngtY29uc3RpdHVlbnRzCisgICAgICAgICAg YCgobGV0ICwobGFtYmRhIChmb3JtKQorICAgICAgICAgICAgICAgICAgICAocngtY2hlY2sgZm9y bSkKKyAgICAgICAgICAgICAgICAgICAgKGxldCAoKHZhciAoY2FkciBmb3JtKSkpCisgICAgICAg ICAgICAgICAgICAgICAgKGNsLWNoZWNrLXR5cGUgdmFyIHN5bWJvbCkKKyAgICAgICAgICAgICAg ICAgICAgICAobGV0ICgoaSAob3IgKGNsLXBvc2l0aW9uIHZhciB2YXJzIDp0ZXN0ICMnZXEpCisg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChwcm9nMSAobGVuZ3RoIHZhcnMpCisg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKHNldHEgdmFycyBgKCxAdmFycyAs dmFyKSkpKSkpCisgICAgICAgICAgICAgICAgICAgICAgICAocngtZm9ybSBgKHN1Ym1hdGNoLW4g LCgxKyBpKSAsQChjZGRyIGZvcm0pKSkpKSkKKyAgICAgICAgICAgICAgICAgMSBuaWwpCisgICAg ICAgICAgICAoYmFja3JlZi12YXIgLChsYW1iZGEgKGZvcm0pCisgICAgICAgICAgICAgICAgICAg ICAgICAgICAgKHJ4LWNoZWNrIGZvcm0pCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgKHJ4 LWZvcm0KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYChiYWNrcmVmICwoMSsgKGNsLXBv c2l0aW9uIChjYWRyIGZvcm0pIHZhcnMKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgIDp0ZXN0ICMnZXEpKSkpKQorICAgICAgICAgICAgICAg ICAgICAgICAgIDEg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