After recently learning about
use-package I decided to port my configuration to it but found myself reluctant to give up the convenience of using
package.el to install packages and keep them updated. I've found it a little tricky to combine
I'm generally interested in learning how people combine
use-package with the
package.el system, but for a more specific question, keep reading.
Here's what I want:
- To have packages installed by the package manager so I can easily browse for packages and keep them updated through
- To configure and load packages exclusively through
use-package, so I can easily see in my init file exactly what I'm loading and how it is configured.
- Optionally, I'd like to also be able to install packages through
If I'm understanding correctly I want very little of what
package-initialize does, basically only the way it sets up the
load-path. Currently I have this in my configuration:
;(package-initialize) (setq package-enable-at-startup nil) (let ((default-directory "~/.emacs.d/elpa")) (normal-top-level-add-subdirs-to-load-path)) (require 'use-package)
The first, commented, line is so Emacs 25 doesn't helpfully add a
(package-initialize) to my init file. The bit with
normal-top-level-add-subdirs-to-load-path is an approximation to what
package-initialize would make the
load-path, an approximation that seems good enough.
This seems to achieve my desires 1 and 2, but not 3. If I try to use
:ensure, I get an error message saying that
package.el is not initialized. Calling
package-initialize would fix that, but I wish to avoid that since a) I don't want all the myriad autoloads to be loaded (I prefer to use
use-package to create precisely the autoloads I need), and b) I want to be able to easily avoid loading certain installed packages whenever I want (which is easy to do with
Does anyone have a recommendation for how to do this?