From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Philip K." Newsgroups: gmane.emacs.bugs Subject: bug#42386: Acknowledgement ([PATCH] Handle symbols in project-kill-buffers-ignores) Date: Fri, 17 Jul 2020 17:30:52 +0200 Message-ID: <87sgdqduqb.fsf@warpmail.net> References: <878sfjkh8o.fsf@warpmail.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37595"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 42386@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 17 17:32:16 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 1jwSLP-0009f7-G1 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 17 Jul 2020 17:32:16 +0200 Original-Received: from localhost ([::1]:37348 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jwSLO-0006sy-FT for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 17 Jul 2020 11:32:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41074) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jwSLC-0006ra-4k for bug-gnu-emacs@gnu.org; Fri, 17 Jul 2020 11:32:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46351) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jwSLB-0007Ms-RB for bug-gnu-emacs@gnu.org; Fri, 17 Jul 2020 11:32:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jwSLB-0004Ej-Mz for bug-gnu-emacs@gnu.org; Fri, 17 Jul 2020 11:32: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, 17 Jul 2020 15:32:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42386 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 42386-submit@debbugs.gnu.org id=B42386.159499986516217 (code B ref 42386); Fri, 17 Jul 2020 15:32:01 +0000 Original-Received: (at 42386) by debbugs.gnu.org; 17 Jul 2020 15:31:05 +0000 Original-Received: from localhost ([127.0.0.1]:57897 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jwSKH-0004DV-2a for submit@debbugs.gnu.org; Fri, 17 Jul 2020 11:31:05 -0400 Original-Received: from out1-smtp.messagingengine.com ([66.111.4.25]:35361) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jwSKD-0004Cx-Qx for 42386@debbugs.gnu.org; Fri, 17 Jul 2020 11:31:03 -0400 Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 7A44B5C0076; Fri, 17 Jul 2020 11:30:56 -0400 (EDT) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Fri, 17 Jul 2020 11:30:56 -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=fm1; bh=M2N7KJf5XKB66Ec8gewb/VD7WdfqHr1AObZTU7y C4S8=; b=fG2HU+SeDWotZ/iFn2NaDMxTN3pf3F9Dr8vhMOOKErQlahwWD34UbDd vlRaL1HmXdnV4apJm+DDdNge/Bc5P/Hvp5011/76hkzuF6bHT0n/T3wq6ylC2o3K QPqoCAK2jeGbMIrMkx5NTYufGZa4+qWd8tuUldV3ksx57I4Uw+rxxm8BCbUrrVJb zrY83wNw5QhUse5XLoyAPKjEZ8GGhcRxOAA7sWuKamTDoloRm75apn7ISObBrw/x inCsz59K01otDBlSwZJ82t7PVNXfxsRdB/zoiujNTi71ndne11jlPKp3ZogJGk03 TasBtqgjePpTtPZU/CPg5SMdbnB0zyg== 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=M2N7KJf5XKB66Ec8g ewb/VD7WdfqHr1AObZTU7yC4S8=; b=KhJaGCZVR8hdOQPDS4ZwKa0sHE6qRVA9a ScbRx+HMiXkK5a+iS5XojQF0IwGMuFbInmLtL2/D/F+QIgmt1GwmhEabHG+WiJl7 LJIsWgaHueLZZdOq9blHREgKZDnfNO0jxVg5GOBwoxWlkg1/bPK5FJ3zHMnRC44H HgVP66ZyYcgfBA3YiH7c9REU15V8WRhxcE+RzObTzq7uSsDNqOElYMEteeuvYAi1 107URP/AIggHAXxwoY+pEMQsDNPo3k9rWMzolssBTsiKvcxL21DHBcOmQO/ZpAAI gUMo1erqVRtS2JjhvtgMKtsfxrQbGNTIj9qWn4hScc69zSCjTt7jw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrfeeigdekjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffujgffkfggtgesmhdtreertddttdenucfhrhhomhepfdfrhhhilhhiphcu mfdrfdcuoehphhhilhhiphesfigrrhhpmhgrihhlrdhnvghtqeenucggtffrrghtthgvrh hnpeejieeuvdellefffefgueetkeelkeegveffieeffffhgfeuueehvdelvdeuvefhgeen ucfkphepkeejrddugeehrddtrdduheeinecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomhepphhhihhlihhpseifrghrphhmrghilhdrnhgvth X-ME-Proxy: Original-Received: from localhost (p5791009c.dip0.t-ipconnect.de [87.145.0.156]) by mail.messagingengine.com (Postfix) with ESMTPA id D5BFB3280068; Fri, 17 Jul 2020 11:30:55 -0400 (EDT) In-Reply-To: <834kq6jsbw.fsf@gnu.org> (message from Eli Zaretskii on Fri, 17 Jul 2020 14:26:11 +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:183153 Archived-At: --=-=-= Content-Type: text/plain The patch below should implement that behaviour + an updating docstring. Eli Zaretskii writes: >> From: "Philip K." >> Cc: 42386@debbugs.gnu.org >> Date: Fri, 17 Jul 2020 13:17:17 +0200 >> >> > Dmitry suggested a cons cell, which will allow you to differentiate >> > between predicates and major-modes. Isn't that a way around the >> > problem? >> >> That's what I had in mind when I wrote: >> >> > How about this: Instead of symbols, adding a cons-cell: >> > >> > (major-mode . erc-mode) >> > >> > prevents erc-buffers from being killed? >> >> So if you're ok with that, I'll try submitting a patch with that >> approach. > > Sure, I'm okay. Especially since Dmitry seems also okay with it. > > Thanks. > -- Philip K. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Handle-symbols-in-project-kill-buffers-ignores.patch >From 4497ef69ed27fff7979966ece8803be1f8918874 Mon Sep 17 00:00:00 2001 From: Philip K Date: Thu, 16 Jul 2020 10:03:35 +0200 Subject: [PATCH] Handle symbols in project-kill-buffers-ignores --- lisp/progmodes/project.el | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 67ce3dc7d9..a73ab8ce8a 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -846,11 +846,18 @@ project-switch-to-buffer (defcustom project-kill-buffers-ignores '("\\*Help\\*") "Conditions for buffers `project-kill-buffers' should not kill. -Each condition is either a regular expression matching a buffer -name, or a predicate function that takes a buffer object as -argument and returns non-nil if it matches. Buffers that match -any of the conditions will not be killed." - :type '(repeat (choice regexp function)) +Each condition is either: +- a regular expression, to match a buffer name, +- a predicate function that takes a buffer object as argument + and returns non-nil if the buffer should not be killed, +- a cons-cell, where the car describes how to interpret the cdr. + If the car contains `major-mode', the cdr has to be the symbol + of a major mode, that should never be killed. + +Buffers that match any of the conditions will not be killed." + :type '(repeat (choice regexp function + (cons :tag "Major mode" + (const major-mode) symbol))) :version "28.1" :package-version '(project . "0.5.0")) @@ -878,12 +885,18 @@ project-kill-buffers (cond ((stringp c) (string-match-p c (buffer-name buf))) ((functionp c) - (funcall c buf)))) + (funcall c buf)) + ((eq (car-safe c) 'major-mode) + (provided-mode-derived-p + (buffer-local-value 'major-mode buf) + (cdr c))))) project-kill-buffers-ignores) (push buf bufs))) - (when (yes-or-no-p (format "Kill %d buffers in %s? " - (length bufs) (project-root pr))) - (mapc #'kill-buffer bufs)))) + (if (null bufs) + (message "No buffers to kill") + (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 --=-=-=--