There is a built-in function called autosave that saves after N keystrokes (and maybe after M seconds, I'm not sure). I usually use this if Emacs fails, and not to see what changes I made; itβs better to cancel it. Here is my configuration:
(setq autosave-dir (concat user-emacs-directory "autosaves/") auto-save-list-file-prefix (concat emacs-persistence-directory "autosave-list")) (if (not (file-exists-p autosave-dir)) (make-directory autosave-dir t)) (add-to-list 'auto-save-file-name-transforms `("\\`/?\\([^/]*/\\)*\\([^/]*\\)\\'" ,(concat autosave-dir "\\2") t)) ;; tramp autosaves (setq tramp-auto-save-directory (concat user-emacs-directory "tramp-autosaves/")) (if (not (file-exists-p tramp-auto-save-directory)) (make-directory tramp-auto-save-directory))
There is also a backup system that creates a copy after each save (rather than autosave). I use this for what I think you are asking for β looking at the story since my last VCS. Here is my configuration:
(setq make-backup-files t vc-make-backup-files t version-control t kept-new-versions 256 kept-old-versions 0 delete-old-versions t backup-by-copying t) (setq backup-dir (concat user-emacs-directory "backup/")) (if (not (file-exists-p backup-dir)) (make-directory backup-dir)) (add-to-list 'backup-directory-alist `(".*" . ,backup-dir)) (defun force-backup-of-buffer () (setq buffer-backed-up nil)) (add-hook 'before-save-hook 'force-backup-of-buffer) ;; this is what tramp uses (setq tramp-backup-directory-alist backup-directory-alist) (add-to-path "backup-walker") (autoload 'backup-walker-start "backup-walker" "start walking with the latest backup" t)
I use an excellent backup-walker to navigate through backups.
source share