Fork me on GitHub
#spacemacs
<
2020-06-15
>
Yehonathan Sharvit07:06:22

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?

jumar07:06:17

It works for me just fine. How do you eval expressions?

Yehonathan Sharvit07:06:15

I have to go into insert mode and press Ctrl-Enter

Yehonathan Sharvit07:06:39

when I am in normal mode, pressing Ctrl-Enter has no effect

Yehonathan Sharvit07:06:22

In insert mode, Enter works also

jumar07:06:17

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?

jumar07:06:37

(Basically anything that works in the standard buffer should work in the repl buffer too)

Yehonathan Sharvit07:06:01

When I press arrow key up I am able to traverse the history of commands evaled in the REPL

Yehonathan Sharvit07:06:08

I am in normal mode

Yehonathan Sharvit07:06:51

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

Yehonathan Sharvit07:06:49

What I could do is use arrow key up in insert mode (with Ctrl-UP )

Yehonathan Sharvit07:06:42

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

Yehonathan Sharvit07:06:03

For instance, I run (reset) from component

jumar09:06:03

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

flefik11:06:59

issn’t it , e f?

jumar13:06:44

By , e w I meant cider-eval-last-sexp-and-replace

practicalli-john13:06:58

@U0L91U7A8 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.

Yehonathan Sharvit16:06:43

@U05254DQM usually I eval expressions from source code buffers. But from time to time, I need to eval expressions form the REPL buffer

Yehonathan Sharvit16:06:00

@U05254DQM any idea why RET doesn’t work? I just noticed that \ RET works.

Yehonathan Sharvit16:06:45

RET is bound to evil-ret

practicalli-john16:06:01

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.

practicalli-john16:06:27

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).

practicalli-john16:06:36

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...

Yehonathan Sharvit16:06:02

I am very eager to learn how to let CIDER drive components when it’s required…

practicalli-john16:06:22

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 🙂

drewverlee13:06:50

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.

practicalli-john14:06:07

I assume this would be done in a .dir-locals.el file if its on per projectile basis

practicalli-john14:06:27

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/