Protesilaos Stavrou (Prot) has an excellent video on the fundamentals of the use-package macro. If you’re new to Emacs or are one of the few Emacs users who isn’t constantly tweaking your init.el
, use-package
is a macro you use in your configuration files that makes it easier to configure packages. One of it’s major features is that it automatically defers loading packages under several circumstances resulting in a decreased load time. That feature is especially useful for packages that you seldom use: they won’t be loaded until you actually need them.
The rules are a bit more complicated than you might think. Prot goes through several examples that illustrate how use-package
decides what to load, when to load it, and how and when to configure it.
As of Emacs 29, use-package
is builtin. Before that, it was a package from John Wiegley that lived on ELPA. Now that it’s builtin there’s no longer a need for special hacks to get it loaded before the rest of your configuration is processed.
When I converted my configuration to use-package
, I simply searched for every instance of the require
command and replaced it and the subsequent package configuration with a use-package
call. There are doubtless exceptions but a good first approximation is that any require
for a package should be replaced with use-package
. It simplifies your init.el
and, as I said before, can reduce your startup time with no effort on your part. Take a look at Prot’s video for the details.
The video is 35 minutes, 44 seconds long so you’ll have to schedule some time but it’s definitely worth your while. Now that it’s builtin, there’s no reason for not using it.