Weekly Emacs tip #25 — Recover (this) file
Unfortunately, just like most other software, Emacs can crash sometimes. Or maybe your whole system hung and you had to reboot. If such cases, it is good to know that Emacs makes backups of the files that you opened.
To try and recover from the last backup you can use either of the following functions:
recover-file
recover-this-file
The first one will ask you for a file name, and the second one will try to recover the file that is visited by the current buffer. After recovery simply use C-x C-s
to save the file.
From the manual:
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.When
M-x recover-file
asks for confirmation, if you answer withdiff
or=
, it shows the diffs between file and its auto-save file#file#
and reprompts you for confirmation.
Simple, but this has helped me on several occasions.
No Comments