GithubHelp home page GithubHelp logo

trptcolin / reply Goto Github PK

View Code? Open in Web Editor NEW
332.0 18.0 45.0 484 KB

REPL-y: A fitter, happier, more productive REPL for Clojure.

License: Eclipse Public License 1.0

Shell 1.73% Clojure 93.35% Java 4.15% Batchfile 0.77%

reply's Introduction

CircleCI Clojars Project cljdoc badge downloads badge

REPL-y

A fitter, happier, more productive REPL for Clojure.

Improvements over the existing REPL that comes in clojure.jar

  • A number of readline commands, some not available in earlier JLine versions:
    • navigation to the start/end of lines, and forward/back by word
    • history navigation and search
    • and much much more
  • CTRL-C:
    • kills the currently running command, breaks out of infinite loops, etc.
    • doesn't bail out of the process - stops interruption-friendly operations
  • Code completion for:
    • Clojure vars and namespaces
    • Clojure namespace-qualified vars
    • Java classes, packages
    • Java package-qualified classes, static methods
  • Optional nREPL integration

Installation

REPLy is bundled with Leiningen and Boot. If you're using one of the two then you're covered.

Here's how to get a standalone version up and running (assuming you have Leiningen installed):

git clone https://github.com/trptcolin/reply.git
cd reply
lein do deps, compile

Usage

Leiningen

The easiest way to use REPLy is simply to run lein repl. That's it!

If you want to check out the latest stuff on REPLy master, you can run lein trampoline run in this project.

Boot

Boot bundles REPLy, so all you have to do is:

boot repl

Clojure CLI (tools.deps)

Starting REPLy using the clojure command is as easy as:

# Assuming Clojure 1.9, and Clojure CLI 1.10.1.727 or later
clojure -Sdeps '{:deps {reply/reply {:mvn/version "0.5.0"}}}' -M -m reply.main

# Assuming Clojure 1.9 and later, and Clojure CLI before 1.10.1.727
clojure -Sdeps '{:deps {reply {:mvn/version "0.5.0"}}}' -m reply.main

Note: Use clojure -Sdescribe to see your Clojure CLI version. On the other hand, the Clojure version, being Clojure just a library, depends on the deps. To see what you could consider the default Clojure, you could use clojure -e '(clojure-version)'. More information about the distinction between Clojure CLI and Clojure.

Other

