diff options
author | Vitalie Spinu <spinuvit@gmail.com> | 2017-07-14 11:51:17 +0200 |
---|---|---|
committer | Bozhidar Batsov <bozhidar.batsov@gmail.com> | 2017-07-16 10:47:55 +0300 |
commit | 388133c435e80ffa20582468a3f07fde6dd95cc3 (patch) | |
tree | 208151d99b9d2f8a340530e14dcfde0ecbcad720 /cider-client.el | |
parent | b185f75f3bde56b6b9ae7f11b68f60323d9d90e7 (diff) |
Better connection types retrival
- new function `cider-project-connections-types`
- `cider-connection-type-for-buffer` returns "multi" in cljc an cljx
Diffstat (limited to 'cider-client.el')
-rw-r--r-- | cider-client.el | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/cider-client.el b/cider-client.el index 29134c1c..87b81345 100644 --- a/cider-client.el +++ b/cider-client.el @@ -137,7 +137,7 @@ Also close associated REPL and server buffers." ;;; Current connection logic -(defvar-local cider-repl-type "clj" +(defvar-local cider-repl-type nil "The type of this REPL buffer, usually either \"clj\" or \"cljs\".") (defun cider-find-connection-buffer-for-project-directory (&optional project-directory all-connections) @@ -178,6 +178,23 @@ connections are returned, instead of just the most recent." cider-connections (car cider-connections))))) +(defun cider-connection-type-for-buffer () + "Return the matching connection type (clj or cljs) for the current buffer. +In cljc and cljx buffers return \"multi\". This function infers connection +type based on the major mode. See `cider-project-connections-types' for a +list of types of actual connections within a project." + (cond + ((derived-mode-p 'clojurescript-mode) "cljs") + ((derived-mode-p 'clojurec-mode) "multi") + ((derived-mode-p 'clojurex-mode) "multi") + ((derived-mode-p 'clojure-mode) "clj") + (cider-repl-type))) + +(defun cider-project-connections-types () + "Return a list of types of connections within current project." + (let ((connections (cider-find-connection-buffer-for-project-directory nil :all-connections))) + (seq-uniq (seq-map #'cider--connection-type connections)))) + (defun cider-read-connection (prompt) "Completing read for connections using PROMPT." (get-buffer (completing-read prompt (mapcar #'buffer-name (cider-connections))))) @@ -221,14 +238,6 @@ 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-toggle-request-dispatch () "Toggle the value of `cider-request-dispatch' between static and dynamic. |