I'm a bit compulsive about updating packages for all of my systems, so I find myself running list-packages
-> U
-> x
-> y
-> y
pretty much daily to update my packages and delete old versions once the update is complete. How can I automate this process so that at the very least I have to run only one function to update, compile, and delete my packages? Or is there some reason I might not want to do that?
3 Answers
The following is now part of the Paradox package. Just invoke paradox-upgrade-packages
.
This should do it.
(defun endless/upgrade ()
"Upgrade all packages, no questions asked."
(interactive)
(save-window-excursion
(list-packages)
(package-menu-mark-upgrades)
(package-menu-execute 'no-query)))
Just check which function is called by each of the steps you enumerated, and throw them inside an interactive function. Normally, the (y or n)
prompts would be an issue, but package-menu-execute
conveniently takes a NO-QUERY
argument.
-
If all packages are up to date, it will return
No operations specified
. Commented Sep 16, 2015 at 6:00
You can automate this with Cask. This works for package development, but also for user configuration. The documentation provides details for setting this up.
Also, Pallet is useful for keeping your Cask file up-to-date with changes you make in the *Packages* buffer.
-
+1 Cask + Pallet are great (but I don't recommend using them on Windows).– rsennaCommented Dec 2, 2014 at 18:50
-
Hmm, that's a problem, because I am on Windows most of the time.– RyanCommented Dec 2, 2014 at 19:03
-
@rsenna Thanks for the information. I don't run any Windows systems, so I wasn't aware they didn't play nicely. Commented Dec 2, 2014 at 21:36
-
In fact you can use Cask + Pallet on Windows, with some work. I was able achieve that by using Cygwin, but I remember it was far from easy...– rsennaCommented Dec 2, 2014 at 22:03
-
Cask will work fine in Windows once you install Python. I'm not sure about Pallet since I haven't tested though. But from looking at the repo it shouldn't depend on anything other than Cask + Emacs. Commented Jan 2, 2015 at 15:26
How about auto-package-update?
Old versions can be deleted by this customization:
(setq auto-package-update-delete-old-versions t)