aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2014-05-26 18:53:45 -0700
committerGlenn Morris2014-05-26 18:53:45 -0700
commite9e341bb4bf06b25bc4feb754544c77b0021a3bd (patch)
tree649355b23a679308903efa3d0f31619f6b5c0463
parent4a12fa5c2e0d69d3dfbf94c9367006ab545e93cc (diff)
downloademacs-e9e341bb4bf06b25bc4feb754544c77b0021a3bd.tar.gz
emacs-e9e341bb4bf06b25bc4feb754544c77b0021a3bd.zip
Doc updates re filter-buffer-substring
* lisp/simple.el (filter-buffer-substring-functions) (filter-buffer-substring-function, buffer-substring-filters) (filter-buffer-substring, buffer-substring--filter): Doc fixes. * doc/lispref/text.texi (Buffer Contents): Update for filter-buffer-substring changes. * doc/lispref/hooks.texi: Remove old comment. * etc/NEWS: Related markup.
-rw-r--r--doc/lispref/ChangeLog3
-rw-r--r--doc/lispref/hooks.texi1
-rw-r--r--doc/lispref/text.texi65
-rw-r--r--etc/NEWS1
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/simple.el50
6 files changed, 72 insertions, 52 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index 75933560739..e4f5c60c2d1 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,5 +1,8 @@
12014-05-27 Glenn Morris <rgm@gnu.org> 12014-05-27 Glenn Morris <rgm@gnu.org>
2 2
3 * text.texi (Buffer Contents):
4 Update for filter-buffer-substring changes.
5
3 * abbrevs.texi (Abbrev Expansion): Update for expand-abbrev changes. 6 * abbrevs.texi (Abbrev Expansion): Update for expand-abbrev changes.
4 * functions.texi (Advising Functions): Standardize menu case. 7 * functions.texi (Advising Functions): Standardize menu case.
5 8
diff --git a/doc/lispref/hooks.texi b/doc/lispref/hooks.texi
index 19e30163590..9408174872d 100644
--- a/doc/lispref/hooks.texi
+++ b/doc/lispref/hooks.texi
@@ -243,7 +243,6 @@ completion-at-point-functions
243completion-list-insert-choice-function 243completion-list-insert-choice-function
244deactivate-current-input-method-function 244deactivate-current-input-method-function
245describe-current-input-method-function 245describe-current-input-method-function
246filter-buffer-substring-functions
247font-lock-function 246font-lock-function
248menu-bar-select-buffer-function 247menu-bar-select-buffer-function
249read-file-name-function 248read-file-name-function
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index 3c70f5f96b0..4c3286adbfc 100644
--- a/doc/lispref/text.texi
+++ b/doc/lispref/text.texi
@@ -220,15 +220,17 @@ the current buffer, as a string.
220@end defun 220@end defun
221 221
222@defun filter-buffer-substring start end &optional delete 222@defun filter-buffer-substring start end &optional delete
223This function passes the buffer text between @var{start} and @var{end} 223This function filters the buffer text between @var{start} and @var{end}
224through the filter functions specified by the wrapper hook 224using a function specified by the variable
225@code{filter-buffer-substring-functions}, and returns the result. The 225@code{filter-buffer-substring-function}, and returns the result.
226obsolete variable @code{buffer-substring-filters} is also consulted. 226
227If both of these variables are @code{nil}, the value is the unaltered 227The default filter function consults the obsolete wrapper hook
228text from the buffer, i.e., what @code{buffer-substring} would 228@code{filter-buffer-substring-functions}, and the obsolete variable
229return. 229@code{buffer-substring-filters}. If both of these are @code{nil}, it
230 230returns the unaltered text from the buffer, i.e., what
231If @var{delete} is non-@code{nil}, this function deletes the text 231@code{buffer-substring} would return.
232
233If @var{delete} is non-@code{nil}, the function deletes the text
232between @var{start} and @var{end} after copying it, like 234between @var{start} and @var{end} after copying it, like
233@code{delete-and-extract-region}. 235@code{delete-and-extract-region}.
234 236
@@ -236,20 +238,29 @@ Lisp code should use this function instead of @code{buffer-substring},
236@code{buffer-substring-no-properties}, 238@code{buffer-substring-no-properties},
237or @code{delete-and-extract-region} when copying into user-accessible 239or @code{delete-and-extract-region} when copying into user-accessible
238data structures such as the kill-ring, X clipboard, and registers. 240data structures such as the kill-ring, X clipboard, and registers.
239Major and minor modes can add functions to 241Major and minor modes can modify @code{filter-buffer-substring-function}
240@code{filter-buffer-substring-functions} to alter such text as it is 242to alter such text as it is copied out of the buffer.
241copied out of the buffer.
242@end defun 243@end defun
243 244
244@c FIXME: `filter-buffer-substring-function' should be documented. 245@defvar filter-buffer-substring-function
246The value of this variable is a function that @code{filter-buffer-substring}
247will call to do the actual work. The function receives three
248arguments, the same as those of @code{filter-buffer-substring},
249which it should treat as per the documentation of that function. It
250should return the filtered text (and optionally delete the source text).
251@end defvar
252
253@noindent The following two variables are obsoleted by
254@code{filter-buffer-substring-function}, but are still supported for
255backward compatibility.
256
245@defvar filter-buffer-substring-functions 257@defvar filter-buffer-substring-functions
246This variable is a wrapper hook (@pxref{Running Hooks}), whose members 258This obsolete variable is a wrapper hook, whose members should be functions
247should be functions that accept four arguments: @var{fun}, 259that accept four arguments: @var{fun}, @var{start}, @var{end}, and
248@var{start}, @var{end}, and @var{delete}. @var{fun} is a function 260@var{delete}. @var{fun} is a function that takes three arguments
249that takes three arguments (@var{start}, @var{end}, and @var{delete}), 261(@var{start}, @var{end}, and @var{delete}), and returns a string. In
250and returns a string. In both cases, the @var{start}, @var{end}, and 262both cases, the @var{start}, @var{end}, and @var{delete} arguments are
251@var{delete} arguments are the same as those of 263the same as those of @code{filter-buffer-substring}.
252@code{filter-buffer-substring}.
253 264
254The first hook function is passed a @var{fun} that is equivalent to 265The first hook function is passed a @var{fun} that is equivalent to
255the default operation of @code{filter-buffer-substring}, i.e., it 266the default operation of @code{filter-buffer-substring}, i.e., it
@@ -263,14 +274,12 @@ hook functions acting in sequence.
263@end defvar 274@end defvar
264 275
265@defvar buffer-substring-filters 276@defvar buffer-substring-filters
266This variable is obsoleted by 277The value of this obsolete variable should be a list of functions
267@code{filter-buffer-substring-functions}, but is still supported for 278that accept a single string argument and return another string.
268backward compatibility. Its value should should be a list of 279The default @code{filter-buffer-substring} function passes the buffer
269functions which accept a single string argument and return another 280substring to the first function in this list, and the return value of
270string. @code{filter-buffer-substring} passes the buffer substring to 281each function is passed to the next function. The return value of the
271the first function in this list, and the return value of each function 282last function is passed to @code{filter-buffer-substring-functions}.
272is passed to the next function. The return value of the last function
273is passed to @code{filter-buffer-substring-functions}.
274@end defvar 283@end defvar
275 284
276@defun current-word &optional strict really-word 285@defun current-word &optional strict really-word
diff --git a/etc/NEWS b/etc/NEWS
index 6dafa37711c..c272660af1b 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1361,6 +1361,7 @@ This is like the old `eval-after-load', but better behaved.
1361*** `generic-make-keywords-list' 1361*** `generic-make-keywords-list'
1362*** `get-upcase-table' (use `case-table-get-table' instead). 1362*** `get-upcase-table' (use `case-table-get-table' instead).
1363 1363
1364+++
1364** `with-wrapper-hook' is obsoleted by `add-function'. 1365** `with-wrapper-hook' is obsoleted by `add-function'.
1365The few hooks that used with-wrapper-hook are replaced as follows: 1366The few hooks that used with-wrapper-hook are replaced as follows:
1366*** `abbrev-expand-function' obsoletes `abbrev-expand-functions'. 1367*** `abbrev-expand-function' obsoletes `abbrev-expand-functions'.
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 13f68a4f476..1b886000014 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,9 @@
12014-05-27 Glenn Morris <rgm@gnu.org> 12014-05-27 Glenn Morris <rgm@gnu.org>
2 2
3 * simple.el (filter-buffer-substring-functions)
4 (filter-buffer-substring-function, buffer-substring-filters)
5 (filter-buffer-substring, buffer-substring--filter): Doc fixes.
6
3 * minibuffer.el (completion-in-region-functions, completion-in-region) 7 * minibuffer.el (completion-in-region-functions, completion-in-region)
4 (completion--in-region): Doc fixes. 8 (completion--in-region): Doc fixes.
5 9
diff --git a/lisp/simple.el b/lisp/simple.el
index 4e10de77964..f8499744194 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -3463,46 +3463,50 @@ These commands include \\[set-mark-command] and \\[start-kbd-macro]."
3463 3463
3464 3464
3465(defvar filter-buffer-substring-functions nil 3465(defvar filter-buffer-substring-functions nil
3466 "This variable is a wrapper hook around `filter-buffer-substring'.") 3466 "This variable is a wrapper hook around `buffer-substring--filter'.")
3467(make-obsolete-variable 'filter-buffer-substring-functions 3467(make-obsolete-variable 'filter-buffer-substring-functions
3468 'filter-buffer-substring-function "24.4") 3468 'filter-buffer-substring-function "24.4")
3469 3469
3470(defvar filter-buffer-substring-function #'buffer-substring--filter 3470(defvar filter-buffer-substring-function #'buffer-substring--filter
3471 "Function to perform the filtering in `filter-buffer-substring'. 3471 "Function to perform the filtering in `filter-buffer-substring'.
3472The function is called with 3 arguments: 3472The function is called with the same 3 arguments (BEG END DELETE)
3473\(BEG END DELETE). The arguments BEG, END, and DELETE are the same 3473that `filter-buffer-substring' received. It should return the
3474as those of `filter-buffer-substring' in each case. 3474buffer substring between BEG and END, after filtering. If DELETE is
3475It should return the buffer substring between BEG and END, after filtering.") 3475non-nil, it should delete the text between BEG and END from the buffer.")
3476 3476
3477(defvar buffer-substring-filters nil 3477(defvar buffer-substring-filters nil
3478 "List of filter functions for `filter-buffer-substring'. 3478 "List of filter functions for `buffer-substring--filter'.
3479Each function must accept a single argument, a string, and return 3479Each function must accept a single argument, a string, and return a string.
3480a string. The buffer substring is passed to the first function 3480The buffer substring is passed to the first function in the list,
3481in the list, and the return value of each function is passed to 3481and the return value of each function is passed to the next.
3482the next.
3483As a special convention, point is set to the start of the buffer text 3482As a special convention, point is set to the start of the buffer text
3484being operated on (i.e., the first argument of `filter-buffer-substring') 3483being operated on (i.e., the first argument of `buffer-substring--filter')
3485before these functions are called.") 3484before these functions are called.")
3486(make-obsolete-variable 'buffer-substring-filters 3485(make-obsolete-variable 'buffer-substring-filters
3487 'filter-buffer-substring-function "24.1") 3486 'filter-buffer-substring-function "24.1")
3488 3487
3489(defun filter-buffer-substring (beg end &optional delete) 3488(defun filter-buffer-substring (beg end &optional delete)
3490 "Return the buffer substring between BEG and END, after filtering. 3489 "Return the buffer substring between BEG and END, after filtering.
3491The hook `filter-buffer-substring-function' performs the actual filtering. 3490If DELETE is non-nil, delete the text between BEG and END from the buffer.
3492By default, no filtering is done. 3491
3493 3492This calls the function that `filter-buffer-substring-function' specifies
3494If DELETE is non-nil, the text between BEG and END is deleted 3493\(passing the same three arguments that it received) to do the work,
3495from the buffer. 3494and returns whatever it does. The default function does no filtering,
3496 3495unless a hook has been set.
3497This function should be used instead of `buffer-substring', 3496
3498`buffer-substring-no-properties', or `delete-and-extract-region' 3497Use `filter-buffer-substring' instead of `buffer-substring',
3499when you want to allow filtering to take place. For example, 3498`buffer-substring-no-properties', or `delete-and-extract-region' when
3500major or minor modes can use `filter-buffer-substring-function' to 3499you want to allow filtering to take place. For example, major or minor
3501extract characters that are special to a buffer, and should not 3500modes can use `filter-buffer-substring-function' to extract characters
3502be copied into other buffers." 3501that are special to a buffer, and should not be copied into other buffers."
3503 (funcall filter-buffer-substring-function beg end delete)) 3502 (funcall filter-buffer-substring-function beg end delete))
3504 3503
3505(defun buffer-substring--filter (beg end &optional delete) 3504(defun buffer-substring--filter (beg end &optional delete)
3505 "Default function to use for `filter-buffer-substring-function'.
3506Its arguments and return value are as specified for `filter-buffer-substring'.
3507This respects the wrapper hook `filter-buffer-substring-functions',
3508and the abnormal hook `buffer-substring-filters'.
3509No filtering is done unless a hook says to."
3506 (with-wrapper-hook filter-buffer-substring-functions (beg end delete) 3510 (with-wrapper-hook filter-buffer-substring-functions (beg end delete)
3507 (cond 3511 (cond
3508 ((or delete buffer-substring-filters) 3512 ((or delete buffer-substring-filters)