Fork me on GitHub
#cider
<
2023-01-26
>
pmooser09:01:03

How do I tell programmatically if there's a cider connection associated with the current buffer?

pmooser09:01:39

Replying to myself as I try to investigate.

pmooser09:01:03

I don't mean cider-reply-type-for-buffer , which will return a type even when we have no associated connection.

pmooser09:01:50

I think I can use cider-current-repl ... if I am not mistaken.

dpsutton15:01:51

(defun cider-connected-p ()
  "Return t if CIDER is currently connected, nil otherwise."
  (process-live-p (get-buffer-process (cider-current-repl))))

Carsten Behring21:01:58

How can I evaluate a Clojure function from EmacsLisp with cider and get its result as a lisp list-of-string (assuming that the Clojure function returns a sequence of Strings) ?

jumraiya22:01:55

Not sure about cider but I used a elisp package called clomacs for calling clojure functions in emacs a while ago. It worked pretty well.

vemv23:01:16

The problem can be decomposed into two parts: • evaluate a clojure expression string, and get a result string back ◦ very easy with CIDER, you can take a look around its eval functions • use elisp's read (which clojurists would call read-string) to turn that string into elisp objects ◦ and cross fingers that one thing can be converted to the other without errors If you don't want to "cross fingers" so much, change (clojure-eval-string "(foo)") to (clojure-eval-string "(my.ns/adjust (foo))")where my.ns/adjust is a custom function that will make data easier to convert, according to your requirements (e.g. turn sets into lists) (and where clojure-eval-string is pseudocode - please look up the actual CIDER functions)

👍 2
vemv23:01:22

Clomacs might just work, I never tried it. Personally I just like the simplicity of composing a few functions, so that I can understand the whole approach being used