[TxMt] Re: Override Menu Action

Allan Odgaard mailinglist at textmate.org
Sun Jan 10 22:22:31 UTC 2016


On 8 Jan 2016, at 9:41, Mike McQuaid wrote:

> I’m wanting to override the “Preview” menu action so that my 
> GitHub Markdown bundle’s “Preview” menu action can take priority 
> using the same shortcut. I’ve found a few possible options that I 
> expected to work but don’t:
>
> - setting the scope to text.html.markdown.github doesn’t seem to 
> match the document scope so never actually matches and the Preview 
> runs the old Markdown one

The scope of the document does not change, only the text matched by the 
injected rules (i.e. the raw blocks) will show scopes from the injection 
grammar.

> - setting the scope to text.html.markdown pops up a little menu to let 
> me choose between the two
>
> This may well not be possible in TextMate 2 as-is. Any thoughts on how 
> to do this (beyond just using another shortcut, my current solution)?

It shows the menu because the two actions have the exact some scope 
selectors.

A workaround would be to use a scope selector like: `text.html.markdown 
attr`.

Since we always have attributes in the scope, we’re matching a bit 
more than just the root scope, and thus will win over the default 
action, but it isn’t an ideal solution, right now though I can’t 
find of anything nicer.


More information about the textmate mailing list