[Top][All Lists]

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

RE: [External] : Re: Ugly regexps

From: Drew Adams
Subject: RE: [External] : Re: Ugly regexps
Date: Wed, 3 Mar 2021 22:17:52 +0000

> >> for a lot of people this won't be +1 thing to learn.
> >
> > See my previous message.  It _will_ be a +1 to learn,
> > in the context of Emacs, if people have to also learn
> > the Elisp syntax anyway, for interactive use.

sk> We could add an option to prefer ERE in interactive use.

Sure, if it were supported generally.

sm> WRT interactive regexp syntax, I'm still hoping someone will write
sm> a proper package that lets the user choose which regexp syntax to use.
sm> Currently `re-builder` has such a thing, but it should really apply
sm> "across the board", i.e. in `read-regexp`, in Isearch, and anywhere
sm> else we read regexps from the keyboard.

Sure, worth hoping.

And then have an option to express one's preference.

Or several options?  Depending on what's implemented,
maybe someone will prefer one thing for, say, Isearch
query-replace*, and completion, and another thing for
some other interactive uses?

[But since Emacs (not so wisely, IMO) forbids commands
from binding options, code couldn't just bind such a
variable when calling `read-regexp'.  `read-regexp'
could accept another arg for this, of course, but then
that too could, in a sense, override a user preference.]
> This is largely orthogonal to what we use in ELisp code.

In one sense, sure.  And especially if we're now talking
only about different regexp dialects, and not also about
alternative ways, such as RX, to enter/create a regexp.

But as I mentioned, I don't think it's orthogonal, in
practice, to what people actually use when coding Elisp.

I think they often code based on what they're used to
using, which, at least for now, is mostly the interactive
syntax (modulo backslashing, etc. for Elisp).  Use of
something like RX seems to be less common, so far.

And then there's the question, interactively, of choosing
one or another.

Often you use a very simple regexp for searching or
completion matching - even just a substring (no special
chars).  Less often you need a more complex regexp.

Will someone want to use something like RX for simple
patterns too?  Would going through some kind of
interactive RX dialog be cumbersome for something simple?
We'd want to make sure that any dialog to be defined
keeps the simple simple.  `(rx "abc")' is simple enough -
it should be possible to type just `abc', like we do now.  

(At least among regexp dialects, as opposed to something
like RX, use of simple-vs-complex patterns shouldn't make
any difference, from one dialect to another.)

BTW, I see this in (emacs) `Rx Notation':

  The ‘rx’ notation is mainly useful in Lisp code; it
  cannot be used in most interactive situations where
  a regexp is requested, such as when running
  ‘query-replace-regexp’ or in variable customization.

I guess that's just saying that an RX-based dialog isn't
available yet, not that it's inconceivable or couldn't
be useful.

reply via email to

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