; Improve documentation of 'match-buffers'

* doc/lispref/buffers.texi (Buffer List):
* lisp/subr.el (match-buffers): Fix documentation of
'buffer-match-p' and 'match-buffers'.
This commit is contained in:
Eli Zaretskii 2023-04-10 12:30:23 +03:00
parent d4d0da96f0
commit 2445100d7d
2 changed files with 20 additions and 17 deletions

View file

@ -959,9 +959,9 @@ infinite recursion.
@defun buffer-match-p condition buffer-or-name &optional arg @defun buffer-match-p condition buffer-or-name &optional arg
This function checks if a buffer designated by @code{buffer-or-name} This function checks if a buffer designated by @code{buffer-or-name}
satisfies a @code{condition}. Optional third argument @var{arg} is satisfies the specified @code{condition}. Optional third argument
passed to the predicate function in @var{condition}. A condition can @var{arg} is passed to the predicate function in @var{condition}. A
be one of the following: valid @var{condition} can be one of the following:
@itemize @bullet{} @itemize @bullet{}
@item @item
A string, interpreted as a regular expression. The buffer A string, interpreted as a regular expression. The buffer
@ -990,21 +990,23 @@ Satisfied if @emph{all} the conditions in @var{conds} satisfy
Satisfied if the buffer's major mode derives from @var{expr}. Satisfied if the buffer's major mode derives from @var{expr}.
@item major-mode @item major-mode
Satisfied if the buffer's major mode is equal to @var{expr}. Prefer Satisfied if the buffer's major mode is equal to @var{expr}. Prefer
using @code{derived-mode} instead when both can work. using @code{derived-mode} instead, when both can work.
@end table @end table
@item t @item t
Satisfied by any buffer. A convenient alternative to @code{""} (empty Satisfied by any buffer. A convenient alternative to @code{""} (empty
string), @code{(and)} (empty conjunction) or @code{always}. string) or @code{(and)} (empty conjunction).
@end itemize @end itemize
@end defun @end defun
@defun match-buffers condition &optional buffer-list arg @defun match-buffers condition &optional buffer-list arg
This function returns a list of all buffers that satisfy a This function returns a list of all buffers that satisfy the
@code{condition}, as defined for @code{buffer-match-p}. By default @code{condition}. If no buffers match, the function returns
all buffers are considered, but this can be restricted via the second @code{nil}. The argument @var{condition} is as defined in
optional @code{buffer-list} argument. Optional third argument @code{buffer-match-p} above. By default, all the buffers are
@var{arg} will be used by @var{condition} in the same way as considered, but this can be restricted via the optional argument
@code{buffer-match-p} does. @code{buffer-list}, which should be a list of buffers to consider.
Optional third argument @var{arg} will be passed to @var{condition} in
the same way as @code{buffer-match-p} does.
@end defun @end defun
@node Creating Buffers @node Creating Buffers

View file

@ -7128,12 +7128,13 @@ CONDITION is either:
(funcall match (list condition)))) (funcall match (list condition))))
(defun match-buffers (condition &optional buffers arg) (defun match-buffers (condition &optional buffers arg)
"Return a list of buffers that match CONDITION. "Return a list of buffers that match CONDITION, or nil if none match.
See `buffer-match-p' for details on CONDITION. By default all See `buffer-match-p' for various supported CONDITIONs.
buffers are checked, this can be restricted by passing an By default all buffers are checked, but the optional
optional argument BUFFERS, set to a list of buffers to check. argument BUFFERS can restrict that: its value should be
ARG is passed to `buffer-match', for predicate conditions in an explicit list of buffers to check.
CONDITION." Optional argument ARG is passed to `buffer-match-p', for
predicate conditions in CONDITION."
(let (bufs) (let (bufs)
(dolist (buf (or buffers (buffer-list))) (dolist (buf (or buffers (buffer-list)))
(when (buffer-match-p condition (get-buffer buf) arg) (when (buffer-match-p condition (get-buffer buf) arg)