From b306117020d4726d2f1c0019969262f071a3c45e Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Mon, 10 Aug 2015 11:59:54 +0300 Subject: [PATCH] [#1217] Add a command for associating projects with connections This command should mostly be used with connections created using `cider-connect`. --- CHANGELOG.md | 1 + cider-interaction.el | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8e0015cd..46cb88260 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 TAB and RET 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 b54e55dc0..fccd4ddc5 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.