Previous: , Up: Emacs Lisp Package Manager and Archives   [Index]


12.2.3 How Packages Work

Whenever Emacs starts up, it automatically calls the function ‘package-initialize’ to load installed packages. This is done after loading the init file and before running ‘after-init-hook’. Automatic package loading is disabled if the user option package-enable-at-startup is nil.

This means you should NOT put package specific initialization into your init.el except in a few ways:

It might be easier just to move package-initialize to another point during startup so you can (require) ELPA packages; this takes care of a lot of the described issues:

;; basic initialization, (require) non-ELPA packages, etc.
(setq package-enable-at-startup nil)
(package-initialize)
;; (require) your ELPA packages, configure them as normal

Using with-eval-after-load For Package Config

Starting in emacs 24.4, with-eval-after-load is simpler than eval-after-load:

(with-eval-after-load 'abcd-mode
       (setq-default abcd-basic-offset 7) ; setting some option
       (add-to-list 'abcd-globals-list "console") ; appending to a list option
       (add-hook 'abcd-mode-hook 'prepare-some-abcd-soup) ; things to do for abcd mode buffers
       (define-key abcd-mode-map (kbd "C-c C-c") 'play-some-abcd-song) ; add some key binding for abcd mode
       )

Previous: Milkypostman’s Emacs Lisp Package Archive—MELPA, Up: Emacs Lisp Package Manager and Archives   [Index]