[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Scan of regexps in Emacs (March 17)
From: |
Stefan Monnier |
Subject: |
Re: Scan of regexps in Emacs (March 17) |
Date: |
Tue, 19 Mar 2019 22:20:53 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
> I also fixed a couple of other problems if I happened to run across
> them. First, the regexp [a-b-c] is ambiguous according to POSIX,
Maybe according to POSIX, but not according to Emacs Lisp's reference
manual:
To include a ‘]’ in a character alternative, you must make it the
first character. For example, ‘[]a]’ matches ‘]’ or ‘a’. To
include a ‘-’, write ‘-’ as the first or last character of the
character alternative, or put it after a range. Thus, ‘[]-]’
matches both ‘]’ and ‘-’. (As explained below, you cannot use ‘\]’
to include a ‘]’ inside a character alternative, since ‘\’ is not
special there.)
> and should be avoided.
Maybe I could go along with that.
[ I wish Elisp regexps just used \ as an escape char in ranges instead
of relying on those special convention of where `-` and `]` can appear
in order to count as themselves. ]
> Second, a regexp like [[:alnum:]-z] is also ambiguous for the
> same reason.
I think the doc above was written for we had those char classes, but if
[a-b-c] is not ambiguous then I think it's only natural to declare that
[[:alnum:]-z] is not ambiguous either.
> Perhaps these regexps currently have a particular behavior in
> Emacs but it's not documented as far as I know and code should avoid
> them. Perhaps the trawler could be modified to catch them.
I wonder why the doc doesn't just say that `-` should be the last
character and not mention the other possibilities which just make the
rule unnecessarily complex.
Stefan
- Scan of regexps in Emacs (March 17), Mattias Engdegård, 2019/03/17
- Re: Scan of regexps in Emacs (March 17), Paul Eggert, 2019/03/18
- Re: Scan of regexps in Emacs (March 17), Mattias Engdegård, 2019/03/19
- Re: Scan of regexps in Emacs (March 17), Paul Eggert, 2019/03/19
- Re: Scan of regexps in Emacs (March 17),
Stefan Monnier <=
- Re: Scan of regexps in Emacs (March 17), Paul Eggert, 2019/03/20
- RE: Scan of regexps in Emacs (March 17), Drew Adams, 2019/03/20
- Re: Scan of regexps in Emacs (March 17), Paul Eggert, 2019/03/20
- Re: Scan of regexps in Emacs (March 17), Eli Zaretskii, 2019/03/20
- RE: Scan of regexps in Emacs (March 17), Drew Adams, 2019/03/21
- Re: Scan of regexps in Emacs (March 17), Eli Zaretskii, 2019/03/21
- Re: Scan of regexps in Emacs (March 17), Stefan Monnier, 2019/03/20
- Re: Scan of regexps in Emacs (March 17), Mattias Engdegård, 2019/03/21
- Re: Scan of regexps in Emacs (March 17), Richard Stallman, 2019/03/20
- Re: Scan of regexps in Emacs (March 17), Stephen Leake, 2019/03/22