Next: , Previous: , Up: Auto Save   [Contents][Index]


14.5.2 Controlling Auto-Saving

Each time you visit a file, auto-saving is turned on for that file’s buffer if the variable auto-save-default is non-nil (but not in batch mode; see Entering Emacs). The default for this variable is t, so Emacs auto-saves buffers that visit files by default. You can use the command M-x auto-save-mode to turn auto-saving for a buffer on or off. Like other minor mode commands, M-x auto-save-mode turns auto-saving on with a positive argument, off with a zero or negative argument; with no argument, it toggles.

Emacs performs auto-saving periodically based on counting how many characters you have typed since the last time auto-saving happened. The variable auto-save-interval specifies the number of characters between auto-saves. By default, it is 300. Emacs also auto-saves whenever you call the function do-auto-save.

Emacs also does auto-saving whenever it gets a fatal error. This includes killing the Emacs job with a shell command such as kill -emacs, or disconnecting a phone line or network connection.

You can set the number of seconds of idle time before an auto-save is done. Setting the value of the variable auto-save-timeout to zero or nil will disable auto-saving due to idleness.

The actual amount of idle time between auto-saves is logarithmically related to the size of the current buffer. This variable is the number of seconds after which an auto-save will happen when the current buffer is 50k or less; the timeout will be 2 1/4 times this in a 200k buffer, 3 3/4 times this in a 1000k buffer, and 4 1/2 times this in a 2000k buffer.

For this variable to have any effect, you must do (require 'timer).


Next: , Previous: , Up: Auto Save   [Contents][Index]