[TxMt] Re: Letters to disambiguate keyboard shortcuts

Allan Odgaard mailinglist at textmate.org
Sun Oct 25 14:16:10 UTC 2015


On 24 Oct 2015, at 18:37, Jacob Carlborg wrote:

> TextMate has a feature that if a keyboard shortcut maps to multiple 
> commands (I'm mostly thinking of bundle commands) a context menu will 
> open to allow the user to disambiguate the command. It's possible to 
> use the numbers on the keyboard to select the correct command.
>
> Would it be possible to use letters in addition/instead of the numbers 
> to disambiguate the commands?

Pressing A-Z already works to select the first item in the menu starting 
with that letter.

> For example, in the Git bundle there are a lot of commands that map to 
> the same same keyboard shortcut (⌘Y). Because they're so many only 
> around a third of the commands have a number to disambiguate using the 
> keyboard.

For Subversion we spent some time naming the items so that the most 
commonly used items would work with letters, e.g. [C]ommit, [D]iff With 
Base, [S]tatus, [B]lame, etc.

The Git bundle was developed a little different, and I think the goal 
there was to put the most commonly used items near the top, so that 
these would be reachable with the number keys.

Personally I wouldn’t be against re-arranging the Git menu so that it 
would work better with letter keys, but I fear it would upset a lot of 
people who are e.g. used to ⌘Y + 2 for commit, etc.

> BTW, I tried to disable the keyboard shortcut for a couple of commands 
> I'm not using but the "Key Equivalent" field is blank for all the Git 
> commands. Does the Git bundle has some kind of special treatment?

The way it works is that the SCM bundle has a proxy item bound to ⌘Y 
(not the Git bundle!).

A proxy item is simply a proxy for one or more other items. As its 
content it has a “query” which queries on the semantic class (of all 
items that would apply in current scope).

For the SCM bundle the query is `action.scm`, i.e. all SCM actions. The 
respective SCM bundles (Git, Subversion, etc.) are scoped to 
`attr.scm.XYZ` so the proxy item will only find items that are scoped to 
the version control system currently in use.

Currently the “query language” used in proxy items is just prefix 
match, otherwise you could change the query so you would only get the 
actions you’re interested in.

Lacking the ability to do more sophisticated queries, you can remove the 
scm.action semantic class from the items you do not want in the menu.

It’s not an ideal solution, as the semantic class is intended for more 
than just this menu, e.g. we might do a “commit” toolbar button, and 
this would then query the semantic class, but right now, we do not have 
this functionality, so you’re not (yet) losing out on anything by 
editing the semantic classes.


More information about the textmate mailing list