While writing a latex document using the array package, I noticed that the line
\newcolumntype{R}{>{$}r<{$}}
confuses TextMate into displaying all following lines as if they were in math mode.
Any chance there's an easy fix?
Chris
On Jan 23, 2007, at 4:04 AM, Chris Stone wrote:
While writing a latex document using the array package, I noticed that the line
\newcolumntype{R}{>{$}r<{$}}
confuses TextMate into displaying all following lines as if they were in math mode.
Any chance there's an easy fix?
There's no particularly easy fix, except perhaps matching >{$} and < {$} as special constructs, in which case it would be nice to know all other use cases as well (i.e. all things that could reasonably be expected to appear in such a >{...} thing).
The problem in a nutshell is as follows: The syntax currently matches any pair of braces, with the content in them matched by a meta.group.braces scope. Similarly, it matches pairs of dollar signs, with the content matched by math mode. What this means is that when TM encounters the first dollar sign, it searches for its closing dollar sign before it ends the math mode, and before even considering closing the braces scope. So it bypasses the first closing brace. Then it encounters a second opening brace, and decides to start a new group scope, and won't stop until it find the closing brace. Then the second dollar sign starts a new math mode, and so on.
So I think the best way is to alter it so that >{$} and <{$} are matched as a whole. I have now changed the grammar to do so, so if you are on svn just svn up and it should work fine.
Chris
Haris
Charilaos Skiadas <skiadas@...> writes:
So I think the best way is to alter it so that >{$} and <{$} are matched as a whole. I have now changed the grammar to do so, so if you are on svn just svn up and it should work fine.
Haris
Yep, it works. Thanks!
I've often used emacs in the past. When it got confused about latex scopes, I could usually get syntax highlighting to recover in following lines by adding a comment containing extra closing braces and/or dollar signs. Unfortunately, TextMate is too smart to fall for this.
Should more complicated examples ever arise, I guess I can just put the problematic lines into a separate file and use \input.
Thanks again, Chris