Skip to content

Commit bd77440

Browse files
committed
Project dir decision where lein & boot are mixed
This functionality was moved from `cider' project
1 parent 1fde668 commit bd77440

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

clojure-mode.el

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

980980

981981

982-
(defun clojure-project-dir ()
982+
(defun clojure-project-dir (dir-name)
983983
"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"))))
984+
(when dir-name
985+
(let ((lein-project-dir (locate-dominating-file dir-name "project.clj"))
986+
(boot-project-dir (locate-dominating-file dir-name "build.boot")))
987+
(file-truename
988+
(reduce #'(lambda (x y)
989+
(cond ((not x) y)
990+
((not y) x)
991+
(t (if (file-in-directory-p x y) x y))))
992+
(list lein-project-dir
993+
boot-project-dir))))))
989994

990995
(defun clojure-project-relative-path (path)
991996
"Denormalize PATH by making it relative to the project root."
992-
(file-relative-name path (clojure-project-dir)))
997+
(file-relative-name path (clojure-project-dir default-directory)))
993998

994999
(defun clojure-expected-ns (&optional path)
9951000
"Return the namespace matching PATH.

0 commit comments

Comments
 (0)