From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: rx.el sexp regexp syntax Date: Sun, 27 May 2018 16:16:47 -0400 Message-ID: References: <87h8mw3yoc.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1527452143 21210 195.159.176.226 (27 May 2018 20:15:43 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 27 May 2018 20:15:43 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun May 27 22:15:39 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 1fN24o-0005Q1-90 for ged-emacs-devel@m.gmane.org; Sun, 27 May 2018 22:15:38 +0200 Original-Received: from localhost ([::1]:53139 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fN26v-0001y9-3l for ged-emacs-devel@m.gmane.org; Sun, 27 May 2018 16:17:49 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54509) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fN26A-0001xy-0C for emacs-devel@gnu.org; Sun, 27 May 2018 16:17:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fN265-0000iT-1D for emacs-devel@gnu.org; Sun, 27 May 2018 16:17:01 -0400 Original-Received: from [195.159.176.226] (port=48970 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fN264-0000hy-Pe for emacs-devel@gnu.org; Sun, 27 May 2018 16:16:56 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1fN23v-0004Qa-BR for emacs-devel@gnu.org; Sun, 27 May 2018 22:14:43 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 24 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:In0NMFj8MXdCnm4nzdKiBHs9YXU= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 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:225769 Archived-At: > rx.el is one of the best concepts I've discovered in a long time. > It's another instance of "Don't come up with a new (mini)language when > Lisp can do better": it's easier to learn, more flexible, easier to > write, much easier to read and as a consequence much more maintainable. FWIW, I find it's cumbersome in RX to define regexps piecewise. E.g. with strings I can do things like: (let* ((word-re "\\(?:\\sw\\|s_\\)+") (spc-re "[ \t\n]*") (re1 (concat spc-re "\\(" word-re "\\)" spc-re)) (re2 (concat spc-re "\\(" word-re "\\)(" word-re)))) but do the same with RX you need something like: (let* ((word-re (rx ...)) (spc-re (rx ...)) (re1 (rx-to-string `(... ,spc-re ... ,word-re ...))) (re2 (rx-to-string `(... ,spc-re ... ,word-re ...)))) I think `rx` would benefit from allowing to refer to variables. Stefan