Emacs Configuration Party
I spent the bulk of this weekend revising and refactoring my emacs configuration. Forgive the potential narcissism, but I thought a little bit of reflection would be worthwhile here.
I started using emacs in 2008 or 2009. I built the best configuration I could at the time, but I didn't know very much about software development or managing complexity, and while I did an ok job maintaining it for a while, in the last year or so, I'd done almost no upkeep and had just thrown more crap into an overflowing folder.
The thing about a configuration for a program that you use every day, is that it needs to be able to change with you as your needs change and the kinds of projects you work on grow and change. The old crufty configuration made me avoidant of making any change to my set up, and a collection of annoying bugs cropped up that I had no idea how to fix.
In situations like this, the only thing to do is to set aside some time and fix things.
Before, I had a directory that was full of emacs lisp most of which I'd downloaded from the internet. The directory is in a git repository that syncs to four computers: my main laptop and my work computer (these are virtually the same system, both Arch Linux based), a mac (work) laptop, and a server that runs Debian. There were also symbolic links to other emacs lisp packages scattered here and there on the system. ~/.emacs was a symlink to a file in this directory that had machine specific configuration options and then loaded two files: a file that did some different initialization based on the name of the daemon process (I run 3 or four different emacs daemons at a time, that have slightly different configuration requirements.) To cap it all of there was a "central" file that all of the actual configuration. Which was itself just as awful as what I described. Then, as if this wasn't enough, there was a layer of tiles namedtycho-<name>.el that contained my own customization and settings that wrapped specific areas of emacs functionality.
The revision process went well. I decided to, for the moment, avoid package.el (concerns about startup time, being able to edit packages more natively, and wanting to let the emacs packaing ecosystem settle down a little.) Instead I'm vendorizing things in a more consistent manner. Here's the shake down of my changes:
I've created a number of folders in the directory all application specific code. This is mostly third party stuff. Large packages have their own folders, single-file modules are grouped into some basic categories: emacs-lisp libraries, apps, programming-langauge specific groups, navigation tools, cloud-service integrations, calendar tools, and so forth.
The code that used to be in tycho-<name>.el files are the only files that remain in the top level of my emacs directory. They have different and better names. For files that customize emacs they have simple names like display.el and keybindings.el and local-functions.el. For the collection of domain-specific customization these files have names like python-config.el.
I went through this code and reduced the number of files drastically, moving global settings out of random files, organizing each function with requirements at the top, setting declarations at the top, followed by keybindings, followed by relevant custom function.
The basic initialization code is much more straightforward as well. There's one file that modifies the load-path, which is the first thing that gets loaded. There's a small amount of system-specific configuration that remains, but it turns out that about 80% of what I thought was system specific wasn't. Nifty.
I also coalesced all of the emacs initialization code, and I refactored the functions to reduce the redundancy in the initialization process.
In the process of moving things around, I was able to delete or archive a bunch of code that I was no longer using, and factor out a bunch of redundant crap. The feeling was spectacular.
I'm no longer afraid of editing the code that runs the software that I use pretty much constantly.
The most annoying bug ever, that broke using emacs sessions in console, is fixed. I'm not sure what did it, but when I open a file from the command line in a console session, it's actually opens properly. No clue what did it, but I'm very happy.
The start up time for an emacs session is now wicked fast. We're talking 2-3 seconds depending on hardware. Ideally it'd be 1-2 but I'll take what I can get for now.
I'd like to not have to think much about organizing my emacs configuration for while. I'm particularly envious of good code folding at the moment.
I think eventually it'd be good to learn more and begin to use the package management tools, but I want to wait for them to mature and also to try and figure out a way to reduce the init-time penalty, to transition my working legacy system. I understand that it's the future, but I want to get to know it a bit better first.
I've been trying to hone my chops in a second, non-python programming language. I've been flirting with common lisp, go, and C++, and while I can hobble around each I hope that being able to actually add stuff to my emacs config will make things like code navigation/completion and compiler integration not suck.