summaryrefslogtreecommitdiff
path: root/lispref
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>2005-03-29 21:08:37 +0000
committerRichard M. Stallman <rms@gnu.org>2005-03-29 21:08:37 +0000
commit8e669bbd42c254c32e3fffa489f4d97d48d9bd76 (patch)
tree5a8048440a13b38a921565b3458f66d420cd583f /lispref
parent19e7dd23ed5859155f955ff327bba9bfc4cf58de (diff)
downloademacs-8e669bbd42c254c32e3fffa489f4d97d48d9bd76.tar.gz
(Buffer Contents): Add filter-buffer-substring and buffer-substring-filters.
Diffstat (limited to 'lispref')
-rw-r--r--lispref/ChangeLog5
-rw-r--r--lispref/text.texi35
2 files changed, 40 insertions, 0 deletions
diff --git a/lispref/ChangeLog b/lispref/ChangeLog
index 232e992e658..7f22ad2e485 100644
--- a/lispref/ChangeLog
+++ b/lispref/ChangeLog
@@ -1,3 +1,8 @@
+2005-03-29 Chong Yidong <cyd@stupidchicken.com>
+
+ * text.texi (Buffer Contents): Add filter-buffer-substring and
+ buffer-substring-filters.
+
2005-03-26 Chong Yidong <cyd@stupidchicken.com>
* anti.texi (Antinews): Mention `G' interactive code.
diff --git a/lispref/text.texi b/lispref/text.texi
index e300b345454..1d4dc0fce8a 100644
--- a/lispref/text.texi
+++ b/lispref/text.texi
@@ -207,6 +207,41 @@ This is like @code{buffer-substring}, except that it does not copy text
properties, just the characters themselves. @xref{Text Properties}.
@end defun
+@defun filter-buffer-substring start end &optional delete
+This function passes the buffer text between @var{start} and @var{end}
+through the filter functions specified by the variable
+@code{buffer-substring-filters}, and returns the value from the last
+filter function. If @code{buffer-substring-filters} is @code{nil},
+the value is the unaltered text from the buffer, what
+@code{buffer-substring} would return.
+
+If @var{delete} is non-@code{nil}, this function deletes the text
+between @var{start} and @var{end} after copying it, like
+@code{delete-and-extract-region}.
+
+Lisp code should use this function instead of @code{buffer-substring}
+or @code{delete-and-extract-region} when copying into user-accessible
+data structures such as the kill-ring, X clipboard, and registers.
+Major and minor modes can add functions to
+@code{buffer-substring-filters} to alter such text as it is copied out
+of the buffer.
+@end defun
+
+@defvar buffer-substring-filters
+This variable should be a list of functions that accept a single
+argument, a string, and return a string.
+@code{filter-buffer-substring} passes the buffer substring to the
+first function in this list, and the return value of each function is
+passed to the next function. The return value of the last function is
+used as the return value of @code{filter-buffer-substring}.
+
+As a special convention, point is set to the start of the buffer text
+being operated on (i.e., the @var{start} argument for
+@code{filter-buffer-substring}) before these functions are called.
+
+If this variable is @code{nil}, no filtering is performed.
+@end defvar
+
@defun buffer-string
This function returns the contents of the entire accessible portion of
the current buffer as a string. It is equivalent to