Same for global-set-key "\C-x … and define-key ctl-x-map "….

I prefer (global-set-key (kbd "M-KEYS") #'COMMAND) because it's more readable, but I would like to know if the two kinds of binding -- expliciting the Meta key and using the ctl-x-map -- differ in some ways.

  • (global-set-key (kbd "C-c M-v") #'command)
    – RichieHH
    Feb 16 '20 at 16:23
  • 1
    @RichieHH: Please post that as an answer (but with C-x, not C-c, since the former is the OP example). And consider elaborating a bit, to make the difference clear. And please also add a corrected string version, i.e., without kbd. Bonus points for pointing to the manual node that explains this. ;-)
    – Drew
    Feb 16 '20 at 16:55
  • I'm pretty sure the effect of these functions is identical, i.e., (global-set-key "\C-x a" 'forward-line) and (define-key ctl-x-map "a" 'forward-line) do exactly the same thing. However, I can't find a definitive confirmation of this in the Emacs manual or the Elisp manual.
    – Tyler
    Feb 18 '20 at 23:21

The potential difference is that esc-map and ctl-x-map can be bound to keys other than ESC and C-x.

If you don't do that, then the two approaches are effectively the same.


Consider using function kbd, which is described here.

(global-set-key (kbd "C-x M-v") #'command)

  • I had tried using kbd but I must have made some mistake because I got an error. I have removed that part from the question. Anyway, that was just a -- wrong -- example of a difference, but my question is more about the difference between the two ways of binding a key, in general, than the specific issue with C-x M-v. Thanks for the tip and sorry if I wasn't clear. Feb 16 '20 at 20:42

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.