I'm reorganising my init.el a bit and I've realised that it contains the following set of use-package declarations: (simplified slightly)

(use-package hasky-extensions
   :states '(normal visual insert emacs)
   :keymap 'haskell-mode-map
   :prefix "K"
   :non-normal-prefix "C-)"
   "xx" 'hasky-extensions
   "xd" 'hasky-extensions-browse-docs
   "hh"  'hoogle
   "hH"  'haskell-hoogle-lookup-from-local))

;; ...
;; then, a bit later:

(use-package general)

Arguably this shouldn't work, as general-define-key is called before general is required through the use-package declaration. However, it turns out to work just fine - I get no errors and can use all the keybindings I have defined. Why does this work?

2 Answers 2


If you installed general through package.el and are using package-initialize, then the answer is that installation produces a general-autoloads.el file which package-initialize loads. That file contains an autoload for general-define-key, which means that whenever you cal general-define-key the general package will be loaded.

(If you installed general in some other way and didn't generate the autoloads file, or if you do have the autoload file but don't use package-initialize or in some way load it, then we'd need more information to figure things out.)

  • This sounds right, especially since I've noticed other packages autoloading.
    – bradrn
    Nov 20, 2018 at 22:01

It is possible that the answer is pure luck! use-package often defers loading a package until it is called so that, as long as general got called first (perhaps by some other package), you are golden.

You can control the situation by putting an :after general in the use-package form for hasky-extensions and then luck will no longer be required...

  • I don't think this is it - putting message calls for debugging seems to indicate that hasky-stack is indeed being loaded before general.
    – bradrn
    Sep 22, 2018 at 2:13

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.