summaryrefslogtreecommitdiff
path: root/cider-client.el
diff options
context:
space:
mode:
authorVitalie Spinu <spinuvit@gmail.com>2017-12-10 22:19:59 +0100
committerVitalie Spinu <spinuvit@gmail.com>2017-12-10 22:19:59 +0100
commit21bdb8d9676e3b4c9d3433535a5c60356de940d6 (patch)
treeef6061e60e7e6d5673fbf6d858b532b3e358f952 /cider-client.el
parent254f17d022353ae5dc95d8a5148a59c8ec9206ee (diff)
Add optional `buffer` argument to cider-connection-type-for-buffer
Diffstat (limited to 'cider-client.el')
-rw-r--r--cider-client.el20
1 files changed, 11 insertions, 9 deletions
diff --git a/cider-client.el b/cider-client.el
index 0472913c..73b2ce7e 100644
--- a/cider-client.el
+++ b/cider-client.el
@@ -178,17 +178,19 @@ 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.
+(defun cider-connection-type-for-buffer (&optional buffer)
+ "Return the matching connection type (clj or cljs) for 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)))
+list of types of actual connections within a project. BUFFER defaults to
+the `current-buffer'."
+ (with-current-buffer (or buffer (current-buffer))
+ (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."