kaushalmodi / .emacs.d

My emacs configuration
MIT License
262 stars 49 forks source link

[setup-dired.el] use undefined variable 'dired-mode-map' #15

Closed smithx closed 8 years ago

smithx commented 8 years ago

Starting Emacs and trying to open dired with "C-x C-d", I'm get Error (use-package): dired-single :config: Symbol’s value as variable is void: dired-mode-map

Are reference to dired-mode-map (at dired-single) used before dired has been introduced (at dired) ?

manuel-uberti commented 8 years ago

Wild guess: using :after dired like this could solve the problem?

(use-package dired-single
  :after dired
  :bind (:map modi-mode-map
...
kaushalmodi commented 8 years ago

First of all, thank you @smithx for trying out my config and help me make it better.

I failed seeing that error as I save my sessions and load them when I next start emacs. When I started emacs without loading a saved session, this issue showed up.

The issue is now fixed in commit https://github.com/kaushalmodi/.emacs.d/commit/3b926c1fe0c3760d5b94d4b6df989656a9a13ed4.

Thanks @manuel-uberti for the proposed fix. I haven't yet started using the :after keyword with use-package. But the fix is in essence similar. Instead of loading the whole dired-single after loading dired, I chose to evaluate just the bindings to dired-mode-map after the loading of dired. The reason is dired-single functions will anyways first load dired, because dired is autoloaded with dired-get-filename is called by the dired-single functions.

Below code snippet is from dired-single.el:

(eval-and-compile
  (autoload 'dired-get-filename "dired"))

I have tested the fix to work with an emacs session without loading desktop.

Let me know if this works for you too.

manuel-uberti commented 8 years ago

To expand on :after: I have replaced almost all the uses of with-eval-after-load with that. But yes, you're right of course: it's the same thing, just more pleasant to my eyes.

smithx commented 8 years ago

Thank you for fix