Skip to content

Commit 21bdb8d

Browse files
committed
Add optional buffer argument to cider-connection-type-for-buffer
1 parent 254f17d commit 21bdb8d

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

cider-client.el

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,19 @@ connections are returned, instead of just the most recent."
178178
cider-connections
179179
(car cider-connections)))))
180180

181-
(defun cider-connection-type-for-buffer ()
182-
"Return the matching connection type (clj or cljs) for the current buffer.
181+
(defun cider-connection-type-for-buffer (&optional buffer)
182+
"Return the matching connection type (clj or cljs) for BUFFER.
183183
In cljc and cljx buffers return \"multi\". This function infers connection
184184
type based on the major mode. See `cider-project-connections-types' for a
185-
list of types of actual connections within a project."
186-
(cond
187-
((derived-mode-p 'clojurescript-mode) "cljs")
188-
((derived-mode-p 'clojurec-mode) "multi")
189-
((derived-mode-p 'clojurex-mode) "multi")
190-
((derived-mode-p 'clojure-mode) "clj")
191-
(cider-repl-type)))
185+
list of types of actual connections within a project. BUFFER defaults to
186+
the `current-buffer'."
187+
(with-current-buffer (or buffer (current-buffer))
188+
(cond
189+
((derived-mode-p 'clojurescript-mode) "cljs")
190+
((derived-mode-p 'clojurec-mode) "multi")
191+
((derived-mode-p 'clojurex-mode) "multi")
192+
((derived-mode-p 'clojure-mode) "clj")
193+
(cider-repl-type))))
192194

193195
(defun cider-project-connections-types ()
194196
"Return a list of types of connections within current project."

0 commit comments

Comments
 (0)