; Clarify documentation of 'filter-buffer-substring'

* doc/lispref/text.texi (Buffer Contents): Clarify that the order
of buffer positions in arguments of 'filter-buffer-substring'
should not matter.

* lisp/simple.el (filter-buffer-substring-function):
(filter-buffer-substring): Doc fix.
This commit is contained in:
Eli Zaretskii 2026-07-13 15:34:11 +03:00
parent b6412271e1
commit 7a9c004924
2 changed files with 11 additions and 3 deletions

View file

@ -238,7 +238,10 @@ reordering of bidirectional text, use the
@defun filter-buffer-substring start end &optional delete
This function filters the buffer text between @var{start} and @var{end}
using a function specified by the variable
@code{filter-buffer-substring-function}, and returns the result.
@code{filter-buffer-substring-function}, and returns the result. The
order of buffer positions specified by @var{start} and @var{end} should
not matter, since this function is frequently used for extracting text
passed to kill functions (@pxref{Kill Functions}).
The default filter function consults the obsolete wrapper hook
@code{filter-buffer-substring-functions} (see the documentation string
@ -264,6 +267,9 @@ will call to do the actual work. The function receives three
arguments, the same as those of @code{filter-buffer-substring},
which it should treat as per the documentation of that function. It
should return the filtered text (and optionally delete the source text).
Note that it must process the @var{start} and @var{end} arguments
regardless of the order of the buffer positions they specify, to comply
with the protocol of extracting text for the purposes of killing it.
@end defvar
@noindent The following two variables are obsoleted by

View file

@ -5579,12 +5579,14 @@ These commands include \\[set-mark-command] and \\[start-kbd-macro]."
"Function to perform the filtering in `filter-buffer-substring'.
The function is called with the same 3 arguments (BEG END DELETE)
that `filter-buffer-substring' received. It should return the
buffer substring between BEG and END, after filtering. If DELETE is
non-nil, it should delete the text between BEG and END from the buffer.")
buffer substring between BEG and END, regardless of the order of
BEG and END, after filtering. If DELETE is non-nil, it should
delete the text between BEG and END from the buffer.")
(defun filter-buffer-substring (beg end &optional delete)
"Return the buffer substring between BEG and END, after filtering.
If DELETE is non-nil, delete the text between BEG and END from the buffer.
The order of BEG and END does not matter.
This calls the function that `filter-buffer-substring-function' specifies
\(passing the same three arguments that it received) to do the work,