Variable: auto-save-mode-hook
auto-save-mode-hook is a customizable variable defined in
simple.el.gz.
Value
nil
Documentation
Hook run after entering or leaving auto-save-mode.
No problems result if this variable is not bound.
add-hook automatically binds it. (This is true for all hook variables.)
Source Code
;; Defined in /usr/src/emacs/lisp/simple.el.gz
(define-minor-mode auto-save-mode
"Toggle auto-saving in the current buffer (Auto Save mode).
When this mode is enabled, Emacs periodically saves each file-visiting
buffer in a separate \"auto-save file\". This is a safety measure to
prevent you from losing more than a limited amount of work if the
system crashes.
Auto-saving does not alter the file visited by the buffer: the visited
file is changed only when you request saving it explicitly (such as
with \\[save-buffer]). If you want to save the buffer into its
visited files automatically, use \\[auto-save-visited-mode]).
For more details, see Info node `(emacs) Auto Save'."
:variable ((and buffer-auto-save-file-name
;; If auto-save is off because buffer has shrunk,
;; then toggling should turn it on.
(>= buffer-saved-size 0))
. (lambda (val)
(setq buffer-auto-save-file-name
(cond
((null val) nil)
((and buffer-file-name auto-save-visited-file-name
(not buffer-read-only))
buffer-file-name)
(t (make-auto-save-file-name))))))
;; If -1 was stored here, to temporarily turn off saving,
;; turn it back on.
(and (< buffer-saved-size 0)
(setq buffer-saved-size 0)))