GNU Emacs Manual. Node: Auto Save Files

prev UPAuto Save NEXTAuto Save Control

12.5.1: 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 because if you deleted the text unintentionally, you might find the auto-save file more useful if it contains the deleted text. To reenable auto-saving after this happens, save the buffer with C-x C-s, or use C-u 1 M-x auto-save.

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.

prev UPAuto Save NEXTAuto Save Control