Next: , Previous: , Up: Configuring   [Index]


4.2.5 Configuring Backups

When configured, Emacs saves the old contents of a file you are working on in a backup file before saving the contents of the newly-changed buffer into the file, but only for the first save of the buffer. If you kill the buffer and then visit the file again, a new backup fill will be made upon a new save. However, this behavior can be overridden manually by adding different numbers of ‘C-u’ ‘s when saving.

make-backup-files

Variable that determines whether to make backup files. It’s default value is ‘t’.

backup-directory-alist

Variable that determines where backups should be saved based upon regexps. Emacs creates the directories when necessary. No files are overwritten because of name clashes.

("." . DIR)

make all backups in the directory DIR.

("." . ".")~

make backups in the invisible subdirectory ‘.~’ of the original file’s directory.

save-buffer

Save current buffer in visited file if modified.

These are the possible variations that affect when backups are created::

C-x C-s

save the buffer in its associated file.

C-u C-x C-s

mark the file to be backed up on the next save.

C-u C-u C-x C-s

save the buffer and make a backup file immediately.

C-u C-u C-u C-x C-s

Do both of the above.

M-0 C-x C-s

Never make the previous version into a backup file.

version-control

Variable that determines whether numbered backup files are produced. It can be set globally as well as locally for individual buffers. This variable can also be set according to an environment variable called ‘VERSION_CONTROL’.

when ‘nil

origin value; make numeric backup versions for files that already have some; otherwise not.

when ‘never

never make numeric backup versions.

when ‘t=

make numeric backup versions unconditionally.

Deleting excessive backups

Emacs can save a certain number of old file backups and a certain number of new file backups, deleting the ones in between, using the following two variables:

kept-old-versions

Variable that determines how many oldest versions to keep (default = 2).

kept-new-versions

Variable that determines how many newest versions to keep (default = 2).

delete-old-versions

Variable that determines whether backups will be deleted silently or only upon confirmation.

nil

Emacs queries whether to delete excess backup versions (default);

t

Emacs deletes excess backup files silently.

Dired’s ‘.

(period) command can be used to delete old versions.

make-backup-file-name-function

Holds an elisp procedure to override the usual way Emacs constructs backup file names.


Next: Configuring File Name Completion, Previous: Init File, Up: Configuring   [Index]