Fork me on GitHub
#cider
<
2018-01-19
>
qqq05:01:57

@bozhidar: hey, sorry, not going to be able to debug this soon -- 'my-cider-test-on-test-last-sexp' works fine for me, and too lazy to learn how edebug works

bozhidar07:01:56

OK, no problem. I was just really wondering how you and me could be getting a different behavior.

iperdomo08:01:06

hi all, i was browsing the code in cider-nrepl (https://github.com/clojure-emacs/cider-nrepl/tree/v0.16.0) and I tried to follow the section "Or (if you know what you're doing) add cider-nrepl to your :dev :dependencies vector plus specific middleware to :nrepl-middleware under :repl-options" ... but my repl always fail to start with Unable to resolve var: cider.nrepl.middleware.out/wrap-out in this context

iperdomo08:01:06

my goal was to see if i can use the wrap-out nrepl middleware from a Cursive Remote REPL

iperdomo08:01:30

is that possible? 😕

bozhidar09:01:57

Yeah, that should be completely possible.

bozhidar09:01:24

Can you try the same with 0.15? I’m curious if that’s some problem caused by the deferred middleware loading we introduced in 0.16.

iperdomo09:01:07

ha! 0.15.0 works 😄

iperdomo09:01:25

well, the repl starts

iperdomo09:01:36

my project.clj

iperdomo09:01:13

the same applies to version 0.15.1 the repl starts .... but now when I connect from Cursive via a Remote REPL, the *out* is not redirected to the Cursive output, do i need to do something extra?

iperdomo09:01:38

btw, this setup just works with CIDER ... we're just a team where some people use Cursive and others CIDER, we get this nice feature and I was trying to make it work for the others 🙂

bozhidar10:01:45

Well, there’s nothing specific about CIDER in any of the middleware, so I’m really puzzled by this.

bozhidar10:01:05

Perhaps the real difference is that CIDER handles some messages it gets from nREPL differently.

bozhidar10:01:35

Can you file a ticket about this in cider-nrepl. I guess we might reconsider whether to provide some eagerly loaded versions of the middleware to address point 1 and think a bit more what’s wrong with the output handing in Cursive.

iperdomo10:01:10

will do, many thanks for your support

qqq10:01:28

@bozhidar: because the horse isn't dead enough: I recently switched to:

(defun my-cider-test-run-test-last-sexp ()
	 (interactive)
	 (save-excursion
	   (search-backward-regexp "ct/deftest")
	   (evil-backward-char 1)
	   (cider-test-run-test)))
so basically, my last version wasn't very stable either, I had to ahve the cursor right after the ")" otherwise, it had problem finding it too now, this new version is: search back regex for most recent ct/deftest ... run that 🙂

bozhidar10:01:44

But your version will fail if you don’t have the ct ns alias.

bozhidar10:01:50

Just saying.

bozhidar10:01:21

Generally regexp search is bad idea, because sooner or later you run in a situation where this matches a text in a string or something like this.

qqq10:01:27

yeah, the correct way is probably:? search back for 'deftest" search back for "("

bozhidar10:01:30

But I guess this will work for you most of the time.

qqq10:01:43

oh right, by "correct" I meant "less hacky"

qqq10:01:31

i guess here's the thing; I can get away with this regex hack because the rest of cider is robust; if all of cider was based on regexes, we'd be f*cked

bozhidar10:01:55

I would just check the current form as a list and see what’s the first item in it.

qqq10:01:47

so I have situations where I do:

(do
...
   (do ...
      (defn ...
      (ct/deftest ...)));;cursor here
so now, my "last sexp" is the outer do, not the ct/deftest

bozhidar10:01:58

But my general puzzlement continues to be you need to do something like this, as the current code works fine for me in the end of the test form and reading its code it was designed to work this - see the usage of clojure-find-defun.

bozhidar10:01:41

(defun cider-test-run-test ()
  "Run the test at point.
The test ns/var exist as text properties on report items and on highlighted
failed/erred test definitions.  When not found, a test definition at point
is searched."
  (interactive)
  (let ((ns  (get-text-property (point) 'ns))
        (var (get-text-property (point) 'var)))
    (if (and ns var)
        ;; we're in a `cider-test-report-mode' buffer
        ;; or on a highlighted failed/erred test definition
        (progn
          (cider-test-update-last-test ns var)
          (cider-test-execute ns (list var)))
      ;; we're in a `clojure-mode' buffer
      (let ((ns  (clojure-find-ns))
            (def (clojure-find-def)))
        (if (and ns (member (car def) cider-test-defining-forms))
            (progn
              (cider-test-update-last-test ns (cdr def))
              (cider-test-execute ns (cdr def)))
          (message "No test at point"))))))

qqq10:01:37

damn it, you've dragged me into this tarpit, I'll learn edebug, hang on 🙂

bozhidar10:01:43

That’s why I really wanted just to see a stepping of this in the debugger to see what’s different for you.

qqq10:01:09

what do you need from me? a screen capture / video? does it also need to show key presses

bozhidar10:01:19

It’s really easy, btw - just C-u C-M-x in the body of this function and then n, n, n once it gets triggered.

bozhidar10:01:37

CIDER’s debugger works exactly the same, as we copied the design of edebug.

qqq10:01:05

so I don't know how to use debuggers, I just use unit tests / print statements, but let me try edebug, brb 5 mins

bozhidar10:01:14

> what do you need from me? a screen capture / video? does it also need to show key presses

bozhidar10:01:40

That would be ideal, but you just tell me what happens at this lines:

bozhidar10:01:49

> (def (clojure-find-def)))

bozhidar10:01:59

> (if (and ns (member (car def) cider-test-defining-forms))

bozhidar10:01:07

> (cider-test-execute ns (cdr def)))

qqq10:01:09

okay this is wher eI get lost

qqq10:01:20

how do I "step" because pressing "n" does not next step

qqq10:01:14

@bozhidar: here is a sequence of screen shots of me pressingn lots of times: https://imgur.com/a/QxCI6

qqq10:01:34

@bozhidar: is this enough: should I generate more / create a video ?

bozhidar11:01:21

@qqq You got the stepping working, right?

qqq11:01:37

@bozhidar: https://imgur.com/a/QxCI6 <-- I have this set of images is this what you mean by 'stepping' ?

bozhidar12:01:01

@qqq I saw what I needed. For some reason for you clojure-find-def is returning nil. Post this to the ticket and I’ll try to reproduce it with your code.

bozhidar12:01:09

That seems to be caused either by the alias or the dos around the deftest.

qqq12:01:35

@bozhidar: remove do / alias , it still breaks

qqq12:01:41

should I step through clojure-find-def ?

qqq12:01:06

@bozhidar: here's a set instrumenting clojure-find-def https://imgur.com/a/RZoAv

qqq12:01:18

debugging elisp is almost sorta kinda fun 🙂

qqq12:01:46

@bozhidar: should I produce a minimal init.el ?

qqq12:01:56

you're basically debugging 'blind' as you can't replicate the issue

qqq13:01:10

@bozhidar: I posted a 58 line init.el replicating the prolblem at https://github.com/clojure-emacs/cider/issues/2168 let me know if there's anything else I can provide

bozhidar13:01:54

Seems might really be some problem with clojure-find-def, but I wonder why this works for me.

bozhidar13:01:14

On the bright side - seems now you’re comfortable with edebug. 😄

qqq13:01:52

yeah, if anyone else wants to learn edebug, just post a but @bozhidar can't replicate, and he'll teach you edebug for free 🙂

qqq13:01:10

I also attached a 58 line init.el (most of it use-package), may be of use if you want to replicate issue locally

qqq15:01:28

@bozhidar: still haven't fixed it? do I need to ship you a VM with a emacs replicating the bug? 🙂

qqq15:01:12

actually, now that I mention it, funnily enough, ikt's possible to create a $5 digital ocean droplet, save the image, and share it, fasicnating how cloud changes things

bozhidar15:01:45

I’ll look into this a bit more when I find some time. Locally I tried some things quickly, but I still can’t find a way to reproduce this.