This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-10-23
Channels
- # announcements (1)
- # architecture (20)
- # babashka (30)
- # beginners (79)
- # calva (27)
- # cider (8)
- # clj-kondo (1)
- # clojure (125)
- # clojure-australia (1)
- # clojure-berlin (4)
- # clojure-europe (62)
- # clojure-france (1)
- # clojure-italy (6)
- # clojure-nl (4)
- # clojure-uk (12)
- # clojuredesign-podcast (5)
- # clojurescript (28)
- # core-async (31)
- # cursive (14)
- # datomic (47)
- # defnpodcast (1)
- # emacs (7)
- # figwheel-main (2)
- # fulcro (10)
- # graalvm (1)
- # graphql (11)
- # jobs-discuss (8)
- # leiningen (2)
- # off-topic (23)
- # rdf (9)
- # re-frame (3)
- # reagent (1)
- # reitit (5)
- # reveal (12)
- # shadow-cljs (12)
- # spacemacs (1)
- # tools-deps (87)
- # vim (22)
- # xtdb (21)
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?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