I am trying to override Meta + left / right arrow keys in my emacs config and cannot figure out how to refer to the key sequence.
If I interact with Emacs directly I can type "M-x, global-set-key, M-, next-buffer", and it works fine. But I can't figure out how to type this into my init.el file. These are some things that I have tried:
(global-set-key "\M right" 'next-buffer)
(global-set-key "\M <right>" 'next-buffer)
(global-set-key [\M right] 'next-buffer)
(global-set-key [M right] 'next-buffer)
(global-set-key [M-right] 'next-buffer)
(global-set-key (kbd M-<right>) 'next-buffer)
(global-set-key [M (kbd <right>)] 'next-buffer)
etc.
More Info:
OK, this does work natively: (global-set-key [M-right] 'next-buffer)
(thank you) - it's not working on iTerm2 in a VM (minor detail :)
And for that environment: M-x describe-key
does not open help but in *Messages*
prints: ESC <right> (translated from ESC M-[ C) is undefined
And that's why I was confused and was not able to just paste that into kbd. And that's why I don't think it is being trumped by another mode.
(global-set-key [M-right] 'next-buffer)
works for me, so you probably have a major-mode or minor-mode that is trumping (taking precedence) over the global setting. TypeM-x describe-key
and thenM-right
and update your question or post a comment with the result. Also, provide what major-mode you are running and minor-modes that are active. You can typeM-x describe-mode
to find out all of that information. - lawlist(kbd "ESC <right>")
or(kbd "ESC M-[ C")
? - philsM-x doctor
- ray