Skip to content

Commit

Permalink
Check for project-root before adding overload
Browse files Browse the repository at this point in the history
Prior to emacs 28, the `project.el` package did not provide
`project-root`.  By providing an overload for `project-root`, any
compatibility checks of `(fboundp 'project-root)` done by other
packages will return true, even for versions that do not have
`project-root`.

Fixes #1868.
  • Loading branch information
Lunderberg committed Nov 25, 2023
1 parent 9446ea9 commit d6d21c7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions projectile.el
Original file line number Diff line number Diff line change
Expand Up @@ -6155,8 +6155,11 @@ when opening new files."
;; it's safe to require this directly, as it was added in Emacs 25.1
(require 'project)

(cl-defmethod project-root ((project (head projectile)))
(cdr project))
;; Only define an override for project-root if the method exists. For versions
;; before emacs 28, project.el provided project-roots instead of project.root.
(if (fboundp 'project-root)
(cl-defmethod project-root ((project (head projectile)))
(cdr project)))

(cl-defmethod project-files ((project (head projectile)) &optional _dirs)
(let ((root (project-root project)))
Expand Down

0 comments on commit d6d21c7

Please sign in to comment.