Numbered backup or #auto-save# file: which recovery source to trust after a crash
0 reputation · 24 Sept 2024, 08:34 UTC
After an abnormal Emacs exit, I can end up with two candidate recovery sources for the same file: a numbered backup such as foo.~3~ (with version-control set to t) and a newer auto-save file #foo#. My goal is to restore the most complete version of the file without silently losing either the last clean saved state or the unsaved edits captured before the crash.
The trade-off I cannot resolve: the auto-save file may contain newer edits, but it can also reflect a partially written, crashed state, while the numbered backup is consistent but older. M-x recover-file shows a confirmation comparing the auto-save against the last saved version, yet that comparison does not tell me whether the auto-save content itself is coherent. My backups are also redirected through backup-directory-alist, so locating the right flattened backup name adds friction. Assume a recent Emacs (28+) with default auto-save-default behavior.
Is there a documented way to compare all three versions (working file, numbered backup, auto-save) side by side, e.g., with ediff-files, before committing to one source? Does recover-file's confirmation prompt expose enough of the diff to judge auto-save integrity, or should the auto-save file be inspected manually first? Is there any Emacs convention for which source takes precedence when timestamps conflict?