10

I read that the usual way to bind key to keyboard macros are C-x C-k 0 to 9 and A to Z.

So for example, after we define a keyboard macro, we can type C-x C-k b and Emacs will ask for a key to bind. And the reserved keys for this purpose are C-x C-k 0 to 9 and A to Z.

But this involves quite a few keystrokes. What are good keys to bind this to? I found that I could bind it to C-<return> or Option + Enter on a Mac running the Ubuntu Virtual Machine using the Emacs GUI version. So that should work, but the Emacs terminal version and the native Emacs on a Mac both treat C-<return> or Option + Enter as just <return>, so that won't work.

What might be unused keys on Emacs that generally can be used to bind keyboard macros?

Or maybe alternatively, is there a way to show all the simple keys that are not bound to Ctrl and Meta?

  • This question is probably too broad and likely to elicit opinion-based answers. Please edit the question to make less opinion-based. – Dan Dec 15 '15 at 15:24
  • done as requested... – nopole Dec 15 '15 at 15:46
10

... is there a way to show all the simple keys that are not bound to CTRL and Meta?

Have you checked the unbound package by Davis Herring? It has the function describe-unbound-keys, which lists unbound key chords based on something he calls key complexity score. Pretty cool feature to play around to isolate just the key chords with CTRL and META keys.

To get at the underlying scoring mechanism, look at the key-complexity-1 function in unbound.el and tweak the weighting factors to isolate CTRL and META keys. This package has great potential for automatic discovery of useful key binding sequences.

  • This is pretty interesting - mine didn't have any keybindings available until complexity 5. I guess to make it more helpful you could combine it with information on how often you use different functions (or other people use - I think Xah Lee compiled that information). This was one of the most tricky parts of Emacs when I was first learning it - what keybindings can I use without wiping out something that might be useful later? Or how can I rebind the most used functions so they don't cause RSI? It's taken a while to work out a good set of bindings, but it could probably be partly automated. – Brian Burns Dec 15 '15 at 22:47
  • Automation is useful only for discovery, not for working out a "good set of bindings" because that set depends on users, features needed, keyboard layout, etc. Even for the same user, bindings will evolve over time. RSI adds another factor. In short, go for comfort now, not what key bindings "might be useful later". – Emacs User Dec 16 '15 at 5:49
  • Hence "partly" automated. There are some keys which are very easy to reach which are bound to something most people barely use. IIRC transpose is like that, and would be a good candidate to rebind - combining this package with function frequency usage would tell you that. M-x is one of the most used keys but it's hard to reach with modern keyboards - ErgoEmacs rebound it to M-a and I've used that and liked it a lot. It's very time consuming to work out a good set of bindings, especially when you're starting and don't know what you're doing, so something that could help would be really useful. – Brian Burns Dec 16 '15 at 7:27
  • @bburns.km go for it because what you're describing is customization, not automation. – Emacs User Dec 16 '15 at 16:17
2

According to the documentation, C-c + letter and F5-F9 are reserved for the user.

Another option is to bind M-m as a leader key and M-M to the original M-m instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.