Emacs: saving and loading desktop configurations with workgroups.el
I’ve been using Emacs for some time, using it mainly for document preparation (LaTeX), config file editing and plain text notes. So far, I’ve managed to get by with the default modes of Emacs 23. Wanting to port my Python scripting process over to Emacs, having used Eclipse for some time and not really liking it too much, I’ve found that I just can’t handle having to reconfigure my Emacs desktop/workspace on every session, especially where multiple frames are concerned.
According to its github page, workgroups allows you to: store an unlimited number of window configs, save window configs to disk, load them from disk, kill and yank window configs, and provides animated window config morphing, frame reversing and window movement, a concept of “base” and “working” configs for maximum flexibility, and lots of other stuff.
When I first started using workgroups, I thought the saving and loading of configurations was broken. It’s turns out I just wasn’t using it properly.
The following is what I’ve learned about using the basics of workgroups, especially with saving and loading configurations…
The first workgroup can be created from the current session using <prefix> c, where the current window configuration will be saved to the workgroup name you supply.
Subsequent workgroups can be created using<prefix> c in the same way, but will reset the session to display only one frame containing the scratch buffer. I didn’t appreciate this for the first few times I used it, assuming that the current configuration I could see would be saved to the new workgroup name I supplied, just as for the first configuration. Not so. A fresh workgroup is created, ready to be configured from scratch.
Saving a set of workgroups to a file for later restoration requires you to update the base configuration via <prefix> U. The base configuration is what is loaded from the workgroup save file, not the working configuration. See the definitions of these configs.
After this, the base configuration can be saved to a file via <prefix> Ctrl+s and loaded manually via <prefix> Ctrl+l. Saving and loading can be automated within the .emacs file, say, as per the documentation.
Once I figured out the way new workgroups are created and the way the base configuration was saved, I found workgroups a joy to use. As is often the case, it was a case of RTFM. Thankfully, the documentation for workgroups is tight.