diff options
| author | Eli Zaretskii | 2017-01-20 10:57:14 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2017-01-20 10:57:14 +0200 |
| commit | 954e9e983b7e446ebf4a7b4dfee0dca82b6b57f7 (patch) | |
| tree | 3bb5cc751c903e2778d354ec15c17b3f10ed2983 | |
| parent | 9fcab85efd10090786266610f4dbb83ee0da4b31 (diff) | |
| download | emacs-954e9e983b7e446ebf4a7b4dfee0dca82b6b57f7.tar.gz emacs-954e9e983b7e446ebf4a7b4dfee0dca82b6b57f7.zip | |
Improve documentation of hooks related to saving buffers
* lisp/files.el (write-file-functions, write-contents-functions)
(before-save-hook, after-save-hook): Note that these are only used
by save-buffer.
* doc/lispref/backups.texi (Auto-Saving):
* doc/lispref/files.texi (Saving Buffers): Mention that
save-related hooks are not run by auto-saving. (Bug#25460)
| -rw-r--r-- | doc/lispref/backups.texi | 5 | ||||
| -rw-r--r-- | doc/lispref/files.texi | 6 | ||||
| -rw-r--r-- | lisp/files.el | 10 |
3 files changed, 17 insertions, 4 deletions
diff --git a/doc/lispref/backups.texi b/doc/lispref/backups.texi index 83d826018ca..361fa81099b 100644 --- a/doc/lispref/backups.texi +++ b/doc/lispref/backups.texi | |||
| @@ -545,6 +545,11 @@ effect in an existing buffer until the next time auto-save mode is | |||
| 545 | reenabled in it. If auto-save mode is already enabled, auto-saves | 545 | reenabled in it. If auto-save mode is already enabled, auto-saves |
| 546 | continue to go in the same file name until @code{auto-save-mode} is | 546 | continue to go in the same file name until @code{auto-save-mode} is |
| 547 | called again. | 547 | called again. |
| 548 | |||
| 549 | Note that setting this variable to a non-@code{nil} value does not | ||
| 550 | change the fact that auto-saving is different from saving the buffer; | ||
| 551 | e.g., the hooks described in @ref{Saving Buffers} are @emph{not} run | ||
| 552 | when a buffer is auto-saved. | ||
| 548 | @end defopt | 553 | @end defopt |
| 549 | 554 | ||
| 550 | @defun recent-auto-save-p | 555 | @defun recent-auto-save-p |
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi index 6f015e2d643..49cb150dc64 100644 --- a/doc/lispref/files.texi +++ b/doc/lispref/files.texi | |||
| @@ -403,7 +403,11 @@ buffer name instead. | |||
| 403 | @end deffn | 403 | @end deffn |
| 404 | 404 | ||
| 405 | Saving a buffer runs several hooks. It also performs format | 405 | Saving a buffer runs several hooks. It also performs format |
| 406 | conversion (@pxref{Format Conversion}). | 406 | conversion (@pxref{Format Conversion}). Note that these hooks, |
| 407 | described below, are only run by @code{save-buffer}, they are not run | ||
| 408 | by other primitives and functions that write buffer text to files, and | ||
| 409 | in particular auto-saving (@pxref{Auto-Saving}) doesn't run these | ||
| 410 | hooks. | ||
| 407 | 411 | ||
| 408 | @defvar write-file-functions | 412 | @defvar write-file-functions |
| 409 | The value of this variable is a list of functions to be called before | 413 | The value of this variable is a list of functions to be called before |
diff --git a/lisp/files.el b/lisp/files.el index a6fe381a50a..83ef4e271cd 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -440,7 +440,8 @@ functions are called." | |||
| 440 | 440 | ||
| 441 | (define-obsolete-variable-alias 'write-file-hooks 'write-file-functions "22.1") | 441 | (define-obsolete-variable-alias 'write-file-hooks 'write-file-functions "22.1") |
| 442 | (defvar write-file-functions nil | 442 | (defvar write-file-functions nil |
| 443 | "List of functions to be called before writing out a buffer to a file. | 443 | "List of functions to be called before saving a buffer to a file. |
| 444 | Only used by `save-buffer'. | ||
| 444 | If one of them returns non-nil, the file is considered already written | 445 | If one of them returns non-nil, the file is considered already written |
| 445 | and the rest are not called. | 446 | and the rest are not called. |
| 446 | These hooks are considered to pertain to the visited file. | 447 | These hooks are considered to pertain to the visited file. |
| @@ -465,6 +466,7 @@ updates before the buffer is saved, use `before-save-hook'.") | |||
| 465 | 'write-contents-functions "22.1") | 466 | 'write-contents-functions "22.1") |
| 466 | (defvar write-contents-functions nil | 467 | (defvar write-contents-functions nil |
| 467 | "List of functions to be called before writing out a buffer to a file. | 468 | "List of functions to be called before writing out a buffer to a file. |
| 469 | Only used by `save-buffer'. | ||
| 468 | If one of them returns non-nil, the file is considered already written | 470 | If one of them returns non-nil, the file is considered already written |
| 469 | and the rest are not called and neither are the functions in | 471 | and the rest are not called and neither are the functions in |
| 470 | `write-file-functions'. | 472 | `write-file-functions'. |
| @@ -4721,13 +4723,15 @@ the last real save, but optional arg FORCE non-nil means delete anyway." | |||
| 4721 | "Normal hook run just before auto-saving.") | 4723 | "Normal hook run just before auto-saving.") |
| 4722 | 4724 | ||
| 4723 | (defcustom before-save-hook nil | 4725 | (defcustom before-save-hook nil |
| 4724 | "Normal hook that is run before a buffer is saved to its file." | 4726 | "Normal hook that is run before a buffer is saved to its file. |
| 4727 | Only used by `save-buffer'." | ||
| 4725 | :options '(copyright-update time-stamp) | 4728 | :options '(copyright-update time-stamp) |
| 4726 | :type 'hook | 4729 | :type 'hook |
| 4727 | :group 'files) | 4730 | :group 'files) |
| 4728 | 4731 | ||
| 4729 | (defcustom after-save-hook nil | 4732 | (defcustom after-save-hook nil |
| 4730 | "Normal hook that is run after a buffer is saved to its file." | 4733 | "Normal hook that is run after a buffer is saved to its file. |
| 4734 | Only used by `save-buffer'." | ||
| 4731 | :options '(executable-make-buffer-file-executable-if-script-p) | 4735 | :options '(executable-make-buffer-file-executable-if-script-p) |
| 4732 | :type 'hook | 4736 | :type 'hook |
| 4733 | :group 'files) | 4737 | :group 'files) |