emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: rx.el sexp regexp syntax


From: Stefan Monnier
Subject: Re: rx.el sexp regexp syntax
Date: Sun, 27 May 2018 16:16:47 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]