141 |
Visiting}). That function sets the buffer major mode, parses local |
Visiting}). That function sets the buffer major mode, parses local |
142 |
variables, warns the user if there exists an auto-save file more recent |
variables, warns the user if there exists an auto-save file more recent |
143 |
than the file just visited, and finishes by running the functions in |
than the file just visited, and finishes by running the functions in |
144 |
@code{find-file-hooks}. |
@code{find-file-hook}. |
145 |
|
|
146 |
If the optional argument @var{rawfile} is non-@code{nil}, then |
If the optional argument @var{rawfile} is non-@code{nil}, then |
147 |
@code{after-find-file} is not called, and the |
@code{after-find-file} is not called, and the |
148 |
@code{find-file-not-found-hooks} are not run in case of failure. What's |
@code{find-file-not-found-functions} are not run in case of failure. What's |
149 |
more, a non-@code{nil} @var{rawfile} value suppresses coding system |
more, a non-@code{nil} @var{rawfile} value suppresses coding system |
150 |
conversion (@pxref{Coding Systems}) and format conversion (@pxref{Format |
conversion (@pxref{Coding Systems}) and format conversion (@pxref{Format |
151 |
Conversion}). |
Conversion}). |
200 |
not treated specially. |
not treated specially. |
201 |
@end defvar |
@end defvar |
202 |
|
|
203 |
@defvar find-file-hooks |
@defvar find-file-hook |
204 |
The value of this variable is a list of functions to be called after a |
The value of this variable is a list of functions to be called after a |
205 |
file is visited. The file's local-variables specification (if any) will |
file is visited. The file's local-variables specification (if any) will |
206 |
have been processed before the hooks are run. The buffer visiting the |
have been processed before the hooks are run. The buffer visiting the |
210 |
it would not be advisable. @xref{Hooks}. |
it would not be advisable. @xref{Hooks}. |
211 |
@end defvar |
@end defvar |
212 |
|
|
213 |
@defvar find-file-not-found-hooks |
@defvar find-file-not-found-functions |
214 |
The value of this variable is a list of functions to be called when |
The value of this variable is a list of functions to be called when |
215 |
@code{find-file} or @code{find-file-noselect} is passed a nonexistent |
@code{find-file} or @code{find-file-noselect} is passed a nonexistent |
216 |
file name. @code{find-file-noselect} calls these functions as soon as |
file name. @code{find-file-noselect} calls these functions as soon as |
285 |
|
|
286 |
If @var{nomodes} is non-@code{nil}, that means don't alter the buffer's |
If @var{nomodes} is non-@code{nil}, that means don't alter the buffer's |
287 |
major mode, don't process local variables specifications in the file, |
major mode, don't process local variables specifications in the file, |
288 |
and don't run @code{find-file-hooks}. This feature is used by |
and don't run @code{find-file-hook}. This feature is used by |
289 |
@code{revert-buffer} in some cases. |
@code{revert-buffer} in some cases. |
290 |
|
|
291 |
The last thing @code{after-find-file} does is call all the functions |
The last thing @code{after-find-file} does is call all the functions |
292 |
in the list @code{find-file-hooks}. |
in the list @code{find-file-hook}. |
293 |
@end defun |
@end defun |
294 |
|
|
295 |
@node Saving Buffers |
@node Saving Buffers |
362 |
conversion (@pxref{Format Conversion}), and may save text properties in |
conversion (@pxref{Format Conversion}), and may save text properties in |
363 |
``annotations'' (@pxref{Saving Properties}). |
``annotations'' (@pxref{Saving Properties}). |
364 |
|
|
365 |
@defvar write-file-hooks |
@defvar write-file-functions |
366 |
The value of this variable is a list of functions to be called before |
The value of this variable is a list of functions to be called before |
367 |
writing out a buffer to its visited file. If one of them returns |
writing out a buffer to its visited file. If one of them returns |
368 |
non-@code{nil}, the file is considered already written and the rest of |
non-@code{nil}, the file is considered already written and the rest of |
369 |
the functions are not called, nor is the usual code for writing the file |
the functions are not called, nor is the usual code for writing the file |
370 |
executed. |
executed. |
371 |
|
|
372 |
If a function in @code{write-file-hooks} returns non-@code{nil}, it |
If a function in @code{write-file-functions} returns non-@code{nil}, it |
373 |
is responsible for making a backup file (if that is appropriate). |
is responsible for making a backup file (if that is appropriate). |
374 |
To do so, execute the following code: |
To do so, execute the following code: |
375 |
|
|
381 |
@code{backup-buffer} and use that to set the mode bits of the file that |
@code{backup-buffer} and use that to set the mode bits of the file that |
382 |
you write. This is what @code{save-buffer} normally does. |
you write. This is what @code{save-buffer} normally does. |
383 |
|
|
384 |
The hook functions in @code{write-file-hooks} are also responsible for |
The hook functions in @code{write-file-functions} are also responsible for |
385 |
encoding the data (if desired): they must choose a suitable coding |
encoding the data (if desired): they must choose a suitable coding |
386 |
system (@pxref{Lisp and Coding Systems}), perform the encoding |
system (@pxref{Lisp and Coding Systems}), perform the encoding |
387 |
(@pxref{Explicit Encoding}), and set @code{last-coding-system-used} to |
(@pxref{Explicit Encoding}), and set @code{last-coding-system-used} to |
388 |
the coding system that was used (@pxref{Encoding and I/O}). |
the coding system that was used (@pxref{Encoding and I/O}). |
389 |
|
|
390 |
Do not make this variable buffer-local. To set up buffer-specific hook |
If you set this hook locally in a buffer, it is assumed to be |
391 |
functions, use @code{write-contents-hooks} instead. |
associated with the file or the way the contents of the buffer were |
392 |
|
obtained. Thus the variable is marked as a permanent local, so that |
393 |
|
changing the major mode does not alter a buffer-local value. On the |
394 |
|
other hand, calling @code{set-visited-file-name} will reset it. |
395 |
|
If this is not what you want, you might like to use |
396 |
|
@code{write-contents-functions} instead. |
397 |
|
|
398 |
Even though this is not a normal hook, you can use @code{add-hook} and |
Even though this is not a normal hook, you can use @code{add-hook} and |
399 |
@code{remove-hook} to manipulate the list. @xref{Hooks}. |
@code{remove-hook} to manipulate the list. @xref{Hooks}. |
400 |
@end defvar |
@end defvar |
401 |
|
|
402 |
@c Emacs 19 feature |
@c Emacs 19 feature |
403 |
@defvar local-write-file-hooks |
@defvar write-contents-functions |
404 |
This works just like @code{write-file-hooks}, but it is intended to be |
This works just like @code{write-file-functions}, but it is intended for |
|
made buffer-local in particular buffers, and used for hooks that pertain |
|
|
to the file name or the way the buffer contents were obtained. |
|
|
|
|
|
The variable is marked as a permanent local, so that changing the major |
|
|
mode does not alter a buffer-local value. This is convenient for |
|
|
packages that read ``file'' contents in special ways, and set up hooks |
|
|
to save the data in a corresponding way. |
|
|
@end defvar |
|
|
|
|
|
@c Emacs 19 feature |
|
|
@defvar write-contents-hooks |
|
|
This works just like @code{write-file-hooks}, but it is intended for |
|
405 |
hooks that pertain to the contents of the file, as opposed to hooks that |
hooks that pertain to the contents of the file, as opposed to hooks that |
406 |
pertain to where the file came from. Such hooks are usually set up by |
pertain to where the file came from. Such hooks are usually set up by |
407 |
major modes, as buffer-local bindings for this variable. |
major modes, as buffer-local bindings for this variable. |
408 |
|
|
409 |
This variable automatically becomes buffer-local whenever it is set; |
This variable automatically becomes buffer-local whenever it is set; |
410 |
switching to a new major mode always resets this variable. When you use |
switching to a new major mode always resets this variable. |
|
@code{add-hooks} to add an element to this hook, you should @emph{not} |
|
|
specify a non-@code{nil} @var{local} argument, since this variable is |
|
|
used @emph{only} buffer-locally. |
|
411 |
@end defvar |
@end defvar |
412 |
|
|
413 |
@c Emacs 19 feature |
@c Emacs 19 feature |
504 |
This function works like @code{insert-file-contents} except that it does |
This function works like @code{insert-file-contents} except that it does |
505 |
not do format decoding (@pxref{Format Conversion}), does not do |
not do format decoding (@pxref{Format Conversion}), does not do |
506 |
character code conversion (@pxref{Coding Systems}), does not run |
character code conversion (@pxref{Coding Systems}), does not run |
507 |
@code{find-file-hooks}, does not perform automatic uncompression, and so |
@code{find-file-hook}, does not perform automatic uncompression, and so |
508 |
on. |
on. |
509 |
@end defun |
@end defun |
510 |
|
|