Skip to content

Commit 806a368

Browse files
committed
Project dir decision where lein & boot are mixed
1 parent 1fde668 commit 806a368

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

clojure-mode.el

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -979,13 +979,19 @@ nil."
979979

980980

981981

982-
(defun clojure-project-dir ()
983-
"Return the absolute path to the project's root directory."
984-
(file-truename
985-
(or (locate-dominating-file default-directory
986-
"project.clj")
987-
(locate-dominating-file default-directory
988-
"build.boot"))))
982+
(defun clojure-project-dir (&optional dir-name)
983+
"Return the absolute path to the project's root directory.
984+
985+
Use `default-directory' if DIR-NAME is nil."
986+
(let ((dir-name (or dir-name default-directory)))
987+
(let ((lein-project-dir (locate-dominating-file dir-name "project.clj"))
988+
(boot-project-dir (locate-dominating-file dir-name "build.boot")))
989+
(file-truename
990+
(cond ((not lein-project-dir) boot-project-dir)
991+
((not boot-project-dir) lein-project-dir)
992+
(t (if (file-in-directory-p lein-project-dir boot-project-dir)
993+
lein-project-dir
994+
boot-project-dir)))))))
989995

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

0 commit comments

Comments
 (0)