Skip to content

Commit

Permalink
Merge pull request #458 from zonuexe/feature/php-project-root-accept-…
Browse files Browse the repository at this point in the history
…string

Make php-project-root accept a string
  • Loading branch information
zonuexe authored Apr 12, 2018
2 parents 6de2923 + 96e1f30 commit ef69a8b
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions php-project.el
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,15 @@
Try to search file in order of `php-project-available-root-files'.
SYMBOL
Key of `php-project-available-root-files'.")
Key of `php-project-available-root-files'.
STRING
A file/directory name of top level marker.
If the string is an actual directory path, it is set as the absolute path
of the root directory, not the marker.")
(make-variable-buffer-local 'php-project-root)
(put 'php-project-root 'safe-local-variable
#'(lambda (v) (assq v php-project-available-root-files))))
#'(lambda (v) (or (stringp v) (assq v php-project-available-root-files)))))

;;;###autoload
(progn
Expand Down Expand Up @@ -177,15 +182,17 @@ Typically it is `pear', `drupal', `wordpress', `symfony2' and `psr2'.")
;;;###autoload
(defun php-project-get-root-dir ()
"Return path to current PHP project."
(let ((detect-method
(cond
((stringp php-project-root) (list php-project-root))
((eq php-project-root 'auto)
(cl-loop for m in php-project-available-root-files
append (cdr m)))
(t (cdr-safe (assq php-project-root php-project-available-root-files))))))
(cl-loop for m in detect-method
thereis (locate-dominating-file default-directory m))))
(if (and (stringp php-project-root) (file-directory-p php-project-root))
php-project-root
(let ((detect-method
(cond
((stringp php-project-root) (list php-project-root))
((eq php-project-root 'auto)
(cl-loop for m in php-project-available-root-files
append (cdr m)))
(t (cdr-safe (assq php-project-root php-project-available-root-files))))))
(cl-loop for m in detect-method
thereis (locate-dominating-file default-directory m)))))

(provide 'php-project)
;;; php-project.el ends here

0 comments on commit ef69a8b

Please sign in to comment.