Skip to content

Case handling in nrepl-project-directory-for #1215

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

Merged
merged 1 commit into from
Aug 1, 2015
Merged
Show file tree
Hide file tree
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
10 changes: 2 additions & 8 deletions cider-interaction.el
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,6 @@ is ambiguity, therefore nil is returned."
(file-name-directory buffer-file-name)
default-directory))

(defun cider-project-directory-for (dir-name)
"Return the project directory for the specified DIR-NAME."
(when dir-name
(or (locate-dominating-file dir-name "project.clj")
(locate-dominating-file dir-name "build.boot"))))

(defun cider-set-relevant-connection (&optional do-prompt)
"Try to set the current REPL buffer based on the the current Clojure source buffer.
If succesful, return the new connection buffer.
Expand All @@ -482,10 +476,10 @@ directory."
(interactive "P")
(cider-ensure-connected)
(let* ((project-directory
(cider-project-directory-for
(clojure-project-dir
(or (when do-prompt
(read-directory-name "Project: "
(cider-project-directory-for (buffer-file-name))
(clojure-project-dir (buffer-file-name))
nil
'confirm))
(cider-current-dir))))
Expand Down
6 changes: 3 additions & 3 deletions cider.el
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ own buffer."
(if (funcall (cider-command-present-p project-type))
(let* ((project (when prompt-project
(read-directory-name "Project: ")))
(project-dir (cider-project-directory-for
(project-dir (clojure-project-dir
(or project (cider-current-dir))))
(params (if prompt-project
(read-string (format "nREPL server command: %s "
Expand Down Expand Up @@ -337,7 +337,7 @@ of list of the form (project-dir port)."
(proj-ports (mapcar (lambda (d)
(-when-let (port (and d (nrepl-extract-port (cider--file-path d))))
(list (file-name-nondirectory (directory-file-name d)) port)))
(cons (cider-project-directory-for dir) paths))))
(cons (clojure-project-dir dir) paths))))
(-distinct (delq nil proj-ports))))

(defun cider--running-nrepl-paths ()
Expand All @@ -355,7 +355,7 @@ Use `cider-ps-running-nrepls-command' and `cider-ps-running-nrepl-path-regexp-li
(defun cider-project-type ()
"Determine the type, either leiningen or boot, of the current project.
If both project file types are present, prompt the user to choose."
(let* ((default-directory (cider-project-directory-for (cider-current-dir)))
(let* ((default-directory (clojure-project-dir (cider-current-dir)))
(lein-project-exists (file-exists-p "project.clj"))
(boot-project-exists (file-exists-p "build.boot")))
(cond ((and lein-project-exists boot-project-exists)
Expand Down
6 changes: 3 additions & 3 deletions test/cider-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@
(should (equal (cider--find-rest-args-position [fmt arg]) nil)))

(ert-deftest test-cider-switch-to-relevant-repl-buffer ()
(noflet ((cider-project-directory-for (dontcare)
(noflet ((clojure-project-dir (dontcare)
nrepl-project-dir))
(let* ((b1 (generate-new-buffer "temp"))
(b2 (generate-new-buffer "temp"))
Expand Down Expand Up @@ -435,7 +435,7 @@
(kill-buffer buf)))))

(ert-deftest test-cider-switch-to-relevant-repl-buffer-ambiguous-project-dir ()
(noflet ((cider-project-directory-for (dontcare)
(noflet ((clojure-project-dir (dontcare)
nrepl-project-dir))
(let* ((b1 (generate-new-buffer "temp"))
(b2 (generate-new-buffer "temp"))
Expand All @@ -459,7 +459,7 @@
(kill-buffer buf)))))

(ert-deftest test-cider-switch-to-relevant-repl-buffer-ambiguous-if-two-projects ()
(noflet ((cider-project-directory-for (dontcare)
(noflet ((clojure-project-dir (dontcare)
nrepl-project-dir))
(let* ((b1 (generate-new-buffer "temp"))
(b2 (generate-new-buffer "temp"))
Expand Down