unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#59153: List project buffers
@ 2022-11-09 17:40 Juri Linkov
  2022-11-09 18:01 ` Eli Zaretskii
                   ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Juri Linkov @ 2022-11-09 17:40 UTC (permalink / raw)
  To: 59153

[-- Attachment #1: Type: text/plain, Size: 617 bytes --]

Version: 29.0.50
Severity: wishlist
Tags: patch

There are project commands and keys corresponding
to the most useful buffer commands:

  C-x k (kill-buffer)      - C-x p k (project-kill-buffers)
  C-x b (switch-to-buffer) - C-x p b (project-switch-to-buffer)

What is still missing is a command to list project buffers:

  C-x C-b (list-buffers)   - C-x p C-b (project-list-buffers)

project-kill-buffers already shows a list of project buffers,
but only as a part of confirmation for killing buffers.

Here is a patch that adds the missing command.  Its argument
has exactly the same meaning as in 'list-buffers'.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: project-list-buffers.patch --]
[-- Type: text/x-diff, Size: 1884 bytes --]

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index fc035675cec..e6f9dd750e7 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -713,6 +713,7 @@ project-prefix-map
     (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.")
 
@@ -1223,6 +1224,25 @@ project-display-buffer-other-frame
   (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 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))
+         (bufs (mapcan
+                (lambda (buf)
+                  (when (and (project--buffer-check buf '("\\`[^ ]"))
+                             (or (not arg)
+                                 (project--buffer-check buf '(buffer-file-name))))
+                    (list buf)))
+                (project-buffers pr))))
+    (display-buffer (list-buffers-noselect arg bufs))))
+
 (defcustom project-kill-buffer-conditions
   '(buffer-file-name    ; All file-visiting buffers are included.
     ;; Most of temp and logging buffers (aside from hidden ones):
@@ -1283,6 +1303,7 @@ project-kill-buffers-display-buffer-list
   :package-version '(project . "0.8.2")
   :safe #'booleanp)
 
+;; UNUSED?
 (defun project--buffer-list (pr)
   "Return the list of all buffers in project PR."
   (let ((conn (file-remote-p (project-root pr)))

^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2022-11-19 19:22 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-09 17:40 bug#59153: List project buffers Juri Linkov
2022-11-09 18:01 ` Eli Zaretskii
2022-11-09 19:22 ` Akib Azmain Turja via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-10  7:56   ` Juri Linkov
2022-11-10  8:56     ` Akib Azmain Turja via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-10 17:59     ` Juri Linkov
2022-11-12  1:41       ` Dmitry Gutov
2022-11-12 18:02         ` Juri Linkov
2022-11-13  2:37           ` Dmitry Gutov
2022-11-13 17:57             ` Juri Linkov
2022-11-13 22:18               ` Dmitry Gutov
2022-11-15  8:36                 ` Juri Linkov
2022-11-15 14:53                   ` Dmitry Gutov
2022-11-15 18:55                     ` Juri Linkov
2022-11-16 10:16                       ` Pankaj Jangid
2022-11-18  7:09                         ` Juri Linkov
2022-11-19 18:34                           ` Dmitry Gutov
2022-11-19 18:48                             ` Juri Linkov
2022-11-19 19:22                               ` Dmitry Gutov
2022-11-10 21:21 ` Dmitry Gutov
2022-11-12  1:39   ` Dmitry Gutov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).