Fork me on GitHub
#calva
<
2020-08-01
>
pez12:08:45

@stefan.van.den.oord, version v2.0.113 should fix the issue you ran into.

Stefan12:08:04

That’s wonderful @pez ! I was still planning to submit the issue but it was quite busy the last few days, finishing up before my holiday. So I guess I won’t have to submit it anymore :) I’ll verify it soon and let you know!

pez12:08:46

Someone else submitted the issue. 😃

pez12:08:43

And @UTF99QP7V ran into it as well. I'm sorry for the messup.

🤷 3
Stefan13:08:46

@pez I just updated to 2.0.113 and indeed the issue with continuously rerunning the tests is resolved. The other issue that I mentioned is not, however, so I created a ticket for it: https://github.com/BetterThanTomorrow/calva/issues/717. It boils down to the REPL window grabbing focus when I have a compile error, which hides my editor window, which is annoying 🙂

dabrazhe13:08:51

Have something changed with repl and keyboard shortcuts in the latest Calva update? I don't see the results of evaluation any longer : (

pez13:08:26

Depends on what you mean with the latest Calva. Things have changed, alright. But you should still be able to see your evaluation results. Can you describe the failing steps a bit?

dabrazhe13:08:23

@pez Sure. When evaluating the result a new window is opening, output.repl-file, instead of the usual repl window. which is ok i guess as I've been using inline results for a while now. But occasionally the shortcut stops evaluating anything, not inline nor in the new output window. I have to re-connect the repl to revive it.

dabrazhe13:08:58

interestingly I can evaluate to the repl window when inline not longer working

dabrazhe13:08:10

i'm connecting to nrepl outside of the project, in case it matters

pez14:08:07

That doesn't matter. But very strange symptoms that. Which shortcut are you using?

dabrazhe14:08:28

evaluate top level form

dabrazhe14:08:50

I guess I found it: once I evaluate a form suspends the repl so that I need to interrupt it the output.repl evaluation won't work any longer and i need to reconnect.

pez14:08:33

You interrupt it using the Calva command for that?

dabrazhe09:08:16

Yes. It doesn’t help though as with the normal repl, I have to reconnect to nrepl every time

Stefan13:08:34

@pez I have a question about formatting. Given this form:

