Happy for any advice on this, I'd also help in making it work, I'm just pretty helpless in emacs lisp beyond absolute basics right now.
So apparently the custom variable cider-merge-sessions , customization Cider Merge Sessions is what causes eval to both REPLs. I set it during work on my Emacs LISP code and then didn't unset it.. 🤦
Now with that variable unset it evals to the last active REPL again and my function still works by binding that variable dynamically.
I had a similar issue in the past with 2 clojure repls and I manage to make it work with a sesman-link-with-buffer call. But I only had 1 file where I wanted to use a different repl
https://docs.cider.mx/cider/usage/managing_connections.html#displaying-session-info maybe have a look at those 2 to see how things are configured
Yes, thank you, I saw that yesterday. I'm glad it seems to work like I described above, the last active repl gets sent the evaluated forms.
Well, of course after I said that, I now see evaluation in both repls too.
what about using sesman-unlink on your babashka link, and then just adding the babashka notebook with sesman-link-with-buffer/directory ?
It might work but I think this is a bug and a workaround should not be necessary for everyone wanting to write a babashka notebook. Appreciate your concrete suggestion for the meantime though! I'm not working on it rn, so can't test, but IIRC only thing that changed in between picking last viewed repl and using both for eval might be nrepl version. If that's correct 1.31 works, 1.51 doesn't.
Ok, that's not it. Now I don't know why it started to eval to both repls..
And of course, it could also not be a bug, if the intent is to always eval on all clojure repls at once. But then it's even more a question whether a babashka repl should just be an additional clojure repl.
@rolthiolliere Now your workaround (unlinking babashka from overall project) at least improves the situation. Thanks again. Just in my case I can't unlink the (real) clojure repl from the babashka directory.
I understand it a bit better now. I'll further test things. But for now it looks like having the right repl in the foreground works.
There's some rough edges around it, like it tries to send clj files to the babashka repl that are not on babashkas classpath (bb.edn). The classpath issue might not always be addressable, but maybe when a bb.edn with :paths exists?
Having the ability to evaluate a .clj file selectively as Clojure or babashka is convenient and due to babashka supporting it even necessary.