emacs.d icon indicating copy to clipboard operation
emacs.d copied to clipboard

Fix error: (wrong-type-argument keymapp nil)

Open jsntn opened this issue 1 year ago • 1 comments

This error occurs because evil-local-set-key expects a valid keymap, but at the time it's being called from my end, the buffer may not have been properly initialized with a major mode that sets up the keymaps. See error details below,

Debugger entered--Lisp error: (wrong-type-argument keymapp nil)
  define-key(nil "q" my-dict-quit-window)
  evil-local-set-key(normal "q" my-dict-quit-window)
  (progn (evil-local-set-key 'normal (kbd "q") 'my-dict-quit-window))
  (if (and (boundp 'evil-mode) evil-mode) (progn (evil-local-set-key 'normal (kbd "q") 'my-dict-quit-window)))
  (save-current-buffer (set-buffer buf) (setq buffer-read-only nil) (erase-buffer) (insert def) (goto-char (point-min)) (local-set-key (kbd "q") 'my-dict-quit-window) (if (and (boundp 'evil-mode) evil-mode) (progn (evil-local-set-key 'normal (kbd "q") 'my-dict-quit-window))))
  (progn (setq buf (get-buffer-create my-dict-buffer-name)) (save-current-buffer (set-buffer buf) (setq buffer-read-only nil) (erase-buffer) (insert def) (goto-char (point-min)) (local-set-key (kbd "q") 'my-dict-quit-window) (if (and (boundp 'evil-mode) evil-mode) (progn (evil-local-set-key 'normal (kbd "q") 'my-dict-quit-window)))) (if (eq (current-buffer) buf) nil (if (null (setq win (get-buffer-window buf))) (switch-to-buffer-other-window buf) (select-window win))))
...

jsntn avatar Nov 22 '24 12:11 jsntn

Try

diff --git a/lisp/init-dictionary.el b/lisp/init-dictionary.el
index 75ac6337..380bef26 100644
--- a/lisp/init-dictionary.el
+++ b/lisp/init-dictionary.el
@@ -59,7 +59,8 @@
           ;; quit easily
           (local-set-key (kbd "q") 'my-dict-quit-window)
           (when (and (boundp 'evil-mode) evil-mode)
-            (evil-local-set-key 'normal "q" 'my-dict-quit-window)))
+            (my-run-with-idle-timer 1 (lambda ()
+                                        (evil-local-set-key 'normal "q" 'my-dict-quit-window)))))
         (unless (eq (current-buffer) buf)
           (if (null (setq win (get-buffer-window buf)))
               (switch-to-buffer-other-window buf)

redguardtoo avatar Nov 27 '24 00:11 redguardtoo