Skip to content

Commit

Permalink
[Fix clojure-emacs/cider#1234] project-dir is nil if not in a project
Browse files Browse the repository at this point in the history
  • Loading branch information
Malabarba committed Aug 4, 2015
1 parent 031f280 commit 9c5e92f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions clojure-mode.el
Expand Up @@ -982,16 +982,18 @@ nil."
(defun clojure-project-dir (&optional dir-name)
"Return the absolute path to the project's root directory.
Use `default-directory' if DIR-NAME is nil."
Use `default-directory' if DIR-NAME is nil.
Return nil if not inside a project."
(let ((dir-name (or dir-name default-directory)))
(let ((lein-project-dir (locate-dominating-file dir-name "project.clj"))
(boot-project-dir (locate-dominating-file dir-name "build.boot")))
(file-truename
(cond ((not lein-project-dir) boot-project-dir)
((not boot-project-dir) lein-project-dir)
(t (if (file-in-directory-p lein-project-dir boot-project-dir)
lein-project-dir
boot-project-dir)))))))
(when (or lein-project-dir boot-project-dir)
(file-truename
(cond ((not lein-project-dir) boot-project-dir)
((not boot-project-dir) lein-project-dir)
(t (if (file-in-directory-p lein-project-dir boot-project-dir)
lein-project-dir
boot-project-dir))))))))

(defun clojure-project-relative-path (path)
"Denormalize PATH by making it relative to the project root."
Expand Down

0 comments on commit 9c5e92f

Please sign in to comment.