This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-08-01
Channels
- # babashka (2)
- # beginners (51)
- # calva (79)
- # cestmeetup (1)
- # chlorine-clover (1)
- # cider (6)
- # clj-kondo (1)
- # cljdoc (4)
- # cljsrn (2)
- # clojure (31)
- # clojure-europe (2)
- # clojurescript (5)
- # conjure (4)
- # cursive (26)
- # datascript (4)
- # datomic (1)
- # figwheel (1)
- # figwheel-main (2)
- # off-topic (25)
- # reagent (2)
- # reveal (4)
- # shadow-cljs (21)
- # xtdb (1)
@stefan.van.den.oord, version v2.0.113 should fix the issue you ran into.
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!
@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 🙂
Have something changed with repl and keyboard shortcuts in the latest Calva update? I don't see the results of evaluation any longer : (
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?
@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.
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.
Yes. It doesn’t help though as with the normal repl, I have to reconnect to nrepl every time
@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?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?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
.
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.
@U015GL869TQ since recently alt+enter
was added as a shortcut doing the same as the one you mention there.
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:
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?
@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.
Awesome, yeah that workflow makes a lot more sense to me. Thanks for the help
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
https://calva.io/try-first/ This doc explains that workflow some
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.
hey everyone i am using luminus and just upgraded calva. im getting the following in the new repl window
; 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.
You had that afterCLJReplJackInCode there before? I believe it does need to require a namespace before calling something in that namespace, i.e. (start)
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
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
so i generated a new lein project to be sure. the settings.json
is the same with the function being called is (start)
Ahhh... maybe we need to make calva require the user namespace before running the jack-in code then. Good find!
https://github.com/BetterThanTomorrow/calva/wiki/How-to-Hack-on-Calva Please read this to get you started
Just to point you in the right direction, see the function connectToHost
in src/connector.ts
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