Fork me on GitHub
#cider
<
2020-06-08
>
bozhidar13:06:23

I don’t there’s a great approach today, as adding an advise won’t work reliably due to the async nature of eval. It’d be best to add some load-file-hook that gets triggered once load-file completes.

bozhidar13:06:28

Actually I see that you can provide a custom done handler even today:

(defun cider-load-file-handler (&optional buffer done-handler)
  "Make a load file handler for BUFFER.
Optional argument DONE-HANDLER lambda will be run once load is complete."
  (let ((eval-buffer (current-buffer)))
    (nrepl-make-response-handler (or buffer eval-buffer)
                                 (lambda (buffer value)
                                   (cider--display-interactive-eval-result value)
                                   (when (buffer-live-p buffer)
                                     (with-current-buffer buffer
                                       (cider--make-fringe-overlays-for-region (point-min) (point-max))
                                       (run-hooks 'cider-file-loaded-hook))))
                                 (lambda (_buffer value)
                                   (cider-emit-interactive-eval-output value))
                                 (lambda (_buffer err)
                                   (cider-emit-interactive-eval-err-output err)
                                   (cider-handle-compilation-errors err eval-buffer))
                                 (or done-handler '())
                                 (lambda ()
                                   (funcall nrepl-err-handler)))))

jumar13:06:52

Hmm, that's too bad. So if I define my own function that calls cider-load-buffer and then instrument it won't work properly, right?

bozhidar13:06:36

Yep. Although a bit of sleep is probably going be enough for most instances. You can define your own wrapper around cider-load-file that provides a custom load-file-handler and this would work.

suskeyhose18:06:27

I'm currently trying to make a version of promise-chan which is derefable in order to allow parking to be used to dereference some promises returned from my api, without causing a breaking change or requiring a duplicate namespace to be created, but I'm running into an issue. I've got a print-method defined and preferred for my new deftype which contains a promise-chan, but because it implements clojure.lang.IDeref, cider seems to be blocking on it to try to print it if I ever return one on the repl, even if cider.nrepl.print-method/*pretty-objects* is set to nil.

suskeyhose18:06:07

Is there any way I can change that behavior without my library depending on nrepl or cider itself?

suskeyhose18:06:37

(for example having a metadata-defined protocol implementation which fixes it or something)

jimka.issy19:06:03

can someone remind me how to tell cider to restart lisp ? as opposed to restart the repl but keep the same lisp image?

neo255119:06:12

@bozhidar I know you have other things on your plate, but do you know if clj-suitable is still maintained? Because shadow-cljs and Cider are incompatible for the new version of shadow-CLJS.

neo255119:06:12

@bozhidar I know you have other things on your plate, but do you know if clj-suitable is still maintained? Because shadow-cljs and Cider are incompatible for the new version of shadow-CLJS.

bozhidar19:06:08

Yeah, I’m aware of the problem. I think @ still maintains clj-suitable.

robertkrahn19:06:26

I do, i’ll have look

robertkrahn01:06:32

Hi @bozhidar! Can we default to (setq cider-enhanced-cljs-completion-p nil) for shadow cljs repls for now? It’ll probably take me a while to adapt @ changes. Tested with suitable disabled and static completion continues to work fine. Will let you know when I have a new version. Thanks!

bozhidar05:06:00

@ We can, but the problem is that won’t help. As some functions are now missing suitable blows up when you require it. At least this is what some users of Calva had observed. Haven’t had much time to investigate the details though.

thheller08:06:22

@ did you see https://github.com/rksm/clj-suitable/issues/15? I'd assume adopting that should be fairly straightforward? I added the cljs-eval so it is in 2.10.4

robertkrahn21:06:20

Hi Thomas, yep I’ve seen that and it is very helpful, thank you! I don’t think that we need anything other than an eval function. The only issue is that I’ve currently trouble allocating time for working on that, but I’ll try to make progress.

dpsutton19:06:56

@jimka.issy sesman-restart-session is what you're looking for

jimka.issy19:06:18

Thanks, but I'll never remember that. Isn't that a pretty obscure name?

jimka.issy19:06:58

Looks like sesman-restart-session needs two arguments. Which arguments can I give it?

dpsutton19:06:36

its an interactive command for me. so just m-x sesman-restart

dpsutton19:06:47

oh. not the session version. just sesman-restart sorry about that

dpsutton19:06:54

C-c C-s r for me