From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 28 02:18:25 2025 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 ) id 1urVxp-0002Uy-6y for submit@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 ) id 1urVxk-0002Sg-LG for submit@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 ) id 1urVxY-0002sJ-0z for bug-gnu-emacs@gnu.org; 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 ) id 1urVxU-0003Td-Mn for bug-gnu-emacs@gnu.org; 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 ; 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 ; Thu, 28 Aug 2025 08:17:51 +0200 (CEST) From: Philip Kaludercic To: bug-gnu-emacs@gnu.org Subject: [PATCH] Use 'buffer-match-p' and 'match-buffer' in project X-Debbugs-Cc: Dmitry Gutov Autocrypt: addr=philipk@posteo.net; 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@posteo.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.66; envelope-from=philipk@posteo.net; 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-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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 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 --=-=-=--