Hi. Part of my workflow currently is having a bit of test code in a comment
form next to the function I'm currently working on, and I change the function a bit, and then eval the same bit of code again. Is there a way for cider to remember that bit of code and run it again? Took a quick glance at the docs and didn't see anything, but might well have missed it ...
I couldn't find anything, so I hacked this together
(defvar-local last-sexp-contents nil)
(defun ed-clojure/eval-last-sexp (&optional re-run-previous-sexp)
"Hacked patched from cider (defun cider-eval-last-sexp ... )
Evaluate the expression preceding point. If invoked with
RE-RUN-PREVIOUS-SEXP, use that rather than the value at point
buffer."
(interactive "P")
(if re-run-previous-sexp
(progn
(setq last-sexp-contents (cider-last-sexp))
(cider-interactive-eval nil nil (cider-last-sexp 'BOUNDS) (cider--nrepl-pr-request-map)))
(if last-sexp-contents
(cider-interactive-eval last-sexp-contents nil nil (cider--nrepl-pr-request-map))
(user-error "No sexp has been run in this buffer - invoke with prefix arg to eval an sexp"))))
which seems to work for me ... is this a terrible idea? Have I done a bad thing? Or is it worth me putting a PR together?or is it just me that has this problem?
I get the following error when trying to jack-in both clj and cljs: Execution error (ExceptionInfo) at shadow.cljs.devtools.server.runtime/get-instance! (runtime.clj:11).
There are suggested fixes here: https://github.com/clojure-emacs/cider/issues/2812, but I do not understand them. Anyone have a simpler fix? XD Or know a better place to ask?
Jacking in both clj and cljs with shadow-cljs never worked for me, I usually just run npx shadow-cljs watch main
on the command line, then just connect clj and cljs with cider
it can't. that command tries to use two different sessions in the same process. That isn't possible when shadow is the process for FE and clojure/lein is running the backend
if you use figwheel, you can start up lein or clojure, and then run a clj repl as normal and another session that invokes the figwheel build process and ultimately gives you a cljs repl