Fork me on GitHub
#cursive
<
2016-09-20
>
cfleming04:09:25

@kenny Cursive already does something like that - do you mean evaluate an individual assertion?

cfleming04:09:45

i.e. an is check or something similar?

kenny04:09:43

Which could (probably is) be surrounded by a let block.

tghali04:09:56

I'm having a little frustration...

tghali04:09:21

created a lien project, added a local repl configuration

tghali04:09:56

when I start the repl, it can't find the .core namespace

cfleming04:09:16

@kenny So that gets a little tricky because of fixtures and the like

cfleming04:09:57

And also cases such as having your assertion in a loop and so on.

cfleming04:09:05

But it’s something I’d really like to have myself, I’ll see what I can do.

cfleming04:09:35

@tghali How did you create the lein project? On the command line or within Cursive?

tghali04:09:43

within cursive

cfleming04:09:19

Ok, can you post a screenshot of your REPL run config?

cfleming05:09:52

Looks good - what’s the error you’re receiving?

kenny05:09:10

While having custom behavior for tests would be cool, the simple use case should be covered. Example:

(let [x 1
      y 1]
  (is (= 2 (+ x y))))
Just running the (is (= 2 (+ x y))) would give you your result, taking into account the parent scope

tghali05:09:43

phooey.core:

tghali05:09:44

(ns phooey.core) (def something "wowee")

tghali05:09:14

Connecting to local nREPL server... Clojure 1.8.0 nREPL server started on port 53981 on host 127.0.0.1 - <nrepl://127.0.0.1:53981> wowee CompilerException java.lang.RuntimeException: Unable to resolve symbol: wowee in this context, compiling:(/tmp/form-init5376564895231553441.clj:1:4272) (str "sdf " wowee) CompilerException java.lang.RuntimeException: Unable to resolve symbol: wowee in this context, compiling:(/tmp/form-init5376564895231553441.clj:1:1) ns => #object[clojure.lang.Namespace 0x6b1ae6c2 "user"] (find-ns 'phooey) => nil (find-ns 'phooey.core) => nil

cfleming05:09:33

@kenny Right, but something like this is harder:

(doseq [x [1 2]
        y [1 2]]
  (is (= 2 (+ x y))))

cfleming05:09:30

@tghali So the problem is that you haven’t loaded your namespace - Cursive doesn’t load namespaces automatically.

cfleming05:09:11

@tghali Tools-&gt;REPL-&gt;Load file in REPL before you start evaluating should do the trick

cfleming05:09:17

@kenny I can special case your simple case, but then it’s more complex than just a case of ensuring all the symbols resolve.

kenny05:09:51

TBH just having this ability for a let would be huge. I think loops are more of a special case

cfleming05:09:55

(that case is probably ok actually, it’ll just run the is multiple times, but there are plenty of trickier cases)

cfleming05:09:22

@kenny Ok, I’ll try something along those lines and see what I can come up with.

kenny05:09:33

Also would be cool to have the values of the let displayed next to their definition (like Light Table), but I recall you saying redrawing the editor in IntelliJ was hard/not possible.

cfleming05:09:07

Again, it’s actually relatively simple in simple cases. It gets difficult when your results are collections.

kenny05:09:33

Because it becomes too large to display?

kenny05:09:40

Also, not sure if this precisely covered but for clarification.. It would be awesome to be able to individually evaluate let bindings (without actually being in the body of the let):

(let [a 1
      b 2
      c (+ a b) ;; <— cursor is after last parens
      d 4])
Then run the command “Send (+ a b) to REPL” and it knows about a and b.

cfleming05:09:11

Yes, @denik’s original case would cover that, with the slight caveat that:

(let [a 1
      b 2
      c (+ a b) ;; <— cursor is after last parens
      d (launch-missiles)])
would launch your missiles since the whole let would be evaluated.

cfleming05:09:35

Actually, thinking about it that’s a little trickier since the return value of the let is not what you want - that would be a little harder.

cfleming05:09:29

