use-package for builtin emacs packages
Since I started to use emacs I had to configure it to my likings and needs. Sometimes variable customization is enough but I also rely on many different modes and non-customizable behavior that I have to write elisp.
The biggest improvement to my init.el
file and sanity has been the use-package
package and macro. use-package allows me to specify what I want out of emacs packages with a
simple macro without having to think much but at the same time I longed for the same ability
with builtin packages. I only ever saw examples of use-package in combination with third party
packages but once I started looking at builtin packages everything fell in place
and started using it with every package I could think of.
The most important difference between builting package and third party packages is that
the emacs package manager (package.el) does not work with builtin packages. This means
that we have to make sure to use :ensure nil
when using the use-package macro.
Passing :ensure nil
to each expansion of use-package makes sure to disable the
default behavior where package.el is used to load the package. As this becomes quickly
kind of boring you can customize use-package-always-ensure
to make it either t
or nil
depending on the amount of builtin packages vs third party packages you use.
This is an example from my config where I use use-package
to configure some variables
and set some hooks for builting packages. I find it is easier for me to read the init.el
than the customised variables file so I started keeping most of my customization there.