From: "Philip K." <philip@warpmail.net>
To: Juri Linkov <juri@linkov.net>
Cc: contovob@tcd.ie, 41868@debbugs.gnu.org, dgutov@yandex.ru
Subject: bug#41868: [PATCH] Add project-clean-up command
Date: Fri, 19 Jun 2020 08:28:12 +0200 [thread overview]
Message-ID: <87k103r2mb.fsf@warpmail.net> (raw)
In-Reply-To: <87zh90kmfh.fsf@mail.linkov.net> (message from Juri Linkov on Fri, 19 Jun 2020 02:02:10 +0300)
[-- Attachment #1: Type: text/plain, Size: 325 bytes --]
Juri Linkov <juri@linkov.net> writes:
>>> But we already agreed on a shorter name project-kill-buffers-ignore,
>>> and Philip sent the patch that renames it.
>>
>> Could you link to it?
>
> I can't find it. Philip, could you please resend your patch
> with project-kill-buffers-ignore.
Sure, added below.
--
Philip K.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-project-kill-buffers-command.patch --]
[-- Type: text/x-diff, Size: 2337 bytes --]
From 0c84b1097941b983738104b0756fd8db4a7eeac4 Mon Sep 17 00:00:00 2001
From: Philip K <philip@warpmail.net>
Date: Fri, 12 Jun 2020 23:37:51 +0200
Subject: [PATCH] Add project-kill-buffers command
---
lisp/progmodes/project.el | 41 +++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index f3df44fa7b..c5301dccd3 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -744,6 +744,47 @@ project-compile
(default-directory (project-root pr)))
(compile command comint)))
+(defcustom project-kill-buffers-ignore
+ '("\\*Help\\*")
+ "Conditions for buffers `project-kill-buffers' should not kill.
+If a condition is a string, it will be interpreted as a regular
+expression, and matched against the buffer name. If a condition
+is a function, it will be called with the buffer object, and
+returns non-nil if it matches. Buffers that match any condition
+are \"spared\", and will hence not be killed by
+`project-kill-buffers'"
+ :type '(repeat (choice regexp function))
+ :version "28.1")
+
+(defun project--buffer-list (pr)
+ "Return a list of all buffers in project PR."
+ (let ((root (project-root pr)) bufs)
+ (dolist (buf (buffer-list))
+ (let ((filename (or (buffer-file-name buf)
+ (buffer-local-value 'default-directory buf))))
+ (when (and filename (file-in-directory-p filename root))
+ (push buf bufs))))
+ (nreverse bufs)))
+
+;;;###autoload
+(defun project-kill-buffers ()
+ "Kill all live buffers of a project.
+Certain buffers may be ignored, depending on the value of
+`project-kill-buffers-ignore'."
+ (interactive)
+ (let ((pr (project-current t)) bufs)
+ (dolist (buf (project--buffer-list pr))
+ (unless (seq-some (lambda (c)
+ (cond ((stringp c)
+ (string-match-p c (buffer-name buf)))
+ ((functionp c)
+ (funcall c buf))))
+ project-kill-buffers-ignore)
+ (push buf bufs)))
+ (when (yes-or-no-p (format "Kill %d buffers in %s? "
+ (length bufs) (project-root pr)))
+ (mapc #'kill-buffer bufs))))
+
\f
;;; Project list
--
2.20.1
next prev parent reply other threads:[~2020-06-19 6:28 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-15 10:00 bug#41868: [PATCH] Add project-clean-up command Philip K.
2020-06-15 11:04 ` Basil L. Contovounesios
2020-06-15 11:32 ` Philip K.
2020-06-15 11:38 ` Basil L. Contovounesios
2020-06-15 12:28 ` Dmitry Gutov
2020-06-15 18:18 ` Philip K.
2020-06-15 20:50 ` Dmitry Gutov
2020-06-15 21:50 ` Philip K.
2020-06-16 10:19 ` Dmitry Gutov
2020-06-16 10:52 ` Basil L. Contovounesios
2020-06-16 14:31 ` Eli Zaretskii
2020-06-16 17:12 ` Philip K.
2020-06-18 1:05 ` Dmitry Gutov
2020-06-18 6:46 ` Philip K.
2020-06-18 13:04 ` Dmitry Gutov
2020-06-18 14:11 ` Philip K.
2020-06-18 15:36 ` Dmitry Gutov
2020-06-18 22:06 ` Juri Linkov
2020-06-18 22:57 ` Dmitry Gutov
2020-06-18 23:02 ` Juri Linkov
2020-06-18 23:10 ` Dmitry Gutov
2020-06-18 23:18 ` Juri Linkov
2020-06-18 23:29 ` Dmitry Gutov
2020-06-26 0:49 ` Dmitry Gutov
2020-06-19 6:28 ` Philip K. [this message]
2020-08-14 17:05 ` Lars Ingebrigtsen
2020-08-14 20:36 ` Dmitry Gutov
2020-06-19 6:20 ` Eli Zaretskii
2020-06-15 22:49 ` Juri Linkov
2020-06-16 0:23 ` Dmitry Gutov
2020-06-16 21:47 ` Juri Linkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k103r2mb.fsf@warpmail.net \
--to=philip@warpmail.net \
--cc=41868@debbugs.gnu.org \
--cc=contovob@tcd.ie \
--cc=dgutov@yandex.ru \
--cc=juri@linkov.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.