Making package.el behave like Vundle

I love Vundle, it allows me to specify a list of packages within my dotfiles repository that is kept up to date and in sync with every other machine I use Vim on. The key point with this is that I can remove a package from all machines by simply deleting the line from my configuration.

Package management through ~/.*rc files is the Shih Tzu. Sadly, package.el doesn’t seem to do this and expects me to use some silly text based menu as well as remembering to keep every single one of my packages in sync. If I remove it from one, I need to remove it from the rest by hand. NO.

I’m not having any of that.

Installing missing packages

This one’s easy enough to solve and many people have many solutions. I have a function, dotfiles-sync, which will get the latest package lists from MELPA (and a few others) and installs all packages I currently don’t have locally. Simple enough and very effective, even if it does require a few reboots to get them all installed, still trying to work that one out.

So here I have a list of packages, a function to fetch them and a macro that I use to wait until each package is loaded before I configure them. To update my packages I have to go into the text based menu, mark out of date packages for upgrade and then execute it all (M-x list-packages RET U x). Despite this being cumbersome and annoying, this appears to be the only way right now.

The other problem, pruning

So I can install and update fairly easily, albeit not perfectly, but I’m still lacking the ability to prune old packages that I no longer have listed in my init.el file. My only main requirement for this process is that it executes as part of my synchronisation. Luckily the problem frustrated me enough to construct a solution, now my Emacs package management isn’t that far behind that of Vim / Vundle’s, but it still doesn’t feel quite a smooth. I’ll take what I can get.

I then amended my dotfiles-sync function to prune my old packages by adding one line. Fantastic.

I hope others will find this useful, I sure feel safer in the knowledge that packages I no longer list in my repository will be removed on my next synchronisation. You can just rip my code from this post, but I suppose I could turn it into a package if there was any real interest in it.

Edit: I created a post on the Emacs subreddit in which syl20bnr ran with the idea and made it far better. The concept can now be found within the spacemacs repository and it looks great!