Posted By

narkisr on 01/01/10


Tagged

clojure REPL rlwrap


Versions (?)

Clojure rlwrap setup


 / Published in: Clojure
 

URL: http://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started#Enhancing_Clojure_REPL_with_rlwrap

Using rlwrap in order to wrap Clojure REPL (getting vi bindings & auto completion).

  1. #!/bin/bash
  2.  
  3. BREAK_CHARS="(){}[],^%$#@\"\";:''|\\"
  4. CLOJURE_DIR=/home/cljuser/install/clojure
  5. CLOJURE_JAR=$CLOJURE_DIR/clojure.jar
  6. if [ $# -eq 0 ]; then
  7. rlwrap --remember -c -b $BREAK_CHARS -f $HOME/.clj_completions \
  8. java -cp $CLOJURE_JAR clojure.lang.Repl
  9. else
  10. java -cp $CLOJURE_JAR clojure.lang.Script $1 -- $@
  11. fi
  12.  
  13. ; generating the completion file
  14. (def completions
  15. (reduce concat (map (fn [p] (keys (ns-publics (find-ns p))))
  16. '(clojure.core clojure.set clojure.xml clojure.zip))))
  17.  
  18. (with-open [f (java.io.BufferedWriter. (java.io.FileWriter. (str (System/getenv "HOME") "/.clj_completions")))]
  19. (.write f (apply str (interleave completions (repeat "\n")))))

Report this snippet  

You need to login to post a comment.