Subject: bug#79409: 31.0.50; project.el uses define-completion-category but depends on 26.1

From: Dmitry Gutov <[email-masked]>
Date: Mon, 8 Sep 2025 23:17:43 +0300

On 08/09/2025 22:41, Daniel Mendler wrote:

> You could add a project-buffer category to completion-category-defaults
> to give the same effect as category inheritance as long as the user
> doesn't override the settings.

I suppose you mean like this. Seems like an improvement, since the 
original commit only added the entry in the latest Emacs.

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index c15148110a6..2291b2a6b4c 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1718,9 +1718,11 @@ project--buffers-completion-table
       (t
        (complete-with-action action buffers string pred)))))

-(when (fboundp 'define-completion-category) ; Introduced in Emacs 31.
-  (define-completion-category 'project-buffer '(buffer)
-    "Completion category for buffers in a given project."))
+(if (fboundp 'define-completion-category) ; Introduced in Emacs 31.
+    (define-completion-category 'project-buffer '(buffer)
+      "Completion category for buffers in a given project.")
+  (add-to-list 'completion-category-defaults
+               '(project-buffer (styles . (basic substring)))))

  (defun project--read-project-buffer ()
    (let* ((pr (project-current t))

Or - the reverse - project--buffers-completion-table could switch to the 
category 'buffer' in older Emacs.

> Otoh you could also just leave things as is. This is not a big deal,
> since it will just result in a minor difference in completion styles
> settings and users could always override if they bother.

Maybe not a big deal indeed.