called with the buffer. If this function returns non-nil,
then the buffer will be displayed in the buffer list.")
+(defvar-local Buffer-menu-buffer-list nil
+ "The current list of buffers or function to return buffers.")
+
(defvar-keymap Buffer-menu-mode-map
:doc "Local keymap for `Buffer-menu-mode' buffers."
:parent tabulated-list-mode-map
This is called by `buffer-menu' and others as a subroutine.
If FILES-ONLY is non-nil, show only file-visiting buffers.
-If BUFFER-LIST is non-nil, it should be a list of buffers; it
-means list those buffers and no others.
+If BUFFER-LIST is non-nil, it should be either a list of buffers
+or a function that returns a list of buffers; it means
+list those buffers and no others.
+See more at `Buffer-menu-buffer-list'.
If FILTER-PREDICATE is non-nil, it should be a function
that filters out buffers from the list of buffers.
See more at `Buffer-menu-filter-predicate'."
(Buffer-menu-mode)
(setq Buffer-menu-files-only
(and files-only (>= (prefix-numeric-value files-only) 0)))
+ (setq Buffer-menu-buffer-list buffer-list)
(setq Buffer-menu-filter-predicate filter-predicate)
(list-buffers--refresh buffer-list old-buffer)
(tabulated-list-print))
Buffer-menu-filter-predicate))
entries name-width)
;; Collect info for each buffer we're interested in.
- (dolist (buffer (or buffer-list
- (buffer-list (if Buffer-menu-use-frame-buffer-list
- (selected-frame)))))
+ (dolist (buffer (cond
+ ((functionp buffer-list)
+ (funcall buffer-list))
+ (buffer-list)
+ ((functionp Buffer-menu-buffer-list)
+ (funcall Buffer-menu-buffer-list))
+ (Buffer-menu-buffer-list)
+ (t (buffer-list
+ (if Buffer-menu-use-frame-buffer-list
+ (selected-frame))))))
(with-current-buffer buffer
(let* ((name (buffer-name))
(file buffer-file-name))
start with a space (which are for internal use). With prefix argument
ARG, show only buffers that are visiting files."
(interactive "P")
- (let ((pr (project-current t)))
+ (let* ((pr (project-current t))
+ (buffer-list-function
+ (lambda ()
+ (seq-filter
+ (lambda (buffer)
+ (let ((name (buffer-name buffer))
+ (file (buffer-file-name buffer)))
+ (and (or (not (string= (substring name 0 1) " "))
+ file)
+ (not (eq buffer (current-buffer)))
+ (or file (not Buffer-menu-files-only)))))
+ (project-buffers pr)))))
(display-buffer
(if (version< emacs-version "29.0.50")
- (let ((buf (list-buffers-noselect arg (project-buffers pr))))
+ (let ((buf (list-buffers-noselect
+ arg (with-current-buffer
+ (get-buffer-create "*Buffer List*")
+ (let ((Buffer-menu-files-only arg))
+ (funcall buffer-list-function))))))
(with-current-buffer buf
(setq-local revert-buffer-function
(lambda (&rest _ignored)
- (list-buffers--refresh (project-buffers pr))
+ (list-buffers--refresh
+ (funcall buffer-list-function))
(tabulated-list-print t))))
buf)
- (list-buffers-noselect
- arg nil (lambda (buf) (memq buf (project-buffers pr))))))))
+ (list-buffers-noselect arg buffer-list-function)))))
(defcustom project-kill-buffer-conditions
'(buffer-file-name ; All file-visiting buffers are included.