I was working in emacs when had a power outage, so my computer was knocked offline. After I got the computer back up, I launched emacs and tried to restore the last session. Emacs then said: "No files can be recovered from this session now". All my files were saved, so all that needs to happen them opened from the .saves-pid-hostname~ file.

I'm not sure if this is even possible after researching the issues. I found this bug report about emacs session restores. It seemed to suggest that emacs didn't perceive the files as needing to be restored because all changes had been saved to them.

What I'm looking for is a way to have emacs open the files that are listed in the saves file. This should only apply to the normal file names and excludes the files that emacs makes in-between saves, like "#filename#".

Saves File:


How do I have emacs automatically open these files? I don't need my work in emacs to be persistence across restarts, so I think desktop save mode would be over kill for the situation.


If you call M-x recover-session RET you are offered a dired buffer with save files. Pressing RET on one of those files opens it in an Emacs file buffer.

You can use the following function to open all files from that buffer.

(defun find-files-in-buffer (&optional include-auto-save separator)
  "Find files listed in current buffer.
Find auto save files only if INCLUDE-AUTO-SAVE is non-nil.
SEPARATOR is used as regexp to split file names.
It defaults to the newline character.

In interactive calls INCLUDE-AUTO-SAVE is the raw prefix-argument \\[universal-argument]."
  (interactive "P")
  (unless (stringp separator)
    (setq separator "\n"))
  (let ((file-list (split-string (buffer-string) separator t)))
    (unless include-auto-save
      (setq file-list (cl-remove-if
               (lambda (file)
             (auto-save-file-name-p (file-name-nondirectory file)))
    (cl-loop for file in file-list
         when (file-readable-p file)
         do (find-file file))))
  • This is perfect. Thank you. – 9716278 Jun 17 '19 at 8:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.