diff options
| author | Chong Yidong | 2009-01-22 04:53:41 +0000 |
|---|---|---|
| committer | Chong Yidong | 2009-01-22 04:53:41 +0000 |
| commit | ae12425c9d1bb813a2c58ec94cb835b76c18fb6a (patch) | |
| tree | a03e7d89795e173ca37950a31c41b3799a9e87d9 | |
| parent | e3aa6669faf38d4b20ddbdb6b5777e68817a6f18 (diff) | |
| download | emacs-ae12425c9d1bb813a2c58ec94cb835b76c18fb6a.tar.gz emacs-ae12425c9d1bb813a2c58ec94cb835b76c18fb6a.zip | |
(Format Conversion Piecemeal): Clarify behavior of
write-region-annotate-functions. Document
write-region-post-annotation-function.
| -rw-r--r-- | doc/lispref/files.texi | 52 |
1 files changed, 34 insertions, 18 deletions
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi index 17d439725d5..8d02831a7fb 100644 --- a/doc/lispref/files.texi +++ b/doc/lispref/files.texi | |||
| @@ -3070,18 +3070,17 @@ place without modifying the buffer. | |||
| 3070 | @c ??? for `write-region-annotate-functions', below? --ttn | 3070 | @c ??? for `write-region-annotate-functions', below? --ttn |
| 3071 | 3071 | ||
| 3072 | In contrast, when reading, the annotations intermixed with the text | 3072 | In contrast, when reading, the annotations intermixed with the text |
| 3073 | are handled immediately. @code{insert-file-contents} sets point to the | 3073 | are handled immediately. @code{insert-file-contents} sets point to |
| 3074 | beginning of some text to be converted, then calls the conversion | 3074 | the beginning of some text to be converted, then calls the conversion |
| 3075 | functions with the length of that text. These functions should always | 3075 | functions with the length of that text. These functions should always |
| 3076 | return with point at the beginning of the inserted text. This approach | 3076 | return with point at the beginning of the inserted text. This |
| 3077 | makes sense for reading because annotations removed by the first | 3077 | approach makes sense for reading because annotations removed by the |
| 3078 | converter can't be mistakenly processed by a later converter. | 3078 | first converter can't be mistakenly processed by a later converter. |
| 3079 | 3079 | Each conversion function should scan for the annotations it | |
| 3080 | Each conversion function should scan for the annotations it | 3080 | recognizes, remove the annotation, modify the buffer text (to set a |
| 3081 | recognizes, remove the annotation, modify the buffer text (to set a text | 3081 | text property, for example), and return the updated length of the |
| 3082 | property, for example), and return the updated length of the text, as it | 3082 | text, as it stands after those changes. The value returned by one |
| 3083 | stands after those changes. The value returned by one function becomes | 3083 | function becomes the argument to the next function. |
| 3084 | the argument to the next function. | ||
| 3085 | 3084 | ||
| 3086 | @defvar write-region-annotate-functions | 3085 | @defvar write-region-annotate-functions |
| 3087 | A list of functions for @code{write-region} to call. Each function in | 3086 | A list of functions for @code{write-region} to call. Each function in |
| @@ -3089,13 +3088,30 @@ the list is called with two arguments: the start and end of the region | |||
| 3089 | to be written. These functions should not alter the contents of the | 3088 | to be written. These functions should not alter the contents of the |
| 3090 | buffer. Instead, they should return annotations. | 3089 | buffer. Instead, they should return annotations. |
| 3091 | 3090 | ||
| 3092 | @c ??? Following adapted from comment in `build_annotations' (fileio.c). | 3091 | As a special case, a function may return with a different buffer |
| 3093 | @c ??? Perhaps this is intended for internal use only? | 3092 | current. Emacs takes this to mean that the current buffer contains |
| 3094 | @c ??? Someone who understands this, please reword it. --ttn | 3093 | altered text to be output. It therefore changes the @var{start} and |
| 3095 | As a special case, if a function returns with a different buffer | 3094 | @var{end} arguments of the @code{write-region} call, giving them the |
| 3096 | current, Emacs takes it to mean the current buffer contains altered text | 3095 | values of @code{point-min} and @code{point-max} in the new buffer, |
| 3097 | to be output, and discards all previous annotations because they should | 3096 | respectively. It also discards all previous annotations, because they |
| 3098 | have been dealt with by this function. | 3097 | should have been dealt with by this function. |
| 3098 | @end defvar | ||
| 3099 | |||
| 3100 | @defvar write-region-post-annotation-function | ||
| 3101 | The value of this variable, if non-@code{nil}, should be a function. | ||
| 3102 | This function is called, with no arguments, after @code{write-region} | ||
| 3103 | has completed. | ||
| 3104 | |||
| 3105 | If any function in @code{write-region-annotate-functions} returns with | ||
| 3106 | a different buffer current, Emacs calls | ||
| 3107 | @code{write-region-post-annotation-function} more than once. Emacs | ||
| 3108 | calls it with the last buffer that was current, and again with the | ||
| 3109 | buffer before that, and so on back to the original buffer. | ||
| 3110 | |||
| 3111 | Thus, a function in @code{write-region-annotate-functions} can create | ||
| 3112 | a buffer, give this variable the local value of @code{kill-buffer} in | ||
| 3113 | that buffer, set up the buffer with altered text, and make the buffer | ||
| 3114 | current. The buffer will be killed after @code{write-region} is done. | ||
| 3099 | @end defvar | 3115 | @end defvar |
| 3100 | 3116 | ||
| 3101 | @defvar after-insert-file-functions | 3117 | @defvar after-insert-file-functions |