X-Loop: help-debbugs@HIDDEN
Subject: bug#79327: [PATCH] Use 'buffer-match-p' and 'match-buffer' in project
Resent-From: Philip Kaludercic <philipk@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: dgutov@HIDDEN, bug-gnu-emacs@HIDDEN
Resent-Date: Thu, 28 Aug 2025 06:19:02 +0000
Resent-Message-ID: <handler.79327.B.17563619059613 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 79327
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: patch
To: 79327 <at> debbugs.gnu.org
Cc: Dmitry Gutov <dgutov@HIDDEN>
X-Debbugs-Original-To: bug-gnu-emacs@HIDDEN
X-Debbugs-Original-Xcc: Dmitry Gutov <dgutov@HIDDEN>
Received: via spool by submit <at> debbugs.gnu.org id=B.17563619059613
(code B ref -1); Thu, 28 Aug 2025 06:19:02 +0000
Received: (at submit) by debbugs.gnu.org; 28 Aug 2025 06:18:25 +0000
Received: from localhost ([127.0.0.1]:38040 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
id 1urVxp-0002Uy-6y
for submit <at> debbugs.gnu.org; Thu, 28 Aug 2025 02:18:25 -0400
Received: from lists.gnu.org ([2001:470:142::17]:59092)
by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.84_2) (envelope-from <philipk@HIDDEN>)
id 1urVxk-0002Sg-LG
for submit <at> debbugs.gnu.org; Thu, 28 Aug 2025 02:18:23 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.90_1) (envelope-from <philipk@HIDDEN>)
id 1urVxY-0002sJ-0z
for bug-gnu-emacs@HIDDEN; Thu, 28 Aug 2025 02:18:08 -0400
Received: from mout02.posteo.de ([185.67.36.66])
by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.90_1) (envelope-from <philipk@HIDDEN>)
id 1urVxU-0003Td-Mn
for bug-gnu-emacs@HIDDEN; Thu, 28 Aug 2025 02:18:06 -0400
Received: from submission (posteo.de [185.67.36.169])
by mout02.posteo.de (Postfix) with ESMTPS id 05454240101
for <bug-gnu-emacs@HIDDEN>; Thu, 28 Aug 2025 08:17:51 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=posteo.net; s=2017;
t=1756361872; bh=Dkbfci9uLzm1KDvP03KS+M3W83z61FIVYEGIRmUIruo=;
h=From:To:Subject:Autocrypt:OpenPGP:Date:Message-ID:MIME-Version:
Content-Type:From;
b=jhblvdnakZZbUPqSdLE71QNH2MD8vg4amJwted7U1RZo85wwllFtpyG+I38zmBHxE
Fo5x4wn1useUvGqoa7PZrmzx86GlPS/IVGAHf2vgED4SCkWi2WOwk0Osc5/dWFj4P4
mCNYRCL1KOEbJIep+d2p8/WlllOLdReicvmPUotnuzVRI8vD2C7ebYiwlAD8XOAEqt
34Eh+tfVKzKshySh3nFd6N+4CFssnaZdofM3HvqoEx50kduKnxSud6cSDbYOC0D52q
I7NON2cGsw2QQGoVVZYD2Yx+KxuFrlo+6LbTFDjjlAx8KbUa59KqPlDww2AIzgN6/Y
Iv1epH6No0ipg==
Received: from customer (localhost [127.0.0.1])
by submission (posteo.de) with ESMTPSA id 4cCB5q3N6Cz9rxM
for <bug-gnu-emacs@HIDDEN>; Thu, 28 Aug 2025 08:17:51 +0200 (CEST)
From: Philip Kaludercic <philipk@HIDDEN>
Autocrypt: addr=philipk@HIDDEN; keydata=
mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo
aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0
ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI
BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0
mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB
BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE
Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK
NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof
z4oM
OpenPGP: id=7126E1DE2F0CE35C770BED01F2C3CC513DB89F66;
url="https://keys.openpgp.org/vks/v1/by-fingerprint/7126E1DE2F0CE35C770BED01F2C3CC513DB89F66";
preference=signencrypt
Date: Thu, 28 Aug 2025 06:17:51 +0000
Message-ID: <877byo0y2d.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: pass client-ip=185.67.36.66; envelope-from=philipk@HIDDEN;
helo=mout02.posteo.de
X-Spam_score_int: -43
X-Spam_score: -4.4
X-Spam_bar: ----
X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001,
RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001,
SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.0 (+)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)
--=-=-=
Content-Type: text/plain
Tags: patch
Hi, I would like to propose that project.el uses buffer-match-p and
match-buffers instead of the custom implementations. For that to work
while project.el is on ELPA, I have added a dependency on Compat.
WDYT?
In GNU Emacs 31.0.50 (build 6, x86_64-pc-linux-gnu, GTK+ Version
3.24.49, cairo version 1.18.4) of 2025-08-22 built on siskin
Repository revision: de3122d56695d5b8363a5e01ff711d6ba198bbd5
Repository branch: local/21Aug25
System Description: Debian GNU/Linux 13 (trixie)
Configured using:
'configure --with-pgtk'
--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
filename=0001-Use-buffer-match-p-and-match-buffer-in-project.patch
From 8d72379a84375207b70fb006cc00b98a494b9f36 Mon Sep 17 00:00:00 2001
From: Philip Kaludercic <pkal@HIDDEN>
Date: Thu, 28 Aug 2025 00:31:47 +0200
Subject: [PATCH] Use 'buffer-match-p' and 'match-buffer' in project
* lisp/progmodes/project.el (compat): Require library.
(project--read-project-buffer): Use 'buffer-match-p' instead of
'project--buffer-check'.
(project--buffer-check, project--buffers-to-kill): Remove
functions.
(project-kill-buffers): Use 'match-buffers' instead of
'project--buffers-to-kill'.
---
lisp/progmodes/project.el | 51 +++++----------------------------------
1 file changed, 6 insertions(+), 45 deletions(-)
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 8438060afa3..3682a619b27 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -2,7 +2,7 @@
;; Copyright (C) 2015-2025 Free Software Foundation, Inc.
;; Version: 0.11.1
-;; Package-Requires: ((emacs "26.1") (xref "1.7.0"))
+;; Package-Requires: ((emacs "26.1") (xref "1.7.0") (compat "29.1"))
;; This is a GNU ELPA :core package. Avoid functionality that is not
;; compatible with the version of Emacs recorded above.
@@ -171,6 +171,7 @@
(require 'cl-generic)
(require 'cl-lib)
(require 'seq)
+(require 'compat)
(eval-when-compile (require 'subr-x))
(defgroup project nil
@@ -1691,8 +1692,8 @@ project--read-project-buffer
;; BUFFER is an entry (BUF-NAME . BUF-OBJ) of Vbuffer_alist.
(and (memq (cdr buffer) buffers)
(not
- (project--buffer-check
- buffer project-ignore-buffer-conditions)))))
+ (buffer-match-p
+ project-ignore-buffer-conditions buffer)))))
(buffer
(if (and (fboundp 'uniquify-get-unique-names)
uniquify-buffer-name-style)
@@ -1893,47 +1894,6 @@ project-kill-buffers-display-buffer-list
:package-version '(project . "0.8.2"))
;;;###autoload(put 'project-kill-buffers-display-buffer-list 'safe-local-variable #'booleanp)
-;; FIXME: Could this be replaced by `buffer-match-p' in Emacs 29+?
-(defun project--buffer-check (buf conditions)
- "Check if buffer BUF matches any element of the list CONDITIONS.
-See `project-kill-buffer-conditions' or
-`project-ignore-buffer-conditions' for more details on the
-form of CONDITIONS."
- (catch 'match
- (dolist (c conditions)
- (when (cond
- ((stringp c)
- (string-match-p c (buffer-name buf)))
- ((functionp c)
- (funcall c buf))
- ((eq (car-safe c) 'major-mode)
- (eq (buffer-local-value 'major-mode buf)
- (cdr c)))
- ((eq (car-safe c) 'derived-mode)
- (provided-mode-derived-p
- (buffer-local-value 'major-mode buf)
- (cdr c)))
- ((eq (car-safe c) 'not)
- (not (project--buffer-check buf (cdr c))))
- ((eq (car-safe c) 'or)
- (project--buffer-check buf (cdr c)))
- ((eq (car-safe c) 'and)
- (seq-every-p
- (apply-partially #'project--buffer-check
- buf)
- (mapcar #'list (cdr c)))))
- (throw 'match t)))))
-
-(defun project--buffers-to-kill (pr)
- "Return list of buffers in project PR to kill.
-What buffers should or should not be killed is described
-in `project-kill-buffer-conditions'."
- (let (bufs)
- (dolist (buf (project-buffers pr))
- (when (project--buffer-check buf project-kill-buffer-conditions)
- (push buf bufs)))
- bufs))
-
;;;###autoload
(defun project-kill-buffers (&optional no-confirm project)
"Kill the buffers belonging to the current project.
@@ -1950,7 +1910,8 @@ project-kill-buffers
Also see the `project-kill-buffers-display-buffer-list' variable."
(interactive)
(let* ((pr (or project (project-current t)))
- (bufs (project--buffers-to-kill pr))
+ (bufs (project-buffers pr))
+ (bufs (match-buffers project-kill-buffer-conditions bufs))
(query-user (lambda ()
(yes-or-no-p
(format "Kill %d buffers in %s? "
--
2.47.2
--=-=-=--
Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) Content-Type: text/plain; charset=utf-8 X-Loop: help-debbugs@HIDDEN From: help-debbugs@HIDDEN (GNU bug Tracking System) To: Philip Kaludercic <philipk@HIDDEN> Subject: bug#79327: Acknowledgement ([PATCH] Use 'buffer-match-p' and 'match-buffer' in project) Message-ID: <handler.79327.B.17563619059613.ack <at> debbugs.gnu.org> References: <877byo0y2d.fsf@HIDDEN> X-Gnu-PR-Message: ack 79327 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 79327 <at> debbugs.gnu.org Date: Thu, 28 Aug 2025 06:19:02 +0000 Thank you for filing a new bug report with debbugs.gnu.org. This is an automatically generated reply to let you know your message has been received. Your message is being forwarded to the package maintainers and other interested parties for their attention; they will reply in due course. As you requested using X-Debbugs-CC, your message was also forwarded to Dmitry Gutov <dgutov@HIDDEN> (after having been given a bug report number, if it did not have one). Your message has been sent to the package maintainer(s): bug-gnu-emacs@HIDDEN If you wish to submit further information on this problem, please send it to 79327 <at> debbugs.gnu.org. Please do not send mail to help-debbugs@HIDDEN unless you wish to report a problem with the Bug-tracking system. --=20 79327: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D79327 GNU Bug Tracking System Contact help-debbugs@HIDDEN with problems
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.