Hi Haris and everybody else,
I split up my different questions into different emails.
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?
Thanks.
Holger
__ Eidgenössische Technische Hochschule Zürich (ETH Zürich) Department of Materials Wolfgang-Pauli-Str. 10, HCI H515 CH-8093 Zürich Switzerland
Phone: (+41) 1 633 6474 Fax: (+41) 1 633 1390 Email: frauenrath@mat.ethz.ch Web: http://www.polychem.mat.ethz.ch/frauenrath/
On Dec 22, 2006, at 10:34 AM, Holger Frauenrath wrote:
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
On Dec 22, 2006, at 1:48 PM, Charilaos Skiadas wrote:
Fine, thanks. So, I created a new language "LaTeX HF" which included
firstLineMatch = '^\documentclass(?!.*{beamer})'; fileTypes = ( 'tex' );
followed by my changes, and a rule include = 'text.tex.latex'. In terms of syntax coloring the LaTeX source, this method does all what I want it to. Cool. However, I have two related technical questions.
1. What are possible ways to make this file take precedence over the original LaTeX language file? So far, I have changed it manually in the language selection at the bottom of the editor window. Is there an automatic way? I guess that I could also remove the above to lines from the original LaTeX language file ... but if I am not mistaken, these changes would mean that future updates to the LaTeX file will be ignored. Is that correct?
2. Which brought up another question for me. Let's assume I made changes to one of the supplied language files. Is there a way to "revert" those changes so that the language file is *for sure* the original one (so that updates are not going to be ignored), without loosing other changes (new cammands etc.) to the associated bundle?
Thanks Holger
On Dec 22, 2006, at 7:01 PM, Holger Frauenrath wrote:
When you manually set the language for a file with a particular extension, TextMate remembers that setting for all files with that extension. So once you set it to your language, you shouldn't have to worry about it again.
The changes are saved in ~/Library/Application Support/TextMate/ Bundles/Latex.tmbundle/...
Just find the corresponding file there, for the particular command you want to revert, and remove it.
Thanks Holger
Haris
On Dec 23, 2006, at 7:49 AM, Holger Frauenrath wrote:
Aaaah. Using "Show package contents" on the LaTex bundle ...
Well, I would use the terminal and the "cd" command there to navigate to the correct level, and then "rm filename" to remove it.
For the terminal, these bundles are just regular folders, so it is easier to navigate in them.
Haris