diff options
author | Dan Fuchs <fuchsd@gmail.com> | 2015-12-19 15:05:03 -0600 |
---|---|---|
committer | Dan Fuchs <dfuchs@leapfrogonline.com> | 2015-12-22 11:53:05 -0600 |
commit | 86f872f772ddce053c1808f4c30520b3425ddcb4 (patch) | |
tree | 5fd870602f10bb54cc9ba59332139053b5d6bc1c /cider-client.el | |
parent | 22cccb7f6d8cf779d9141bc445d80ebe85b4bb5c (diff) |
Check major mode first when choosing connection
`cider-repl-type` does not initially get set differently for the two
repls created by `cider-jack-in-clojurescript`. If the major mode of
the current buffer is definitely Clojure or ClojureScript, use the
matching REPL connection for that type, if there is one open. If the
major mode is not either of those modes, only then determine the
appropriate connection by looking at `cider-repl-type`.
Thanks to @rfkm for the suggestion for the change
(https://github.com/clojure-emacs/cider/commit/003adaa11c7b417486f58a7265e85c5e4c6d188b#commitcomment-15082109)!
Diffstat (limited to 'cider-client.el')
-rw-r--r-- | cider-client.el | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/cider-client.el b/cider-client.el index 492ce731..4cdfd66c 100644 --- a/cider-client.el +++ b/cider-client.el @@ -197,6 +197,14 @@ such a link cannot be established automatically." (cider-ensure-connected) (kill-local-variable 'cider-connections)) +(defun cider-connection-type-for-buffer () + "Return the matching connection type (clj or cljs) for the current buffer." + (cond + ((derived-mode-p 'clojurescript-mode) "cljs") + ((derived-mode-p 'clojure-mode) "clj") + (cider-repl-type) + (t "clj"))) + (defun cider-current-connection (&optional type) "Return the REPL buffer relevant for the current Clojure source buffer. A REPL is relevant if its `nrepl-project-dir' is compatible with the @@ -218,9 +226,7 @@ from the file extension." ;; Only one match, just return it. (car project-connections) ;; OW, find one matching the language of the current buffer. - (let ((type (or type cider-repl-type - (if (derived-mode-p 'clojurescript-mode) - "cljs" "clj")))) + (let ((type (or type (cider-connection-type-for-buffer)))) (or (seq-find (lambda (conn) (equal (cider--connection-type conn) type)) project-connections) |