I’m actually planning some more sophisticated manipulation of this kind of form for extract function, since in a lot of cases you’d like intermediate local let bindings moved into the extracted function too.

cfleming05:09:53

@kenny Sorry, missed your earlier question about collections display - yes, the restriction is that I can only display a single line at the end of the code line.

cfleming05:09:33

So the only available space is whatever space is left at the end of the line after the code, simple values should be ok but collections will be tricky.

kenny05:09:27

That super awesome. That feature would be HUGE! 😀

tghali05:09:27

@cfleming , was there a time when the core namespace was loaded and set as current ns on repl launch? I have an older project with a local repl that behaves that way (very conveniently).

kenny05:09:09

@tghali There’s no way to tell a REPL what the “main" namespace is

kenny05:09:47

Also, it takes no time at all to load and switch into the namespace you want. Just set keybindings for load and switch commands and you’ll be set 😉

tghali05:09:10

@kenny - I just found the missing ingredient. I needed :main phooey.core in my defproject.

tghali05:09:39

thanks for pointing out keybindings; I'll look into them. I'm sure they can be very useful.

tap11:09:04

In clojure file, when I type ; on a non-empty line, this semi-colon is shifted to column 61. I just want to it stay where I typed. I’m not sure if it’s IntelliJ thing or Cursive thing. Anyone knows how to turn this off?

cfleming20:09:45

@tap Settings-&gt;Editor-&gt;Code Style-&gt;Clojure-&gt;General-&gt;Comment alignment column. Setting that to 0 will do what you want.

bradrhod21:09:57

@cfleming : I have an application written storm. I really want to debug some of the lower level startup code in Storm that is written on clojure. I have a remote debug jvm and I am connected to that vm with Intellij and Cursive. That is hitting breakpoints but none of the symbols are resolving, and the step throughs seem to be java byte code step throughs. I am not stepping through at the Clojure level.

bradrhod21:09:00

I have spent a bit too much time on this already. Those applications are starting with nrepl running from nrepl.jar file.

bradrhod21:09:33

But I am not sure the debug port, the process does not have any ports other than the ones for jmx, already in the java command line.

bradrhod21:09:12

I also need to debug at startup. so I have -agentlib:jdwp=transport=dt_socket,server=y,address=8100,suspend=y which is halting until I connect with initellij debugger.

bradrhod21:09:44

Can I get the Clojure symbols and step through with Clojure using lines?

bradrhod21:09:00

This is a link to the nrepl jar file: https://github.com/clojure/tools.nrepl

cfleming21:09:49

@bradrhod Cursive uses the JDI under the hood, which actually debugs Java bytecode. It’s difficult to get e.g. expression level debugging with it.

cfleming21:09:07

I spoke about this at Clojure/West last year, and I discussed a bunch of the problems with it there.

cfleming21:09:36

The symbol resolution should work, with the caveat that Storm is extremely macro heavy and Cursive struggles with it.

cfleming21:09:53

Do symbols like defn resolve ok? Which are some of the symbols that do not resolve?

bradrhod21:09:08

I do not think any variables are resolving.

bradrhod21:09:36

I saw your talk on Clojure/West and have a note to look at it again.

bradrhod21:09:14

thanks for all your help.

cfleming22:09:58

bradrhod When you say the symbols are not resolving, what do you mean? Do you mean local variables in the debugger view? I was referring to the editor, where everything except nimbus appears to be resolving correctly.

bradrhod22:09:06

in the debugger. Symbols

bradrhod22:09:46

If nothing can be done, that is fine. Just wanted to ask the question.

cfleming22:09:57

You’re seeing no symbols where the debugger is currently stopped in that image because it’s stopped in a class initialiser (<clinit> in the stack frame)

bradrhod22:09:31

It hit the break point on line on 437

bradrhod22:09:38

(defnk launch-process [command :environment {}]

bradrhod22:09:02

I think it is showing the javabytecode decompile symbols there, correct?

cfleming23:09:30

Could be, can you send a screenshot of what you’re seeing when it’s stopped at that line?

cfleming23:09:48

@bradrhod ^^, sorry, forgot to ping you again