Search code examples
emacsclojureleiningencider

How to debug a console app from the REPL?


It's really confortable to use emacs+cider for the daily development. All the stuff I've configured in my text editor makes it ideal for the task.

The current project that I'm working on my spare time is a text editor. I've already implmented one in C++ and I used gdb to debug, from emacs. To run it, I entered set new-console on and run in the gdb buffer. This would pop a new console that would handle all the I/O.

Now I'm trying to reimplement it in Clojure. By far, one of my biggest concerns is debugging. I think it wouldn't be bad something similar to what I used with gdb.

For reading the keyboard without buffering, I'm using JLine. This means read-line won't provide the desired result.

What is a reasonable way to debug this kind of app (with lots of I/O from the console)?

How to do so from emacs/cider preferently?

I'm using lein, if this matters.


P.S.: Here's a similar question I made, with a more broad "intend". I think it's worth seeing.


Solution

  • CIDER comes with an excellent debugger nowadays. See also this screenshot.

    The easiest thing for you will probably be to create a lein/boot build profile which includes nREPL and CIDER as dependencies and make use of an embedded CIDER instance. This will let you run your app "standalone" from a terminal where you'll be able to get unbuffered keyboard I/O, and you can connect via M-x cider-connect to the embedded nREPL+CIDER instance to take full advantage of the debugger and code loading as you normally would.