Fork me on GitHub
#cider
<
2015-08-25
>
bozhidar07:08:21

@alejandro: can you share with us some concrete use-case regarding what you want to do?

bozhidar07:08:45

we don’t have real conditional breaks (although you can definitely request their addition)

bozhidar07:08:57

but at least we can suggest some reasonable workarounds

malabarba10:08:40

@alejandro: You can add an if into your code, and then break inside a branch of that if

malabarba10:08:04

(defn do-it [arg]
  (if (i-want-to-break arg)
    #break arg
    arg))

malabarba10:08:35

YOu can also try binding the *skip-breaks* var to (atom true), this is leveraging on internal debugger stuff, but it might work

malabarba10:08:36

(defn do-it [arg]
  (binding [cider.nrepl.middleware.debug/*skip-breaks*
            (if (i-want-to-break arg)
              cider.nrepl.middleware.debug/*skip-breaks*)
              (atom true)]
     (do-the-usual-function-here)))

alejandro12:08:22

@bozhidar: really just want to use it for a clause in a loop (or function called in a loop), but only on like the 10,000th iteration

alejandro12:08:56

@malabarba: I actually haven’t been able to get #break or #dbg to work at all. I use the "cider instrument top level form” to get it to work

malabarba12:08:58

@alejandro: Oh, then you're probably using 0.9.1. The #break and #dbg are only on the snapshot release for now.

alejandro12:08:27

@malabarba: got it. what’s the best way to move to the snapshot release? I have no problem using a later build

malabarba12:08:30

@alejandro: The *skip-breaks* solution might still work

malabarba12:08:09

Or not ... 😛

malabarba12:08:41

To install the snapshot, just bump the version to 0.10.0-SNAPSHOT

malabarba12:08:47

(on the clojure side)

malabarba12:08:03

And install the cider package from Melpa (on the emacs side)

alejandro12:08:02

@malabarba: hmm, says I’m on cider snapshot already 0.10.0snapshot (20150824.244)

alejandro12:08:22

and [cider/cider-nrepl "0.10.0-SNAPSHOT”]

malabarba12:08:41

then the reader macros should work

malabarba12:08:32

What happens if you write in a file (let [x 1] #break (inc x)) and hit C-x C-e?

alejandro12:08:35

yeah that work

alejandro13:08:04

hmm, maybe I was using it incorrectly? I tried it in a lengthy let statement and it wasn’t triggering yesterday

malabarba13:08:27

How were you evaluating it? C-c C-k won't work

alejandro13:08:38

ah that’s probably it

malabarba13:08:52

Yeah, you're not the first to run into that.

alejandro13:08:00

so I need to C-x C-e the form itself

malabarba13:08:16

It has to be one of the evaluation commands, like C-x C-e or C-M-x

malabarba13:08:39

Loading the file (`C-c C-k`) doesn't do it

alejandro13:08:51

cool, I’ll roll with that. That will make a conditional break much easier to set up

malabarba13:08:17

np :thumbsup:

alejandro13:08:26

oh, one more question: if I’ve setup debugging on a top level form, is there a way to then disable it?

malabarba13:08:43

yes, just reevaluate it normally

alejandro13:08:59

so just C-x C-e it

alejandro13:08:05

and it will not be instrumented anymore

malabarba13:08:16

I think C-c C-k will work in this case too

malabarba13:08:45

At least it should, so if it doesn't do let us know simple_smile

alejandro13:08:51

cool, thanks again