good morning 🙂 Any advice on getting the result of a cider-interactive-eval as a string that I can further parse with eg parseedn-parse-str? I tried the following, but it appears cider-interactive-eval doesn't return a string.
(defun demo ()
(interactive)
(let* ((edn-str (cider-interactive-eval "(map (partial * 10) '(1 2 3))"))
(elisp-values (parseedn-read-str edn-str)))
elisp-values))
;; then M-x demo from a buffer with a running REPL.(The idea is to use completing-read to select one of the elisp values, and then do further REPL incantations with that)
Originally posted in #emacs, but moved here. https://clojurians.slack.com/archives/C099W16KZ/p1751973522823009
I think maybe I could use callback.
(defun cider-interactive-eval (form &optional callback bounds additional-params)
"Evaluate FORM and dispatch the response to CALLBACK.
If the code to be evaluated comes from a buffer, it is preferred to use a
nil FORM, and specify the code via the BOUNDS argument instead.
...Either callback, or check cider-nrepl-send-sync-request
Great — thank you! 🙏
I have a few hacks where I use the callback to paste it into a buffer to format results using an elisp mode: https://github.com/dgtized/dotfiles/blob/master/site-lisp/clgc-clojure.el#L1. Specifically look at how clj-dissasemble and clj-decompile emit cider eval results into a popup buffer to apply transformations on. I suspect what you want instead is to put your edn parsing in something like the clj-combined-popup-eval-handler I have as a callback with clj-decompile-render.
The main thing to remember is that cider-interactive-eval is an async call that may take a while to return, so you don't want emacs to block, so you definitely need a callback to receive the result. For little evaluations like you suggested the sync handler mentioned may work, but careful if it blocks the emacs UI.
I'm struggling to get a basic ClojureScript REPL working with node because of https://github.com/clojure-emacs/cider/issues/3781 problem. Does anybody have any advice? In order of things I would be happy to give up.... 1. Version of node 2. Version of Clojure 3. Version of cider ecosystem deps 4. Version of ClojureScript 5. Version of CIDER 6. Version of emacs It's been a while since I worked in ClojureScript, so maybe I'm just doing it wrong, but this problem is debilitating.
That's my issue, and I'd for sure like to see it resolved. fwiw, we've worked around it currently by doubling down on #shadow-cljs, which, for the most part, works great with cider. Our biggest outstanding issue is this one: https://github.com/clojure-emacs/cider/issues/3597 which I'm almost but not quite smart enough to fix, but I am learning things every day 🙂
--- David's recent talk: https://www.youtube.com/watch?v=An-ImWVppNQ pops off about the benefits of cljs with fewer layers of tooling, and I do think it'd be great to have everything he's excited about working in Cider.
Thanks for the quick reply, Harold. I saw David's talk and was intrigued. I've been away from ClojureScript for the past couple of years, but I'm dabbling again.
yeah, it's interesting, when I logged that issue I was thinking about some of the same things from that talk (these ideas are in the air), but for real work, shadow-cljs is serving us well (better than I thought it would).