Fork me on GitHub
#cider
<
2021-07-14
>
ohsufresh22:07:02

Hi 👋 I was curious if anybody knows how I can send code from my file to my REPL and have it be evaluated. cider-eval-last-sexp-to-repl is the closest thing I can find but it requires me to move into the repl and hit enter? I asked the question in ClojureVerse also but no real feedback: https://clojureverse.org/t/cider-eval-to-repl-new-prompt/7796 I'm using Doom emacs.... I think Spacemacs has this functionality and certain Cursive does 🤷

dpsutton22:07:27

there's a lovely map that does just this. C-c C-j is the prefix for the insert into repl buffer keymap. there you can do C-c C-j d for top level defun, C-c C-j e for last expression

dpsutton22:07:31

there are three helpful options for you here

(setq cider-invert-insert-eval-p t)
(setq cider-switch-to-repl-on-insert nil)
(setq clojure-toplevel-inside-comment-form t)
these do: 1. eval automatically when you insert things in the repl. the default was to just put them in the repl but not eval 2. don't switch to the repl during this, just eval it and stay where you are 3. helpful, but it is useful for when you are in (comment ...) blocks to not treat the whole comment block as the top level form, but each form inside it as "top level". Kinda a natural helper with this endeavor

dpsutton22:07:48

(i had the wrong keybinding, updated now to C-c C-j