emacs-devel
[Top][All Lists]
Advanced

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

Re: Unquoted special characters in regexps


From: Richard Stallman
Subject: Re: Unquoted special characters in regexps
Date: Wed, 01 Mar 2006 12:54:49 -0500

    `]', like `-' are only special in the context of a character
    alternative, that is if, before you type them, you are in a character
    alternative.   By contrast, `['  and all other special characters
    (except `^') are  only special outside that context.

You're interpreting the term "context" the same way the regexp
compiler does: meaning the preceding characters of the regexp.  The
regexp compiler works from left to right.  However, to a person, the
context of a character set, or any sub-regexp, is found on both sides
of it.  Understood in this way, the role of a character set's closing
] is dual to that of the opening [; both of them delimit the character
set.  Both characters play special roles in the syntax of regexps, and
these roles are not internal to a character set.

    First of all, there are (surprisingly) many occurrences of "\\]" in
    the Emacs source, where the `]' _is_ special and closes a character
    alternative that contains a slash.

That is a good point.  We don't want people to get confused about that.

So I think we should not encourage the quoting of ], but we need to be
careful about how to explain this.  I will write it.

Meanwhile, please do install your search.c patch.




reply via email to

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