[TxMt] How to make variables take precedence over an included language? [Was: naming embedded (included) scopes ?]

Allan Odgaard throw-away-1 at macromates.com
Mon Apr 10 04:52:39 UTC 2006


On 10/4/2006, at 1:02, Dirk van Oosterbosch, IR labs wrote:

> [...]
> I have my bundle recognize cheetah placeholders (or 'variables'),  
> which look like this: $placeholder or $placeholder.argument. But  
> when I also have { include = 'text.html.basic'; } in my patterns  
> the placeholders which are inside html tags (e.g. as arguments or  
> values), are no longer recognized and become just  
> 'string.quotes.double.html'. The text outside html tags stays  
> unaffected, and thus placeholder.

Yes -- the rules you declare are at the root level. So when the  
(included) HTML grammar starts a sub-context, your rules will not be  
applied.

A better approach would be to duplicate the existing HTML grammar and  
locate the “ embedded-code” rule. Here add another rule to include  
cheetah. The HTML grammar re-uses this “embedded-code” rule in most  
of the contexts where embedded code makes sense.

You will then have to select this (duplicated and modified) HTML  
grammar for your cheetah files, instead of selecting cheetah.


Long term I plan to do something akin to activate the scope selector  
text field for language grammars (and allow UTI’s/file types to be  
targeted by scope selectors). Then one would be able to set a scope  
selector for a language grammar, which would basically be where this  
grammar should be “injected” (which could be in multiple places/for  
different file types.) But this is post 2.0, so for now one is stuck  
with just editing the language grammar in which the injection should  
take place.




More information about the textmate mailing list