I've befriended `use-package` and `init.el`

Tags: emacs

I could never relate to the concept of Emacs bankruptcy. It's an unnecessary waste of time and resources; not only you throw out years of carefully written code, but you also have to go through everything and write it from scratch. I've tried it a few times, but those few attempts ended with me arriving at the state I was previously at.

The problem with Emacs bankruptcy is that it's a concept that comes from deep past, when every Emacs configuration was a collection of random bits of ELisp code, combined together without any organizational effort. Since there was no notion of packages or libraries besides the built-in ones Emacs user would often resort to collecting snippets of ELisp code in their .emacs file without trying to organize them in any way. I'd call it James Wood's method of Emacs configuration. The end result of this process was always the same -- unmanagebale multi-thousand lines long configuration with varying level of code quality and no consistency whatsoever.

Nowadays you have the tools to organize your configuration without paying the ultimate price of clutter. package.el has introduced proper package management to Emacs and el-get has shown that package management doesn't have to be complicated. I've used a combination of the latter and some hand crafted stuff for the past few years, then switched to "modular setup" with package.el for package management, however I've recently switched to use-package and that significantly simplified my configuration.

Previous versions of my configuration have gone through several waves of major improvements, but I was never quite satisfied with it. This is where use-package comes into play. I've managed to untangle some mess into pretty manageable code. I still don't understand how the underlying mechanisms work, what lazy loading does and how in hell does :init and :config differ between each other, but I can navigate my config in a much simpler way. Obviously, the current setup can be improved, since it mostly consists of modules which don't have to be modules. In fact, all of my configuration can now neetly fit into single init.el and it will hardly take more than a few hundred lines of code. This is a dramatic improvement over what I had before and enables very quick refactoring and gives a much cleaner overview over setup of each bit of ELisp I have installed.

As a bonus, use-package can be used to decrease the load time of Emacs. This doesn't really concern me, since most of the time I run only one copy of Emacs for prolonged periods of time. Case in point, M-x emacs-uptime shows 4 days, 18 hours, 30 minutes, 31 seconds and that's simply because I've rebooted my laptop recently.

Overall I'm really happy with use-package, however things could still be improved. For example, as a Helm user I'm often finding myself setting up various bits of Helm functionality all over the place. Hardly an ideal situation but it seems that most use-package users deal with it by simply ignoring the issue. I'm not a big fan of ignoring issues like these, but I guess there's no way to avoid this. :)