Skip to content

Commit ef69a8b

Browse files
authored
Merge pull request #458 from zonuexe/feature/php-project-root-accept-string
Make php-project-root accept a string
2 parents 6de2923 + 96e1f30 commit ef69a8b

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

php-project.el

+18-11
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,15 @@
9595
Try to search file in order of `php-project-available-root-files'.
9696
9797
SYMBOL
98-
Key of `php-project-available-root-files'.")
98+
Key of `php-project-available-root-files'.
99+
100+
STRING
101+
A file/directory name of top level marker.
102+
If the string is an actual directory path, it is set as the absolute path
103+
of the root directory, not the marker.")
99104
(make-variable-buffer-local 'php-project-root)
100105
(put 'php-project-root 'safe-local-variable
101-
#'(lambda (v) (assq v php-project-available-root-files))))
106+
#'(lambda (v) (or (stringp v) (assq v php-project-available-root-files)))))
102107

103108
;;;###autoload
104109
(progn
@@ -177,15 +182,17 @@ Typically it is `pear', `drupal', `wordpress', `symfony2' and `psr2'.")
177182
;;;###autoload
178183
(defun php-project-get-root-dir ()
179184
"Return path to current PHP project."
180-
(let ((detect-method
181-
(cond
182-
((stringp php-project-root) (list php-project-root))
183-
((eq php-project-root 'auto)
184-
(cl-loop for m in php-project-available-root-files
185-
append (cdr m)))
186-
(t (cdr-safe (assq php-project-root php-project-available-root-files))))))
187-
(cl-loop for m in detect-method
188-
thereis (locate-dominating-file default-directory m))))
185+
(if (and (stringp php-project-root) (file-directory-p php-project-root))
186+
php-project-root
187+
(let ((detect-method
188+
(cond
189+
((stringp php-project-root) (list php-project-root))
190+
((eq php-project-root 'auto)
191+
(cl-loop for m in php-project-available-root-files
192+
append (cdr m)))
193+
(t (cdr-safe (assq php-project-root php-project-available-root-files))))))
194+
(cl-loop for m in detect-method
195+
thereis (locate-dominating-file default-directory m)))))
189196

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

0 commit comments

Comments
 (0)