Go to the first, previous, next, last section, table of contents.

Recovering Data from Auto-Saves

You can use the contents of an auto-save file to recover from a loss of data with the command M-x recover-file RET file RET. This visits file and then (after your confirmation) restores the contents from its auto-save file `#file#'. You can then save with C-x C-s to put the recovered text into file itself. For example, to recover file `foo.c' from its auto-save file `#foo.c#', do:

M-x recover-file RET foo.c RET
yes RET
C-x C-s

Before asking for confirmation, M-x recover-file displays a directory listing describing the specified file and the auto-save file, so you can compare their sizes and dates. If the auto-save file is older, M-x recover-file does not offer to read it.

If Emacs or the computer crashes, you can recover all the files you were editing from their auto save files with the command M-x recover-session. This first shows you a list of recorded interrupted sessions. Move point to the one you choose, and type C-c C-c.

Then recover-session asks about each of the files that were being edited during that session, asking whether to recover that file. If you answer y, it calls recover-file, which works in its normal fashion. It shows the dates of the original file and its auto-save file, and asks once again whether to recover that file.

When recover-session is done, the files you've chosen to recover are present in Emacs buffers. You should then save them. Only this--saving them--updates the files themselves.

Interrupted sessions are recorded for later recovery in files named `~/.saves-pid-hostname'. The `~/.saves' portion of these names comes from the value of auto-save-list-file-prefix. You can arrange to record sessions in a different place by setting that variable in your `.emacs' file, but you'll have to redefine recover-session as well to make it look in the new place. If you set auto-save-list-file-prefix to nil in your `.emacs' file, sessions are not recorded for recovery.

Go to the first, previous, next, last section, table of contents.