(cond
      (= list1 list2) :equal
      (some #{list2} parts-of-1) :superlist
      (some #{list1} parts-of-2) :sublist
      :else :unequal)
Is Calva able to format it like this?
(cond
      (= list1 list2)            :equal
      (some #{list2} parts-of-1) :superlist
      (some #{list1} parts-of-2) :sublist
      :else                      :unequal)
In other words: align the “right-hand side” in a column?

pez14:08:05

No, I don't think cljfmt has that option yet.

👍 3
Jack Arrington17:08:09

I have a REPL-driven development question. I'm a total beginner to this workflow so apologies if it is basic. Say I have some code like this:

;; a function
(defn f1 [arg] (...do something...))

;; another function which depends on f1
(defn f2 [arg]
  (let [result (f1 arg)]
    (...do something with result...))
Then I want to test f2, so I write an expression and evaluate it with ctrl+enter:
(f2 whatever-value)
But then I get an error because f2 is undefined, so I have to go back and eval it, then I get an error because f1 is undefined, so I have to go back and eval it too, before finally going back down and evaluating my test expression. If I find something wrong and want to change something in either function, I have to repeat the whole cycle by re-evaluating the function I changed and the test expression all over again. Is there not some more efficient way to do this, that would allow me to just eval my test expression and have it automatically use the latest versions of everything it references?

ksd17:08:12

I am also relatively new to Calva and Clojure so take what I say with a grain of salt. I use ctrl+alt+c followed by either ctrl+alt+space or just space and it uses the latest version I’ve evaluated. I don’t know if there’s a difference with ctrl+enter.

ksd18:08:04

In your case I would eval f1, then f2 and then my test expression and then if I update f2 I eval it again and then eval my test expression and I don’t have to eval f1 a second time.

pez18:08:14

@U015GL869TQ since recently alt+enter was added as a shortcut doing the same as the one you mention there.

ksd18:08:36

oh I see

Jack Arrington18:08:55

I was searching the docs for what ctrl+alt+c, space did and I think I might have answered my own question by finding the ctrl+alt+c, enter command (load current file) anc ctrl+alt+c, ctrl+alt+n (load current namespace). Though I'm confused why the load current namespace opens a new CLJS REPL, separate from the output.repl-file :thinking_face:

bringe18:08:23

Load current namespace in repl window is a remnant of the old repl window that we're in the process of phasing out. I believe this needs to be changed to use the new repl-window. Right @pez?

bringe18:08:39

@U0174QDHXV3 But yes, load current file will eval everything in the file. You can also enable the calva setting Eval on save , but either way you must press some key combo (ctrl+s to save or the load current file shortcut) to have your latest changes loaded into the repl.

bringe18:08:59

I commonly will make a change and then load the file with ctrl+alt+c enter

Jack Arrington18:08:55

Awesome, yeah that workflow makes a lot more sense to me. Thanks for the help

bringe18:08:05

Be careful with top level code though. Use the comment form to house your test expressions and playground code. I commonly have one of these at the bottom of the ns/file for testing things out as I go

bringe18:08:16

No problem!

bringe18:08:45

https://calva.io/try-first/ This doc explains that workflow some

bringe18:08:58

And the "See also" links on that page may be helpful to you

👍 3
pez20:08:55

I think it is healthy to get used to evaluating things form by form. If something else is evaluating my forms, I am not in control, so to speak.

tjb18:08:07

hey everyone i am using luminus and just upgraded calva. im getting the following in the new repl window

tjb18:08:07

; Hooking up nREPL sessions...
; Connected session: clj
; TIPS: You can edit the contents here. Use it as a REPL if you like.
;   Use `alt+enter` to evaluate the current top level form.
;   (`ctrl+enter` evaluates the current form.)
;   File URLs in stacktrace frames are peekable and clickable.
clj::shadow.user=> 
; Debugger initialized
; Evaluating 'afterCLJReplJackInCode'
clj::shadow.user=> 
(start)
; Syntax error compiling at (.calva/output-window/output.repl-file:14:1).
; Unable to resolve symbol: start in this context
[{:file "Compiler.java" :line 6808 :method "analyze" :flags [:tooling :java]}
 {:file "Compiler.java" :line 6745 :method "analyze" :flags [:dup :tooling :java]}
 {:file "Compiler.java" :line 3820 :method "parse" :flags [:tooling :java]}
 {:file "Compiler.java" :line 7109 :method "analyzeSeq" :flags [:tooling :java]}
 {:file "Compiler.java" :line 6789 :method "analyze" :flags [:tooling :java]}
 {:file "Compiler.java" :line 6745 :method "analyze" :flags [:dup :tooling :java]}
 {:file "Compiler.java" :line 6120 :method "parse" :flags [:tooling :java]}
 {:file "Compiler.java" :line 5467 :method "parse" :flags [:tooling :java]}
 {:file "Compiler.java" :line 4029 :method "parse" :flags [:tooling :java]}
 {:file "Compiler.java" :line 7105 :method "analyzeSeq" :flags [:tooling :java]}
 {:file "Compiler.java" :line 6789 :method "analyze" :flags [:tooling :java]}
 {:file "Compiler.java" :line 7174 :method "eval" :flags [:tooling :java]}
 {:file "Compiler.java" :line 7132 :method "eval" :flags [:dup :tooling :java]}
 {:file "jar:file:/home/canti/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1.jar!/clojure/core.clj:3214" :fn "eval"  :method "invokeStatic" :flags [:clj]}
 {:file "jar:file:/home/canti/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1.jar!/clojure/core.clj:3210" :fn "eval"  :method "invoke" :flags [:clj]}
 {:file "jar:file:/home/canti/.m2/repository/nrepl/nrepl/0.7.0/nrepl-0.7.0.jar!/nrepl/middleware/interruptible_eval.clj:91" :fn "evaluate/fn"  :method "invoke" :flags [:tooling :clj]}
 {:file "jar:file:/home/canti/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1.jar!/clojure/main.clj:437" :fn "repl/read-eval-print/fn"  :method "invoke" :flags [:clj]}
 {:file "jar:file:/home/canti/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1.jar!/clojure/main.clj:437" :fn "repl/read-eval-print"  :method "invoke" :flags [:dup :clj]}
 {:file "jar:file:/home/canti/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1.jar!/clojure/main.clj:458" :fn "repl/fn"  :method "invoke" :flags [:clj]}
 {:file "jar:file:/home/canti/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1.jar!/clojure/main.clj:458" :fn "repl"  :method "invokeStatic" :flags [:dup :clj]}
 {:file "jar:file:/home/canti/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1.jar!/clojure/main.clj:368" :fn "repl"  :method "doInvoke" :flags [:clj]}
 {:file "RestFn.java" :line 1523 :method "invoke" :flags [:java]}
 {:file "jar:file:/home/canti/.m2/repository/nrepl/nrepl/0.7.0/nrepl-0.7.0.jar!/nrepl/middleware/interruptible_eval.clj:84" :fn "evaluate"  :method "invokeStatic" :flags [:tooling :clj]}
 {:file "jar:file:/home/canti/.m2/repository/nrepl/nrepl/0.7.0/nrepl-0.7.0.jar!/nrepl/middleware/interruptible_eval.clj:56" :fn "evaluate"  :method "invoke" :flags [:tooling :clj]}
 {:file "jar:file:/home/canti/.m2/repository/nrepl/nrepl/0.7.0/nrepl-0.7.0.jar!/nrepl/middleware/interruptible_eval.clj:155" :fn "interruptible-eval/fn/fn"  :method "invoke" :flags [:tooling :clj]}
 {:file "AFn.java" :line 22 :method "run" :flags [:java]}
 {:file "jar:file:/home/canti/.m2/repository/nrepl/nrepl/0.7.0/nrepl-0.7.0.jar!/nrepl/middleware/session.clj:190" :fn "session-exec/main-loop/fn"  :method "invoke" :flags [:tooling :clj]}
 {:file "jar:file:/home/canti/.m2/repository/nrepl/nrepl/0.7.0/nrepl-0.7.0.jar!/nrepl/middleware/session.clj:189" :fn "session-exec/main-loop"  :method "invoke" :flags [:tooling :clj]}
 {:file "AFn.java" :line 22 :method "run" :flags [:java]}
 {:file "Thread.java" :line 834 :method "run" :flags [:java]}]
clj::shadow.user=> 
; Evaluation failed.

tjb18:08:07

has anyone encountered this type of output / error?

bringe18:08:07

@tjb It looks like you need to require the namespace for start before calling it

tjb18:08:10

prior to the calva changes, things would boot up with no issues

tjb18:08:23

unsure how the upgrade has changed anything? so i am a bit lost 😞

bringe18:08:13

You had that afterCLJReplJackInCode there before? I believe it does need to require a namespace before calling something in that namespace, i.e. (start)

tjb18:08:16

i will be honest i am not sure. i am fairly new to clojure and when i created the luminus template there was an option to boot both the server + client up via a dropdown

tjb18:08:34

then two repl windows would be created (prior to upgrade of calva)

tjb18:08:03

Server + Client is what i used prior

bringe18:08:35

Oh I see, yeah this should work "out of the box" - we need to look at this @pez

bringe18:08:57

Thanks for reporting @tjb

tjb19:08:26

i wish i am able to be more helpful but i am not sure what direction to debug in

bringe19:08:51

If you don't mind, can you create an issue? Lots of things to keep track of right now. Best not to let things get lost in chat

tjb19:08:03

Sure i can create on the github

bringe19:08:09

Yeah, would be great

tjb19:08:13

let me write it up and do my best to give as much detail as possible

💯 6
tjb19:08:18

should i tag you in it?

tjb19:08:59

np thank you!@

tjb19:08:28

lmao i fixed it

tjb19:08:38

"afterCLJReplJackInCode": "(user/start)",

bringe19:08:02

Was that after code something you had added yourself to begin with or calva did?

tjb19:08:52

so i generated a new lein project to be sure. the settings.json is the same with the function being called is (start)

tjb19:08:22

that is what is auto generated

bringe19:08:39

Ahhh... maybe we need to make calva require the user namespace before running the jack-in code then. Good find!

👍 3
tjb19:08:40

if i modify to (user/start) it works as the proper namespace is used

tjb19:08:00

np! glad i could help test and find stuff

tjb19:08:38

wonder if i could maybe make a PR? might take me longer than others 😛

bringe19:08:48

Please feel free!

tjb19:08:34

ill give it a look to see if i can figure it out

bringe19:08:20

It's pretty simple

tjb19:08:33

dope! ill read this and fork the repo

calva 3
bringe19:08:17

Just to point you in the right direction, see the function connectToHost in src/connector.ts

bringe19:08:50

And a tip. The session objects have an eval function on them that allows you to eval some code in that nrepl session. In that function you will see a cljSession and also you will see where the afterCLJReplJackInCode code is evaluated

bringe19:08:55

I'll leave it at that 😃

tjb19:08:45

thank you bringe!

tjb19:08:13

looking at the contribution guide i am a bit confused how to debug with Jack-in. when i go into debug mode i get No Jack-in possible

tjb19:08:32

ah i got it 🙂 need to connect to the proper repl port

👍 3