You can just SPC b m
Currently, in order to eval an expression in my Cider REPL buffer I have to be in insert mode. Is there a way to eval an expression in normal mode?
It works for me just fine. How do you eval expressions?
I have to go into insert mode and press Ctrl-Enter
when I am in normal mode, pressing Ctrl-Enter
has no effect
In insert mode, Enter
works also
Ah, I thought you're talking about clojure buffer.
How about just calling cider-eval-last-sexp
?
And what's your use case for evaling expression in normal mode in the REPL buffer?
(Basically anything that works in the standard buffer should work in the repl buffer too)
When I press arrow key up I am able to traverse the history of commands evaled in the REPL
I am in normal mode
cider-eval-last-sexp
works in the REPL buffer but it is a bit weird as it doesn’t create a new line in the REPL
What I could do is use arrow key up in insert mode (with Ctrl-UP
)
But quite often I need to go to the buffer REPL for a brief moment, re-execute the previous expression and move back to the previous REPL
For instance, I run (reset)
from component
If you really care about getting the same thing as if pressing Enter manually you could also use cider-send-last-sexp-to-repl
(`, s e` ) - but it's a bit weird in the REPL itself since it duplicates the expression.
the ,e w
might be interesting too
issn’t it , e f
?
By , e w
I meant cider-eval-last-sexp-and-replace
@viebel RET
in the REPL buffer using Evil normal state should evaluate the current expression. If you have to change to insert mode then perhaps something is incorrect with your setup.
C-k
and C-j
in the REPL buffer in Evil insert state will scroll through REPL buffer history. These keys are very common for scrolling through lists in Spacemacs (e.g. helm lists)
Is there something stopping you from just evaluating the code in the source code buffers? I find the REPL buffer experience quite limited, especially as it requires switching namespaces or require namespace or provide fully qualified names.
I take it its possible to set functionality on a per projectile basis? things like:
(setq clojure-indent-style 'align-arguments)
(setq clojure-indent-style 'always-indent)
i'll follow up in this thread when i figure out how.I assume this would be done in a .dir-locals.el
file if its on per projectile basis
Not dissimilar to this I guess https://practicalli.github.io/spacemacs/clojure-projects/monorepo-nested-projects.html
or defining default aliases to include for deps.end projects as in this article https://practicalli.github.io/blog/posts/cider-jack-in-to-clojure-cli-projects-from-spacemacs/
@jr0cket usually I eval expressions from source code buffers. But from time to time, I need to eval expressions form the REPL buffer
@jr0cket any idea why RET
doesn’t work? I just noticed that \ RET
works.
RET
is bound to evil-ret
Are you on an older version of CIDER or Spacemacs? I am using CIDER 0.25.0 (Bergamo) and updated Spacemacs and packages a few days ago.
Otherwise maybe there is something in your dotspacemacs/user-config
in .spacemacs
that configures CIDER to behave differently. I believe you can configure multi-line support, but I think that only affects what RET
does in Evil insert (so you can have mutiple lines).
I am assuming you are just jumping to the REPL to run the (reset)
function, you can set up CIDER to drive components when refreshing the repl, so everything would be done in an existing keybinding. If that makes sense, I'll try dig out the code...
I am very eager to learn how to let CIDER drive components when it’s required…
This is what I've learnt so far, its not extensively tested, but should get you close https://practicalli.github.io/spacemacs/clojure-repl/component-lifecycle.html Let me know if the .dir-locals.el setup works for you and if you have better examples of using component to share 🙂