diff options
| -rw-r--r-- | doc/emacs/files.texi | 600 |
1 files changed, 277 insertions, 323 deletions
diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi index 3227a71386c..b21947619cf 100644 --- a/doc/emacs/files.texi +++ b/doc/emacs/files.texi | |||
| @@ -48,106 +48,82 @@ on file directories. | |||
| 48 | @section File Names | 48 | @section File Names |
| 49 | @cindex file names | 49 | @cindex file names |
| 50 | 50 | ||
| 51 | Most Emacs commands that operate on a file require you to specify the | 51 | Many Emacs commands that operate on a file require you to specify |
| 52 | file name. (Saving and reverting are exceptions; the buffer knows which | 52 | the file name, using the minibuffer (@pxref{Minibuffer}). You can use |
| 53 | file name to use for them.) You enter the file name using the | 53 | @dfn{completion} to specify long file names (@pxref{Completion}). |
| 54 | minibuffer (@pxref{Minibuffer}). @dfn{Completion} is available | 54 | Note that file name completion ignores file names whose extensions |
| 55 | (@pxref{Completion}) to make it easier to specify long file names. When | 55 | appear in the variable @code{completion-ignored-extensions} |
| 56 | completing file names, Emacs ignores those whose file-name extensions | 56 | (@pxref{Completion Options}). |
| 57 | appear in the variable @code{completion-ignored-extensions}; see | 57 | |
| 58 | @ref{Completion Options}. | 58 | For most operations, there is a @dfn{default file name} which is |
| 59 | 59 | used if you type just @key{RET} to enter an empty argument. Normally, | |
| 60 | For most operations, there is a @dfn{default file name} which is used | 60 | the default file name is the name of the file visited in the current |
| 61 | if you type just @key{RET} to enter an empty argument. Normally the | 61 | buffer. |
| 62 | default file name is the name of the file visited in the current buffer; | ||
| 63 | this makes it easy to operate on that file with any of the Emacs file | ||
| 64 | commands. | ||
| 65 | 62 | ||
| 66 | @vindex default-directory | 63 | @vindex default-directory |
| 67 | Each buffer has a default directory which is normally the same as the | 64 | @vindex insert-default-directory |
| 68 | directory of the file visited in that buffer. When you enter a file | 65 | Each buffer has a @dfn{default directory} which is normally the same |
| 69 | name without a directory, the default directory is used. If you specify | 66 | as the directory of the file visited in that buffer. For example, if |
| 70 | a directory in a relative fashion, with a name that does not start with | 67 | the default file name is @file{/u/rms/gnu/gnu.tasks}, the default |
| 71 | a slash, it is interpreted with respect to the default directory. The | 68 | directory is normally @file{/u/rms/gnu/}. The default directory is |
| 72 | default directory is kept in the variable @code{default-directory}, | 69 | kept in the variable @code{default-directory}, which has a separate |
| 73 | which has a separate value in every buffer. | 70 | value in every buffer. When a command reads a file name using the |
| 71 | minibuffer, the default directory usually serves as the initial | ||
| 72 | contents of the minibuffer. To inhibit the insertion of the default | ||
| 73 | directory, set the variable @code{insert-default-directory} to | ||
| 74 | @code{nil}. | ||
| 74 | 75 | ||
| 75 | @findex cd | 76 | If you enter a file name without a directory, that specifies a file |
| 76 | @findex pwd | 77 | in the default directory. If you specify a directory in a relative |
| 77 | The command @kbd{M-x pwd} displays the current buffer's default | 78 | fashion, with a name that does not start with a slash, it is |
| 78 | directory, and the command @kbd{M-x cd} sets it (to a value read using | 79 | interpreted with respect to the default directory. For example, |
| 79 | the minibuffer). A buffer's default directory changes only when the | 80 | suppose the default directory is @file{/u/rms/gnu/}. Entering just |
| 80 | @code{cd} command is used. A file-visiting buffer's default directory | 81 | @samp{foo} in the minibuffer, with a directory omitted, specifies the |
| 81 | is initialized to the directory of the file it visits. If you create | 82 | file @file{/u/rms/gnu/foo}; entering @samp{../.login} specifies |
| 82 | a buffer with @kbd{C-x b}, its default directory is copied from that | 83 | @file{/u/rms/.login}; and entering @samp{new/foo} specifies |
| 83 | of the buffer that was current at the time. | ||
| 84 | |||
| 85 | For example, if the default file name is @file{/u/rms/gnu/gnu.tasks} | ||
| 86 | then the default directory is normally @file{/u/rms/gnu/}. If you | ||
| 87 | type just @samp{foo}, which does not specify a directory, it is short | ||
| 88 | for @file{/u/rms/gnu/foo}. @samp{../.login} would stand for | ||
| 89 | @file{/u/rms/.login}. @samp{new/foo} would stand for the file name | ||
| 90 | @file{/u/rms/gnu/new/foo}. | 84 | @file{/u/rms/gnu/new/foo}. |
| 91 | 85 | ||
| 92 | @vindex insert-default-directory | 86 | When typing a file name into the minibuffer, you can make use of a |
| 93 | The default directory actually appears in the minibuffer when the | 87 | couple of shortcuts: a double slash is interpreted as ``ignore |
| 94 | minibuffer becomes active to read a file name. This serves two | 88 | everything before the second slash in the pair,'' and @samp{~/} is |
| 95 | purposes: it @emph{shows} you what the default is, so that you can type | 89 | interpreted as your home directory. @xref{Minibuffer File}, for more |
| 96 | a relative file name and know with certainty what it will mean, and it | 90 | information about these shortcuts. |
| 97 | allows you to @emph{edit} the default to specify a different directory. | 91 | |
| 98 | This insertion of the default directory is inhibited if the variable | 92 | @findex cd |
| 99 | @code{insert-default-directory} is set to @code{nil}. | 93 | @findex pwd |
| 100 | 94 | The command @kbd{M-x pwd} displays the default directory, and the | |
| 101 | Note that it is legitimate to type an absolute file name after you | 95 | command @kbd{M-x cd} sets it to a value read using the minibuffer. A |
| 102 | enter the minibuffer, ignoring the presence of the default directory | 96 | buffer's default directory changes only when the @code{cd} command is |
| 103 | name as part of the text. The final minibuffer contents may look | 97 | used. A file-visiting buffer's default directory is initialized to |
| 104 | invalid, but that is not so. For example, if the minibuffer starts out | 98 | the directory of the file it visits. If you create a buffer with |
| 105 | with @samp{/usr/tmp/} and you add @samp{/x1/rms/foo}, you get | 99 | @kbd{C-x b}, its default directory is copied from that of the buffer |
| 106 | @samp{/usr/tmp//x1/rms/foo}; but Emacs ignores everything through the | 100 | that was current at the time (@pxref{Select Buffer}). |
| 107 | first slash in the double slash; the result is @samp{/x1/rms/foo}. | ||
| 108 | @xref{Minibuffer File}. | ||
| 109 | |||
| 110 | @cindex home directory shorthand | ||
| 111 | You can use @file{~/} in a file name to mean your home directory, | ||
| 112 | or @file{~@var{user-id}/} to mean the home directory of a user whose | ||
| 113 | login name is @code{user-id}@footnote{ | ||
| 114 | On MS-Windows and MS-DOS systems, where a user doesn't have a home | ||
| 115 | directory, Emacs replaces @file{~/} with the value of the | ||
| 116 | environment variable @code{HOME}; see @ref{General Variables}. On | ||
| 117 | these systems, the @file{~@var{user-id}/} construct is supported only | ||
| 118 | for the current user, i.e., only if @var{user-id} is the current | ||
| 119 | user's login name.}. | ||
| 120 | 101 | ||
| 121 | @cindex environment variables in file names | 102 | @cindex environment variables in file names |
| 122 | @cindex expansion of environment variables | 103 | @cindex expansion of environment variables |
| 123 | @cindex @code{$} in file names | 104 | @cindex @code{$} in file names |
| 124 | @anchor{File Names with $}@samp{$} in a file name is used to | 105 | @anchor{File Names with $}The character @samp{$} is used to |
| 125 | substitute an environment variable. The environment variable name | 106 | substitute an environment variable into a file name. The name of the |
| 126 | consists of all the alphanumeric characters after the @samp{$}; | 107 | environment variable consists of all the alphanumeric characters after |
| 127 | alternatively, it can be enclosed in braces after the @samp{$}. For | 108 | the @samp{$}; alternatively, it can be enclosed in braces after the |
| 128 | example, if you have used the shell command @command{export | 109 | @samp{$}. For example, if you have used the shell command |
| 129 | FOO=rms/hacks} to set up an environment variable named @env{FOO}, then | 110 | @command{export FOO=rms/hacks} to set up an environment variable named |
| 130 | you can use @file{/u/$FOO/test.c} or @file{/u/$@{FOO@}/test.c} as an | 111 | @env{FOO}, then both @file{/u/$FOO/test.c} and |
| 131 | abbreviation for @file{/u/rms/hacks/test.c}. If the environment | 112 | @file{/u/$@{FOO@}/test.c} are abbreviations for |
| 132 | variable is not defined, no substitution occurs: @file{/u/$notdefined} | 113 | @file{/u/rms/hacks/test.c}. If the environment variable is not |
| 133 | stands for itself (assuming the environment variable @env{notdefined} | 114 | defined, no substitution occurs, so that the character @samp{$} stands |
| 134 | is not defined). | 115 | for itself. |
| 135 | 116 | ||
| 136 | Note that shell commands to set environment variables affect Emacs | 117 | Note that environment variables affect Emacs only if they are |
| 137 | only when done before Emacs is started. | 118 | applied before Emacs is started. |
| 138 | 119 | ||
| 139 | To access a file with @samp{$} in its name, if the @samp{$} causes | 120 | To access a file with @samp{$} in its name, if the @samp{$} causes |
| 140 | expansion, type @samp{$$}. This pair is converted to a single | 121 | expansion, type @samp{$$}. This pair is converted to a single |
| 141 | @samp{$} at the same time as variable substitution is performed for a | 122 | @samp{$} at the same time that variable substitution is performed for |
| 142 | single @samp{$}. Alternatively, quote the whole file name with | 123 | a single @samp{$}. Alternatively, quote the whole file name with |
| 143 | @samp{/:} (@pxref{Quoted File Names}). File names which begin with a | 124 | @samp{/:} (@pxref{Quoted File Names}). File names which begin with a |
| 144 | literal @samp{~} should also be quoted with @samp{/:}. | 125 | literal @samp{~} should also be quoted with @samp{/:}. |
| 145 | 126 | ||
| 146 | @findex substitute-in-file-name | ||
| 147 | The Lisp function that performs the @samp{$}-substitution is called | ||
| 148 | @code{substitute-in-file-name}. The substitution is performed only on | ||
| 149 | file names read as such using the minibuffer. | ||
| 150 | |||
| 151 | You can include non-@acronym{ASCII} characters in file names if you set the | 127 | You can include non-@acronym{ASCII} characters in file names if you set the |
| 152 | variable @code{file-name-coding-system} to a non-@code{nil} value. | 128 | variable @code{file-name-coding-system} to a non-@code{nil} value. |
| 153 | @xref{File Name Coding}. | 129 | @xref{File Name Coding}. |
| @@ -180,48 +156,44 @@ Visit a file with no conversion of the contents. | |||
| 180 | @cindex saving files | 156 | @cindex saving files |
| 181 | @dfn{Visiting} a file means reading its contents into an Emacs | 157 | @dfn{Visiting} a file means reading its contents into an Emacs |
| 182 | buffer so you can edit them. Emacs makes a new buffer for each file | 158 | buffer so you can edit them. Emacs makes a new buffer for each file |
| 183 | that you visit. We often say that this buffer ``is visiting'' that | 159 | that you visit. |
| 184 | file, or that the buffer's ``visited file'' is that file. Emacs | 160 | |
| 185 | constructs the buffer name from the file name by throwing away the | 161 | Emacs normally constructs the buffer name from the file name, |
| 186 | directory, keeping just the name proper. For example, a file named | 162 | omitting the directory name. For example, a file named |
| 187 | @file{/usr/rms/emacs.tex} would get a buffer named @samp{emacs.tex}. | 163 | @file{/usr/rms/emacs.tex} is visited in a buffer named |
| 188 | If there is already a buffer with that name, Emacs constructs a unique | 164 | @samp{emacs.tex}. If there is already a buffer with that name, Emacs |
| 189 | name---the normal method is to append @samp{<2>}, @samp{<3>}, and so | 165 | constructs a unique name; the normal method is to append @samp{<2>}, |
| 190 | on, but you can select other methods (@pxref{Uniquify}). | 166 | @samp{<3>}, and so on, but you can select other methods. |
| 191 | 167 | @xref{Uniquify}. | |
| 192 | Each window's mode line shows the name of the buffer that is being displayed | 168 | |
| 193 | in that window, so you can always tell what buffer you are editing. | 169 | Each window's mode line shows the name of the buffer that is being |
| 170 | displayed in that window, so you can always tell what buffer you are | ||
| 171 | editing. @pxref{Mode Line}. | ||
| 194 | 172 | ||
| 195 | The changes you make with editing commands are made in the Emacs | 173 | The changes you make with editing commands are made in the Emacs |
| 196 | buffer. They do not take effect in the file that you visited, or any | 174 | buffer. They do not take effect in the file that you visited, or any |
| 197 | permanent place, until you @dfn{save} the buffer. Saving the buffer | 175 | permanent place, until you @dfn{save} the buffer (@pxref{Saving}). |
| 198 | means that Emacs writes the current contents of the buffer into its | ||
| 199 | visited file. @xref{Saving}. | ||
| 200 | 176 | ||
| 201 | @cindex modified (buffer) | 177 | @cindex modified (buffer) |
| 202 | If a buffer contains changes that have not been saved, we say the | 178 | If a buffer contains changes that have not been saved, we say the |
| 203 | buffer is @dfn{modified}. This is important because it implies that | 179 | buffer is @dfn{modified}. This implies that some changes will be lost |
| 204 | some changes will be lost if the buffer is not saved. The mode line | 180 | if the buffer is not saved. The mode line displays two stars near the |
| 205 | displays two stars near the left margin to indicate that the buffer is | 181 | left margin to indicate that the buffer is modified. |
| 206 | modified. | ||
| 207 | 182 | ||
| 208 | @kindex C-x C-f | 183 | @kindex C-x C-f |
| 209 | @findex find-file | 184 | @findex find-file |
| 210 | To visit a file, use the command @kbd{C-x C-f} (@code{find-file}). Follow | 185 | To visit a file, type @kbd{C-x C-f} (@code{find-file}) and use the |
| 211 | the command with the name of the file you wish to visit, terminated by a | 186 | minibuffer to enter the name of the desired file. The usual |
| 212 | @key{RET}. | 187 | defaulting and completion behavior is available in this minibuffer |
| 213 | 188 | (@pxref{Minibuffer File}). Note, also, that completion ignores | |
| 214 | The file name is read using the minibuffer (@pxref{Minibuffer}), with | 189 | certain file names (@pxref{Completion Options}). While in the |
| 215 | defaulting and completion in the standard manner (@pxref{File Names}). | 190 | minibuffer, you can abort @kbd{C-x C-f} by typing @kbd{C-g}. |
| 216 | While in the minibuffer, you can abort @kbd{C-x C-f} by typing | 191 | |
| 217 | @kbd{C-g}. File-name completion ignores certain file names; for more | 192 | Your can tell that @kbd{C-x C-f} has completed successfully by the |
| 218 | about this, see @ref{Completion Options}. | 193 | appearance of new text on the screen and a new buffer name in the mode |
| 219 | 194 | line. If the specified file does not exist and you could not create | |
| 220 | Your confirmation that @kbd{C-x C-f} has completed successfully is | 195 | it, or exists but you can't read it, an error message is displayed in |
| 221 | the appearance of new text on the screen and a new buffer name in the | 196 | the echo area. |
| 222 | mode line. If the specified file does not exist and you could not | ||
| 223 | create it, or exists but you can't read it, then you get an error, | ||
| 224 | with an error message displayed in the echo area. | ||
| 225 | 197 | ||
| 226 | If you visit a file that is already in Emacs, @kbd{C-x C-f} does not make | 198 | If you visit a file that is already in Emacs, @kbd{C-x C-f} does not make |
| 227 | another copy. It selects the existing buffer containing that file. | 199 | another copy. It selects the existing buffer containing that file. |
| @@ -233,72 +205,70 @@ to reread it. | |||
| 233 | @cindex maximum buffer size exceeded, error message | 205 | @cindex maximum buffer size exceeded, error message |
| 234 | If you try to visit a file larger than | 206 | If you try to visit a file larger than |
| 235 | @code{large-file-warning-threshold} (the default is 10000000, which is | 207 | @code{large-file-warning-threshold} (the default is 10000000, which is |
| 236 | about 10 megabytes), Emacs will ask you for confirmation first. You | 208 | about 10 megabytes), Emacs asks you for confirmation first. You can |
| 237 | can answer @kbd{y} to proceed with visiting the file. Note, however, | 209 | answer @kbd{y} to proceed with visiting the file. Note, however, that |
| 238 | that Emacs cannot visit files that are larger than the maximum Emacs | 210 | Emacs cannot visit files that are larger than the maximum Emacs buffer |
| 239 | buffer size, which is around 256 megabytes on 32-bit machines | 211 | size, which is around 256 megabytes on 32-bit machines |
| 240 | (@pxref{Buffers}). If you try, Emacs will display an error message | 212 | (@pxref{Buffers}). If you try, Emacs will display an error message |
| 241 | saying that the maximum buffer size has been exceeded. | 213 | saying that the maximum buffer size has been exceeded. |
| 242 | 214 | ||
| 215 | @cindex wildcard characters in file names | ||
| 216 | @vindex find-file-wildcards | ||
| 217 | If the file name you specify contains shell-style wildcard | ||
| 218 | characters, Emacs visits all the files that match it. (On | ||
| 219 | case-insensitive filesystems, Emacs matches the wildcards disregarding | ||
| 220 | the letter case.) Wildcards include @samp{?}, @samp{*}, and | ||
| 221 | @samp{[@dots{}]} sequences. To enter the wild card @samp{?} in a file | ||
| 222 | name in the minibuffer, you need to type @kbd{C-q ?}. @xref{Quoted | ||
| 223 | File Names}, for information on how to visit a file whose name | ||
| 224 | actually contains wildcard characters. You can disable the wildcard | ||
| 225 | feature by customizing @code{find-file-wildcards}. | ||
| 226 | |||
| 243 | @cindex file selection dialog | 227 | @cindex file selection dialog |
| 244 | On graphical displays there are two additional methods for | 228 | On graphical displays, there are two additional methods for visiting |
| 245 | visiting files. Firstly, when Emacs is built with a suitable GUI | 229 | files. Firstly, when Emacs is built with a suitable GUI toolkit, |
| 246 | toolkit, commands invoked with the mouse (by clicking on the menu bar | 230 | commands invoked with the mouse (by clicking on the menu bar or tool |
| 247 | or tool bar) use the toolkit's standard File Selection dialog instead | 231 | bar) use the toolkit's standard ``File Selection'' dialog instead of |
| 248 | of prompting for the file name in the minibuffer. On Unix and | 232 | prompting for the file name in the minibuffer. On GNU/Linux and Unix |
| 249 | GNU/Linux platforms, Emacs does that when built with GTK, LessTif, and | 233 | platforms, Emacs does this when built with GTK, LessTif, and Motif |
| 250 | Motif toolkits; on MS-Windows and Mac, the GUI version does that by default. | 234 | toolkits; on MS-Windows and Mac, the GUI version does that by default. |
| 251 | For information on how to customize this, see @ref{Dialog Boxes}. | 235 | For information on how to customize this, see @ref{Dialog Boxes}. |
| 252 | 236 | ||
| 253 | Secondly, Emacs supports ``drag and drop''; dropping a file into an | 237 | Secondly, Emacs supports ``drag and drop'': dropping a file into an |
| 254 | ordinary Emacs window visits the file using that window. However, | 238 | ordinary Emacs window visits the file using that window. As an |
| 255 | dropping a file into a window displaying a Dired buffer moves or | 239 | exception, dropping a file into a window displaying a Dired buffer |
| 256 | copies the file into the displayed directory. For details, see | 240 | moves or copies the file into the displayed directory. For details, |
| 257 | @ref{Drag and Drop}, and @ref{Misc Dired Features}. | 241 | see @ref{Drag and Drop}, and @ref{Misc Dired Features}. |
| 258 | 242 | ||
| 259 | @cindex creating files | 243 | @cindex creating files |
| 260 | What if you want to create a new file? Just visit it. Emacs displays | 244 | What if you want to create a new file? Just visit it. Emacs |
| 261 | @samp{(New file)} in the echo area, but in other respects behaves as if | 245 | displays @samp{(New file)} in the echo area, but in other respects |
| 262 | you had visited an existing empty file. If you make any changes and | 246 | behaves as if you had visited an existing empty file. If you make |
| 263 | save them, the file is created. | 247 | changes and save them, the file is created. |
| 264 | 248 | ||
| 265 | Emacs recognizes from the contents of a file which end-of-line | 249 | @kindex C-x C-v |
| 266 | convention it uses to separate lines---newline (used on GNU/Linux and | 250 | @findex find-alternate-file |
| 267 | on Unix), carriage-return linefeed (used on Microsoft systems), or | 251 | If you visit a nonexistent file unintentionally (because you typed |
| 268 | just carriage-return (used on the Macintosh)---and automatically | 252 | the wrong file name), type @kbd{C-x C-v} (@code{find-alternate-file}) |
| 269 | converts the contents to the normal Emacs convention, which is that | 253 | to visit the file you really wanted. @kbd{C-x C-v} is similar to |
| 270 | the newline character separates lines. This is a part of the general | 254 | @kbd{C-x C-f}, but it kills the current buffer (after first offering |
| 271 | feature of coding system conversion (@pxref{Coding Systems}), and | 255 | to save it if it is modified). When @kbd{C-x C-v} reads the file name |
| 272 | makes it possible to edit files imported from different operating | 256 | to visit, it inserts the entire default file name in the buffer, with |
| 273 | systems with equal convenience. If you change the text and save the | 257 | point just after the directory part; this is convenient if you made a |
| 274 | file, Emacs performs the inverse conversion, changing newlines back | 258 | slight error in typing the name. |
| 275 | into carriage-return linefeed or just carriage-return if appropriate. | ||
| 276 | 259 | ||
| 277 | @vindex find-file-run-dired | 260 | @vindex find-file-run-dired |
| 278 | If the file you specify is actually a directory, @kbd{C-x C-f} invokes | 261 | If you ``visit'' a file that is actually a directory, Emacs invokes |
| 279 | Dired, the Emacs directory browser, so that you can ``edit'' the contents | 262 | Dired, the Emacs directory browser; this lets you you ``edit'' the |
| 280 | of the directory (@pxref{Dired}). Dired is a convenient way to view, delete, | 263 | contents of the directory. @xref{Dired}. You can disable this |
| 281 | or operate on the files in the directory. However, if the variable | 264 | behavior by setting the variable @code{find-file-run-dired} to |
| 282 | @code{find-file-run-dired} is @code{nil}, then it is an error to try | 265 | @code{nil}; in that case, it is an error to try to visit a directory. |
| 283 | to visit a directory. | ||
| 284 | 266 | ||
| 285 | Files which are actually collections of other files, or @dfn{file | 267 | Files which are actually collections of other files, or @dfn{file |
| 286 | archives}, are visited in special modes which invoke a Dired-like | 268 | archives}, are visited in special modes which invoke a Dired-like |
| 287 | environment to allow operations on archive members. @xref{File | 269 | environment to allow operations on archive members. @xref{File |
| 288 | Archives}, for more about these features. | 270 | Archives}, for more about these features. |
| 289 | 271 | ||
| 290 | @cindex wildcard characters in file names | ||
| 291 | @vindex find-file-wildcards | ||
| 292 | If the file name you specify contains shell-style wildcard | ||
| 293 | characters, Emacs visits all the files that match it. (On | ||
| 294 | case-insensitive filesystems, Emacs matches the wildcards disregarding | ||
| 295 | the letter case.) Wildcards include @samp{?}, @samp{*}, and | ||
| 296 | @samp{[@dots{}]} sequences. To enter the wild card @samp{?} in a file | ||
| 297 | name in the minibuffer, you need to type @kbd{C-q ?}. @xref{Quoted | ||
| 298 | File Names}, for information on how to visit a file whose name | ||
| 299 | actually contains wildcard characters. You can disable the wildcard | ||
| 300 | feature by customizing @code{find-file-wildcards}. | ||
| 301 | |||
| 302 | If you visit a file that the operating system won't let you modify, | 272 | If you visit a file that the operating system won't let you modify, |
| 303 | or that is marked read-only, Emacs makes the buffer read-only too, so | 273 | or that is marked read-only, Emacs makes the buffer read-only too, so |
| 304 | that you won't go ahead and make changes that you'll have trouble | 274 | that you won't go ahead and make changes that you'll have trouble |
| @@ -311,17 +281,6 @@ saving afterward. You can make the buffer writable with @kbd{C-x C-q} | |||
| 311 | yourself from entering changes accidentally, visit it with the command | 281 | yourself from entering changes accidentally, visit it with the command |
| 312 | @kbd{C-x C-r} (@code{find-file-read-only}) instead of @kbd{C-x C-f}. | 282 | @kbd{C-x C-r} (@code{find-file-read-only}) instead of @kbd{C-x C-f}. |
| 313 | 283 | ||
| 314 | @kindex C-x C-v | ||
| 315 | @findex find-alternate-file | ||
| 316 | If you visit a nonexistent file unintentionally (because you typed the | ||
| 317 | wrong file name), use the @kbd{C-x C-v} command | ||
| 318 | (@code{find-alternate-file}) to visit the file you really wanted. | ||
| 319 | @kbd{C-x C-v} is similar to @kbd{C-x C-f}, but it kills the current | ||
| 320 | buffer (after first offering to save it if it is modified). When | ||
| 321 | @kbd{C-x C-v} reads the file name to visit, it inserts the entire | ||
| 322 | default file name in the buffer, with point just after the directory | ||
| 323 | part; this is convenient if you made a slight error in typing the name. | ||
| 324 | |||
| 325 | @kindex C-x 4 f | 284 | @kindex C-x 4 f |
| 326 | @findex find-file-other-window | 285 | @findex find-file-other-window |
| 327 | @kbd{C-x 4 f} (@code{find-file-other-window}) is like @kbd{C-x C-f} | 286 | @kbd{C-x 4 f} (@code{find-file-other-window}) is like @kbd{C-x C-f} |
| @@ -339,15 +298,28 @@ new frame, or makes visible any existing frame showing the file you | |||
| 339 | seek. This feature is available only when you are using a window | 298 | seek. This feature is available only when you are using a window |
| 340 | system. @xref{Frames}. | 299 | system. @xref{Frames}. |
| 341 | 300 | ||
| 301 | Emacs recognizes from the contents of a file which end-of-line | ||
| 302 | convention it uses to separate lines---newline (used on GNU/Linux and | ||
| 303 | on Unix), carriage-return linefeed (used on Microsoft systems), or | ||
| 304 | just carriage-return (used on the Macintosh)---and automatically | ||
| 305 | converts the contents to the normal Emacs convention, which is that | ||
| 306 | the newline character separates lines. This is a part of the general | ||
| 307 | feature of coding system conversion (@pxref{Coding Systems}), and | ||
| 308 | makes it possible to edit files imported from different operating | ||
| 309 | systems with equal convenience. If you change the text and save the | ||
| 310 | file, Emacs performs the inverse conversion, changing newlines back | ||
| 311 | into carriage-return linefeed or just carriage-return if appropriate. | ||
| 312 | |||
| 342 | @findex find-file-literally | 313 | @findex find-file-literally |
| 343 | If you wish to edit a file as a sequence of @acronym{ASCII} characters with no special | 314 | If you wish to edit a file as a sequence of @acronym{ASCII} |
| 344 | encoding or conversion, use the @kbd{M-x find-file-literally} command. | 315 | characters with no special encoding or conversion, use the @kbd{M-x |
| 345 | It visits a file, like @kbd{C-x C-f}, but does not do format conversion | 316 | find-file-literally} command. This visits a file, like @kbd{C-x C-f}, |
| 346 | (@pxref{Formatted Text}), character code conversion (@pxref{Coding | 317 | but does not do format conversion (@pxref{Formatted Text}), character |
| 347 | Systems}), or automatic uncompression (@pxref{Compressed Files}), and | 318 | code conversion (@pxref{Coding Systems}), or automatic uncompression |
| 348 | does not add a final newline because of @code{require-final-newline}. | 319 | (@pxref{Compressed Files}), and does not add a final newline because |
| 349 | If you already have visited the same file in the usual (non-literal) | 320 | of @code{require-final-newline} (@pxref{Customize Save}). If you have |
| 350 | manner, this command asks you whether to visit it literally instead. | 321 | already visited the same file in the usual (non-literal) manner, this |
| 322 | command asks you whether to visit it literally instead. | ||
| 351 | 323 | ||
| 352 | @vindex find-file-hook | 324 | @vindex find-file-hook |
| 353 | @vindex find-file-not-found-functions | 325 | @vindex find-file-not-found-functions |
| @@ -423,6 +395,9 @@ like this in the echo area: | |||
| 423 | (No changes need to be saved) | 395 | (No changes need to be saved) |
| 424 | @end example | 396 | @end example |
| 425 | 397 | ||
| 398 | With a prefix argument, @kbd{C-u C-x C-s}, Emacs also marks the buffer | ||
| 399 | to be backed up when the next save is done. @xref{Backup}. | ||
| 400 | |||
| 426 | @kindex C-x s | 401 | @kindex C-x s |
| 427 | @findex save-some-buffers | 402 | @findex save-some-buffers |
| 428 | The command @kbd{C-x s} (@code{save-some-buffers}) offers to save any | 403 | The command @kbd{C-x s} (@code{save-some-buffers}) offers to save any |
| @@ -458,21 +433,19 @@ Display a help message about these options. | |||
| 458 | 433 | ||
| 459 | @kindex M-~ | 434 | @kindex M-~ |
| 460 | @findex not-modified | 435 | @findex not-modified |
| 461 | If you have changed a buffer but you do not want to save the changes, | 436 | If you have changed a buffer but do not wish to save the changes, |
| 462 | you should take some action to prevent it. Otherwise, each time you use | 437 | you should take some action to prevent it. Otherwise, each time you |
| 463 | @kbd{C-x s} or @kbd{C-x C-c}, you are liable to save this buffer by | 438 | use @kbd{C-x s} or @kbd{C-x C-c}, you are liable to save this buffer |
| 464 | mistake. One thing you can do is type @kbd{M-~} (@code{not-modified}), | 439 | by mistake. One thing you can do is type @kbd{M-~} |
| 465 | which clears out the indication that the buffer is modified. If you do | 440 | (@code{not-modified}), which clears out the indication that the buffer |
| 466 | this, none of the save commands will believe that the buffer needs to be | 441 | is modified. If you do this, none of the save commands will believe |
| 467 | saved. (@samp{~} is often used as a mathematical symbol for `not'; thus | 442 | that the buffer needs to be saved. (@samp{~} is often used as a |
| 468 | @kbd{M-~} is `not', metafied.) You could also use | 443 | mathematical symbol for `not'; thus @kbd{M-~} is `not', metafied.) |
| 469 | @code{set-visited-file-name} (see below) to mark the buffer as visiting | ||
| 470 | a different file name, one which is not in use for anything important. | ||
| 471 | Alternatively, you can cancel all the changes made since the file was | 444 | Alternatively, you can cancel all the changes made since the file was |
| 472 | visited or saved, by reading the text from the file again. This is | 445 | visited or saved, by reading the text from the file again. This is |
| 473 | called @dfn{reverting}. @xref{Reverting}. (You could also undo all the | 446 | called @dfn{reverting}. @xref{Reverting}. (You could also undo all |
| 474 | changes by repeating the undo command @kbd{C-x u} until you have undone | 447 | the changes by repeating the undo command @kbd{C-x u} until you have |
| 475 | all the changes; but reverting is easier.) You can also kill the buffer. | 448 | undone all the changes; but reverting is easier.) |
| 476 | 449 | ||
| 477 | @findex set-visited-file-name | 450 | @findex set-visited-file-name |
| 478 | @kbd{M-x set-visited-file-name} alters the name of the file that the | 451 | @kbd{M-x set-visited-file-name} alters the name of the file that the |
| @@ -486,15 +459,15 @@ buffer as ``modified'' so that @kbd{C-x C-s} in that buffer | |||
| 486 | 459 | ||
| 487 | @kindex C-x C-w | 460 | @kindex C-x C-w |
| 488 | @findex write-file | 461 | @findex write-file |
| 489 | If you wish to mark the buffer as visiting a different file and save it | 462 | If you wish to mark the buffer as visiting a different file and save |
| 490 | right away, use @kbd{C-x C-w} (@code{write-file}). It is | 463 | it right away, use @kbd{C-x C-w} (@code{write-file}). This is |
| 491 | equivalent to @code{set-visited-file-name} followed by @kbd{C-x C-s} | 464 | equivalent to @code{set-visited-file-name} followed by @kbd{C-x C-s}, |
| 492 | (except that @kbd{C-x C-w} asks for confirmation if the file exists). | 465 | except that @kbd{C-x C-w} asks for confirmation if the file exists. |
| 493 | @kbd{C-x C-s} used on a buffer that is not visiting a file has the | 466 | @kbd{C-x C-s} used on a buffer that is not visiting a file has the |
| 494 | same effect as @kbd{C-x C-w}; that is, it reads a file name, marks the | 467 | same effect as @kbd{C-x C-w}; that is, it reads a file name, marks the |
| 495 | buffer as visiting that file, and saves it there. The default file name in | 468 | buffer as visiting that file, and saves it there. The default file |
| 496 | a buffer that is not visiting a file is made by combining the buffer name | 469 | name in a buffer that is not visiting a file is made by combining the |
| 497 | with the buffer's default directory (@pxref{File Names}). | 470 | buffer name with the buffer's default directory (@pxref{File Names}). |
| 498 | 471 | ||
| 499 | If the new file name implies a major mode, then @kbd{C-x C-w} switches | 472 | If the new file name implies a major mode, then @kbd{C-x C-w} switches |
| 500 | to that major mode, in most cases. The command | 473 | to that major mode, in most cases. The command |
| @@ -518,6 +491,11 @@ throws away the old contents of the file---or it would, except that | |||
| 518 | Emacs carefully copies the old contents to another file, called the | 491 | Emacs carefully copies the old contents to another file, called the |
| 519 | @dfn{backup} file, before actually saving. | 492 | @dfn{backup} file, before actually saving. |
| 520 | 493 | ||
| 494 | Emacs makes a backup for a file only the first time the file is | ||
| 495 | saved from a buffer. No matter how many times you subsequently save | ||
| 496 | the file, its backup remains unchanged. However, if you kill the | ||
| 497 | buffer and then visit the file again, a new backup file will be made. | ||
| 498 | |||
| 521 | For most files, the variable @code{make-backup-files} determines | 499 | For most files, the variable @code{make-backup-files} determines |
| 522 | whether to make backup files. On most operating systems, its default | 500 | whether to make backup files. On most operating systems, its default |
| 523 | value is @code{t}, so that Emacs does write backup files. | 501 | value is @code{t}, so that Emacs does write backup files. |
| @@ -534,9 +512,9 @@ control system. | |||
| 534 | @xref{General VC Options}. | 512 | @xref{General VC Options}. |
| 535 | @end ifnottex | 513 | @end ifnottex |
| 536 | 514 | ||
| 537 | |||
| 538 | At your option, Emacs can keep either a single backup for each file, | 515 | At your option, Emacs can keep either a single backup for each file, |
| 539 | or make a series of numbered backup files for each file that you edit. | 516 | or make a series of numbered backup files for each file that you edit. |
| 517 | @xref{Backup Names}. | ||
| 540 | 518 | ||
| 541 | @vindex backup-enable-predicate | 519 | @vindex backup-enable-predicate |
| 542 | @vindex temporary-file-directory | 520 | @vindex temporary-file-directory |
| @@ -546,43 +524,50 @@ prevents backup files being written for files in the directories used | |||
| 546 | for temporary files, specified by @code{temporary-file-directory} or | 524 | for temporary files, specified by @code{temporary-file-directory} or |
| 547 | @code{small-temporary-file-directory}. | 525 | @code{small-temporary-file-directory}. |
| 548 | 526 | ||
| 549 | Emacs makes a backup for a file only the first time the file is saved | 527 | You can explicitly tell Emacs to make another backup file from a |
| 550 | from one buffer. No matter how many times you save a file, its backup file | 528 | buffer, even though that buffer has been saved before. If you save |
| 551 | continues to contain the contents from before the file was visited. | ||
| 552 | Normally this means that the backup file contains the contents from before | ||
| 553 | the current editing session; however, if you kill the buffer and then visit | ||
| 554 | the file again, a new backup file will be made by the next save. | ||
| 555 | |||
| 556 | You can also explicitly request making another backup file from a | ||
| 557 | buffer even though it has already been saved at least once. If you save | ||
| 558 | the buffer with @kbd{C-u C-x C-s}, the version thus saved will be made | 529 | the buffer with @kbd{C-u C-x C-s}, the version thus saved will be made |
| 559 | into a backup file if you save the buffer again. @kbd{C-u C-u C-x C-s} | 530 | into a backup file if you save the buffer again. @kbd{C-u C-u C-x |
| 560 | saves the buffer, but first makes the previous file contents into a new | 531 | C-s} saves the buffer, but first makes the previous file contents into |
| 561 | backup file. @kbd{C-u C-u C-u C-x C-s} does both things: it makes a | 532 | a new backup file. @kbd{C-u C-u C-u C-x C-s} does both things: it |
| 562 | backup from the previous contents, and arranges to make another from the | 533 | makes a backup from the previous contents, and arranges to make |
| 563 | newly saved contents if you save again. | 534 | another from the newly saved contents if you save again. |
| 564 | 535 | ||
| 565 | @menu | 536 | @menu |
| 566 | * One or Many: Numbered Backups. Whether to make one backup file or many. | ||
| 567 | * Names: Backup Names. How backup files are named. | 537 | * Names: Backup Names. How backup files are named. |
| 568 | * Deletion: Backup Deletion. Emacs deletes excess numbered backups. | 538 | * Deletion: Backup Deletion. Emacs deletes excess numbered backups. |
| 569 | * Copying: Backup Copying. Backups can be made by copying or renaming. | 539 | * Copying: Backup Copying. Backups can be made by copying or renaming. |
| 570 | @end menu | 540 | @end menu |
| 571 | 541 | ||
| 572 | @node Numbered Backups | 542 | @node Backup Names |
| 573 | @subsubsection Numbered Backups | 543 | @subsubsection Single or Numbered Backups |
| 544 | |||
| 545 | When Emacs makes a backup file, its name is normally constructed by | ||
| 546 | appending @samp{~} to the file name being edited; thus, the backup | ||
| 547 | file for @file{eval.c} would be @file{eval.c~}. | ||
| 548 | |||
| 549 | If access control stops Emacs from writing backup files under the usual | ||
| 550 | names, it writes the backup file as @file{%backup%~} in your home | ||
| 551 | directory. Only one such file can exist, so only the most recently | ||
| 552 | made such backup is available. | ||
| 553 | |||
| 554 | Emacs can also make @dfn{numbered backup files}. Numbered backup | ||
| 555 | file names contain @samp{.~}, the number, and another @samp{~} after | ||
| 556 | the original file name. Thus, the backup files of @file{eval.c} would | ||
| 557 | be called @file{eval.c.~1~}, @file{eval.c.~2~}, and so on, all the way | ||
| 558 | through names like @file{eval.c.~259~} and beyond. | ||
| 574 | 559 | ||
| 575 | @vindex version-control | 560 | @vindex version-control |
| 576 | The choice of single backup file or multiple numbered backup files | 561 | The variable @code{version-control} determines whether to make |
| 577 | is controlled by the variable @code{version-control}. Its possible | 562 | single backup files or multiple numbered backup files. Its possible |
| 578 | values are: | 563 | values are: |
| 579 | 564 | ||
| 580 | @table @code | 565 | @table @code |
| 581 | @item t | ||
| 582 | Make numbered backups. | ||
| 583 | @item nil | 566 | @item nil |
| 584 | Make numbered backups for files that have numbered backups already. | 567 | Make numbered backups for files that have numbered backups already. |
| 585 | Otherwise, make single backups. | 568 | Otherwise, make single backups. This is the default. |
| 569 | @item t | ||
| 570 | Make numbered backups. | ||
| 586 | @item never | 571 | @item never |
| 587 | Never make numbered backups; always make single backups. | 572 | Never make numbered backups; always make single backups. |
| 588 | @end table | 573 | @end table |
| @@ -606,41 +591,23 @@ value is @samp{nil} or @samp{existing}, then @code{version-control} | |||
| 606 | becomes @code{nil}; if it is @samp{never} or @samp{simple}, then | 591 | becomes @code{nil}; if it is @samp{never} or @samp{simple}, then |
| 607 | @code{version-control} becomes @code{never}. | 592 | @code{version-control} becomes @code{never}. |
| 608 | 593 | ||
| 609 | @node Backup Names | ||
| 610 | @subsubsection Single or Numbered Backups | ||
| 611 | |||
| 612 | When Emacs makes a single backup file, its name is normally | ||
| 613 | constructed by appending @samp{~} to the file name being edited; thus, | ||
| 614 | the backup file for @file{eval.c} would be @file{eval.c~}. | ||
| 615 | |||
| 616 | @vindex make-backup-file-name-function | ||
| 617 | @vindex backup-directory-alist | 594 | @vindex backup-directory-alist |
| 618 | You can change this behavior by defining the variable | 595 | You can customize the variable @code{backup-directory-alist} to |
| 619 | @code{make-backup-file-name-function} to a suitable function. | 596 | specify that files matching certain patterns should be backed up in |
| 620 | Alternatively you can customize the variable | 597 | specific directories. This variable applies to both single and |
| 621 | @code{backup-directory-alist} to specify that files matching certain | 598 | numbered backups. A typical use is to add an element @code{("." |
| 622 | patterns should be backed up in specific directories. | 599 | . @var{dir})} to make all backups in the directory with absolute name |
| 623 | 600 | @var{dir}; Emacs modifies the backup file names to avoid clashes | |
| 624 | A typical use is to add an element @code{("." . @var{dir})} to make | 601 | between files with the same names originating in different |
| 625 | all backups in the directory with absolute name @var{dir}; Emacs | 602 | directories. Alternatively, adding, @code{("." . ".~")} would make |
| 626 | modifies the backup file names to avoid clashes between files with the | 603 | backups in the invisible subdirectory @file{.~} of the original file's |
| 627 | same names originating in different directories. Alternatively, | 604 | directory. Emacs creates the directory, if necessary, to make the |
| 628 | adding, say, @code{("." . ".~")} would make backups in the invisible | 605 | backup. |
| 629 | subdirectory @file{.~} of the original file's directory. Emacs | ||
| 630 | creates the directory, if necessary, to make the backup. | ||
| 631 | 606 | ||
| 632 | If access control stops Emacs from writing backup files under the usual | 607 | @vindex make-backup-file-name-function |
| 633 | names, it writes the backup file as @file{%backup%~} in your home | 608 | If you define the variable @code{make-backup-file-name-function} to |
| 634 | directory. Only one such file can exist, so only the most recently | 609 | a suitable Lisp function, that overrides the usual way Emacs |
| 635 | made such backup is available. | 610 | constructs backup file names. |
| 636 | |||
| 637 | If you choose to have a series of numbered backup files, backup file | ||
| 638 | names contain @samp{.~}, the number, and another @samp{~} after the | ||
| 639 | original file name. Thus, the backup files of @file{eval.c} would be | ||
| 640 | called @file{eval.c.~1~}, @file{eval.c.~2~}, and so on, all the way | ||
| 641 | through names like @file{eval.c.~259~} and beyond. The variable | ||
| 642 | @code{backup-directory-alist} applies to numbered backups just as | ||
| 643 | usual. | ||
| 644 | 611 | ||
| 645 | @node Backup Deletion | 612 | @node Backup Deletion |
| 646 | @subsubsection Automatic Deletion of Backups | 613 | @subsubsection Automatic Deletion of Backups |
| @@ -778,10 +745,10 @@ file. | |||
| 778 | @cindex locking files | 745 | @cindex locking files |
| 779 | When you make the first modification in an Emacs buffer that is | 746 | When you make the first modification in an Emacs buffer that is |
| 780 | visiting a file, Emacs records that the file is @dfn{locked} by you. | 747 | visiting a file, Emacs records that the file is @dfn{locked} by you. |
| 781 | (It does this by creating a symbolic link in the same directory with a | 748 | (It does this by creating a specially-named symbolic link in the same |
| 782 | different name.) Emacs removes the lock when you save the changes. The | 749 | directory.) Emacs removes the lock when you save the changes. The |
| 783 | idea is that the file is locked whenever an Emacs buffer visiting it has | 750 | idea is that the file is locked whenever an Emacs buffer visiting it |
| 784 | unsaved changes. | 751 | has unsaved changes. |
| 785 | 752 | ||
| 786 | @cindex collision | 753 | @cindex collision |
| 787 | If you begin to modify the buffer while the visited file is locked by | 754 | If you begin to modify the buffer while the visited file is locked by |
| @@ -813,23 +780,22 @@ editing of new files that will not really exist until they are saved. | |||
| 813 | there are cases where lock files cannot be written. In these cases, | 780 | there are cases where lock files cannot be written. In these cases, |
| 814 | Emacs cannot detect trouble in advance, but it still can detect the | 781 | Emacs cannot detect trouble in advance, but it still can detect the |
| 815 | collision when you try to save a file and overwrite someone else's | 782 | collision when you try to save a file and overwrite someone else's |
| 816 | changes. | 783 | changes. Every time Emacs saves a buffer, it first checks the |
| 784 | last-modification date of the existing file on disk to verify that it | ||
| 785 | has not changed since the file was last visited or saved. If the date | ||
| 786 | does not match, it implies that changes were made in the file in some | ||
| 787 | other way, and these changes are about to be lost if Emacs actually | ||
| 788 | does save. To prevent this, Emacs displays a warning message and asks | ||
| 789 | for confirmation before saving. Occasionally you will know why the | ||
| 790 | file was changed and know that it does not matter; then you can answer | ||
| 791 | @kbd{yes} and proceed. Otherwise, you should cancel the save with | ||
| 792 | @kbd{C-g} and investigate the situation. | ||
| 817 | 793 | ||
| 818 | If Emacs or the operating system crashes, this may leave behind lock | 794 | If Emacs or the operating system crashes, this may leave behind lock |
| 819 | files which are stale, so you may occasionally get warnings about | 795 | files which are stale, so you may occasionally get warnings about |
| 820 | spurious collisions. When you determine that the collision is spurious, | 796 | spurious collisions. When you determine that the collision is spurious, |
| 821 | just use @kbd{p} to tell Emacs to go ahead anyway. | 797 | just use @kbd{p} to tell Emacs to go ahead anyway. |
| 822 | 798 | ||
| 823 | Every time Emacs saves a buffer, it first checks the last-modification | ||
| 824 | date of the existing file on disk to verify that it has not changed since the | ||
| 825 | file was last visited or saved. If the date does not match, it implies | ||
| 826 | that changes were made in the file in some other way, and these changes are | ||
| 827 | about to be lost if Emacs actually does save. To prevent this, Emacs | ||
| 828 | displays a warning message and asks for confirmation before saving. | ||
| 829 | Occasionally you will know why the file was changed and know that it does | ||
| 830 | not matter; then you can answer @kbd{yes} and proceed. Otherwise, you should | ||
| 831 | cancel the save with @kbd{C-g} and investigate the situation. | ||
| 832 | |||
| 833 | The first thing you should do when notified that simultaneous editing | 799 | The first thing you should do when notified that simultaneous editing |
| 834 | has already taken place is to list the directory with @kbd{C-u C-x C-d} | 800 | has already taken place is to list the directory with @kbd{C-u C-x C-d} |
| 835 | (@pxref{Directories}). This shows the file's current author. You | 801 | (@pxref{Directories}). This shows the file's current author. You |
| @@ -933,23 +899,20 @@ the file was edited only slightly, you will be at approximately the | |||
| 933 | same piece of text after reverting as before. However, if you have made | 899 | same piece of text after reverting as before. However, if you have made |
| 934 | drastic changes, point may wind up in a totally different piece of text. | 900 | drastic changes, point may wind up in a totally different piece of text. |
| 935 | 901 | ||
| 936 | Reverting marks the buffer as ``not modified'' until another change is | 902 | Reverting marks the buffer as ``not modified''. |
| 937 | made. | ||
| 938 | 903 | ||
| 939 | Some kinds of buffers whose contents reflect data bases other than files, | 904 | Some kinds of buffers that are not associated with files, such as |
| 940 | such as Dired buffers, can also be reverted. For them, reverting means | 905 | Dired buffers, can also be reverted. For them, reverting means |
| 941 | recalculating their contents from the appropriate data base. Buffers | 906 | recalculating their contents. Buffers created explicitly with |
| 942 | created explicitly with @kbd{C-x b} cannot be reverted; @code{revert-buffer} | 907 | @kbd{C-x b} cannot be reverted; @code{revert-buffer} reports an error |
| 943 | reports an error when asked to do so. | 908 | if you try. |
| 944 | 909 | ||
| 945 | @vindex revert-without-query | 910 | @vindex revert-without-query |
| 946 | When you edit a file that changes automatically and frequently---for | 911 | When you edit a file that changes automatically and frequently---for |
| 947 | example, a log of output from a process that continues to run---it may be | 912 | example, a log of output from a process that continues to run---it may |
| 948 | useful for Emacs to revert the file without querying you, whenever you | 913 | be useful for Emacs to revert the file without querying you. To |
| 949 | visit the file again with @kbd{C-x C-f}. | 914 | request this behavior, set the variable @code{revert-without-query} to |
| 950 | 915 | a list of regular expressions. When a file name matches one of these | |
| 951 | To request this behavior, set the variable @code{revert-without-query} | ||
| 952 | to a list of regular expressions. When a file name matches one of these | ||
| 953 | regular expressions, @code{find-file} and @code{revert-buffer} will | 916 | regular expressions, @code{find-file} and @code{revert-buffer} will |
| 954 | revert it automatically if it has changed---provided the buffer itself | 917 | revert it automatically if it has changed---provided the buffer itself |
| 955 | is not modified. (If you have edited the text, it would be wrong to | 918 | is not modified. (If you have edited the text, it would be wrong to |
| @@ -962,17 +925,18 @@ discard your changes.) | |||
| 962 | @findex global-auto-revert-mode | 925 | @findex global-auto-revert-mode |
| 963 | @findex auto-revert-mode | 926 | @findex auto-revert-mode |
| 964 | @findex auto-revert-tail-mode | 927 | @findex auto-revert-tail-mode |
| 928 | @vindex auto-revert-interval | ||
| 965 | 929 | ||
| 966 | You may find it useful to have Emacs revert files automatically when | 930 | In addition, you can tell Emacs to periodically revert a buffer by |
| 967 | they change. Three minor modes are available to do this. | 931 | typing @kbd{M-x auto-revert-mode}. This turns on Auto-Revert mode, a |
| 968 | 932 | minor mode that makes Emacs automatically revert the current buffer | |
| 969 | @kbd{M-x global-auto-revert-mode} enables Global Auto-Revert mode, | 933 | every five seconds. You can change this interval through the variable |
| 970 | which periodically checks all file buffers and reverts when the | 934 | @code{auto-revert-interval}. Typing @kbd{M-x global-auto-revert-mode} |
| 971 | corresponding file has changed. @kbd{M-x auto-revert-mode} enables a | 935 | enables Global Auto-Revert mode, which does the same for all file |
| 972 | local version, Auto-Revert mode, which applies only to the current | 936 | buffers. Auto-Revert mode and Global Auto-Revert modes do not check |
| 973 | buffer. | 937 | or revert remote files, because that is usually too slow. |
| 974 | 938 | ||
| 975 | You can use Auto-Revert mode to ``tail'' a file such as a system | 939 | One use of Auto-Revert mode is to ``tail'' a file such as a system |
| 976 | log, so that changes made to that file by other programs are | 940 | log, so that changes made to that file by other programs are |
| 977 | continuously displayed. To do this, just move the point to the end of | 941 | continuously displayed. To do this, just move the point to the end of |
| 978 | the buffer, and it will stay there as the file contents change. | 942 | the buffer, and it will stay there as the file contents change. |
| @@ -980,11 +944,6 @@ However, if you are sure that the file will only change by growing at | |||
| 980 | the end, use Auto-Revert Tail mode instead | 944 | the end, use Auto-Revert Tail mode instead |
| 981 | (@code{auto-revert-tail-mode}). It is more efficient for this. | 945 | (@code{auto-revert-tail-mode}). It is more efficient for this. |
| 982 | 946 | ||
| 983 | @vindex auto-revert-interval | ||
| 984 | The variable @code{auto-revert-interval} controls how often to check | ||
| 985 | for a changed file. Since checking a remote file is too slow, these | ||
| 986 | modes do not check or revert remote files. | ||
| 987 | |||
| 988 | @xref{VC Mode Line}, for Auto Revert peculiarities in buffers that | 947 | @xref{VC Mode Line}, for Auto Revert peculiarities in buffers that |
| 989 | visit files under version control. | 948 | visit files under version control. |
| 990 | 949 | ||
| @@ -998,11 +957,10 @@ visit files under version control. | |||
| 998 | @cindex mode, Auto Save | 957 | @cindex mode, Auto Save |
| 999 | @cindex crashes | 958 | @cindex crashes |
| 1000 | 959 | ||
| 1001 | Emacs saves all the visited files from time to time (based on | 960 | From time to time, Emacs automatically saves each visited file in a |
| 1002 | counting your keystrokes) without being asked, in separate files so as | 961 | separate file, without altering the file you actually use. This is |
| 1003 | not to alter the files you actually use. This is called | 962 | called @dfn{auto-saving}. It prevents you from losing more than a |
| 1004 | @dfn{auto-saving}. It prevents you from losing more than a limited | 963 | limited amount of work if the system crashes. |
| 1005 | amount of work if the system crashes. | ||
| 1006 | 964 | ||
| 1007 | When Emacs determines that it is time for auto-saving, it considers | 965 | When Emacs determines that it is time for auto-saving, it considers |
| 1008 | each buffer, and each is auto-saved if auto-saving is enabled for it | 966 | each buffer, and each is auto-saved if auto-saving is enabled for it |
| @@ -1022,12 +980,11 @@ execution of commands you have been typing. | |||
| 1022 | @node Auto Save Files | 980 | @node Auto Save Files |
| 1023 | @subsection Auto-Save Files | 981 | @subsection Auto-Save Files |
| 1024 | 982 | ||
| 1025 | Auto-saving does not normally save in the files that you visited, because | 983 | Auto-saving does not normally save in the files that you visited, |
| 1026 | it can be very undesirable to save a program that is in an inconsistent | 984 | because it can be very undesirable to save a change that you did not |
| 1027 | state when you have made half of a planned change. Instead, auto-saving | 985 | want to make permanent. Instead, auto-saving is done in a different |
| 1028 | is done in a different file called the @dfn{auto-save file}, and the | 986 | file called the @dfn{auto-save file}, and the visited file is changed |
| 1029 | visited file is changed only when you request saving explicitly (such as | 987 | only when you request saving explicitly (such as with @kbd{C-x C-s}). |
| 1030 | with @kbd{C-x C-s}). | ||
| 1031 | 988 | ||
| 1032 | Normally, the auto-save file name is made by appending @samp{#} to the | 989 | Normally, the auto-save file name is made by appending @samp{#} to the |
| 1033 | front and rear of the visited file name. Thus, a buffer visiting file | 990 | front and rear of the visited file name. Thus, a buffer visiting file |
| @@ -1157,9 +1114,9 @@ this---saving them---updates the files themselves. | |||
| 1157 | @vindex auto-save-list-file-prefix | 1114 | @vindex auto-save-list-file-prefix |
| 1158 | Emacs records information about interrupted sessions for later | 1115 | Emacs records information about interrupted sessions for later |
| 1159 | recovery in files named | 1116 | recovery in files named |
| 1160 | @file{~/.emacs.d/auto-save-list/.saves-@var{pid}-@var{hostname}}. All | 1117 | @file{~/.emacs.d/auto-save-list/.saves-@var{pid}-@var{hostname}}. The |
| 1161 | of this name except the @file{@var{pid}-@var{hostname}} part comes | 1118 | directory used, @file{~/.emacs.d/auto-save-list/}, is determined by |
| 1162 | from the value of @code{auto-save-list-file-prefix}. You can record | 1119 | the variable @code{auto-save-list-file-prefix}. You can record |
| 1163 | sessions in a different place by customizing that variable. If you | 1120 | sessions in a different place by customizing that variable. If you |
| 1164 | set @code{auto-save-list-file-prefix} to @code{nil} in your | 1121 | set @code{auto-save-list-file-prefix} to @code{nil} in your |
| 1165 | @file{.emacs} file, sessions are not recorded for recovery. | 1122 | @file{.emacs} file, sessions are not recorded for recovery. |
| @@ -1214,11 +1171,8 @@ description of what was changed in that version. | |||
| 1214 | 1171 | ||
| 1215 | The Emacs version control interface is called VC. Its commands work | 1172 | The Emacs version control interface is called VC. Its commands work |
| 1216 | with different version control systems---currently, it supports CVS, | 1173 | with different version control systems---currently, it supports CVS, |
| 1217 | GNU Arch, RCS, Subversion, and SCCS. Of these, the GNU | 1174 | GNU Arch, RCS, Subversion, SCCS, Mercurial, Monotone, Bazaar, and Git. |
| 1218 | project distributes CVS, GNU Arch, and RCS. We also have free | 1175 | Of these, the GNU project distributes CVS, GNU Arch, RCS, and Bazaar. |
| 1219 | software to replace SCCS, known as CSSC; if you are using SCCS and | ||
| 1220 | don't want to make the incompatible change to RCS or CVS, you can | ||
| 1221 | switch to CSSC. | ||
| 1222 | 1176 | ||
| 1223 | VC is enabled by default in Emacs. To disable it, set the | 1177 | VC is enabled by default in Emacs. To disable it, set the |
| 1224 | customizable variable @code{vc-handled-backends} to @code{nil} | 1178 | customizable variable @code{vc-handled-backends} to @code{nil} |