GNU bug report logs -
#41868
[PATCH] Add project-clean-up command
Previous Next
Reported by: "Philip K." <philip <at> warpmail.net>
Date: Mon, 15 Jun 2020 10:02:02 UTC
Severity: normal
Tags: fixed, patch
Fixed in version 28.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
"Philip K." <philip <at> warpmail.net> writes:
> I wanted to propose a command for project.el to kill all opened buffers
> in a project, called when one finishes working on some specific
> code-base.
Thanks, just some minor nits from me.
[...]
> And it might be worth considering to add a prompt, to ask the user if
> they actually want to kill all the buffers.
Something like "Kill <N> buffers under <root>? "?
[...]
> +(defcustom project-dont-clean-regexps
> + '("\\*Help\\*")
> + "List of regular expressions to be ignored by `project-clean-up'."
> + :type '(repeat regexp))
This needs a :version tag.
> +(defun project--list-buffers (pr)
> + "Return a list of all buffers in project PR."
> + (let ((root (project-root pr))
> + bufs)
> + (dolist (buf (buffer-list))
> + (when-let* ((path (or (buffer-file-name buf)
^^^^
Nit: Paths in Emacs are directory lists, whereas this is a file name.
> + (buffer-local-value 'default-directory buf)))
> + (true (file-truename path)))
Doesn't file-in-directory-p do this for us?
> + (when (file-in-directory-p true root)
> + (push buf bufs))))
> + bufs))
Maybe the list should be returned in the same order as (buffer-list), by
using either nreverse or seq-filter?
> +;;;###autoload
> +(defun project-clean-up ()
> + "Kill all opened buffers in a project."
^^^^^^
live?
> + (interactive)
> + (let* ((pr (project-current t)))
Nit: No need for let*.
> + (dolist (buf (project--list-buffers pr))
> + (let ((match (mapcar (lambda (re)
> + (and (string-match-p re (buffer-name buf)) t))
> + project-dont-clean-regexps)))
> + (unless (memq t match)
> + (kill-buffer buf))))))
Nit: AKA
(unless (seq-some (lambda (re)
(string-match-p re (buffer-name buf)))
project-dont-clean-regexps)
...)
Thanks,
--
Basil
This bug report was last modified 4 years and 282 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.