Minifying(?) My Emacs Config
Easy Customization interface?
There is the impression, at least to me, the built-in Emacs configuration utility known as the Easy Customization
gets a bit overlooked by a lot of users. I see posts in different places about people just coming to Emacs and wanting to get started. What they tend to find is random snippets of Emacs Lisp to paste into a file. Rarely does anyone actually mention you can configure Emacs without writing any lisp code and get quite a well configured Emacs as a result.
The problem.
I have been nagged by a behavior in Emacs, one I'm guilty of authoring in which the *Completions*
window unhelpfully pops up when I'm trying to complete something in the minibuffer
with fido-vertical-mode
. This seems like a duplication of effort and is largely due to the way Crafted Emacs sets up completion in the crafted-defaults-config
module. As I was considering how I might resolve this I started Emacs in a blank directory (ala the --init-directory
command line parameter), and then I opened the Emacs manual (C-h i
) and started reading chapter 9 on completions.
Researching.
As I was reading, I thought to set some customizations for completions, so I ran M-x customize-option RET <option> RET
and then applied the settings. This generated a bunch of variable settings in a block of lisp. But I didn't write any of it. I just set values for my preferences and Emacs saved those decisions in a way it would be able to consume later – in the custom-set-variables
form.
Going bigger.
After tinkering with completions for a bit, this thing grew another head and I thought about trying to see how close I could get to my current configuration without installing any packages and not writing any elisp
, or at least as little as possible. The result can be found here. I think I was a bit surprised at how close I got to my normal configuration. Really, its about 80%-90% of the way there. I need a few extra packages to really flush things out, but in general, I have most of everything I need on a day-to-day basis. Full disclosure, I did write some lisp, I didn't find a way to change key bindings through the Easy Customization
interface, and I modified the display-buffer-alist
by copying code from Crafted Emacs, but I could have used the Easy Customization
interface instead.
And bigger still.
Inspired by how easy that was, I rewrote my entire configuration. Starting with the base from above, I just added more customization through the Easy Customization
interface, wrote some elisp
where it seemed to make sense and restarted Emacs. I goofed in a couple of places, but those were easy to fix. I looked through all the packages I was installing decided I didn't really need some of them, and left them out of this configuration. I listed all the packages directly in the custom-set-variables
form as values for the package-selected-packages
variable. Crafted Emacs does this by calling add-to-list
in the *-package
modules. So, by putting them directly there I didn't need any of the *-package
modules, and since the custom.el
file gets loaded early, I could still call package-install-selected-packages
per the Crafted Emacs manual. I do have some elisp
to conditionally add some packages to the list based on which system-type
or emacs-version
or if certain executables are on the system. I still use the *-config
modules from Crafted Emacs and some of my own personal modules get loaded as well. The rest of the configuration is largely keybindings and lazily applied settings when certain packages are loaded.
The result.
Overall, I'm happy with the result. The “minimal” version of my init.el
file is about 66% of the size of the “craftedv2” version, which is a bit arbitrary as I have my configuration spread out over numerous other files (custom.el
, custom modules, Crafted Emacs modules). Startup time is less than a second, not that it matters since I run Emacs as a server and then use emacsclient
to start editing sessions as needed.
Conclusion
What started out as just tinkering with completions and the Easy Customization
interface turned into a rewrite of my configuration. I do like to recommend the usage of the Easy Customization
interface, especially for those coming to Emacs for the first time.
Tags: emacs