From fe4abfc719314764a86de80791204ffa7d240afb Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Fri, 21 Jan 2022 04:34:31 +0900 Subject: [PATCH] Add php-project-project-find-function compatible with project-find-functions ```el (add-hook 'project-find-functions #'php-project-project-find-function 0 t) ``` --- CHANGELOG.md | 1 + lisp/php-project.el | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 666ee46e..31960fd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this * Add `php-imenu-generic-expression-default` for default value or `php-imenu-generic-expression` * Add `php-imenu-generic-expression-legacy` for compatibility * Add `php-imenu-generic-expression-simple` for simple display + * Add `php-project-project-find-function` compatible with `project-find-functions` ### Changed diff --git a/lisp/php-project.el b/lisp/php-project.el index b6111719..3ed761eb 100644 --- a/lisp/php-project.el +++ b/lisp/php-project.el @@ -282,6 +282,17 @@ Typically it is `pear', `drupal', `wordpress', `symfony2' and `psr2'.") php-project-root (php-project--detect-root-dir))) +;;;###autoload +(defun php-project-project-find-function (dir) + "Return path to current PHP project from DIR. + +This function is compatible with `project-find-functions'." + (let ((default-directory dir)) + (when-let (root (php-project-get-root-dir)) + (if (file-exists-p (expand-file-name ".git" root)) + (cons 'vc root) + (cons 'transient root))))) + (defun php-project--detect-root-dir () "Return detected project root." (if (and php-project-use-projectile-to-detect-root