Skip to content

Instantly share code, notes, and snippets.

@aaronc
Created February 24, 2012 02:14
Show Gist options
  • Save aaronc/1896712 to your computer and use it in GitHub Desktop.
Save aaronc/1896712 to your computer and use it in GitHub Desktop.
A simple minor mode that can be added to emacs to automatically save a file while you are typing.
(define-minor-mode auto-save-mode
"Auto-save mode"
nil " Reload" nil
(if auto-save-mode
;; Edit hook buffer-locally.
(add-hook 'post-command-hook 'auto-save nil t)
(remove-hook 'post-command-hook 'auto-save t)))
(defun auto-save ()
(when (buffer-modified-p)
(save-buffer)))
(provide 'auto-save)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment