aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorGlenn Morris2012-02-04 11:48:06 -0800
committerGlenn Morris2012-02-04 11:48:06 -0800
commit34c999980444dc3aea494fbf87d71d858fbc3f0f (patch)
treeb9a4a056c0cc3f5137e464e208a5a44a66ab8c90 /doc
parent79c1cc1e971d0f8766e62d60f459d5253b913f05 (diff)
downloademacs-34c999980444dc3aea494fbf87d71d858fbc3f0f.tar.gz
emacs-34c999980444dc3aea494fbf87d71d858fbc3f0f.zip
Try to document filter-buffer-substring changes
* doc/lispref/text.texi (Buffer Contents): Update filter-buffer-substring description. * lisp/simple.el (filter-buffer-substring-functions) (buffer-substring-filters, filter-buffer-substring): Doc fixes. * etc/NEWS: Related edits.
Diffstat (limited to 'doc')
-rw-r--r--doc/lispref/ChangeLog5
-rw-r--r--doc/lispref/text.texi52
2 files changed, 32 insertions, 25 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index e98e18b864d..ddc459cc50e 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,8 @@
12012-02-04 Glenn Morris <rgm@gnu.org>
2
3 * text.texi (Buffer Contents):
4 Update filter-buffer-substring description.
5
12012-02-04 Chong Yidong <cyd@gnu.org> 62012-02-04 Chong Yidong <cyd@gnu.org>
2 7
3 * functions.texi (What Is a Function): Add closures. Mention 8 * functions.texi (What Is a Function): Add closures. Mention
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index 448634ba5a7..8e7434de2ed 100644
--- a/doc/lispref/text.texi
+++ b/doc/lispref/text.texi
@@ -218,44 +218,46 @@ This is like @code{buffer-substring}, except that it does not copy text
218properties, just the characters themselves. @xref{Text Properties}. 218properties, just the characters themselves. @xref{Text Properties}.
219@end defun 219@end defun
220 220
221@defun filter-buffer-substring start end &optional delete noprops 221@defun filter-buffer-substring start end &optional delete
222This function passes the buffer text between @var{start} and @var{end} 222This function passes the buffer text between @var{start} and @var{end}
223through the filter functions specified by the variable 223through the filter functions specified by the wrapper hook
224@code{buffer-substring-filters}, and returns the value from the last 224@code{filter-buffer-substring-functions}, and returns the final
225filter function. If @code{buffer-substring-filters} is @code{nil}, 225result of applying all filters. The obsolete variable
226the value is the unaltered text from the buffer, what 226@code{buffer-substring-filters} is also consulted. If both of these
227@code{buffer-substring} would return. 227variables are @code{nil}, the value is the unaltered text from the
228buffer, as @code{buffer-substring} would return.
228 229
229If @var{delete} is non-@code{nil}, this function deletes the text 230If @var{delete} is non-@code{nil}, this function deletes the text
230between @var{start} and @var{end} after copying it, like 231between @var{start} and @var{end} after copying it, like
231@code{delete-and-extract-region}. 232@code{delete-and-extract-region}.
232 233
233If @var{noprops} is non-@code{nil}, the final string returned does not
234include text properties, while the string passed through the filters
235still includes text properties from the buffer text.
236
237Lisp code should use this function instead of @code{buffer-substring}, 234Lisp code should use this function instead of @code{buffer-substring},
238@code{buffer-substring-no-properties}, 235@code{buffer-substring-no-properties},
239or @code{delete-and-extract-region} when copying into user-accessible 236or @code{delete-and-extract-region} when copying into user-accessible
240data structures such as the kill-ring, X clipboard, and registers. 237data structures such as the kill-ring, X clipboard, and registers.
241Major and minor modes can add functions to 238Major and minor modes can add functions to
242@code{buffer-substring-filters} to alter such text as it is copied out 239@code{filter-buffer-substring-functions} to alter such text as it is
243of the buffer. 240copied out of the buffer.
244@end defun 241@end defun
245 242
246@defvar buffer-substring-filters 243@defvar filter-buffer-substring-functions
247This variable should be a list of functions that accept a single 244This variable is a wrapper hook (@pxref{Running Hooks}), whose members
248argument, a string, and return a string. 245should be functions that accept four arguments: @var{fun},
249@code{filter-buffer-substring} passes the buffer substring to the 246@var{start}, @var{end}, and @var{delete}. @var{fun} is a function
250first function in this list, and the return value of each function is 247that takes three arguments (@var{start}, @var{end}, and @var{delete}),
251passed to the next function. The return value of the last function is 248and returns a string. In both cases, the @var{start}, @var{end}, and
252used as the return value of @code{filter-buffer-substring}. 249@var{delete} arguments are the same as those of
253 250@code{filter-buffer-substring}.
254As a special convention, point is set to the start of the buffer text 251
255being operated on (i.e., the @var{start} argument for 252The first hook function is passed a @var{fun} that is equivalent to
256@code{filter-buffer-substring}) before these functions are called. 253the default operation of @code{filter-buffer-substring}, i.e. it
257 254returns the buffer-substring between @var{start} and @var{end}
258If this variable is @code{nil}, no filtering is performed. 255(processed by any @code{buffer-substring-filters}) and optionally
256deletes the original text from the buffer. In most cases, the hook
257function will call @var{fun} once, and then do its own processing of
258the result. The next hook function receives a @var{fun} equivalent to
259this, and so on. The actual return value is the result of all the
260hook functions acting in sequence.
259@end defvar 261@end defvar
260 262
261@defun buffer-string 263@defun buffer-string