3

I am wondering if there is a way to have the output of the current execution in emacs cider when using cider-connect.

For instance :

  • I run lein repl on a project directory

  • then connect to it in emacs using cider-connect.

Now let's say that I have (println "cider is amazing by the way") in the code of one of my ring handlers, this will only be printed in the console I ran lein repl when a request is made.

How can I have this output also in my nrepl buffer ?

nha
  • 17,623
  • 13
  • 87
  • 133

2 Answers2

2

Sorry to say, I suspect that you cannot do this in the way you describe. The output is going strait to the console of that device and not through anything related to nrepl on the way. This also makes sense if you consider that nrepl is often not even running on the same computer. (the "n" in nrepl is for "network").

Perhaps you can arrange for that output to be teed to a file where you can get at it? Then you could start a thread on your nrepl buffer that cated that file. Or have a buffer in emacs that watches the remote file.

Arthur Ulfeldt
  • 90,827
  • 27
  • 201
  • 284
  • Thanks Arthur, is there another way then, maybe by having a nrepl open in the Clojure code ? The aim is to have the output in Emacs, If I have to modify my workflow I'm fine with it :) And you're right, I use it on a different (virtual) machine. – nha Aug 05 '15 at 08:31
  • For other reasons (working with others, speed etc) my preferred method is to start emacs on the remote system in a tmux session, then several people can mosh in (mosh is an amazing complement to ssh), tmux attach and have the shared emacs. I can then *also* attach from an emacs session running directly on my laptop, though this comes up less often. this is not a direct answer, just another way of working that flows nicely for some. – Arthur Ulfeldt Aug 05 '15 at 15:59
  • Well that's interesting, thanks for sharing that. Please correct me if I am wrong, this means having a "vanilla" emacs ? Which seem coherent with sharing it with others. – nha Aug 05 '15 at 16:07
  • 1
    "vanila" emacs use useless to all (flame proof suit) this really, in this case, becomes a question of building community with your team and working well together. So I suspect It's beyond the scope of a SO comment or answer. PS: we check our config's into github mine is here: https://github.com/thearthur/arthur-s-emacs-config – Arthur Ulfeldt Aug 06 '15 at 21:13
0

If you start leiningen via cider-jack-in you should get the output in the repl buffer.

One way to use this with a remote setup could be to call C-u M-x cider-jack-in and use a specialized server command that will essentially trigger the lein repl command (say over ssh) on the remote machine -- I haven't checked whether this will actually work, but I don't see any reason why it shouldn't. If you can access the code over tramp, it shouldn't matter much whether the code is remote or not.

schaueho
  • 3,419
  • 1
  • 21
  • 32
  • Well even with `cider-jack-in` I don't get output for the namespaces I want. I get it for the commands I type in the repl, but not for all messages. – nha Aug 09 '15 at 13:03