From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: "Philip K." Newsgroups: gmane.emacs.bugs Subject: bug#41868: [PATCH] Add project-clean-up command Date: Fri, 19 Jun 2020 08:28:12 +0200 Message-ID: <87k103r2mb.fsf@warpmail.net> References: <87k108wsvb.fsf@warpmail.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="126872"; mail-complaints-to="usenet@ciao.gmane.io" Cc: contovob@tcd.ie, 41868@debbugs.gnu.org, dgutov@yandex.ru To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jun 19 08:29:11 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jmAWT-000Wvc-K4 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 19 Jun 2020 08:29:10 +0200 Original-Received: from localhost ([::1]:37064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmAWS-0003F3-Md for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 19 Jun 2020 02:29:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55408) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAWM-0003Ev-3i for bug-gnu-emacs@gnu.org; Fri, 19 Jun 2020 02:29:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43316) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jmAWL-0001Bx-Q4 for bug-gnu-emacs@gnu.org; Fri, 19 Jun 2020 02:29:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jmAWL-0002Fz-Mh for bug-gnu-emacs@gnu.org; Fri, 19 Jun 2020 02:29:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Philip K." Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 19 Jun 2020 06:29:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41868 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 41868-submit@debbugs.gnu.org id=B41868.15925481058630 (code B ref 41868); Fri, 19 Jun 2020 06:29:01 +0000 Original-Received: (at 41868) by debbugs.gnu.org; 19 Jun 2020 06:28:25 +0000 Original-Received: from localhost ([127.0.0.1]:54862 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jmAVk-0002F8-VK for submit@debbugs.gnu.org; Fri, 19 Jun 2020 02:28:25 -0400 Original-Received: from out2-smtp.messagingengine.com ([66.111.4.26]:48323) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jmAVg-0002Er-Vi for 41868@debbugs.gnu.org; Fri, 19 Jun 2020 02:28:23 -0400 Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id A97705C01BA; Fri, 19 Jun 2020 02:28:15 -0400 (EDT) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Fri, 19 Jun 2020 02:28:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=warpmail.net; h= from:to:cc:subject:in-reply-to:date:message-id:mime-version :content-type; s=fm3; bh=lBFytGgnHwJBAvSLxiRMEr4+Q0pBUL9qf8MDJrL rV1k=; b=nx9bTxnX1EQdtMqH3TZI0XC0j+doGWjIw3c7Gy4IniSsvFRTkA7JAbl OhvU2hBuN+DvtxUZL0wKL6zYD1JmxF2lg0Zmi4Mw2LEzDBxINMEXmZQ5UkZcm6qU 1VfGl/xe8YUDbHkkjf+KHZIOGHii0Dm4GX+doxHtOE+lTVAUAx15ZA2wYneIRrpV f0wDEnHUcLfd8gOHDtDwWHd3pphnn5yV5qw0+7wW5KS90fxqB5lB2UZQIA2MuVsF A+oN8xsuardDW+Yiw10RYk0C1m1oQM61vjgzu/AcF2lHgtyBN6a7q/D0uo1ULNlW DM9rUM5B5RFkcebyC/N30kChBbx7i0A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=lBFytGgnHwJBAvSLx iRMEr4+Q0pBUL9qf8MDJrLrV1k=; b=KwGznVf4rZeOfkaluyfXPldI7b7LShHll lFiwVwsgXOrB4Wtmrlm8wz9am+2cjsw35A9eJyAdwF/pXmjRkNr9V4Np7R1q+bmN 72IgHjDQ/zo7ksVk8bbLlXmUmjTk8cfvY2tAXyx8Qa+NWI7AjD6CqQiAAs2xpkPa M/WRU1nAtVe61rsIbtOmO6PhUyWga4+6qdegSLBm1KFRSVlGQTN9jkHJMIAaZQhM +JJLF676CGDxcb//ykR1O8H7ggTiQ96KlTQf3wX3ZTzEk9t+/tlMzsG7v8s2LATG Dc/oHGqcYalbh4aEE3i6qv+fXeu6wa3Jd3cgYeu0nz+ariUOQL75A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrudejhedguddtlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffujgffkfggtgesmhdtreertddttdenucfhrhhomhepfdfrhhhilhhi phcumfdrfdcuoehphhhilhhiphesfigrrhhpmhgrihhlrdhnvghtqeenucggtffrrghtth gvrhhnpeejieeuvdellefffefgueetkeelkeegveffieeffffhgfeuueehvdelvdeuvefh geenucfkphepjeelrddvudelrdduleelrddvudehnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepphhhihhlihhpseifrghrphhmrghilhdrnhgv th X-ME-Proxy: Original-Received: from localhost (p4fdbc7d7.dip0.t-ipconnect.de [79.219.199.215]) by mail.messagingengine.com (Postfix) with ESMTPA id D74703280063; Fri, 19 Jun 2020 02:28:14 -0400 (EDT) In-Reply-To: <87zh90kmfh.fsf@mail.linkov.net> (message from Juri Linkov on Fri, 19 Jun 2020 02:02:10 +0300) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:182171 Archived-At: --=-=-= Content-Type: text/plain Juri Linkov 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Add-project-kill-buffers-command.patch >From 0c84b1097941b983738104b0756fd8db4a7eeac4 Mon Sep 17 00:00:00 2001 From: Philip K 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)))) + ;;; Project list -- 2.20.1 --=-=-=--