1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 18:40:39 -08:00

New command 'project-list-buffers' bound to 'C-x p C-b' (bug#59153)

* doc/emacs/maintaining.texi (Project Buffer Commands):
Add 'project-list-buffers'.

* lisp/buff-menu.el (Buffer-menu-filter-predicate): New defvar-local.
(list-buffers-noselect): Add new optional arg 'filter-predicate'.
Set 'Buffer-menu-filter-predicate' to 'filter-predicate'.
(list-buffers--refresh): Use 'Buffer-menu-filter-predicate'.

* lisp/progmodes/project.el (project-prefix-map): Bind "\C-b" to
'project-list-buffers'.
(project-list-buffers): New command.
This commit is contained in:
Juri Linkov 2022-11-15 20:54:39 +02:00
parent 69d1278527
commit 125b5684c3
4 changed files with 52 additions and 3 deletions

View file

@ -712,6 +712,7 @@ DIRS must contain directory names."
(define-key map "G" 'project-or-external-find-regexp)
(define-key map "r" 'project-query-replace-regexp)
(define-key map "x" 'project-execute-extended-command)
(define-key map "\C-b" 'project-list-buffers)
map)
"Keymap for project commands.")
@ -1222,6 +1223,28 @@ displayed."
(interactive (list (project--read-project-buffer)))
(display-buffer-other-frame buffer-or-name))
;;;###autoload
(defun project-list-buffers (&optional arg)
"Display a list of project buffers.
The list is displayed in a buffer named \"*Buffer List*\".
By default, all project buffers are listed except those whose names
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)))
(display-buffer
(if (version< emacs-version "29.0.50")
(let ((buf (list-buffers-noselect arg (project-buffers pr))))
(with-current-buffer buf
(setq-local revert-buffer-function
(lambda (&rest _ignored)
(list-buffers--refresh (project-buffers pr))
(tabulated-list-print t))))
buf)
(list-buffers-noselect
arg nil (lambda (buf) (memq buf (project-buffers pr))))))))
(defcustom project-kill-buffer-conditions
'(buffer-file-name ; All file-visiting buffers are included.
;; Most of temp and logging buffers (aside from hidden ones):