Confusion with translate-key
Opened this issue · 5 comments
Thanks for this great package. This is more of a question than an issue. I would like to avoid the emacs pinky and cramps by remaping M-m
to 'C-c' and 'M-,' to 'C-x'. I thought that the correct way of doing so would be to use
(general-translate-key nil 'global
"M-," "C-x"
"M-m" "C-c"
)
or
(general-translate-key nil 'override
"M-," "C-x"
"M-m" "C-c"
)
But this does not seem to work... Only some keys appear to be defined if I do this: e.g. other keys I defined using general in the global
keymap. What am I doing wrong? Thank you!
I managed to accomplish what I wanted by using
(general-define-key :keymaps 'override
"M-," (general-simulate-key "C-x")
"M-m" (general-simulate-key "C-c")
)
however I am confused why the original approach does not work. Could you please explain and/or point me in the correct direction? I read the manual in depth (especially the relevant sections) but could not find an answer.
Also, with both methods I cannot get M-m M-m
to map to 'C-c C-c' automatically. Is there a way?
general-translate-key
works on specific keymaps. Not all C-c
keybindings, for example, are defined in the global keymap (e.g. org mode C-c
keybindings are bound in org-mode-map
), so not all C-c
keybindings will be available. Simulation is the right approach here.
Also, with both methods I cannot get M-m M-m to map to 'C-c C-c' automatically. Is there a way?
You should be able to bind a key to (general-key "C-c C-c")
.
Thanks for the heads up
You should be able to bind a key to
(general-key "C-c C-c")
.
I thought about this, but then wouldn't I need to redefine every possible prefix combination? Ultimately i just want to makeM-m
behave exactly like the keyC-c
on all occasions. Is there a way?
If you want M-m
to always act as C-c
, you can use keyboard-translate
.
If you want to bind both M-m
and M-m M-m
, you can try general-key-dispatch
.
I ended up doing what I wanted by using:
(general-define-key :keymaps 'key-translation-map
"M-," '(nil :wk "C-x")
"M-m" '(nil :wk "C-c")
"M-," (lambda (interactive) () (kbd "C-x"))
"M-m" (lambda (interactive) () (kbd "C-c"))
)
I did not try keyboard-translate
because of the comment on the ergoemacs blog