Endless Parentheses

Concise ramblings on Emacs productivity.

New in Emacs 25.1: User-selected packages

In Thurday's post on dependency management, I briefly mentioned that package.el now keeps track of which packages the user explicitly requested, and which were pulled in as dependencies. But there’s a bit more to this feature, so it deserves some time in the spolight.

Simply put, there is now a new custom variable package-selected-packages. This variable stores the names of packages installed explicitly by user. So every time you do M-x package-install or you do i x in the Package Menu, the name of that package gets added to this list. Packages which get pulled in as dependencies are not added to this list, and those which are explictly deleted get removed from the list. This is how package-autoremove knows what to remove, it just finds packages which (a) are not on this list and (b) are not required by anything else.

But this variable comes with other benefits too. First, the user can edit it manually with the usual customize-variable and use it to keep track of their list of wanted packages. Second, there’s now another command, package-install-selected-packages, which ensures that all packages on the list are installed. This means you can safely move to a new computer, or even just delete your elpa/ subdir. As long as you keep your custom settings you can just invoke the command and all your packages will be reinstalled.

There’s one small caveat, which some of you may have noticed. This bookkeeping is done during installation. So, when you finally upgrade to Emacs 25.1, how is it going to know which of your installed packages were user-selected and which were dependencies?

Well, it’s just impossible to know for sure, so it makes an educated guess. It takes all installed packages that are not required by any other installed package, and considers them to have been explicitly installed. This can (and probably will) yield both false positives and negatives, but that only happens the very first time you start Emacs 25. So just keep in mind you may need to customize-variable and fine-tune this list.

Tags: emacs-25, package, emacs

Say thanks on Gratipay
comments powered by Disqus