Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make php-project-root accept a string #458

Merged
merged 1 commit into from
Apr 12, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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