Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

First cut

Uses jline2 and therefore supports word-forward, word-back,
and a host of other goodies.
  • Loading branch information...
commit dd5e38972e83e2613ced0bb3583e5dc601eb19d1 0 parents
@trptcolin authored
6 .gitignore
@@ -0,0 +1,6 @@
+pom.xml
+*jar
+/lib/
+/classes/
+.lein-failures
+.lein-deps-sum
21 README
@@ -0,0 +1,21 @@
+# REPL-y
+
+A newer, hotter REPL using JLine2.
+
+Improvements:
+- allow jumping back and forth by words
+- CTRL-C doesn't bail out of the process; just gives a fresh prompt
+- some code completion
+
+Nice to haves:
+- colorization
+
+## Usage
+
+Run `bin/reply.sh`
+
+## License
+
+Copyright (C) 2011 Colin Jones
+
+Distributed under the Eclipse Public License, the same as Clojure.
1  bin/reply.sh
@@ -0,0 +1 @@
+java -cp lib/clojure-1.3.0.jar:lib/jline-2.9.1.jar:lib/jansi-1.4.jar:src/ clojure.main -m reply.core
4 project.clj
@@ -0,0 +1,4 @@
+(defproject reply "0.0.1-SNAPSHOT"
+ :description "REPL-y: a better Clojure REPL"
+ :dependencies [[org.clojure/clojure "1.3.0"]
+ [org.scala-lang/jline "2.9.1"]])
25 src/reply/core.clj
@@ -0,0 +1,25 @@
+(ns reply.core
+ (:use [clojure.main :only [repl]])
+ (:import [scala.tools.jline.console ConsoleReader]
+ [java.io PrintWriter]))
+
+(defn -main [& args]
+ (let [reader (doto (ConsoleReader.)
+ (.setBellEnabled false)
+ (.setPrompt ""))
+ out (-> reader
+ (.getOutput)
+ (PrintWriter.))
+ jline-read (fn [request-prompt request-exit]
+ (let [input (.readLine reader)]
+ (cond (not input)
+ request-exit
+ (every? #(Character/isWhitespace %) input)
+ request-prompt
+ :else
+ (read-string input))))
+ jline-prompt (fn [] (.setPrompt reader
+ (format "%s=> " (ns-name *ns*))))]
+ (binding [*out* out]
+ (repl :read jline-read
+ :prompt jline-prompt))))
Please sign in to comment.
Something went wrong with that request. Please try again.