Function: consult--buffer-query
consult--buffer-query is a byte-compiled function defined in
consult.el.
Signature
(consult--buffer-query &key SORT DIRECTORY MODE AS PREDICATE (FILTER t) INCLUDE (EXCLUDE consult-buffer-filter) (BUFFER-LIST consult-buffer-list-function))
Documentation
Query for a list of matching buffers.
The function supports filtering by various criteria which are
used throughout Consult. In particular it is the backbone of
most consult-buffer-sources.
DIRECTORY can either be the symbol project or a file name.
SORT can be visibility, alpha or nil.
FILTER can be either t, nil or invert.
EXCLUDE is a list of regexps.
INCLUDE is a list of regexps.
MODE can be a mode or a list of modes to restrict the returned buffers.
PREDICATE is a predicate function.
BUFFER-LIST is a function or a list of buffers.
AS is a conversion function.
Source Code
;; Defined in ~/.emacs.d/elpa/consult-20260805.1130/consult.el
(cl-defun consult--buffer-query ( &key sort directory mode as predicate (filter t)
include (exclude consult-buffer-filter)
(buffer-list consult-buffer-list-function))
"Query for a list of matching buffers.
The function supports filtering by various criteria which are
used throughout Consult. In particular it is the backbone of
most `consult-buffer-sources'.
DIRECTORY can either be the symbol project or a file name.
SORT can be visibility, alpha or nil.
FILTER can be either t, nil or invert.
EXCLUDE is a list of regexps.
INCLUDE is a list of regexps.
MODE can be a mode or a list of modes to restrict the returned buffers.
PREDICATE is a predicate function.
BUFFER-LIST is a function or a list of buffers.
AS is a conversion function."
(let ((root (consult--normalize-directory directory)))
(setq buffer-list (cond
((functionp buffer-list) (funcall buffer-list))
((listp buffer-list) (copy-sequence buffer-list))
(t (buffer-list))))
(when (or filter mode root)
(let ((exclude-re (consult--regexp-filter exclude))
(include-re (consult--regexp-filter include))
(case-fold-search))
(consult--keep! buffer-list
(and
(or (not mode)
(let ((mm (buffer-local-value 'major-mode it)))
(if (consp mode)
(any (lambda (m) (provided-mode-derived-p mm m)) mode)
(provided-mode-derived-p mm mode))))
(pcase-exhaustive filter
('nil t)
((or 't 'invert)
(eq (eq filter t)
(and
(or (not exclude)
(not (string-match-p exclude-re (buffer-name it))))
(or (not include)
(not (not (string-match-p include-re (buffer-name it)))))))))
(or (not root)
(when-let* ((dir (buffer-local-value 'default-directory it)))
(string-prefix-p root
(if (and (/= 0 (length dir)) (eq (aref dir 0) ?/))
dir
(expand-file-name dir)))))
(or (not predicate) (funcall predicate it))
it))))
(when sort
(setq buffer-list (funcall (intern (format "consult--buffer-sort-%s" sort)) buffer-list)))
(when as
(cl-loop for it in-ref buffer-list do (setf it (funcall as it))))
buffer-list))