Fork me on GitHub
#calva
<
2022-04-10
>
pinkfrog14:04:23

How can I evaluate (bar "xxx") only given the top level form

(foo (bar "xxx"))

pinkfrog14:04:50

The cursor is within xxx

pez15:04:49

There is no single command for that. The closest you get is Evaluate surrounding form, default shortcut ctrl+shift+enter. You'll have to go up one form first, ctrl+up (or go forward up ctrl+alt+down), Then Cursor Undo (on mac cmd+u. Putting it together: ctrl+up, ctrl+shift+enter, cmd+u. There are some extensions that let you string commands and bind them to a shortcut, if this is too much finger exercise. 😃 Could be less of an exercise to go up two levels and evaluate current form: ctrl+up, ctrl+up, ctrl+enter, cmd+u, cmd+u

😂 1
pinkfrog15:04:36

I don’t quite get why evaluate surrounding form concerns about the “” string pair. It would be more natural to directly evaluate on the () enclosing form.

pez15:04:49

It's an effect of that Calva treats strings as list.

rayat19:04:31

Should it continue to do so for eval purposes? Is it possible to decouple the definition of list that Paredit uses from that which is used by eval operations?

👍 1
pez16:04:31

So far I've been keeping it consistent on purpose. If a user who wants to check what would be evaluated by Evaluate Current Form can use Expand Selection (or Select Current form, depending) to investigate this, w/o actually evaluating anything. Similarly with Evaluate Surrounding Form (with Expand Selection x 2). I see it as a contract/promise. I made a short video about this recently: https://www.youtube.com/watch?v=8ygw7LLLU1w

1
rayat21:04:52

Would users find it particularly confusing or contract violating when faced with the exceptional case of evaluation where there is a single "semantically fitting" discrepancy with other "Current Form" operations? I think it wouldn't be unreasonable to internalize that "Ah, because one never evaluates strings, when inside one, Eval Current Form behaves somewhat differently from otherwise, and evals the nearest evaluate-able form, and I understand this distinction and hopefully benefit from it"

rayat21:04:05

Though I'd like to hear from others to get a pulse on what users actually think

pez21:04:26

I think it adds unnecessary complexity. Both for the user and for us. I'd probably not merge a PR adding this.

Michael17:04:55

Hello! I am extremely new to Clojure and Calva, and I am trying to get the REPL up and running. The REPL with Leinengen is running, however I am not seeing the automatic results on my source file. I have attached a picture of what I expect to show, however it shows nothing. I can call it in the REPL window just fine though. I am on an M1 MacBook Pro, if that helps. . . Although, I am sure this is user error somehow

Cora (she/her)17:04:24

have you done the Getting Started REPL yet? https://calva.io/getting-started/

Cora (she/her)17:04:18

that should get you started and teach you the key chords needed to get eval results inline like you'd like

Michael17:04:55

Starting the "Getting Started REPL" produces the following: java -jar '/Users/makeitekim/.vscode/extensions/betterthantomorrow.calva-2.0.265/deps.clj.jar' -Sdeps '{:deps {nrepl/nrepl {:mvn/version,"0.9.0"},cider/cider-nrepl {:mvn/version,"0.27.4"}}}' -M -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]" Error building classpath. Expected edn map in: /private/var/folders/hl/OMITTED/T/betterthantomorrow.calva/kcbay8/deps.edn Jack-in process exited. Status: 1 I am reading through the guide, but it seems to indicate if you have a build tool (I use Lein), Java, VSCode, and Calva extension, it should just work. However, I may be reading over something crucial

pez17:04:46

I'll have a look at what's going wrong in the Getting Started REPL.

Michael17:04:05

Getting Started still doesn't work. However, I am able to get "=> output" working now. My Option Key was bound to my window manager, and thus auto-interpretation of functions wasn't able to be called

Michael17:04:48

I for some reason thought that it would auto-evaluate a function just by clicking on the function, didn't know I needed to run a keyboard command each time

pez17:04:08

To the original expectation. Can you describe the steps you take before the expected results?

Michael18:04:04

Sure, For using the getting started REPL 1. cmd+shift+p > "Calva: Fire Up the Getting Started REPL" 2. Create New Temp Directory 3. "Starting Jack-In terminal" 4. Error occurs due to empty end map in deps.edn file

Michael18:04:37

If this helps, when it creates the Temp directory, the deps.edn file created is empty. Shown here with a cat command on the file.

pez18:04:15

Thanks. However, I meant the original problem. The one you first posted about

Michael18:04:17

Ahh, yeah they are basically the same 1. lien new app some-app-name 2. Open CLJ project in VS Code 3. Open core.clj 4. cmd-shift-p 5. > Clava: Start a Project REPL... 6. Leinengen 7. :uberjar 8. jack-in done 9. have to use Alt-Enter to evaluate current line

Michael18:04:06

I think my only issue with the project repl was that I didn't understand I had to press Alt Enter every time (option enter on Mac)

pez19:04:11

Ah, thanks for clarifying that. Yes, you need evaluate things by command. See this page for an intro: https://calva.io/evaluation/

💜 2
Cora (she/her)19:04:46

thanks for hopping in, Peter! 😄

❤️ 1
pez19:04:18

Very strange with the Getting Started REPL....

pez19:04:25

Are the other files also empty, @U03BL70M5A4?

Cora (she/her)19:04:43

also is this all running locally on your native OS or is it in WSL or a remote machine or similar?

pez19:04:43

@U03BL70M5A4: Don't select uberjar at step 7 there. Selecting nothing is probably best.

pez19:04:05

The deps.edn file should contain

{:paths ["."]}
Really strange that it's empty.

Michael19:04:34

The only Empty file is the deps.edn in the temp folder of Getting Started

Michael19:04:43

all 3 Clojure files have code in them

pez19:04:16

Maybe it was a fluke. What if you try the command again, choosing to create new files?

Michael19:04:32

I have done that a few times, same result

Michael19:04:06

If I manually sudo edit the file through vim, I am able to get the REPL running.

Michael19:04:27

So, for the time being, now that I know what is supposed to be in the deps.edn file, I can manually bypass the error.

Cora (she/her)19:04:41

oh weird, you needed sudo

Michael19:04:55

Oh I just assumed since it was outside my home directory

Michael19:04:06

I am relatively new to macOS, I come from archlinux

Cora (she/her)19:04:25

in theory you shouldn't need to do that... hmmm

pez19:04:47

It was a misconfiguration, @U03BL70M5A4. Try the command again now.

Michael19:04:29

Holy moly, it worked

pez19:04:59

Thanks for letting us know! It must have been broken for some days...

Michael19:04:36

I should have said this, but I wasn't able to get it working on archlinux either, I really just assumed I was doing something wrong, but that makes sense

Michael19:04:43

but now it works

pez19:04:11

Awesome. I can see how you thought it was a user error. Very hard to know what to expect when you are new to something. Please don't hesitate to fire questions here if you wonder things. I'm always interested in feedback on those guides.

Michael20:04:15

Thank you so much! will do

🙏 1
calva 1