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)))))

❤️ 2
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)

Jim Newton19: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?

dpsutton19:06:56

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

Jim Newton19:06:18

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

Jim Newton19: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