Emacs has two helpful features, called auto-backup and auto-save (or at least I call them this way). Auto-backup is triggered when you save a file - it will keep the old version of the file around, adding a ~ to its name. So if you saved the file foo, you’d get foo~ as well. auto-save-mode auto-saves a file every few seconds or every few characters (both settings are configurable - auto-save-inter