The code you are looking for is:
(define-key keymap-1 (kbd "new prefix")
(lookup-key keymap-2 (kbd "old prefix")))
You don't usually need to know the names of the keymaps as the expressions
(current-global-map)
and (current-local-map)
return the global and local maps in
force. Although the emacs manual says you can re-map any of the function keys, I have found that strange things can happen if you try to re-map f1, f2, f3, f4 or f10. For this reason I usually re-map f5 or f6. As an example from my .emacs file, the code:
(add-hook 'planner-mode-hook
#'(lambda ()
(local-set-key (kbd "M-RET") 'muse-insert-list-item)
(local-set-key (kbd "M-S-RET") 'pcomplete)
(define-key (current-local-map) (kbd "<f5>")
(lookup-key (current-local-map) (kbd "C-c C-j")))))
sets M-RET and M-S-RET in planner-mode and also makes the prefix
f5 into an alias for C-c C-j in that mode.
Be aware, however, that it doesn't
always work as lookup-key
seem understand macros which, unfortunately, are
legal in keymaps. In such cases you can usually find a way round it. Ask again if
you have problems.
I'm not sure why you're mentionning prefixes, but this works, and the hook idea is interesting (even though i'm more familiar with knowing how keymaps are called). I donk know much about macros, the bright side being I therefore don't care (I mean, if that's the
C-x (
/C-x )
thing, mapping constructs based on them to other bindings seems very deviant to me >_<). Are you running in problems with f1 to f4 and f10 because they're already bound, sometimes later defined than your own definition, by any chance ? – Nikana Reklawyks – 2012-11-20T07:08:35.647Some major modes rebind them. For instance f1 is bound to help but some major modes have their own variant of help and re-bind the key. I find it easier not to use them. – Bernard Hurley – 2012-11-20T08:33:05.247