Safely Loading Your Emacs Configuration

Over at the Emacs Reddit, tending asks how to fall back to a known good Emacs configuration when initialization gets an error. His complaint is that if there's an error early in his .emacs file, the initialization is aborted and he's dumped into a default Emacs that doesn't have his usual environment. We've all been there.

Last time I looked, no one had a solution for falling back to a known good configuration but Renan Ranelli pointed to his solution for the problem. Ranelli's approach is to divide his configuration into several files—as many Emacs users do—and then have a small “bootloader” that loads each file but within a condition-case that captures any errors and records them. The rest of the files (assuming no further errors) are loaded normally. At the end of the loading, any errors are reported but most of his environment is available.

It's a very nice solution and, if you already have your configuration divided into separate files, very easy to implement. Take a look at his init-bootstrap.el file. You may find you want to do something similar. You could even use the same idea to implement the solution tending was seeking.

This entry was posted in General and tagged . Bookmark the permalink.