[txmt-dev] Re: Grammar injection

Gerd Knops gerti-textmate at bitart.com
Sat Aug 18 17:17:51 UTC 2012


On Aug 18, 2012, at 4:16 AM, Allan Odgaard <odgaard at macromates.com> wrote:

> On Aug 18, 2012, at 6:53 AM, Gerd Knops <gerti at bitart.com> wrote:
> 
>> - Right now it seems injection appends to the patterns. Would it be possible to also have 'early injection' where the new patterns are prepended to the patterns? I am experimenting with special comment sections like /*H:   */, and can't seem to do this with injection. (Another example application: Headerdoc/Docbook comments /** */ etc).
> 
> I am not following why this would work for appending but not prepending… this is because you want to replace the _entire_ comment rule? As opposed to inject the grammar into the comment?
> 
Right. Here is a simple example: I like to use line comments '//' that begin at the start of the line as code separators, so I draw the line background in a different color, so basically

	match = "^//.*\n?";

This doesn't work with injections, because the 'regular' grammar already gobbles up any '//', so the injected grammar never sees it.

Similar for docbook comments: an injected grammar never sees the '/**' comments.

Another example is leading whitespace: I like to have leading tabs highlighted with alternating light backgrounds, like so:



I would LOVE to use injection for that, unfortunately many definitions eat up leading space. So my only recourse is to write custom language grammars for ALL languages I want to have this feature (eg ALL languages I use), start with my rules (so they get first dib), then include the actual language.



> Though we definitely do need more flexibility wrt. injection, I think I did the append because then an injected grammar will not screw up the parent grammar, with our current grammars though, I think none of them would. I.e. this is only when you inject fallback matches.
> 
> I think both Joachim and Michael sheets have input on these things, why not use the mailing list for this?
> 
Done.


>> - Would it be possible to access other grammars repositories? I could imagine something like
>> 
>> 	{ include = 'source.objc.#interface_innards'; }, 
> 
> This should already be possible, but without the dot, so simply ‘source.objc#interface_innards’.
> 
Oh, that made my day!!! Thanks!

Gerd

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate-dev/attachments/20120818/ed879472/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PastedGraphic-2.png
Type: image/png
Size: 33214 bytes
Desc: not available
URL: <http://lists.macromates.com/textmate-dev/attachments/20120818/ed879472/attachment-0001.png>


More information about the textmate-dev mailing list