REPL support for new Clojure editor


#1

I built a ridiculously simple text editor in C based on the Kilo editor which uses no external libraries at all. I actually use it every day for writing Clojure, and the next thing I want to do is hook it up to a Socket REPL (or maybe pREPL?) to turn it into a proper Clojure editor.

But to be perfectly honest, I have no idea how to do that. I’m just figuring it out as I go. If anyone thinks it would be a worthwhile collaborative project, I would be absolutely delighted. Even if you could just point me in the right direction, anything at all would be most helpful.

What’s the point? Why do we need another text editor!??

Well, because the thing is so darn cool, especially for beginners. It has basic load/save functionality and a search feature, and is even easier to use than Nano. Best of all, the code is so simple that it is very easily hackable, how I believe all software should be.

Looking forward to possibly getting some feedback on this.


#2

You’ll want to look at nrepl and tooling around it. Though if you’re aiming for maximum simplicity, maybe socket repl or even just basic inferior-style repl would be enough.

PS. Ctrl-Q is bound to my terminal’s “close window” command, how do I quit bob (I’m having flashbacks about the horrors of ed right now)


#3

Haha… get the sledgehammer.

The key binding for quitting the editor is line 628:

case CTRL_KEY('q'):

I haven’t looked into it but from what I’ve heard, nrepl does way more than what I’m looking for, at least at first. It seems pretty complicated to implement, and the main thing I’m interested in is simply the ability to evaluate forms.


#4

Hey, you know what, I’ve also added Alt+ijkl cursor movement (from Ergoemacs), and now I’m actually starting to like it, thanks! Maybe I’ll even alias vi (and nano) to bob, haha. The only other thing I’d like to have is word forward\backward commands - please let me know if you add those :wink:

If not nrepl, then I guess socket repl would be the best choice (it’s already in the core, you can easily use standard clj tools that come with the lang to run the server). You’d still need to do the networking though, which might or might not fit into your definition of a ‘minimal text editor’, hehe.


#5

That’s awesome! Exactly what I love about this editor, there’s no need for a .config file. You’re the config.

You’re right, I’d use word forward\backward all the time. But what I really want is undo/redo. Since as it is right now, it works beautifully for development with figwheel, since it’s connected to the browser repl. But figwheel without undo is living dangerously…

EDIT:
And yes, connection to a repl (for a Clojure editor) absolutely qualifies as “minimal”.

Are we witnessing the beginning of software bloat?


#6

I came up with an eval hack using Planck and a Bash file-watcher.

When you press Ctrl+e it runs your file and prints the results of the last expression.

I also implemented Clojure syntax highlighting.