0

I want to make a prefix key. So which command is better for making a prefix key?

REF:

  • 2
    Newcomers to Emacs keybindings are well advised to read this excellent article: masteringemacs.org/article/mastering-key-bindings-emacs (it's way more information than you're asking for, but it will answer a ton of questions that you haven't asked yet). – phils Jul 26 '17 at 10:06
  • @phils Thx for your advice :) – Big Shield Jul 27 '17 at 1:50
  • @Drew Edited. That means making a prefix key. – Big Shield Jul 27 '17 at 1:53
4

The short answer:

If you wish the prefix to be present in all buffers and all modes, use global-set-key. If you wish it to be present only in one mode, use local-set-key.

The difference between the two is what keymap they put the binding into: The global one, or the local one. When you type a key sequence, the local map is searched first, then the global one. So a binding in the local map could shadow the global binding. Each major mode typically defines its own local map, which is shared among all buffers using that mode.

There is much more to say about keymaps and keymap searching, but this should be a good start.

  • Do you mean that the choice is based on modes or a mode? – Big Shield Jul 26 '17 at 9:27
  • If you mean your choice of which one to use, it depends how you are going to use it. – Harald Hanche-Olsen Jul 26 '17 at 10:03

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.