I am trying to write the following function:
(defun define-keymap-onto-keymap (from-map to-map)
(map-keymap
(lambda (key cmd) (define-key to-map key cmd))
from-map))
My implementation above does not work in general, since
the key argument to map-keymap is not a key,
but an event, which is not always understood by define-key. For example:
(define-keymap-onto-keymap
(let ((kmap (make-sparse-keymap)))
(define-key kmap (kbd "<s-return>") nil)
kmap)
emacs-lisp-mode-map)
*** Eval error *** Wrong type argument: arrayp, s-return
Also:
(define-keymap-onto-keymap
(let ((kmap (make-sparse-keymap)))
(define-key kmap (kbd "s-2") nil)
kmap)
emacs-lisp-mode-map)
*** Eval error *** Wrong type argument: arrayp, 8388658
Is there a
function similar to define-key, which understands whatever may be
the type of key?
I am not interested in solutions like derived-mode-merge-keymaps, which use
(setcdr (nthcdr (1- (length new)) new) old)
which can result in infinite lists, and I'm not interested in a brand-new copy of from-map,
like in keymap--merge-bindings but to add
bindings to an existing to-map.
Can I just append from-map onto to-map?
set-keymap-parent? – npostavs Apr 06 '17 at 01:53Wrong type argument: arrayp, menu-bar,Wrong type argument: arrayp, 8388703,Wrong type argument: arrayp, s-return– erjoalgo Apr 06 '17 at 01:55emacs-lisp-mode-mapwith a keymap I've created. – erjoalgo Apr 06 '17 at 01:56arrayperrors, you're missing a call tovector, try(lambda (key cmd) (define-key to-map (vector key) cmd)). – npostavs Apr 06 '17 at 03:05