1

emacs gives me an error when i try the bind keys to wdired-mode-map:

(define-key wdired-mode-map (kbd "TAB") 'my-mark-file-name-forward )
(define-key wdired-mode-map (kbd "-") 'my-mark-file-name-backward )
(define-key wdired-mode-map (kbd "<f2>") 'my-mark-file-name-for-rename )

the error is:

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

any clue what im doing wrong here? i always define-key for other modes like this an never encountered an issue

2 Answers 2

2

wdired-mode-map only becomes available after wdired-mode is used, if you want to change the keymap, you can use "mode hook" (wdired-mode-hook)

(add-hook 'wdired-mode-hook
          (lambda () (define-key wdired-mode-map ...)))

or with-eval-after-load

(with-eval-after-load "wdired"
  (define-key wdired-mode-map ...))
1

In general, when a variable or function is void, the most likely suspect is that the applicable library has not yet been loaded. Two common approaches are to require the library beforehand with (require 'wdired) or use (eval-after-load "wdired" '(progn ...)). Many people prefer the second option because Emacs starts up faster.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.