If for some reason your use case requires avoiding the tools listed so far, you can use the bin scripts as a guide (you're probably used to shell scripting anyway, in that case). If you want to add additional dependencies to the classpath, setting $USER_CP will. For example: USER_CP=$(lein classpath) reply.

If you want to use REPLy from another piece of software, your entry point should be reply.main/launch-nrepl. There are lots of options, which you can learn more about by running (println (last (reply.main/parse-args ["-h"]))).

Debugging

If you're having problems, feel free to open an issue, but the following may help.

For keybinding issues, check out ~/.inputrc - you can mostly use the same specifications there as you can with normal readline applications like bash, but from time to time we do come across missing features that we then add to jline.

To get a very detailed look at what jline is doing under the hood, you can export JLINE_LOGGING=trace (or debug) before starting REPLy. There may be more output than you'd like, but this kind of output is especially helpful when debugging keybinding issues.

You can use the --standalone flag to rule out any nREPL-related questions, but I'm not aware of anyone using --standalone for other purposes. Please let me know if you are!

Thanks

Thanks to the developers of Clojure, JLine, nREPL, incomplete, for their work on the excellent projects that this project depends upon.

Special thanks to 8th Light for allowing me to work on this during our open-source Friday afternoons.

License

Copyright (C) 2011-2021 Colin Jones

Distributed under the Eclipse Public License, the same as Clojure. See the LICENSE file for details.

reply's People

Contributors

alexander-yakushev avatar bbatsov avatar borkdude avatar cemerick avatar crazysacx avatar dakrone avatar dlebrero avatar dundalek avatar frenchy64 avatar glts avatar greglook avatar hypirion avatar ivan avatar jafingerhut avatar jgomo3 avatar michaelklishin avatar ninjudd avatar pfeodrippe avatar samaaron avatar technomancy avatar timmc-bcov avatar tirkarthi avatar tobias avatar trptcolin avatar willchilds-klein avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

reply's Issues

Issues with Overtone and lein2

Hi, I'm not sure what the best place to mention this is - please feel free to redirect me appropriately.

When I start the REPL in lein2, I get all sorts of strange issues when attempting to (use 'overtone.live)

In order to reproduce:

lein2 new foo
emacs foo/project.clj #=> add [overtone "0.6.0"] as a dependency
cd foo
lein2 repl

user=> (use 'overtone.live)

Now, Overtone starts firing up, but the repl stops working properly, you have to hit return a few times to get the prompt back, then none of the overtone vars are available. Doing a second (use 'overtone.live) seems to fix it - but that clearly indicates that something is wrong.

Try it with lein1's REPL to see what is expected to happen.

Printing really long messages doesn't work

If you try to print something really long (like pprinting a really long data structure), all you get is a single newline and no data.

Note that I do mean long. As in, really, really long.

doc and find-doc don't work

Looks related to #17, but source and javadoc work for me.

Example failures:

user=> (doc reduce)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: doc in this context, compiling:(NO_SOURCE_PATH:0) 
nil
user=> (find-doc "reduce")
CompilerException java.lang.RuntimeException: Unable to resolve symbol: find-doc in this context, compiling:(NO_SOURCE_PATH:0) 
nil

Cursor blink on end parentheses

It would be great to have this work similarly to how rlwrap does it: after entering a closing paren, briefly flash/highlight/flicker the matching opening paren.

This will likely end up being a jline2 / rlwrap deep dive - yay!

Missing JLine2 bindings

See JLine2 issue 12 - we lost a few bindings in my perhaps-too-hasty move to the non-scala version of JLine.

Ctrl-d is hooked up hackily already here in reply, but forward-delete of both characters and words are broken :(

Loading Custom Libraries at Startup

I'm hoping to be able to load some debugging scripts of my own and libraires like 'useful' and 'bultitude' at startup...

I'm trying to integrate reply with cljr.... is there any way of adding a preference for user loaded libraries at repl startup?

Easier standalone install mechanism

lein2 should be enough for serious use, but for just-playing-around / standalone use, it would be nice to not have to check out the repo, pull dependencies down, etc.

Maybe Homebrew? That's relatively easy and works for OSX users, but we'd also need a solution for Windows and Linux. apt-get seems unlikely to be worth the effort. Maybe just a shell script to self-install, a la rvm or lein?

REPLy can't attach properly to the nREPL session on Android

Hello,

Let me describe my situation. I fire up nREPL server on Android device and then I try to connect to it with REPLy. When I do, the connection actually succeeds, but with the following error:

CompilerException java.lang.RuntimeException: Unable to resolve symbol: defn in this context, compiling:(NO_SOURCE_PATH:1)

The REPL appears with this namespace: reply.eval-modes.nrepl. The namespace seems like it doesn't "refer-clojure", so you can't actually do anything in it.

I discovered that the above-mentioned error happens when (reply.initialization/export-definition 'reply.signals/set-signal-handler!) is called in this namespace which doesn't know what defn is. Because of this error I can't actually switch to another namespace by :custom-init option because it is called after the error (so it is not called at all).

Could you please explain what should I do to solve this situation?

doc, source, find-doc and javadoc no longer working

Looks like something went awry with the clojure referring:

∴ clj
Welcome to REPL-y!
Clojure 1.3.0
    Exit: Control+D or (exit) or (quit)
Commands: (help)
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
Examples from clojuredocs.org:
          (clojuredocs name-here)
          (clojuredocs "ns-here" "name-here")
user=> (doc map)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: doc in this context, compiling:(NO_SOURCE_PATH:0) 
nil
user=> (source map)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: source in this context, compiling:(NO_SOURCE_PATH:0) 
nil
user=> (find-doc "foo")
CompilerException java.lang.RuntimeException: Unable to resolve symbol: find-doc in this context, compiling:(NO_SOURCE_PATH:0) 
nil
user=> (javadoc String)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: javadoc in this context, compiling:(NO_SOURCE_PATH:0) 
nil

Send completion ns across nREPL connection if it's not there

It'd be best if, instead of just a no-op when trying to tab-complete when it's unavailable on the nREPL server, we could send the actual code for completion over, as proposed by @cemerick in #32.

The tricky part (maybe not that tricky - I haven't spent too long thinking about it) is reading the complete.core ns into a string suitable for nREPL transport. Doing the actual send is easy enough.

NumberFormatException For input string: ""

I've run into a problem with lein2 repl that appears to be reply related. When i try to execute the lein2 repl command, I get the following stack trace:

wendigo git:metaweblog ❯ lein2 repl                                       
NumberFormatException For input string: ""
java.lang.NumberFormatException.forInputString (NumberFormatException.java:48)
java.lang.Integer.parseInt (Integer.java:470)
java.lang.Integer.parseInt (Integer.java:499)
reply.eval-modes.nrepl/get-connection (nrepl.clj:66)
reply.eval-modes.nrepl/main (nrepl.clj:86)
reply.main/launch-nrepl/fn--1386 (main.clj:60)
clojure.core/with-redefs-fn (core.clj:6483)
reply.main/launch-nrepl (main.clj:58)
leiningen.repl/repl (repl.clj:57)
clojure.lang.Var.invoke (Var.java:401)
clojure.lang.Var.applyTo (Var.java:518)
clojure.core/apply (core.clj:602)

Bye for now!

I've taken a guess about whether reply or lein was the more appropriate project to raise the issue on (based on the stack)

Classpath setup

I may of course be missing something, but while playing with reply (great fun!)
I found it difficult to load existing code (e.g. from a lein/cake project).

It would be great to have the classpath set up to include at least the cwd.
Better still to be able to use the classpath setup from leiningen/cake projects when
starting reply from the project root (maybe as a lein plugin? lein reply would be very
cool).

Home and End keys not working as expected

I honestly don't know if this is a REPL-y issue or not, so I apologize if it is not.

In either case, my Home and End keys insert H and F characters instead of moving the cursor to the beginning or end of the line. I am using REPL-y as it comes with Leiningen 2 preview 2, if that matters. The lein1 REPL works as expected.

Moving around in Jline produces weird characters

~/code/jline2(master) $ java -cp target/jline-2.7-SNAPSHOT.jar:target/jline-2.7-SNAPSHOT-tests.jar jline.example.Example none
prompt> foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo ba;86Rr baz

Notice towards the end there are some characters: ;86R. I keep getting this whenever I move around the text with the arrow keys (left and right). It is spontaneous and doesn't happen for every key stroke, but consistently happens every 30 or so.

This is in bash on iTerm 2 in OS X. The jline version used in the above example is SHA: 5dcfc6b16224f397b0bde251e05d0393c89b1e01

jLine for new Lein 2 installation

I can't get jLine to work in Leiningen 2, and I'm convinced I'm missing something obvious.

I upgraded to Lein 2 from a Homebrew-installed Lein 1. After the upgrade, I lost the ability to cycle through history. I understand that jLine is required by default in Reply, so I'm not sure what I'm doing wrong.

I blew away my Homebrew directory yesterday and reinstalled everything but Leiningen. I then installed Lein 2 preview 2 using the script listed in the Leiningen README. Even after that, I'm having no luck with REPL history. Probably the only thing I haven't blown away is my Maven repo.

Any pointers for what I could be doing wrong?

(I'm on OS X 10.7.3, Clojure 1.3)

Don't assume that introspection utils are already available in the REPL server

With the addition of a :connect option to lein repl, connecting to an nREPL server started by other means (e.g. by a running application, counterclockwise, whatever) results in this error upon connecting:

FileNotFoundException Could not locate complete/core__init.class or complete/core.clj on classpath:   clojure.lang.RT.load (RT.java:430)

The REPL remains usable, but obviously without completion and other introspection utils. Ideally, reply should check to see if the necessary namespaces are available immediately upon connecting; if not, load them and proceed.

Suggest shorter name than clojuredocs for easier interactive use

I just tried out lein2 repl for the first time today, and was pleasantly surprised to see (clojuredocs symbol) in there. Cool.

Not a huge deal, but it might be nice if there were a shorter name to type for that, e.g. cdocs instead of clojuredocs. Just that much more inviting for interactive use.

Control-D kills the REPL prematurely

Ctrl-D is a very useful readline bindings for forward delete. It's also used as a convention to kill the REPL if typed by itself at the beginning of a line.

In your current implementation however, attempting to use Ctrl-D as forward-delete at any point in the line will immediately kill the REPL, which is unexpected.

I recommend checking the current cursor or buffer size to determine if there are actual characters to delete and keeping the current forward delete behavior unless the buffer is empty. You should be able to determine if it's safe to kill the REPL with something along the lines of:

reader.getCursorBuffer().cursor == 0 && reader.getCursorBuffer().length() == 0

and invoking

reader.delete() otherwise to keep the expected Ctrl-D behavior.

Using completion bashes out *1, *2, *3

e.g.:

user=> :x
:x
user=> *1
:x
user=> Thr
Thread                            Thread$State                      Thread$UncaughtExceptionHandler   
ThreadDeath                       ThreadGroup                       ThreadLocal                       
Throwable                         
user=> *1
("Thread" "Thread$State" "Thread$UncaughtExceptionHandler" "ThreadDeath" "ThreadGroup" "ThreadLocal" "Throwable")
user=> 

You'll need to use a separate nREPL session for the completion stuff to avoid this.

Alternatively, having completion middleware would eliminate this problem, along with a pile of others, but that might be out of scope here. :-)

IncompatibleClassChangeError ....

I followed the steps and when I type "reply" I get the following error that keeps scrolling till I kill the terminal:

IncompatibleClassChangeError Found class jline.Terminal, but interface was expected jline.TerminalFactory.create (TerminalFactory.java:93)

Add help and exit tasks

(user/help) would print out the REPL-use info that shows up on launch, and (user/exit) would be just like ctrl-D. (quit) should work as well for exiting.

Basic indentation

Even something dumb like 2 spaces per indent level would be helpful.

REPL fails on windows 7 64 using leiningen 2x: Unknown Signal: CONT

Hello, I was asked to open this issue

from comments at
technomancy/leiningen#486 (comment)


C:\home\vladik\devel\cascalog2>lein2 version
CLASSPATH=;"C:\Users\developer1.lein\self-installs\leiningen-2.0.0-preview2-sta
ndalone.jar"
Leiningen 2.0.0-preview2 on Java 1.6.0_31 Java HotSpot(TM) 64-Bit Server VM
C:\home\vladik\devel\cascalog2>lein2 repl
CLASSPATH=;"C:\Users\developer1.lein\self-installs\leiningen-2.0.0-preview2-sta
ndalone.jar"
Listening for transport dt_socket at address: 60423

<Agent$Closeable$b14108b6@418bdc7a: {:ss #<ServerSocket ServerSocket[addr=0.0.0

.0/0.0.0.0,port=0,localport=60426]>, :transport #<transport$bencode clojure.tool
s.nrepl.transport$bencode@603a3e21>, :greeting nil, :handler #<session$session$f
n__683 clojure.tools.nrepl.middleware.session$session$fn__683@fc519e2>}>
IllegalArgumentException Unknown signal: CONT
sun.misc.Signal. (:-1)
reply.signals/set-signal-handler! (signals.clj:4)
reply.main/launch-nrepl (main.clj:58)
leiningen.repl/repl (repl.clj:70)
clojure.lang.Var.invoke (Var.java:401)
clojure.lang.Var.applyTo (Var.java:518)
clojure.core/apply (core.clj:602)
leiningen.core.main/resolve-task/fn--648 (main.clj:54)
clojure.lang.AFunction$1.doInvoke (AFunction.java:29)
clojure.core/apply (core.clj:602)
leiningen.core.main/apply-task (main.clj:75)
leiningen.core.main/-main (main.clj:124)
Bye for now!
C:\home\vladik\devel\cascalog2>


steps to reproduce

a) install leiningen lein.bat from leiningen master (these are 2x series)
b) do lein2 self-install
c) download and unzip from github cascalog branch: cascading2
d) cd to the unzipped cascalog directory at CMD command line and run
e) lein2 repl

Allow changing namespaces

Currently, things like (ns foo) and (in-ns clojure.core) are broken, because for killability, eval needs to happen in a thread. So when trying to change nses, we get:

Can't set!: *ns* from non-binding thread

The solution may be to have eval happen on the same thread every time, one that has some persistented state, so that we can hold onto the *ns* binding there. This design would move towards what I think integration with Leiningen would need to look like.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.