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-filerecover-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-filedisplays 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-filedoes not offer to read it.When
M-x recover-fileasks for confirmation, if you answer withdiffor=, 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