diff options
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/lispref/ChangeLog | 5 | ||||
| -rw-r--r-- | doc/lispref/text.texi | 52 |
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 @@ | |||
| 1 | 2012-02-04 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * text.texi (Buffer Contents): | ||
| 4 | Update filter-buffer-substring description. | ||
| 5 | |||
| 1 | 2012-02-04 Chong Yidong <cyd@gnu.org> | 6 | 2012-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 | |||
| 218 | properties, just the characters themselves. @xref{Text Properties}. | 218 | properties, 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 |
| 222 | This function passes the buffer text between @var{start} and @var{end} | 222 | This function passes the buffer text between @var{start} and @var{end} |
| 223 | through the filter functions specified by the variable | 223 | through 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 |
| 225 | filter function. If @code{buffer-substring-filters} is @code{nil}, | 225 | result of applying all filters. The obsolete variable |
| 226 | the 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. | 227 | variables are @code{nil}, the value is the unaltered text from the |
| 228 | buffer, as @code{buffer-substring} would return. | ||
| 228 | 229 | ||
| 229 | If @var{delete} is non-@code{nil}, this function deletes the text | 230 | If @var{delete} is non-@code{nil}, this function deletes the text |
| 230 | between @var{start} and @var{end} after copying it, like | 231 | between @var{start} and @var{end} after copying it, like |
| 231 | @code{delete-and-extract-region}. | 232 | @code{delete-and-extract-region}. |
| 232 | 233 | ||
| 233 | If @var{noprops} is non-@code{nil}, the final string returned does not | ||
| 234 | include text properties, while the string passed through the filters | ||
| 235 | still includes text properties from the buffer text. | ||
| 236 | |||
| 237 | Lisp code should use this function instead of @code{buffer-substring}, | 234 | Lisp code should use this function instead of @code{buffer-substring}, |
| 238 | @code{buffer-substring-no-properties}, | 235 | @code{buffer-substring-no-properties}, |
| 239 | or @code{delete-and-extract-region} when copying into user-accessible | 236 | or @code{delete-and-extract-region} when copying into user-accessible |
| 240 | data structures such as the kill-ring, X clipboard, and registers. | 237 | data structures such as the kill-ring, X clipboard, and registers. |
| 241 | Major and minor modes can add functions to | 238 | Major 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 |
| 243 | of the buffer. | 240 | copied out of the buffer. |
| 244 | @end defun | 241 | @end defun |
| 245 | 242 | ||
| 246 | @defvar buffer-substring-filters | 243 | @defvar filter-buffer-substring-functions |
| 247 | This variable should be a list of functions that accept a single | 244 | This variable is a wrapper hook (@pxref{Running Hooks}), whose members |
| 248 | argument, a string, and return a string. | 245 | should 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 |
| 250 | first function in this list, and the return value of each function is | 247 | that takes three arguments (@var{start}, @var{end}, and @var{delete}), |
| 251 | passed to the next function. The return value of the last function is | 248 | and returns a string. In both cases, the @var{start}, @var{end}, and |
| 252 | used 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}. | |
| 254 | As a special convention, point is set to the start of the buffer text | 251 | |
| 255 | being operated on (i.e., the @var{start} argument for | 252 | The first hook function is passed a @var{fun} that is equivalent to |
| 256 | @code{filter-buffer-substring}) before these functions are called. | 253 | the default operation of @code{filter-buffer-substring}, i.e. it |
| 257 | 254 | returns the buffer-substring between @var{start} and @var{end} | |
| 258 | If this variable is @code{nil}, no filtering is performed. | 255 | (processed by any @code{buffer-substring-filters}) and optionally |
| 256 | deletes the original text from the buffer. In most cases, the hook | ||
| 257 | function will call @var{fun} once, and then do its own processing of | ||
| 258 | the result. The next hook function receives a @var{fun} equivalent to | ||
| 259 | this, and so on. The actual return value is the result of all the | ||
| 260 | hook functions acting in sequence. | ||
| 259 | @end defvar | 261 | @end defvar |
| 260 | 262 | ||
| 261 | @defun buffer-string | 263 | @defun buffer-string |