Fork me on GitHub
#cider
<
2023-03-22
>
Drew Verlee22:03:59

I'm starting to brainstorm how I can improve my clojure project repl management. Basically, I want to bring all my repl management under one interface rather than have it spread out. It's spread out because my nrepl connection are run from bash shells, my nrepl connects are in emacs buffers and my shadow repl information are usually lost in chrome tabs, etc. I want one place to view all of that information, or at least tie it all together. In my current workflow, I often find that I want to quit emacs, but I don't want to lose the nrpel server in that process. so I have started running the clj command that starts nrepl in a shell. This is fine, but there are some clear managerial improvements. Sitting down at my computer, i can't quickly pull up a view of all my clojure projects and the state of their repl connections. And so that's what i would like to have, and i imagine it shouldn't be too hard, in fact, i'm guessing this functionality already exists in multiple formats, but maybe not one that quite brings everything into one place. I imagine this UI (connection manager) would display and give the option to update: • clojure project name • if the nrepl was running • if emacs were connected • If a nrepl was busy (evaling something • if it's a shadow project if the shadow server was running • if it's a shadow project if the shadow server was connected. Some functionality i'm not sure how to achieve... • how to have emacs launch a process that doesn't die when it dies. I'm looking at the detached package though. • How to get a list of nrepl connections. • nearly everything 🙂 I'm looking at the sesman docs on the cider site as well, as i understand it's related to managing sessions, but i'm not sure yet how it will fit into this picture. Thanks!

phronmophobic23:03:10

> • how to have emacs launch a process that doesn't die when it dies. I'm looking at the detached package though. > I'm away from keyboard, but check out emacs --daemon and emacsclient -nw

👀 2
👍 2
hkjels07:03:20

I agree with @U7RJTCH6J, there's really no need to exit Emacs 😁

Rupert (All Street)12:03:33

Here's a few suggestions for dealing with REPL in emacs that may or may not be relevant: • Agree with others suggesting emacs should generally be left open and just attach using emacsclient to continue where you left off. • REPLs should also be left open - use something like https://github.com/weavejester/integrant-repl to reload your project. • If you have multiple projects. you can sometimes create a top level project that depends on the other projects and then launch a REPL in this project (so you end up with fewer REPLs). • In some situations use sesman-link-with-buffer to temporarily assign a namespace to a different REPL (good for updating a library namespace from a parent REPL). • You can build many kinds of business and interactive websites entirely on the backed with hiccup and a sprinkling of HTMX and _HyperScript - if you do this then you can you don't need a ClojureScript/shadow REPL at all. • You can add something like this to your .emacs file to start several REPLs at once in a single command:

(defun cider-init ()
  (interactive)
  (find-file "~/code1/project.clj")
  (call-interactively 'cider-jack-in)
  (find-file "~/code2/project.clj")
  (call-interactively 'cider-jack-in-cljs))

(global-set-key (kbd "C-x C-y") 'cider-init)

Drew Verlee16:03:30

So the emacs server is going to start the nrepl server independently of the emacs client?

Drew Verlee16:03:51

lets see if chat gtp can help

Drew Verlee16:03:02

the site is so busy that i can't even upgrade to pro in order to get an answer. It's almost as if a universal flexible query model is going to bottleneck so quickly that it becomes meaningless.

Rupert (All Street)16:03:36

I don't think you need chatgpt for this:slightly_smiling_face: - there's plenty of info on the web.

Drew Verlee17:03:09

@UJVEQPAKS i know, it's more to test the waters. Your insights were very helpful. I'm looking into a couple of them more before i ask another question.

phronmophobic17:03:13

I wasn't trying to say that you shouldn't have to exit emacs. Only that you don't have to.

phronmophobic17:03:34

I use a separate emacs for each project I work on. However, I use emacs --daemon when I'm working on a hobby project with a server. It means that my session persists even if I lose my connection. I'll often even use it to run the http server for the project.

Drew Verlee17:03:05

I understand, starting emacs as a server and then starting the repl from the client seems to persist the repl server across clients. Which is a big part of what I wanted.

Drew Verlee17:03:45

so thanks a ton 🙂

phronmophobic17:03:20

> In my current workflow, I often find that I want to quit emacs, but I don't want to lose the nrpel server in that process Just curious, why do you want to quit emacs rather than just leaving it open?

phronmophobic17:03:09

I do think your centralized nrepl-connection-manager idea is neat.

Drew Verlee17:03:31

@U7RJTCH6J, roughly the same reasons that i need to restart my computer, things start to get slow in various points and a restart will seem to improve the situation without having to do a more specific diagnosis as to why. I believe spacemacs suggests restarting after package installs and upgrades as well, though that might not be critical.

👍 2
Drew Verlee18:03:47

@UJVEQPAKS > In some situations use sesman-link-with-buffer to temporarily assign a namespace to a different REPL (good for updating a library namespace from a parent REPL). So for example, you want to update a libraries version, but that lib is currently being used as that's part of a running server, so you can't just bump it without restarting the server. So instead you make a new clj project, with the library set to the newer version, and start a repl, then using sesman-link-with-buffer to attach the namespace in the server to the updated project?

Rupert (All Street)19:03:36

Sort of. Example: You have a REPL open in some code and you spot a bug in a library that you also have the code for: Use sesman-link-with-buffer to evaluate code that you have fixed in a library namespace in your current REPL session.

👀 2
Drew Verlee23:03:14

There is a toolchain by lambda island that i'm looking into before I start trying to build my own thing https://github.com/lambdaisland/launchpad.