Subject: Re: bug#31953: [VanL] Re: bug#31953: feature request - `highlight-rx` interactively

From: Juri Linkov <[email-masked]>
Date: Sun, 20 Oct 2019 18:49:39 +0300

>> I think the idea is to be able to *interactively* enter rx syntax
>> and have it highlighted (as opposed to `highlight-regexp' which will
>> obviously treat what you enter interactively as an actual regexp,
>> rather than something to be transformed into one).
>>
>> i.e. These would be equivalent:
>>
>> M-x highlight-rx RET (or "foo" "bar") RET
>> M-x highlight-regexp RET \(foo\|bar\) RET
>
> What I can tell from the emacs-devel list and the git log is the rx
> feature is being worked on.  I'd like to use rx everywhere regexp occurs
> and highlight-rx would be the first easy use case.

Do you mean using rx also in all search and replace commands?

But the documentation says:

     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 customisation.

> At the limit there are things expressible in regexp that rx won't be
> able to.  And, in that case, I'd like to see in the rx documentation
> a sign post to regexp at depth for that.  And, if there are patterns
> rx and/or regexp are unable to express then providing a see also for
> those would be a help.

There is still some shortcomings in the current rx shorthands:

Such verbose constructs as ‘zero-or-more’ and ‘one-or-more’
are hard to remember and too long to type.  But fortunately
there are shorter synonyms ‘*’ and ‘+’ and other.  But they have
inconsistencies:

- ‘or’ has a synonym ‘|’, but ‘and’ has no synonym ‘&’

- ‘A{N}’ is the same as ‘=’, ‘A{N,}’ is ‘>=’, but ‘A{N,M}’ for some
  reason is ‘**’.  It would be more mnemonic something like ‘==’

- ‘line-start’ and ‘line-end’ have no shorter synonyms ‘^’ and ‘$’
  maybe because adding them would also require adding ‘\`’ and ‘\'’
  for ‘buffer-start’ and ‘buffer-end’, but ‘\`’ and ‘\'’ are very ugly.
  Fortunately there are already good synonyms ‘bol’ and ‘eol’
  that are easy to remember

- there is still problem with ‘buffer-start’ and ‘buffer-end’:
  their shorter synonyms are ‘bot’ and ‘eot’ that have no logic at all.
  Like there are already functions ‘bolp’, ‘eolp’, ‘bobp’ and ‘eobp’
  the best synonyms for buffer matches would be ‘bob’ and ‘eob’

- following the same logic ‘word-start’ could have a synonym ‘bow’
  and ‘word-end’ - ‘eow’.  I checked the implementation, and see
  there synonyms already are supported, but not documented.  Why?