[TxMt] Augmenting grammars in the future (was: Design of Textmate)

Allan Odgaard throw-away-1 at macromates.com
Thu Apr 27 05:34:01 UTC 2006


On 26/4/2006, at 18:25, Plessl Christian wrote:

> [...] Is there a way to implement this in Textmate without either:  
> a) modifying all programming language modes with the new rule, or  
> b) creating new language bundles C (+fixme), Java (+fixme) etc.  
> that include the language definitions for C/Java and add the new  
> syntax highlighting rule?

There is not, no. But a solution will appear, and is conceptually  
rather simple IMO.

Currently the scope selector is disabled for language grammars, now  
imagine it wasn’t, and that selector decided where to inject the  
grammar!

That would allow to tear out the PHP, Ruby, and Smarty handling of  
the HTML grammar, and instead have that with the language. Likewise  
it allows the mentioned FIXME/TODO grammar to be in the TODO bundle,  
and be injected based on a scope selector -- disabling the TODO  
bundle would then disable this injection automatically.

There is a scope addition which will make this more powerful, namely  
exposing arbitrary file attributes in the scope (which scope  
selectors can then target), that way, the Java bundle can inject <%  
java %> support to HTML files only when the file type attribute is  
‘jsp’, and the Subversion bundle can inject the various svn keywords  
only when the SCM attribute is ‘svn’.

> Probably I should ask this question on the mailing list, should I?

I cc’ed the mailing list, seeing how others probably would enjoy  
reading my reply to this (though I think I have hinted at this  
earlier, maybe only on IRC).

I hope to have the file attributes exposed in the scope already in  
2.0 (this will then also allow all SCM bundles to use the same key  
equivalents), but grammar injection is probably at earlist 2.1 or so…  
the technical challenge isn’t that big, but I would also need to  
extend scope selectors to allow an injection to stop after a given  
depth, so to speak -- and I also need to only focus on one thing at a  
time, to actually get anything done :)

Kind regars Allan




More information about the textmate mailing list