The value of the symbol as a variable is empty: dired-mode-map

I am trying to remap some keys in this style:

(add-hook 'dired-mode-hook
  (lambda ()
    (require 'dired )
    (define-key dired-mode-map (kbd "M-o") nil)))
    (define-key dired-mode-map (kbd "M-o") 'other-window)
    ))

      

Unfortunately it doesn't work, I get this error

Symbol value as variable is void: dired-mode-map

      

Which is werid because I have to be loaded into dired. What could I be doing wrong?

+3


source to share


1 answer


The original poster has two (2) multiple [pun intended] closing parentheses at this point: (define-key dired-mode-map (kbd "M-o") nil)))

- that is, the two (2) closing parentheses at the end of this line should be eliminated. Also, I see no reason to set the binding to nil

before overriding it.

The next is another way to achieve the same goal. Add any additional key bindings after the instruction progn

as desired.



(eval-after-load "dired" '(progn
  (define-key dired-mode-map (kbd "M-o") 'other-window) ))

      

+3


source







All Articles