aboutsummaryrefslogtreecommitdiff
path: root/projectile.el
diff options
context:
space:
mode:
authorBozhidar Batsov <bozhidar@batsov.dev>2022-10-27 10:49:49 +0300
committerBozhidar Batsov <bozhidar@batsov.dev>2022-10-27 10:49:49 +0300
commita0105e7c40d30f10bc42fd271e2583587a1f5ae4 (patch)
tree2284d99d226ed2584f0602ee83cde74cc60e50fa /projectile.el
parentc8eee2199a8cf5d7dccc1d9acb04a10e20944dc8 (diff)
[Fix #1591] Add project.el integration
Diffstat (limited to 'projectile.el')
-rw-r--r--projectile.el32
1 files changed, 32 insertions, 0 deletions
diff --git a/projectile.el b/projectile.el
index 80a5dd6..8f36c01 100644
--- a/projectile.el
+++ b/projectile.el
@@ -5987,6 +5987,38 @@ Otherwise behave as if called interactively.
;;;###autoload
(define-obsolete-function-alias 'projectile-global-mode 'projectile-mode "1.0")
+;;;; project.el integration
+;;
+;; Projectile will become the default provider for
+;; project.el project and project files lookup.
+;; See https://github.com/bbatsov/projectile/issues/1591 for
+;; more details.
+
+;; 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))
+
+(cl-defmethod project-files ((project (head projectile)) &optional dirs)
+ (let ((root (project-root project)))
+ ;; Make paths absolute and ignore the optional dirs argument,
+ ;; see https://github.com/bbatsov/projectile/issues/1591#issuecomment-896423965
+ ;; That's needed because Projectile uses relative paths for project files
+ ;; and project.el expects them to be absolute.
+ ;; FIXME: That's probably going to be very slow in large projects.
+ (mapcar (lambda (f)
+ (concat f root))
+ (projectile-project-files root))))
+
+(defun project-projectile (dir)
+ "Return Projectile project of form ('projectile . root-dir) for DIR."
+ (let ((root (projectile-project-root dir)))
+ (when root
+ (cons 'projectile root))))
+
+(add-hook 'project-find-functions #'project-projectile)
+
(provide 'projectile)
;;; projectile.el ends here