Recover Session

I just came across a really interesting post from Tory Anderson. Like me, Anderson lives in Emacs. In fact, since he’s a Linux user and runs exwm, he lives in Emacs even more than I do. Anderson notes that sometime Emacs crashes or freezes and has to be restarted. We’ve probably all experienced this. It doesn’t happen very often to me but it does happen. I’m pretty conservative about Emacs and don’t run unreleased versions. Lots of people do, though, and they probably have more crashes and hangs than I do.

In any event, the question is what do you do about recovering files that were open and unsaved when the editor died? Emacs, of course, has us covered. The recover-file command lets you recover (most of) what was in the buffer when Emacs died. It gets that information from the auto save file for that buffer, which is why it may not have everything.

The problem is, you have to remember which files to recover. Anderson says he did this by going through his error log. It turns out, though, that Emacs has us covered here too. You can run the command recover-session and it will present you with a list of every session’s saved data that it knows about. You pick the one you’re interested—usually the most recent one—and then run recover-session-finish (bound to Ctrl+c Ctrl+c) and Emacs will query you for each file it knows about in that session and ask you if you want to recover it.

Anderson describes a slightly different process involving only recover-session-final that didn’t work for me so be sure to read the documentation too.

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