I'm new to textmate, so...
I was trying to figure out why the syntax highlighting in perl sucked so much, when I realized it was getting messed up by some regex code.
Paste this into file (e.g. test.pl) and view in textmate. Does the 2nd function hilight correctly? It is the /\/ regex I think - comment the first one out and watch the hilighting change.
sub fn() { # some perl code my $f = shift; if( $f =~ /\/ ) { my $var = "Hello"; } }
sub fn2() { # some perl code my $f = shift; if( $f =~ /\/ ) { my $var = "Hello"; } }
Thoughts? I am using textmate Version 1.5.10 (1631)
thanks -thomas
On 8 Nov 2011, at 20:38, Thomas Blom wrote:
I was trying to figure out why the syntax highlighting in perl sucked so much, when I realized it was getting messed up by some regex code.
Paste this into file (e.g. test.pl) and view in textmate. Does the 2nd function hilight correctly? It is the /\/ regex I think - comment the first one out and watch the hilighting change.
sub fn() { # some perl code my $f = shift; if( $f =~ /\/ ) { my $var = "Hello"; } }
sub fn2() { # some perl code my $f = shift; if( $f =~ /\/ ) { my $var = "Hello"; } }
Hi Thomas,
syntax highlighting for Perl is not so easy but in that case you can fix the highlighting if you simply make usage of the "standard" syntax in the if clauses:
... my $f = shift; if( $f =~ m/\/ ) { ....
write m// instead of // .
Cheers, --Hans
Thankyou! I didn't mean to denigrate textmate, but had been wondering why things didn't look as nice as I thought they should, when I realized the regex was causing problems!
Thanks again. -thomas
On Tue, Nov 8, 2011 at 1:57 PM, Hans-Jörg Bibiko bibiko@eva.mpg.de wrote:
On 8 Nov 2011, at 20:38, Thomas Blom wrote:
I was trying to figure out why the syntax highlighting in perl sucked so
much, when I realized it was getting messed up by some regex code.
Paste this into file (e.g. test.pl) and view in textmate. Does the 2nd
function hilight correctly? It is the /\/ regex I think - comment the first one out and watch the hilighting change.
sub fn() { # some perl code my $f = shift; if( $f =~ /\/ ) { my $var = "Hello"; } }
sub fn2() { # some perl code my $f = shift; if( $f =~ /\/ ) { my $var = "Hello"; } }
Hi Thomas,
syntax highlighting for Perl is not so easy but in that case you can fix the highlighting if you simply make usage of the "standard" syntax in the if clauses:
... my $f = shift; if( $f =~ m/\\/ ) { ....
write m// instead of // .
Cheers, --Hans
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
On Tue, Nov 8, 2011 at 21:01, Thomas Blom blomcode@gmail.com wrote:
Thankyou! I didn't mean to denigrate textmate, but had been wondering why things didn't look as nice as I thought they should, when I realized the regex was causing problems!
So the problem is that the grammar doesn't recognize the "simple" regexp in your example and tries to match it as an extended regexp instead (i.e. /\/x works).
This means that the problematic pattern in the grammar is 'string.regexp.find.perl', which is defined as:
(?<!\)((~\s*)?/)(\S.*?)(?<!\)(\{2})*(/)
specifically, the third group `(\S.*?)` which unconditionally eats the first backslash, which prevents the negative look-behind `(?<!\)` from matching (there are backslashes everywhere!) until the closing slash gets eaten.
We could fix this case by changing the pattern to
(?<!\)((~\s*)?/)(.*?)(?<!\)(\{2})*(/)
but I don't know which edge cases we'd introduce by allowing whitespace after the opening slash.
Cheers, Martin
On Nov 8, 2011, at 1:38 PM, Thomas Blom wrote:
I was trying to figure out why the syntax highlighting in perl sucked so much, when I realized it was getting messed up by some regex code.
Paste this into file (e.g. test.pl) and view in textmate. Does the 2nd function hilight correctly? It is the /\/ regex I think - comment the first one out and watch the hilighting change.
I've pushed a patch that fixes this.