[TxMt] Re: Trying to match triple-backticks

Martin Kühl martin.kuehl at gmail.com
Thu Jan 21 00:15:52 UTC 2016

On 10 January 2016 at 23:37, Allan Odgaard <mailinglist at textmate.org> wrote:
> On 8 Jan 2016, at 9:18, Martin Kühl wrote:
>> Thinking about this more, I believe this is a bug.
>> The `L:` prefix seems to cause the injected begin matcher
>> to match even before its own end matcher can,
> The `L:` prefix means “inject the rules before the current context’s rules”.
> What happens here is that we inject a begin/end match, each for `~~~`.
> Once we match `~~~` we start a new context, in this new context, the
> injection grammar is once again injected, so once we see the ending `~~~` it
> is actually matched by a new instance of the injection grammar, because we
> inject it before the current context’s rules (in which we find the rule to
> match the ending `~~~`).

I guess my assumption was that the injection scope
would refer to a piece of a grammar,
analogous to what `include` refers to.

Am I understanding correctly then that an injection scope:
* refers to (and is compared to) a scope in the active document?
* is valid for the whole (injected) grammar

Is there a way to inject different rules into different scopes
or would one create multiple injected grammars for that?

Now to help me understand…

Let's assume our position is inside some scope S
opened by a `begin`/`end` rule.
Let's call its `end` matcher END
and its included rules INC.
TM would try matching END, then INC, right?
Let's abbreviate that as [ENC, INC].

There is another grammar supposed to inject rules into the current scope,
let's call its rules INJ.
If I understand correctly,
injecting into scope "S" would result in trying [END, INC, INJ],
while injecting into "L:S" would result in trying [INJ, END, INC], right?

What do the R and B prefixes do?
I can imagine R being useful for lowering priority
in the face of several injected grammars,
is that the intended purpose?

Is there a way to inject the grammar such that TM would try [END, INJ, INC]?

Thanks for your patience,

More information about the textmate mailing list