emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/php-mode fe4abfc719 1/2: Add php-project-project-find-func


From: ELPA Syncer
Subject: [nongnu] elpa/php-mode fe4abfc719 1/2: Add php-project-project-find-function compatible with project-find-functions
Date: Thu, 20 Jan 2022 15:58:31 -0500 (EST)

branch: elpa/php-mode
commit fe4abfc719314764a86de80791204ffa7d240afb
Author: USAMI Kenta <tadsan@zonu.me>
Commit: USAMI Kenta <tadsan@zonu.me>

    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 666ee46ebb..31960fd0c3 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 b611171924..3ed761eb28 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]