Invalid type argument: keymapp, emacs-lisp -mode-map

I have the following lines in init.el:

(dolist (map '(emacs-lisp-mode-map
           lisp-interaction-mode-map))
  (define-key map (kbd "C-c C-e") 'eval-and-replace))

      

When I evaluate it, I get the error:

Wrong type argument: keymapp, emacs-lisp-mode-map

      

But if I check:

(keymapp emacs-lisp-mode-map)

      

result:

t

      

I don't know what happened to this I also tried another version of mapcar:

(mapcar '(lambda (map)
       (define-key map (kbd "C-c C-e") 'eval-and-replace))
    '(emacs-lisp-mode-map
      lisp-interaction-mode-map))

      

but the result is the same.

+3


source to share


1 answer


define-key

expects the actual layout as the first argument. You pass him a character(variable) whose value is the layout . You should use this:

(dolist (map  (list emacs-lisp-mode-map lisp-interaction-mode-map))...)

      



list

is a normal function, so it evaluates its arguments. In this case, you get a list of two layouts, not two keyboard variables (characters). The code you are using quote

just returns a list (emacs-lisp-mode-map lisp-interaction-mode-map)

.

You have tested (keymapp emacs-lisp-mode-map)

. But if you tested (keymapp 'emacs-lisp-mode-map)

, then the result would be nil

: the symbol is not a layout.

+3


source







All Articles