A while ago there was a post about LaTeX syntax highlighting in the case of
\newcolumntype{R}{>{$}r<{$}}
where the math mode highlighting would leak outside the brackets. Apparently this is now highlighted correctly in the stable version of TextMate. Quoting from the original thread:
Should more complicated examples ever arise, I guess I can just put the problematic lines into a separate file and use \input.
Or just let us know, and we'll try to fix it ;)
Haris
Well, if you're asking for it, Haris, I'm frequently using constructs like this one:
\newcolumntype{q}{>{$\rm}l<{$}}
which, unfortunately breaks the highlighting. My current workaround is this:
\newcommand{\eat}[1]{} \newcolumntype{q}{>{$\rm\eat$}l<{$}}
But then again, this breaks syntax highlighting for another editor, which I'm using on a Linux system.
Any ideas?
cheers Hendrik
I had a similar problem a while ago, and I fixed it by editing the 'TeX' language definition, changing the end delimeter of string.other.math.tex as follows:
… { name = 'string.other.math.tex'; begin = '$'; end = '}|$'; …
It has worked without trouble for me. Since other people are having similar problems, perhaps this change should be applied.
Robin
On Apr 25, 2007, at 6:45 AM, Robin Houston wrote:
I had a similar problem a while ago, and I fixed it by editing the 'TeX' language definition, changing the end delimeter of string.other.math.tex as follows:
… { name = 'string.other.math.tex '; begin = '\$'; end = '\}|\$'; …
It has worked without trouble for me. Since other people are having similar problems, perhaps this change should be applied.
The problem with that is that it makes code like $foo} valid, so makes it harder occasionally to detect problems with runaway braces (hm, or perhaps it makes it more easy). It just feels wrong though to make this change on that general level. I think we need a particular rule that handles the \newcolumntype command, and perhaps tabular environments in general, and I guess perhaps simply makes $ into a regular character in there.
Robin
Haris Skiadas Department of Mathematics and Computer Science Hanover College
On 4/25/07, Charilaos Skiadas skiadas@hanover.edu wrote:
The problem with that is that it makes code like $foo} valid, so
I see what you mean (about making it harder to detect problems with braces), but on the other hand $foo} *is* potentially valid code.
For example, here is the definition that originally prompted me to make the change:
%% Centred math environment, spilling into the margins if needed \newenvironment{mspill}{% \vskip\abovedisplayskip\hbox to \textwidth\bgroup\hss% \hbox\bgroup$\displaystyle }{%
$\egroup\hss\egroup\vskip\belowdisplayskip\noindent\ignorespacesafterend }
Robin
god almighty; latex is such a gigantic hack, isn't it?
On Apr 25, 2007, at 7:38 AM, Robin Houston wrote:
On 4/25/07, Charilaos Skiadas skiadas@hanover.edu wrote: The problem with that is that it makes code like $foo} valid, so
I see what you mean (about making it harder to detect problems with braces), but on the other hand $foo} *is* potentially valid code.
For example, here is the definition that originally prompted me to make the change:
%% Centred math environment, spilling into the margins if needed \newenvironment{mspill}{% \vskip\abovedisplayskip\hbox to \textwidth\bgroup\hss% \hbox\bgroup$\displaystyle }{% $\egroup\hss\egroup\vskip\belowdisplayskip\noindent \ignorespacesafterend }
Robin
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
On 25/04/07, Alex Ross alex.j.ross@gmail.com wrote:
god almighty; latex is such a gigantic hack, isn't it?
On that view, I think that syntax highlighting for code such as LaTeX will never be perfect. You can assign arbitrary meanings to commands, and the semantics of those commands will never be picked up by a syntax highlighter.
There's one issue with Robin's solution though: doesn't this break the 'Select Enclosing Brackets' function?
(Cannot test this at the moment; not on a Mac right now.)
cheers Hendrik
On 4/25/07, Hendrik Fuß hendrik.fuss@gmail.com wrote:
There's one issue with Robin's solution though: doesn't this break the 'Select Enclosing Brackets' function?
I'm not quite sure what you mean, but it doesn't seem to.
Robin
On 25/04/07, Robin Houston robin.houston@gmail.com wrote:
On 4/25/07, Hendrik Fuß hendrik.fuss@gmail.com wrote:
There's one issue with Robin's solution though: doesn't this break the 'Select Enclosing Brackets' function?
I'm not quite sure what you mean, but it doesn't seem to.
Okay, I am unable to test this at the moment, but: In the expression {$foo} doesn't TextMate take the } as the closing brace for $? That would mean that there is still one unmatched opening brace {.
Simple test case:
{ \newcolumntype{f}{>{$\rm}l<{$}} }
If you positioned the cursor at the end of the second line and choose "Select enclosing braces", what would you get? I may not fully understand TextMate's brace matching works, but I would expect this to fail.
Hendrik
On 4/25/07, Hendrik Fuß hendrik.fuss@gmail.com wrote:
Okay, I am unable to test this at the moment, but: In the expression {$foo} doesn't TextMate take the } as the closing brace for $? That would mean that there is still one unmatched opening brace {.
I see what you mean. Yes, that is a problem: see below for a fix. The reason you confused me is that this doesn't affect "Select Enclosing Brackets", which I don't think uses the scope information at all. Indeed, "Select Enclosing Brackets" works perfectly as expected in all the cases I've tested, including the one you just posted.
You *can* see the problem by typing
{$foo}
positioning the cursor after it, and pressing control-shift-P. This shows that the brace group is still in effect. The fix is to use a lookahead:
… { name = 'string.other.math.tex'; begin = '$'; end = '(?=})|$'; …
Thanks for pointing this out.
Robin
Alex Ross <alex.j.ross@...> writes:
god almighty; latex is such a gigantic hack, isn't it?
If you think *that* is a hack, take a look at the infamous xii.tex by David Carlisle (it's plain tex):
http://dante.ctan.org/CTAN/macros/plain/contrib/misc/xii.tex
Piero