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: martin rudalics
Subject: Re: Unquoted special characters in regexps
Date: Thu, 02 Mar 2006 19:40:08 +0100
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

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

There are very few expressions where `\\' does have to precede a right
bracket, `[^\\]', `[]\\]', and `[^]\\]' come to mind.  I any other case
people may avoid confusion by moving the backslash in front of another
character.

In current Emacs code there are some 100 occurrencs where programmers
were able to convey the intention that they indeed wanted to match a
right bracket by writing `\\]'.  Simultaneously, programmers were able
to express that they did _not_ want a character alternative to end here.
Your change will make it difficult if not impossible to express such
intentions.

And, your change is motivated by the pessimistic assumption that people
frequently submit code with buggy regexps.  Even if that were the case
your change would hardly help.  Consider the following expression from
`gud-jdb-marker-filter':

         "\\(\[[0-9]+\] \\)*\\([a-zA-Z0-9.$_]+\\)\\.[a-zA-Z0-9$_<>(),]+ \
\\(([a-zA-Z0-9.$_]+:\\|line=\\)\\([0-9.,]+\\)"

Experience tells me that this should be probably written as

         "\\(\\[[0-9]+\\] \\)*\\([a-zA-Z0-9.$_]+\\)\\.[a-zA-Z0-9$_<>(),]+ \
\\(([a-zA-Z0-9.$_]+:\\|line=\\)\\([0-9.,]+\\)"

but I'm not quite sure since `gud.el' is one of the few Emacs files that
do not consistently use `\\]' to match a right bracket.






reply via email to

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