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.
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.
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.
Emacs records information about interrupted sessions for later
recovery in files named
directory used, ~/.emacs.d/auto-save-list/, is determined by
auto-save-list-file-prefix. You can record
sessions in a different place by customizing that variable. If you
nil in your
.emacs file, sessions are not recorded for recovery.