Function: consult-buffer

consult-buffer is an autoloaded, interactive and byte-compiled function defined in consult.el.

Signature

(consult-buffer &optional SOURCES)

Documentation

Enhanced switch-to-buffer command with support for virtual buffers.

The command supports recent files, bookmarks, views and project files as virtual buffers. Buffers are previewed. Narrowing to buffers (b), files (f), bookmarks (m) and project files (p) is supported via the corresponding keys. In order to determine the project-specific files and buffers, the consult-project-function is used. The virtual buffer SOURCES default to consult-buffer-sources. See consult--multi for the configuration of the virtual buffer sources.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/consult-20260805.1130/consult.el
;;;###autoload
(defun consult-buffer (&optional sources)
  "Enhanced `switch-to-buffer' command with support for virtual buffers.

The command supports recent files, bookmarks, views and project files as
virtual buffers.  Buffers are previewed.  Narrowing to buffers (b), files (f),
bookmarks (m) and project files (p) is supported via the corresponding
keys.  In order to determine the project-specific files and buffers, the
`consult-project-function' is used.  The virtual buffer SOURCES
default to `consult-buffer-sources'.  See `consult--multi' for the
configuration of the virtual buffer sources."
  (interactive)
  (let ((selected (consult--multi (or sources consult-buffer-sources)
                                  :require-match
                                  (confirm-nonexistent-file-or-buffer)
                                  :prompt "Switch to: "
                                  :history 'consult--buffer-history
                                  :sort nil)))
    ;; For non-matching candidates, fall back to buffer creation.
    (unless (plist-get (cdr selected) :match)
      (consult--buffer-action (car selected)))))