Fork me on GitHub

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.


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

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?


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.


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.


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


(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?


@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?


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


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


C-c C-s r for me