diff options
| author | Richard M. Stallman | 2005-03-29 21:08:37 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2005-03-29 21:08:37 +0000 |
| commit | 8e669bbd42c254c32e3fffa489f4d97d48d9bd76 (patch) | |
| tree | 5a8048440a13b38a921565b3458f66d420cd583f /lispref | |
| parent | 19e7dd23ed5859155f955ff327bba9bfc4cf58de (diff) | |
| download | emacs-8e669bbd42c254c32e3fffa489f4d97d48d9bd76.tar.gz emacs-8e669bbd42c254c32e3fffa489f4d97d48d9bd76.zip | |
(Buffer Contents): Add filter-buffer-substring and buffer-substring-filters.
Diffstat (limited to 'lispref')
| -rw-r--r-- | lispref/ChangeLog | 5 | ||||
| -rw-r--r-- | lispref/text.texi | 35 |
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 @@ | |||
| 1 | 2005-03-29 Chong Yidong <cyd@stupidchicken.com> | ||
| 2 | |||
| 3 | * text.texi (Buffer Contents): Add filter-buffer-substring and | ||
| 4 | buffer-substring-filters. | ||
| 5 | |||
| 1 | 2005-03-26 Chong Yidong <cyd@stupidchicken.com> | 6 | 2005-03-26 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 7 | ||
| 3 | * anti.texi (Antinews): Mention `G' interactive code. | 8 | * 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 | |||
| 207 | properties, just the characters themselves. @xref{Text Properties}. | 207 | properties, just the characters themselves. @xref{Text Properties}. |
| 208 | @end defun | 208 | @end defun |
| 209 | 209 | ||
| 210 | @defun filter-buffer-substring start end &optional delete | ||
| 211 | This function passes the buffer text between @var{start} and @var{end} | ||
| 212 | through the filter functions specified by the variable | ||
| 213 | @code{buffer-substring-filters}, and returns the value from the last | ||
| 214 | filter function. If @code{buffer-substring-filters} is @code{nil}, | ||
| 215 | the value is the unaltered text from the buffer, what | ||
| 216 | @code{buffer-substring} would return. | ||
| 217 | |||
| 218 | If @var{delete} is non-@code{nil}, this function deletes the text | ||
| 219 | between @var{start} and @var{end} after copying it, like | ||
| 220 | @code{delete-and-extract-region}. | ||
| 221 | |||
| 222 | Lisp code should use this function instead of @code{buffer-substring} | ||
| 223 | or @code{delete-and-extract-region} when copying into user-accessible | ||
| 224 | data structures such as the kill-ring, X clipboard, and registers. | ||
| 225 | Major and minor modes can add functions to | ||
| 226 | @code{buffer-substring-filters} to alter such text as it is copied out | ||
| 227 | of the buffer. | ||
| 228 | @end defun | ||
| 229 | |||
| 230 | @defvar buffer-substring-filters | ||
| 231 | This variable should be a list of functions that accept a single | ||
| 232 | argument, a string, and return a string. | ||
| 233 | @code{filter-buffer-substring} passes the buffer substring to the | ||
| 234 | first function in this list, and the return value of each function is | ||
| 235 | passed to the next function. The return value of the last function is | ||
| 236 | used as the return value of @code{filter-buffer-substring}. | ||
| 237 | |||
| 238 | As a special convention, point is set to the start of the buffer text | ||
| 239 | being operated on (i.e., the @var{start} argument for | ||
| 240 | @code{filter-buffer-substring}) before these functions are called. | ||
| 241 | |||
| 242 | If this variable is @code{nil}, no filtering is performed. | ||
| 243 | @end defvar | ||
| 244 | |||
| 210 | @defun buffer-string | 245 | @defun buffer-string |
| 211 | This function returns the contents of the entire accessible portion of | 246 | This function returns the contents of the entire accessible portion of |
| 212 | the current buffer as a string. It is equivalent to | 247 | the current buffer as a string. It is equivalent to |