summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBozhidar Batsov <bozhidar@batsov.com>2015-08-10 11:59:54 +0300
committerBozhidar Batsov <bozhidar@batsov.com>2015-08-10 11:59:54 +0300
commitb306117020d4726d2f1c0019969262f071a3c45e (patch)
tree4abd888362c7d2da0b79397f0be628099caf042f
parentb1a7b1fa354074d843b54524869d503d59e9cfa8 (diff)
[#1217] Add a command for associating projects with connections
This command should mostly be used with connections created using `cider-connect`.
-rw-r--r--CHANGELOG.md1
-rw-r--r--cider-interaction.el12
2 files changed, 13 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e8e0015c..46cb8826 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,7 @@
### New features
+* [#1217](https://github.com/clojure-emacs/cider/issues/1217): Add new command `cider-assoc-project-with-connection` to associate a project directory with a connection.
* [#1248](https://github.com/clojure-emacs/cider/pull/1248): Add <kbd>TAB</kbd> and <kbd>RET</kbd> keys to the test-report buffer.
* [#1245](https://github.com/clojure-emacs/cider/pull/1245): New variable, `cider-ovelays-use-font-lock` controls whether results overlay should be font-locked or just use a single face.
* [#1235](https://github.com/clojure-emacs/cider/pull/1235): Add support for syntax-quoted forms to the debugger.
diff --git a/cider-interaction.el b/cider-interaction.el
index b54e55dc..fccd4ddc 100644
--- a/cider-interaction.el
+++ b/cider-interaction.el
@@ -472,6 +472,18 @@ is ambiguity, therefore nil is returned."
(file-name-directory buffer-file-name)
default-directory))
+(defun cider-assoc-project-with-connection ()
+ "Associate a Clojure project with an nREPL connection.
+
+Useful for connections created using `cider-connect', as for them
+such a link cannot be established automatically."
+ (interactive)
+ (let ((conn-buf (completing-read "Connection: " (nrepl-connection-buffers)))
+ (project-dir (read-directory-name "Project: " nil (clojure-project-dir))))
+ (when conn-buf
+ (with-current-buffer conn-buf
+ (setq nrepl-project-dir project-dir)))))
+
(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.