]> git.eshelyaron.com Git - emacs.git/commitdiff
Add project argument to project-kill-buffers
authorSpencer Baugh <sbaugh@janestreet.com>
Tue, 9 Jul 2024 18:30:27 +0000 (14:30 -0400)
committerEshel Yaron <me@eshelyaron.com>
Wed, 17 Jul 2024 21:48:07 +0000 (23:48 +0200)
Previously, project-kill-buffers always called (project-current t).  A
Lisp program could change what project project-kill-buffers operated
on by binding project-current-directory-override.  However, in some
edge cases (for example, if the project was deleted between looking it
up and calling project-kill-buffers) this might fail to detect a
project, and so (project-current t) would prompt the user.

To avoid this, accept the project to kill buffers for as an argument.

* lisp/progmodes/project.el (project-kill-buffers): Take project as an
optional argument (bug#72019).

(cherry picked from commit 6b2f51633e0f508d393516d6624e1a4ddaca31d1)

lisp/progmodes/project.el

index 8369f6f51202a961262312cc798c812019bbdb64..7c58bc4a6bab6c52aabda6b9acd90ee07862138f 100644 (file)
@@ -1731,7 +1731,7 @@ in `project-kill-buffer-conditions'."
     bufs))
 
 ;;;###autoload
-(defun project-kill-buffers (&optional no-confirm)
+(defun project-kill-buffers (&optional no-confirm project)
   "Kill the buffers belonging to the current project.
 Two buffers belong to the same project if their project
 instances, as reported by `project-current' in each buffer, are
@@ -1741,9 +1741,11 @@ is non-nil, the command will not ask the user for confirmation.
 NO-CONFIRM is always nil when the command is invoked
 interactively.
 
+If PROJECT is non-nil, kill buffers for that project instead.
+
 Also see the `project-kill-buffers-display-buffer-list' variable."
   (interactive)
-  (let* ((pr (project-current t))
+  (let* ((pr (or project (project-current t)))
          (bufs (project--buffers-to-kill pr))
          (query-user (lambda ()
                        (yes-or-no-p