can anyone tell me why the perl bundle treats the letter 's' oddly when it is used as a hash index? for example the statements
$OPT{w} = 'a'; $OPT{s} = 'a';
are highlighted differently. what's up?
tia, tom
On 4 Jun 2008, at 19:26, bin@cox.net wrote:
can anyone tell me why the perl bundle treats the letter 's' oddly when it is used as a hash index? for example the statements
$OPT{w} = 'a'; $OPT{s} = 'a';
are highlighted differently. what's up?
Oh yeah. Heh. I wonder if it's getting confused by a rule somewhere that's supposed to handle s///.
i'm new to textmate so i know nothing. if i had the slightest idea of how to fix the highlighting, i would.
tom
Here a hack I've just tried and it seems to work (though don't be surprised if colouring falls over elsewhere!)
1. Bring up Bundle Editor -> Edit Languages -> Perl
2. Copy the bareword grammar (pasted below) so that it gets higher precedence than regex.replace thats causing the problem (see my other email)
{ name = 'constant.other.bareword.perl'; match = '(?<={)\s*\w+\s*(?=})'; },
Here whats the top of my Perl syntax grammar now looks like....
{ scopeName = 'source.perl'; comment = ' TODO: Include RegExp syntax '; firstLineMatch = '^#!.*\bperl\b'; fileTypes = ( 'pl', 'pm', 'pod', 't', 'PL' ); foldingStartMarker = '(/*|({|[|()\s*$)'; foldingStopMarker = '(*/|^\s*(}|]|)))'; patterns = ( { include = '#line_comment'; }, { name = 'constant.other.bareword.perl'; match = '(?<={)\s*\w+\s*(?=})'; }, { name = 'comment.block.documentation.perl'; begin = '^='; end = '^=cut'; captures = { 0 = { name = 'punctuation.definition.comment.perl'; }; }; },
BTW... that TODO: was already in there ;-)
PS. For more info on syntax grammar click on the ? button on the this bundles editor page.
bin@cox.net wrote:
i'm new to textmate so i know nothing. if i had the slightest idea of how to fix the highlighting, i would.
tom
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
Andy Armstrong wrote:
On 4 Jun 2008, at 19:26, bin@cox.net wrote:
can anyone tell me why the perl bundle treats the letter 's' oddly when it is used as a hash index? for example the statements
$OPT{w} = 'a'; $OPT{s} = 'a';
are highlighted differently. what's up?
Oh yeah. Heh. I wonder if it's getting confused by a rule somewhere that's supposed to handle s///.
It certainly is s/// causing the confusion ;-( Strangely tr/// doesn't ;-)
Have a look a colour syntax on these different lines....
$OPT{ s } = 'a'; # => ok $OPT{'s'} = 'a'; # => ok $OPT{tr} = 'a'; # => ok! s/from/to/; # => ok s{from}{to}; # => ok tr/A/B/; # => ok tr{A}{B}; # => Nope!
The grammar regex below is being incorrectly used in the $OPT{s} example....
{ comment = 'string.regexp.replace.perl'; begin = '\b(?=(s)(\s+\S|\s*[;,#{}()[<]|$))'; end = '((([egimosx]*)))(?=(\s+\S|\s*[;,#{})]>]|$))'; endCaptures = { 1 = { name = 'linomuck.regexp.replace.perl'; }; 2 = { name = 'punctuation.definition.linomuck.perl'; }; 3 = { name = 'keyword.control.regexp-option.perl'; }; }; ==snip==
Grrrr.... first time I've looked at this grammar file so not sure what "best" fix is?
-- /I3az/
LOL... ignore that lilomuck bit! Thats me just playing around with grammar file in Textmate to make it easier for me to spot how it all worked!
This is the correct lines in question.....
{ comment = 'string.regexp.replace.perl'; begin = '\b(?=(s)(\s+\S|\s*[;,#{}()[<]|$))'; end = '((([egimosx]*)))(?=(\s+\S|\s*[;,#{})]>]|$))'; endCaptures = { 1 = { name = 'string.regexp.replace.perl'; }; 2 = { name = 'punctuation.definition.string.perl'; }; 3 = { name = 'keyword.control.regexp-option.perl'; }; };
Now what context this bit of grammar is really for I don't know. From what I can see the other examples I gave don't use above.
Perhaps the original author of this grammar can shed light on this and make the proper changes.
-- /I3az/
Barry Walsh wrote:
Andy Armstrong wrote:
On 4 Jun 2008, at 19:26, bin@cox.net wrote:
can anyone tell me why the perl bundle treats the letter 's' oddly when it is used as a hash index? for example the statements
$OPT{w} = 'a'; $OPT{s} = 'a';
are highlighted differently. what's up?
Oh yeah. Heh. I wonder if it's getting confused by a rule somewhere that's supposed to handle s///.
It certainly is s/// causing the confusion ;-( Strangely tr/// doesn't ;-) Have a look a colour syntax on these different lines....
$OPT{ s } = 'a'; # => ok $OPT{'s'} = 'a'; # => ok $OPT{tr} = 'a'; # => ok! s/from/to/; # => ok s{from}{to}; # => ok tr/A/B/; # => ok tr{A}{B}; # => Nope!
The grammar regex below is being incorrectly used in the $OPT{s} example....
{ comment = 'string.regexp.replace.perl'; begin = '\b(?=(s)(\s+\S|\s*[;\,\#\{\}\(\)\[<]|$))'; end = '((([egimosx]*)))(?=(\s+\S|\s*[;\,\#\{\}\)\]>]|$))'; endCaptures = { 1 = { name = 'linomuck.regexp.replace.perl'; }; 2 = { name = 'punctuation.definition.linomuck.perl'; }; 3 = { name = 'keyword.control.regexp-option.perl'; }; }; ==snip==
Grrrr.... first time I've looked at this grammar file so not sure what "best" fix is?
-- /I3az/
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate