Go to the first, previous, next, last section, table of contents.

Auto-Save Files

Auto-saving does not normally save in the files that you visited, because it can be very undesirable to save a program that is in an inconsistent state when you have made half of a planned change. Instead, auto-saving is done in a different file called the auto-save file, and the visited file is changed only when you request saving explicitly (such as with C-x C-s).

Normally, the auto-save file name is made by appending `#' to the front and rear of the visited file name. Thus, a buffer visiting file `foo.c' is auto-saved in a file `#foo.c#'. Most buffers that are not visiting files are auto-saved only if you request it explicitly; when they are auto-saved, the auto-save file name is made by appending `#%' to the front and `#' to the rear of buffer name. For example, the `*mail*' buffer in which you compose messages to be sent is auto-saved in a file named `#%*mail*#'. Auto-save file names are made this way unless you reprogram parts of Emacs to do something different (the functions make-auto-save-file-name and auto-save-file-name-p). The file name to be used for auto-saving in a buffer is calculated when auto-saving is turned on in that buffer.

When you delete a substantial part of the text in a large buffer, auto save turns off temporarily in that buffer. This is so that if you delete text accidentally, it is likely to remain present in the auto save file. To reenable auto-saving after this happens, simply save the file explicitly with C-x C-s. Using C-u 1 M-x auto-save-mode also cancels this particular state.

If you want auto-saving to be done in the visited file, set the variable auto-save-visited-file-name to be non-nil. In this mode, there is really no difference between auto-saving and explicit saving.

A buffer's auto-save file is deleted when you save the buffer in its visited file. To inhibit this, set the variable delete-auto-save-files to nil. Changing the visited file name with C-x C-w or set-visited-file-name renames any auto-save file to go with the new visited name.

When you delete a large amount of a buffer's text, auto-saving turns off in that buffer. This is because if you deleted the text unintentionally, you might find the auto-save file more useful if it contains the deleted text. To restart auto-saving in that buffer, save the buffer with C-x C-s, or use M-x auto-save.


Go to the first, previous, next, last section, table of contents.