[TxMt] How to include private additions to syntax coloring?

Charilaos Skiadas skiadas at hanover.edu
Fri Dec 22 12:48:28 UTC 2006


On Dec 22, 2006, at 10:34 AM, Holger Frauenrath wrote:

> Sorry for choosing a potentially confusing example. What I meant to  
> say is that I have a custom command for including schemes and  
> figures: \includescheme{scale}{name}{caption} which inserts a  
> centered figure environment, inserts file <name> at scale <scale>,  
> creates a label <name>, and inserts the caption <caption>. So, it  
> is not targeted by the scope mechanism ... But this just served as  
> a specific example.
>
> My question was more general. In case I have a custom LaTeX command  
> (any command) that I want to have a syntax colored, i.e., or in  
> case I want to change an existing syntax color behavior, *what is  
> the best way to do it*?
>
> I just don't understand yet how to do it so that it does not break  
> forward compatibility. I assume, it would be best to put my own  
> private additions/changes to the syntax coloring into a separate  
> language file, e.g. "LaTeX HF", instead of just writing them into  
> the "LaTeX" language file itself. Is that correct? But, then, how  
> do I either call/include it from the LaTeX file or vice versa? How  
> do I set up such a separate file for my private additions?

For most changes you want to do, including the one described above,  
you should simply create a new language, and in its patterns add the  
rules you want and finish by adding a rule that does: include =  
'text.tex.latex'. See http://macromates.com/textmate/manual/ 
language_grammars#language_grammars for details. But the reason I was  
asking you for what particular changes you want to do is that this  
method should allow most changes you might want, but perhaps not all  
of them. It is certainly the most forward compatible method.

The language changes alter the scope of elements. You can see the  
scope at a given location via ctrl-shift-P. You can read more about  
scopes here: http://macromates.com/textmate/manual/ 
scope_selectors#scope_selectors
If you want to change the color that commands at a particular scope  
are shown as, that's where you would want to edit a theme. Since I  
don't know which of these two different settings the phrase "syntax  
coloring" refers to, I mention them both.

> Thanks.
>
> Holger

Haris





More information about the textmate mailing list