[TxMt] Re: Python bundle syntax highlighting bug
Charilaos Skiadas
cskiadas at gmail.com
Wed Aug 15 01:50:19 UTC 2007
On Aug 14, 2007, at 9:09 PM, Alex Ross wrote:
>> To be honest, I don't really like this idea too much (in lieu of
>> having to use re.*(r" ... ") in order to get the regex highlight,
>> let's say).
>>
>> While adding a (?#) is "harmless" in terms of the parsing of the
>> actual code, changing your code to fit your text editor just
>> doesn't "feel" right. More tangibly, I think it's probably "the
>> wrong thing to do" if you're working on a project w/ other people
>> (especially if they're not fellow TextMate users). The code won't
>> break, but I could imagine that the extra line noise could tick
>> people off and add some bit-rot to your version control ...
>
> I agree that prefixing all re's is not ideal.
>
> So, we have five options:
>
> 1. Match all raw strings unambiguously as regular expressions. We
> will sometimes have false-positives.
>
> 2. Match raw strings that are arguments to methods from the re
> module. We will sometimes not match raw strings that are regular
> expressions, but can be pretty well guaranteed to never have a
> false-positive.
>
> 3. Require some prefix to a raw string to "turn on" regular
> expression matching. This has an extremely high probability of
> removing false-positives and false-negatives, but at the cost of
> additional CRUFT.
>
> 4. A combination of 2. and 3. Match raw strings that are arguments
> to re.compile and raw strings prefixed with (?#) as regular
> expressions, but no others.
>
> 5. Don't match re's at all.
>
> It would seem there is no perfect option. I propose that we put it
> to a vote, and perhaps appeal to our BDFL Allan.
I think option number 4 comes pretty darn close to perfect.
Then again, I don't write python, so my vote probably doesn't count
much ;). But option 4 guarantees that, for most uses, things will me
matched as expected, and for the other uses, there is a way to
document what needs to be done. It also avoids to a good extent the
bad case of having non-regexp raw strings colored as regexps.
> –Alex
Haris Skiadas
Department of Mathematics and Computer Science
Hanover College
More information about the textmate
mailing list