How can I swap M-x
and M-q
?
I can swap C-x
and C-q
with
;; swap C-q and C-x
(keyboard-translate ?\C-q ?\C-x)
(keyboard-translate ?\C-x ?\C-q)
The following errors out
(keyboard-translate ?\M-q ?\M-x)
(keyboard-translate ?\M-x ?\M-q)
as well as
(keyboard-translate (kbd "M-q") (kbd "M-x"))
I would expect the key references (?\C-x
and ?\M-x
) to be symmetric, but clearly something in my understanding is off.
EDIT: Reading @phils response and the referenced documentation, I can see that the above fails, at least in part, because there isn't a character in range to translate.
Thinking more about the problem, translation is probably not what I need but rather good old rebinding:
(global-set-key (kbd "M-q") 'execute-extended-command)
(global-set-key (kbd "M-x") 'fill-paragraph)
That is, make M-q
call the command which is typically associated with M-x
(execute-extended-command
) and remap the displaced command (fill-paragraph
).