Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm trying to remap some keys in dired like this:

(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 this doesn't seem to work, I get this error

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

Which is werid, because I should be loading in dired. What could I be doing wrong?

like image 799
Shep Avatar asked Jan 09 '23 02:01

Shep


1 Answers

The original poster has two (2) many [pun intended] closing parentheses at this point: (define-key dired-mode-map (kbd "M-o") nil))) -- i.e., two (2) closing parentheses at the end of that line need to be eliminated. Furthermore, I do not see a reason to set the binding to nil before redefining it.

The following is another way of accomplishing the same goal. Add any additional key bindings after the progn statement as desired.

(eval-after-load "dired" '(progn
  (define-key dired-mode-map (kbd "M-o") 'other-window) ))
like image 168
lawlist Avatar answered Jan 18 '23 01:01

lawlist