aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/lispref/ChangeLog5
-rw-r--r--doc/lispref/text.texi52
-rw-r--r--etc/NEWS6
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/simple.el38
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 @@
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
diff --git a/etc/NEWS b/etc/NEWS
index 0a401eb3a3f..98fbc6302dd 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1019,6 +1019,11 @@ similar to the ones created by shift-selection. In previous Emacs
1019versions, these regions were delineated by `mouse-drag-overlay', which 1019versions, these regions were delineated by `mouse-drag-overlay', which
1020has now been removed. 1020has now been removed.
1021 1021
1022+++
1023** The fourth argument of filter-buffer-substring, which says to remove
1024text properties from the final result, has been removed.
1025Eg 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.
1416Rather than setting this to t, disable Tooltip mode instead. 1421Rather than setting this to t, disable Tooltip mode instead.
1417 1422
1423+++
1418*** buffer-substring-filters is obsolete. 1424*** buffer-substring-filters is obsolete.
1419Use `filter-buffer-substring-functions' instead. 1425Use `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 @@
12012-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
12012-02-04 Lars Ljung <lars@matholka.se> (tiny change) 62012-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'.
2918The functions on this special hook are called with four arguments: 2918Each 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
2920NEXT-FUN is a function of three arguments (BEG END DELETE) 2920\(BEG END DELETE). The arguments BEG, END, and DELETE are the same
2921that performs the default operation. The other three arguments 2921as those of `filter-buffer-substring' in each case.
2922are like the ones passed to `filter-buffer-substring'.") 2922
2923The first hook function to be called receives a FUN equivalent
2924to the default operation of `filter-buffer-substring',
2925i.e. one that returns the buffer-substring between BEG and
2926END (processed by any `buffer-substring-filters'). Normally,
2927the hook function will call FUN and then do its own processing
2928of the result. The next hook function receives a FUN equivalent
2929to the previous hook function, calls it, and does its own
2930processing, and so on. The overall result is that of all hook
2931functions acting in sequence.
2932
2933Any hook may choose not to call FUN though, in which case it
2934effectively replaces the default behavior with whatever it chooses.
2935Of 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'.
2926Each function must accept a single argument, a string, and return 2939Each function must accept a single argument, a string, and return
2927a string. The buffer substring is passed to the first function 2940a string. The buffer substring is passed to the first function
2928in the list, and the return value of each function is passed to 2941in the list, and the return value of each function is passed to
2929the next. The return value of the last function is used as the 2942the next. The final result (if `buffer-substring-filters' is
2930return value of `filter-buffer-substring'. 2943nil, this is the unfiltered buffer-substring) is passed to the
2944first function on `filter-buffer-substring-functions'.
2931 2945
2932If this variable is nil, no filtering is performed.") 2946As a special convention, point is set to the start of the buffer text
2947being operated on (i.e., the first argument of `filter-buffer-substring')
2948before 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.
2938The filtering is performed by `filter-buffer-substring-functions'. 2954The wrapper hook `filter-buffer-substring-functions' performs
2955the actual filtering. The obsolete variable `buffer-substring-filters'
2956is also consulted. If both of these are nil, no filtering is done.
2939 2957
2940If DELETE is non-nil, the text between BEG and END is deleted 2958If DELETE is non-nil, the text between BEG and END is deleted
2941from the buffer. 2959from the buffer.