Magnar Sveen has a new episode of Emacs Rocks up. This time he talks about key-chord.el, a package that lets you press two keys simultaneously (or a single key twice in quick succession) to run a command. For example, I could bind prettify-key-sequence
to the key chord 【p+k】 and avoid having to run it with 【Meta+x】.
I probably wouldn’t do that because smex
makes calling prettify-key-sequence
fast enough for the relatively few times that I call it. There are other cases where it’s just what you need, though. I see its real utility in two areas.
The first, as explored in the Emacs Rocks video is for commands that you run all the time and want to be able to invoke as quickly as possible. Of course, you could just bind those commands to a function key or something like 【Ctrl+c κ】 where 【κ】 is some arbitrary key. The problem with that solution is that there are a lot of useful commands but all except a few of the convenient key sequences are already used, especially if you’re in something like org-mode.
This is an ideal situation in which to use key-chord.el
. Suppose, for example, that I was writing fiction with a lot of dialog. It would be great to be able to press 【d+q】 to run the dq command that I’ve written about previously to insert open and close quotes. Actually, key-chord.el
lets you do that directly by adding an expression such as
(key-chord-define-global "dq" "“”\C-b")
to your .emacs
or init.el
file.
In summary, I see key-chord.el
being useful to
- Bind a fast two-key sequence to a frequently used command that is bound to a less convenient key sequence.
- Extend the number of convenient key sequences.