[TxMt] Question regarding scoping

Allan Odgaard throw-away-1 at macromates.com
Mon Oct 23 19:46:28 UTC 2006

On 22. Oct 2006, at 22:45, Branko wrote:

> I'm doing some HTML coding and need to add JavaScript using the  
> Prototype framework. In this early develpment phase I like to write  
> JavaScript embedded in HTML. When I write a script tag,  
> "source.js.embedded.html" gets added to the scope. How can I tell  
> TextMate to use features from the Prototype & Scriptaculous bundle  
> in addition to the JavaScript default one? Shifting languages is  
> tedious and messes up the highlighting.

If you select Bundles → Bundle Editor → Edit Languages… you get  
the ability to unfold the HTML bundle and edit its language definition.

There is an include for source.js somewhere there. You can change  
that to source.js.prototype instead, to have it include the Prototype  
JS grammar.

Caution: by editing the HTML grammar, you won’t see future updates  
to it, since you basically fork it. You can later revert to the  
default grammars [1]. Another approach is 1) duplicate the HTML  
grammar before editing, change the scopeName (near the top) to e.g.  
text.html.prototype, and use that for your HTML files, or 2) create a  
new grammar which has just the <script> rule and includes  
source.js.prototype and then includes text.html.basic. That way your  
subclasses grammar will see changes done to the default HTML grammar,  
as it just includes it (rather than duplicates and edits).

For more info see http://macromates.com/textmate/manual/ 

[1] http://macromates.com/wiki/Troubleshooting/RevertToDefaultBundles

More information about the textmate mailing list