diff options
| -rw-r--r-- | doc/lispref/ChangeLog | 5 | ||||
| -rw-r--r-- | doc/lispref/text.texi | 52 | ||||
| -rw-r--r-- | etc/NEWS | 6 | ||||
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/simple.el | 38 |
5 files changed, 71 insertions, 35 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 |
| @@ -1019,6 +1019,11 @@ similar to the ones created by shift-selection. In previous Emacs | |||
| 1019 | versions, these regions were delineated by `mouse-drag-overlay', which | 1019 | versions, these regions were delineated by `mouse-drag-overlay', which |
| 1020 | has now been removed. | 1020 | has now been removed. |
| 1021 | 1021 | ||
| 1022 | +++ | ||
| 1023 | ** The fourth argument of filter-buffer-substring, which says to remove | ||
| 1024 | text properties from the final result, has been removed. | ||
| 1025 | Eg simply pass the result through substring-no-properties if you need this. | ||
| 1026 | |||
| 1022 | --- | 1027 | --- |
| 1023 | ** cl.el no longer provides `cl-19'. | 1028 | ** cl.el no longer provides `cl-19'. |
| 1024 | 1029 | ||
| @@ -1415,6 +1420,7 @@ an empty uninterned symbol. | |||
| 1415 | *** `tooltip-use-echo-area' is obsolete. | 1420 | *** `tooltip-use-echo-area' is obsolete. |
| 1416 | Rather than setting this to t, disable Tooltip mode instead. | 1421 | Rather than setting this to t, disable Tooltip mode instead. |
| 1417 | 1422 | ||
| 1423 | +++ | ||
| 1418 | *** buffer-substring-filters is obsolete. | 1424 | *** buffer-substring-filters is obsolete. |
| 1419 | Use `filter-buffer-substring-functions' instead. | 1425 | Use `filter-buffer-substring-functions' instead. |
| 1420 | 1426 | ||
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 888b7e20307..89ce0f67408 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2012-02-04 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * simple.el (filter-buffer-substring-functions) | ||
| 4 | (buffer-substring-filters, filter-buffer-substring): Doc fixes. | ||
| 5 | |||
| 1 | 2012-02-04 Lars Ljung <lars@matholka.se> (tiny change) | 6 | 2012-02-04 Lars Ljung <lars@matholka.se> (tiny change) |
| 2 | 7 | ||
| 3 | * eshell/esh-ext.el (eshell-windows-shell-file): Match "cmdproxy" | 8 | * eshell/esh-ext.el (eshell-windows-shell-file): Match "cmdproxy" |
diff --git a/lisp/simple.el b/lisp/simple.el index cc56dfe04ce..8bd32a8db8d 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -2914,28 +2914,46 @@ These commands include \\[set-mark-command] and \\[start-kbd-macro]." | |||
| 2914 | 2914 | ||
| 2915 | 2915 | ||
| 2916 | (defvar filter-buffer-substring-functions nil | 2916 | (defvar filter-buffer-substring-functions nil |
| 2917 | "Wrapper hook around `filter-buffer-substring'. | 2917 | "This variable is a wrapper hook around `filter-buffer-substring'. |
| 2918 | The functions on this special hook are called with four arguments: | 2918 | Each member of the hook should be a function accepting four arguments: |
| 2919 | NEXT-FUN BEG END DELETE | 2919 | \(FUN BEG END DELETE), where FUN is itself a function of three arguments |
| 2920 | NEXT-FUN is a function of three arguments (BEG END DELETE) | 2920 | \(BEG END DELETE). The arguments BEG, END, and DELETE are the same |
| 2921 | that performs the default operation. The other three arguments | 2921 | as those of `filter-buffer-substring' in each case. |
| 2922 | are like the ones passed to `filter-buffer-substring'.") | 2922 | |
| 2923 | The first hook function to be called receives a FUN equivalent | ||
| 2924 | to the default operation of `filter-buffer-substring', | ||
| 2925 | i.e. one that returns the buffer-substring between BEG and | ||
| 2926 | END (processed by any `buffer-substring-filters'). Normally, | ||
| 2927 | the hook function will call FUN and then do its own processing | ||
| 2928 | of the result. The next hook function receives a FUN equivalent | ||
| 2929 | to the previous hook function, calls it, and does its own | ||
| 2930 | processing, and so on. The overall result is that of all hook | ||
| 2931 | functions acting in sequence. | ||
| 2932 | |||
| 2933 | Any hook may choose not to call FUN though, in which case it | ||
| 2934 | effectively replaces the default behavior with whatever it chooses. | ||
| 2935 | Of course, a later hook function may do the same thing.") | ||
| 2923 | 2936 | ||
| 2924 | (defvar buffer-substring-filters nil | 2937 | (defvar buffer-substring-filters nil |
| 2925 | "List of filter functions for `filter-buffer-substring'. | 2938 | "List of filter functions for `filter-buffer-substring'. |
| 2926 | Each function must accept a single argument, a string, and return | 2939 | Each function must accept a single argument, a string, and return |
| 2927 | a string. The buffer substring is passed to the first function | 2940 | a string. The buffer substring is passed to the first function |
| 2928 | in the list, and the return value of each function is passed to | 2941 | in the list, and the return value of each function is passed to |
| 2929 | the next. The return value of the last function is used as the | 2942 | the next. The final result (if `buffer-substring-filters' is |
| 2930 | return value of `filter-buffer-substring'. | 2943 | nil, this is the unfiltered buffer-substring) is passed to the |
| 2944 | first function on `filter-buffer-substring-functions'. | ||
| 2931 | 2945 | ||
| 2932 | If this variable is nil, no filtering is performed.") | 2946 | As a special convention, point is set to the start of the buffer text |
| 2947 | being operated on (i.e., the first argument of `filter-buffer-substring') | ||
| 2948 | before these functions are called.") | ||
| 2933 | (make-obsolete-variable 'buffer-substring-filters | 2949 | (make-obsolete-variable 'buffer-substring-filters |
| 2934 | 'filter-buffer-substring-functions "24.1") | 2950 | 'filter-buffer-substring-functions "24.1") |
| 2935 | 2951 | ||
| 2936 | (defun filter-buffer-substring (beg end &optional delete) | 2952 | (defun filter-buffer-substring (beg end &optional delete) |
| 2937 | "Return the buffer substring between BEG and END, after filtering. | 2953 | "Return the buffer substring between BEG and END, after filtering. |
| 2938 | The filtering is performed by `filter-buffer-substring-functions'. | 2954 | The wrapper hook `filter-buffer-substring-functions' performs |
| 2955 | the actual filtering. The obsolete variable `buffer-substring-filters' | ||
| 2956 | is also consulted. If both of these are nil, no filtering is done. | ||
| 2939 | 2957 | ||
| 2940 | If DELETE is non-nil, the text between BEG and END is deleted | 2958 | If DELETE is non-nil, the text between BEG and END is deleted |
| 2941 | from the buffer. | 2959 | from the buffer. |