|
95 | 95 | Try to search file in order of `php-project-available-root-files'.
|
96 | 96 |
|
97 | 97 | 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.") |
99 | 104 | (make-variable-buffer-local 'php-project-root)
|
100 | 105 | (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))))) |
102 | 107 |
|
103 | 108 | ;;;###autoload
|
104 | 109 | (progn
|
@@ -177,15 +182,17 @@ Typically it is `pear', `drupal', `wordpress', `symfony2' and `psr2'.")
|
177 | 182 | ;;;###autoload
|
178 | 183 | (defun php-project-get-root-dir ()
|
179 | 184 | "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))))) |
189 | 196 |
|
190 | 197 | (provide 'php-project)
|
191 | 198 | ;;; php-project.el ends here
|
0 commit comments