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: Eric Abrahamsen
Subject: Re: rx.el sexp regexp syntax
Date: Fri, 25 May 2018 11:01:50 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Pierre Neidhardt <address@hidden> writes:

> Alan Mackenzie <address@hidden> writes:
>
>>> 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.
>>
>> Much easier than what?  Than the putative mini-language that doesn't get
>> written?
>
> I meant that in my opinion rx is easier to write than regexps.  That it
> is not popular is the root of the question here.

Slightly off-topic: I wouldn't ever use rx unless I was writing a really
brutal regexp, but what I *would* use all day long would be a macro that
un-escaped backslashes for me. Ideally:

(string-match (rx-unescape "turn (left|right)") "turn right") => 0

But even this would be an improvement:

(string-match (rx-unescape "turn \(left\|right\)") "turn right") => 0

I looked in the repos, but didn't see any packages that do this.

As an aside, this thread led me to find the rx pcase matcher, something
I'd daydreamed about before, so I'm already pretty happy :)

Eric




reply via email to

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