Better 'project-buffer' completion category defaults in Emacs <= 30

* lisp/progmodes/project.el: Fall back to adding 'project-buffer'
to 'completion-category-defaults' if 'define-completion-category'
is not available (bug#79409).
This commit is contained in:
Dmitry Gutov 2025-09-10 01:54:36 +03:00
parent 0e9cee2bf5
commit a060bdec82

View file

@ -1718,9 +1718,11 @@ Return non-nil if PROJECT is not a remote project."
(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))