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

巧了我就是萌 提交于 2021-01-02 20:11:02

问题


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?


回答1:


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) ))


来源:https://stackoverflow.com/questions/30989838/symbols-value-as-variable-is-void-dired-mode-map

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!