[TxMt] Re: Combined diff and source code highlighting
Jacob Carlborg
doob at me.com
Mon Jan 19 12:38:05 UTC 2015
On 2015-01-19 03:27, Allan Odgaard wrote:
> I don’t understand you here.
>
> The problem is that TextMate grammars have nested rules that will match
> constructs that span multiple lines. Take e.g. this:
>
> 1 --- test.cc (saved version)
> 2 +++ (current document)
> 3 @@ -1,6 +1,6 @@
> 4 int main (int argc, char const* argv[])
> 5 {
> 6 - for(size_t i = 0; i < count; ++i)
> 7 +/* for(size_t i = 0; i < count; ++i)
> 8 fprintf(stderr, "%zu\n", i);
> 9 - return 0;
> 10 +*/ return 0;
> 11 }
>
> How can you use the existing C++ grammar to figure out that line 9
> should not be rendered as commented?
Oh, I see. I guess it can't. It would render everything after the line
starting with "@@ ..." as C++. If possible, ignoring leading + or -.
> GitHub produces the diff themselves from the two versions of the file,
> so they have the ability to style the two original versions.
>
> TextMate generally just sees the resulting diff file.
Right.
--
/Jacob Carlborg
More information about the textmate
mailing list