Clojure standard REPL with buffer editor?

I am not looking for an IDE or integrated REPL. I just wanted to ask if anyone knows if there is a buffer editor in the REPL editor, as is known from "psql" or some * nix shells.

In psql, for example, you simply enter "\ e" and you will get the last command in your EDITOR, and the top output will be executed.

That would be great for clojure repl.

$ java -cp jline.jar:clojure-1.3.0.jar jline.ConsoleRunner clojure.main 

So, is there such a feature? Where should this be implemented in jline?

Decision:

rlwrap does the trick.

I had to compile readline ftp://ftp.gnu.org/gnu/readline/ and then rlwrap http://utopia.knoware.nl/~hlub/rlwrap/#rlwrap .

After that, I could use the following shortcut to start the editor.

Ctrl + ^

rlwrap -m -- java -cp clojure-1.3.0.jar clojure.main

To use leiningen on Mac OSX, I had to change the following:

 lein 1.6.2 *** 226,233 **** rlwrap -m -q '"' echo "hi" > /dev/null 2>&1 if [ $? -eq 0 ]; then RLWRAP="$RLWRAP -r -m -q '\"'" - else - RLWRAP="$RLWRAP -m --" fi fi fi --- 226,231 ---- 

and export RLWRAP_EDITOR

export RLWRAP_EDITOR="vim +%L"

+6
source share
2 answers

rlwrap

There are several ways to achieve the desired result, but rlwrap does what you need. I also had some problems with jline versions in the past on Mac OS X, so he stopped using it.

When I type 'clj' in my terminal, it really does REPL wrapped in rlwrap using the following bash script in /usr/local/bin/clj :

 #!/bin/sh # Runs clojure. # With no arguments, runs Clojure REPL. CLOJURE=$CLASSPATH:/usr/local/clojure/1.3.0/clojure-1.3.0.jar rlwrap java -cp $CLOJURE clojure.main " $@ " 

Place the script anywhere in your path to use.

Finally, you do not need a script, I just have it as a convenience. If rlwrap is on your system and clj is on your way, you can simply type:

rlwrap clj

Further reading from the Clojure wiki: Enhancing the Clojure REPL with rlwrap

+8
source

See my answers to One REPL questions to link them all? and How to install Clojure on Ubuntu 10.04 from the Github repository without clojure.jar . Highlights:

  • Do not install Clojure at all. Install Leiningen and let it manage the versions of Clojure that you have, and also get classpaths rights for replacement or other use.
  • If you must start Clojure manually, use rlwrap or some other readline program.
+6
source

Source: https://habr.com/ru/post/905766/


All Articles