From 055ff04a4c0f0e74cb9b3a2b713fca29cf7e4549 Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Tue, 9 Jul 2024 14:30:27 -0400 Subject: [PATCH] Add project argument to project-kill-buffers 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 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 8369f6f5120..7c58bc4a6ba 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -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 -- 2.39.5