Description
Is your feature request related to a problem? Please describe.
I want to run custom logic inside the REPL when it starts up, and binding to cider-connected-hook
runs outside of the REPL even when using cider-interactive-eval
. E.g., I have a hook defined like:
(use-package cider
:ensure t
:hook ((cider-connected . (lambda () (cider-interactive-eval "(go)")))))
Which does run the function, but at a different time and place than when I run (go)
in the REPL. Specifically, I want to print a startup message in the REPL, but using this I get all printed logs in the nrepl-server
buffer and don't show up in the REPL (even though running cider-interactive-eval
manually afterwards does show up in the REPL buffer). Also, I'm doing some monkeypatching to print-method
which works well when I run it after cider-nrepl is up but when run with the hook as shown above CIDER's own work with print-method
happens after my custom function is run and overrides it.
Describe the solution you'd like
There's multiple ways of solving this, but I think the cleanest one would be to have some var cider-repl-startup-sexp
which would default to nil
and when it exists then the first REPL prompt after startup should yank that variable and run it, or else an appropriate hook (cider-repl-mode-hook
?) and some function to do this (cider-interactive-eval
I suppose, but I couldn't get it to work for this and it only shows the result in the REPL and not the command). Or else to do smth convoluted like storing the startup command as a macro and hooking that to idle REPL buffers or something, but overall this feels like something that should be simple to do and documented somewhere.
How would this be best approached? Is this already solvable with CIDER? I'd love to put a PR together but I'm not sure where to start.