1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
<h4 class="subsection">Making Backup Files</h4> <dl> <dt id="backup-buffer">Function: <strong>backup-buffer</strong>
</dt> <dd>
<p>This function makes a backup of the file visited by the current buffer, if appropriate. It is called by <code>save-buffer</code> before saving the buffer the first time. </p> <p>If a backup was made by renaming, the return value is a cons cell of the form (<var>modes</var> <var>extra-alist</var> <var>backupname</var>), where <var>modes</var> are the mode bits of the original file, as returned by <code>file-modes</code> (see <a href="testing-accessibility">Testing Accessibility</a>), <var>extra-alist</var> is an alist describing the original file’s extended attributes, as returned by <code>file-extended-attributes</code> (see <a href="extended-attributes">Extended Attributes</a>), and <var>backupname</var> is the name of the backup. </p> <p>In all other cases (i.e., if a backup was made by copying or if no backup was made), this function returns <code>nil</code>. </p>
</dd>
</dl> <dl> <dt id="buffer-backed-up">Variable: <strong>buffer-backed-up</strong>
</dt> <dd><p>This buffer-local variable says whether this buffer’s file has been backed up on account of this buffer. If it is non-<code>nil</code>, the backup file has been written. Otherwise, the file should be backed up when it is next saved (if backups are enabled). This is a permanent local; <code>kill-all-local-variables</code> does not alter it. </p></dd>
</dl> <dl> <dt id="make-backup-files">User Option: <strong>make-backup-files</strong>
</dt> <dd>
<p>This variable determines whether or not to make backup files. If it is non-<code>nil</code>, then Emacs creates a backup of each file when it is saved for the first time—provided that <code>backup-inhibited</code> is <code>nil</code> (see below). </p> <p>The following example shows how to change the <code>make-backup-files</code> variable only in the Rmail buffers and not elsewhere. Setting it <code>nil</code> stops Emacs from making backups of these files, which may save disk space. (You would put this code in your init file.) </p> <div class="example"> <pre class="example">(add-hook 'rmail-mode-hook
(lambda () (setq-local make-backup-files nil)))
</pre>
</div> </dd>
</dl> <dl> <dt id="backup-enable-predicate">Variable: <strong>backup-enable-predicate</strong>
</dt> <dd>
<p>This variable’s value is a function to be called on certain occasions to decide whether a file should have backup files. The function receives one argument, an absolute file name to consider. If the function returns <code>nil</code>, backups are disabled for that file. Otherwise, the other variables in this section say whether and how to make backups. </p> <p>The default value is <code>normal-backup-enable-predicate</code>, which checks for files in <code>temporary-file-directory</code> and <code>small-temporary-file-directory</code>. </p>
</dd>
</dl> <dl> <dt id="backup-inhibited">Variable: <strong>backup-inhibited</strong>
</dt> <dd>
<p>If this variable is non-<code>nil</code>, backups are inhibited. It records the result of testing <code>backup-enable-predicate</code> on the visited file name. It can also coherently be used by other mechanisms that inhibit backups based on which file is visited. For example, VC sets this variable non-<code>nil</code> to prevent making backups for files managed with a version control system. </p> <p>This is a permanent local, so that changing the major mode does not lose its value. Major modes should not set this variable—they should set <code>make-backup-files</code> instead. </p>
</dd>
</dl> <dl> <dt id="backup-directory-alist">User Option: <strong>backup-directory-alist</strong>
</dt> <dd>
<p>This variable’s value is an alist of filename patterns and backup directories. Each element looks like </p>
<div class="example"> <pre class="example">(<var>regexp</var> . <var>directory</var>)
</pre>
</div> <p>Backups of files with names matching <var>regexp</var> will be made in <var>directory</var>. <var>directory</var> may be relative or absolute. If it is absolute, so that all matching files are backed up into the same directory, the file names in this directory will be the full name of the file backed up with all directory separators changed to ‘<samp>!</samp>’ to prevent clashes. This will not work correctly if your filesystem truncates the resulting name. </p> <p>For the common case of all backups going into one directory, the alist should contain a single element pairing ‘<samp>"."</samp>’ with the appropriate directory. </p> <p>If this variable is <code>nil</code> (the default), or it fails to match a filename, the backup is made in the original file’s directory. </p> <p>On MS-DOS filesystems without long names this variable is always ignored. </p>
</dd>
</dl> <dl> <dt id="make-backup-file-name-function">User Option: <strong>make-backup-file-name-function</strong>
</dt> <dd>
<p>This variable’s value is a function to use for making backup file names. The function <code>make-backup-file-name</code> calls it. See <a href="backup-names">Naming Backup Files</a>. </p> <p>This could be buffer-local to do something special for specific files. If you change it, you may need to change <code>backup-file-name-p</code> and <code>file-name-sans-versions</code> too. </p>
</dd>
</dl><div class="_attribution">
<p class="_attribution-p">
Copyright © 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br>
<a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Making-Backups.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Making-Backups.html</a>
</p>
</div>
|