Giter VIP home page Giter VIP logo

iclojure's Introduction

IClojure

An Interactive Clojure repl, inspired by IPython.

Build Status

Getting started

Standalone

The simplest way to start with IClojure is to download the latest standalone IClojure jar

curl -O -L http://clk.tc/iclojure-latest.jar
java -jar iclojure-latest.jar

Alternatively, you can download the following script, mark it executable and put it somewhere in path

curl -O https://raw.github.com/cosmin/IClojure/master/bin/iclojure
chmod +x iclojure
sudo mv iclojure /usr/local/bin

Then you can simply launch iclojure at any time.

Leiningen

If you are already using Leiningen the simplest way to get started with IClojure is to use the lein-iclojure plugin.

Leiningen 1.x

lein plugin install lein-iclojure 1.2

Leiningen 2

Add [lein-iclojure "1.2"] to the :user profile in ~/.lein/profiles.clj. Here is an example

{:user {:plugins [ [lein-iclojure "1.2"] ]}}

Maven

If you are already using the latest clojure-maven-plugin snapshot you can simply add IClojure to your dependencies

<dependency>
  <groupId>com.offbytwo.iclojure</groupId>
  <artifactId>iclojure</artifactId>
  <version>1.2.0</version>
</dependency>

and then IClojure will replace the usual repl

mvn clojure:repl

Development

IClojure ships with the latest alpha of Clojure 1.4, although it supports Clojure >= 1.2

git checkout https://github.com/cosmin/IClojure
cd IClojure
bin/run.sh

Package

You can package IClojure for distribution, including sources and a standalone jar with

mvn clean package

The iclojure-*-standalone.jar is a self-contained Jar that includes all the necessary dependencies.

Features

  • Tab completion
  • Shorthand for source and doc
  • Shorthand for introspecting Java objects and classes via reflection
  • Proper Control-C handling, although not very portable
  • persist history across sessions to ~/.iclojure_history
  • input and output caching of last 1000 elements

Tab completion

  • variable
  • method invocations
  • "(.method" completion for all java methods for any of the classes in the current namespace
  • "(. object method" completion for all the methods of the object (or a form that evaluates to an object)
  • namespaces
  • java classes
  • import statements for both symbols and import lists

Input / output caching

In addition to the Clojure convention of caching the last 3 output in *1, *2 and *3 IClojure also caches the last 1000 input and output

(input 102) ; => returns the input from line 102
(output 102) ; => returns the output from line 102

Other shorthands

    ?symbol          => (doc symbol)
    ??symbol         => (source symbol)
    %d symbol        => show constructors, methods and fields of the given object or Class
    %f class         => find all classes matching this name (supports globs)
    %f class package => like the above, but restrict search to the given package

Roadmap

  • tab completion for require and use forms
  • abort long runing tasks with Ctrl+C
  • launch editor from within IClojure

License

Copyright (C) 2013 Cosmin Stejerean

Distributed under the Eclipse Public License, the same as Clojure.

iclojure's People

Contributors

brandonbloom avatar coltnz avatar cosmin avatar jaskirat 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

iclojure's Issues

Help is wrong

When issued '?', this is shown:

user[2]: ?
doc => show documentatio...
source => ...
...
(input i) => return the input from line i
(output i) => return the output from line i

Here is not stated how 'doc' or 'source' should be used (as they are clojure functions) and when I installed IClojure for the first time, I thought they are commands, and should be used like:

user[2]: source "map"

or

user[3]: dir user

Documentation for given commands should be the same as for 'input/output' or (which is much better) it could be implemented as commands (like %d).

Also, when IClojure is started, one options are printed (?symbol, %d) but when ? is issued, they are not visible.

Thanks.

jline artifact moved

Hey Cosmin,
Just wanted to give a heads-up that the jline artifact is now under the "jline" groupId.
I'd put a github issue in about a release, and that's one of the things that came out of it. No full release yet as far as I know.

  • Colin

Include cd-client

I've found ClojureDocs to be an invaluable reference for its user-contributed examples. Too bad you need to visit it in a browser. But now there's a great little cd-client to access it from the REPL. It would seem like a nice fit for IClojure to support its cdoc-like lookup. So two things that IClojure could add:

  1. Some auto-installation/packaging of cd-client (since it's awesome documentation but many won't know it exists)
  2. A shortcut syntax to cdoc (like ?foo and ??foo)

Neither is critical, but would be nice-to-haves.

Autocomplete not working

I have found that autocomplete is not working in such case

(def x (interl<TAB>

nothing happens, while REPL-y appends to interleave

open $EDITOR with %edit-like command, returning the contents to the repl

For longer ipython-sessions, I regularly use the %edit functionality, which opens an editor (defined in $EDITOR) and upon closing the editor, returns the contents in a string to the interactive shell.

With python, the functionality is really nice when needing to insert custom classes in your ipython session, those indentations are much more easily managed in a sane editor than in the shell. The same is the case for me when trying to keep track of the parentheses.

See http://ipython.org/ipython-doc/rel-0.12/interactive/tips.html#lightweight-version-control for reference.

Implement multi-line editing

Multi-line editing would be significantly more productive for working with Clojure at the REPL. Getting this to work with the current state of jline2 might prove challenging however

Auto-wrapping in parentheses

Currently the non-first form seems to be just ignored by IClojure:

user[4]: 4 whatever
user[4]= 4

It can be useful to simplify function calls by allowing to omit parentheses (on top level) in such cases, so, for example, Math/sin 4 will be interpreted as (Math/sin 4). Tab completion can optionally auto-insert parentheses as well, like + 4 <tab> -> (+ 4 <cursor>).

Some other for-convenience rules can apply, like "qwe" .sta<tab> -> (. "qwe" startsWith<cursor>) or (.startsWith<cursor> "qwe").

Allow customizing colors

IClojure will by default output prompt in blue (including current namespace) and stacktrace bar in red. These colors looks bad in terminal with black background (I often use this setup) and the prompt is practically not visible.

reflecting on an Integer causes a crash

λ java -jar iclojure-1.0-SNAPSHOT.jar                                          
Clojure 1.4.0-alpha4                                                           

IClojure 1.0 -- an enhanced Interactive Clojure                                
?         -> Introduction and overview of IClojure's features                  
?symbol   -> Print documentation for symbol                                    
??symbol  -> Show source of function or macro                                  
%d symbol -> Describe Java class (show constructors, methods and fields)       

user[1]: (def d (Integer. 1))                                                  
user[1]= #'user/d                                                              

user[2]: %d                                                                    
Exception in thread "main" java.lang.RuntimeException: EOF while reading       
        at clojure.lang.Util.runtimeException(Util.java:170)                   
        at clojure.lang.LispReader.read(LispReader.java:165)                   
        at clojure.lang.RT.readString(RT.java:1691)                            
        at com.offbytwo.iclojure.Main.read(Main.java:109)                      
        at com.offbytwo.iclojure.Main.loop(Main.java:177)                      
        at com.offbytwo.iclojure.Main.main(Main.java:227)                      

dep errors for ' lein plugin install lein-iclojure "1.0.0-SNAPSHOT" '

Downloading: net/sf/jline/jline/2.6-SNAPSHOT/jline-2.6-20120211.211349-7.jar from repository sonatype-nexus-snapshots at https://oss.sonatype.org/content/repositories/snapshots
Unable to locate resource in repository
An error has occurred while processing the Maven artifact tasks.
Diagnosis:

Unable to resolve artifact: Missing:

  1. net.sf.jline:jline:jar:2.6-SNAPSHOT

Try downloading the file manually from the project website.

Then, install it using the command:
mvn install:install-file -DgroupId=net.sf.jline -DartifactId=jline -Dversion=2.6-20120211.211349-7 -Dpackaging=jar -Dfile=/path/to/file

Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=net.sf.jline -DartifactId=jline -Dversion=2.6-20120211.211349-7 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

Path to dependency:
1) org.apache.maven:super-pom:pom:2.0
2) com.offbytwo.iclojure:iclojure:jar:1.0.2-SNAPSHOT
3) net.sf.jline:jline:jar:2.6-SNAPSHOT


1 required artifact is missing.

for artifact:
org.apache.maven:super-pom:pom:2.0

from the specified remote repositories:
central (http://repo1.maven.org/maven2),
clojars (http://clojars.org/repo/)

Exception in thread "main" Unable to resolve artifact: Missing:

  1. net.sf.jline:jline:jar:2.6-SNAPSHOT

Try downloading the file manually from the project website.

Then, install it using the command:
mvn install:install-file -DgroupId=net.sf.jline -DartifactId=jline -Dversion=2.6-20120211.211349-7 -Dpackaging=jar -Dfile=/path/to/file

Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=net.sf.jline -DartifactId=jline -Dversion=2.6-20120211.211349-7 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

Path to dependency:
1) org.apache.maven:super-pom:pom:2.0
2) com.offbytwo.iclojure:iclojure:jar:1.0.2-SNAPSHOT
3) net.sf.jline:jline:jar:2.6-SNAPSHOT


1 required artifact is missing.

for artifact:
org.apache.maven:super-pom:pom:2.0

from the specified remote repositories:
central (http://repo1.maven.org/maven2),
clojars (http://clojars.org/repo/)

(NO_SOURCE_FILE:0)
at clojure.lang.Compiler.eval(Compiler.java:5440)
at clojure.lang.Compiler.eval(Compiler.java:5391)
at clojure.core$eval.invoke(core.clj:2382)
at clojure.main$eval_opt.invoke(main.clj:235)
at clojure.main$initialize.invoke(main.clj:254)
at clojure.main$script_opt.invoke(main.clj:270)
at clojure.main$main.doInvoke(main.clj:354)
at clojure.lang.RestFn.invoke(RestFn.java:551)
at clojure.lang.Var.invoke(Var.java:390)
at clojure.lang.AFn.applyToHelper(AFn.java:193)
at clojure.lang.Var.applyTo(Var.java:482)
at clojure.main.main(main.java:37)

Caused by: Unable to resolve artifact: Missing:

  1. net.sf.jline:jline:jar:2.6-SNAPSHOT

Try downloading the file manually from the project website.

Then, install it using the command:
mvn install:install-file -DgroupId=net.sf.jline -DartifactId=jline -Dversion=2.6-20120211.211349-7 -Dpackaging=jar -Dfile=/path/to/file

Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=net.sf.jline -DartifactId=jline -Dversion=2.6-20120211.211349-7 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

Path to dependency:
1) org.apache.maven:super-pom:pom:2.0
2) com.offbytwo.iclojure:iclojure:jar:1.0.2-SNAPSHOT
3) net.sf.jline:jline:jar:2.6-SNAPSHOT


1 required artifact is missing.

for artifact:
org.apache.maven:super-pom:pom:2.0

from the specified remote repositories:
central (http://repo1.maven.org/maven2),
clojars (http://clojars.org/repo/)

at org.apache.maven.artifact.ant.DependenciesTask.doExecuteResolution(DependenciesTask.java:268)
at org.apache.maven.artifact.ant.DependenciesTask.doExecute(DependenciesTask.java:168)
at org.apache.maven.artifact.ant.AbstractArtifactTask.execute(AbstractArtifactTask.java:751)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:90)
at clojure.lang.Reflector.invokeNoArgInstanceMember(Reflector.java:265)
at leiningen.deps$do_deps.invoke(deps.clj:133)
at leiningen.deps$deps.doInvoke(deps.clj:198)
at clojure.lang.RestFn.invoke(RestFn.java:410)
at leiningen.install$install.invoke(install.clj:75)
at leiningen.plugin$install.invoke(plugin.clj:52)
at leiningen.plugin$plugin.invoke(plugin.clj:83)
at clojure.lang.Var.invoke(Var.java:373)
at clojure.lang.AFn.applyToHelper(AFn.java:167)
at clojure.lang.Var.applyTo(Var.java:482)
at clojure.core$apply.invoke(core.clj:540)
at leiningen.core$apply_task.invoke(core.clj:265)
at leiningen.core$_main.doInvoke(core.clj:331)
at clojure.lang.RestFn.applyTo(RestFn.java:139)
at clojure.core$apply.invoke(core.clj:542)
at leiningen.core$_main.invoke(core.clj:334)
at user$eval42.invoke(NO_SOURCE_FILE:1)
at clojure.lang.Compiler.eval(Compiler.java:5424)
... 11 more

Caused by: org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException: Missing:

  1. net.sf.jline:jline:jar:2.6-SNAPSHOT

Try downloading the file manually from the project website.

Then, install it using the command:
mvn install:install-file -DgroupId=net.sf.jline -DartifactId=jline -Dversion=2.6-20120211.211349-7 -Dpackaging=jar -Dfile=/path/to/file

Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=net.sf.jline -DartifactId=jline -Dversion=2.6-20120211.211349-7 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

Path to dependency:
1) org.apache.maven:super-pom:pom:2.0
2) com.offbytwo.iclojure:iclojure:jar:1.0.2-SNAPSHOT
3) net.sf.jline:jline:jar:2.6-SNAPSHOT


1 required artifact is missing.

for artifact:
org.apache.maven:super-pom:pom:2.0

from the specified remote repositories:
central (http://repo1.maven.org/maven2),
clojars (http://clojars.org/repo/)

at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolveTransitively(DefaultArtifactResolver.java:360)
at org.apache.maven.artifact.ant.DependenciesTask.doExecuteResolution(DependenciesTask.java:263)
... 36 more

Add nrepl support

IClojure should support nrepl. This will eliminate the need for trampoline inside lein-iclojure

clojurescript support

IClojure is mostly written in Java now... is it possible to do much of the work in Clojure itself so making port on clojurescript can be less painful as possible?

(map vec :keyword) crashes iclojure

[user@host]$ iclojure
log4j:WARN No appenders could be found for logger (com.offbytwo.class_finder.ClassFinder).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Clojure 1.4.0

IClojure 1.1.1-SNAPSHOT -- an enhanced Interactive Clojure
? -> Introduction and overview of IClojure's features
?symbol -> Print documentation for symbol
??symbol -> Show source of function or macro
%d symbol -> Describe Java class (show constructors, methods and fields)
%f class -> find all classes matching this name (supports globs)
%f class package -> like the above, but restrict search to the given package

user[1]: (map vec :a)
Exception in thread "main" java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword
at clojure.lang.RT.seqFrom(RT.java:494)
at clojure.lang.RT.seq(RT.java:475)
at clojure.core$seq.invoke(core.clj:133)
at clojure.core$map$fn__465.invoke(core.clj:2426)
at clojure.lang.LazySeq.sval(LazySeq.java:42)
at clojure.lang.LazySeq.seq(LazySeq.java:60)
at clojure.lang.RT.seq(RT.java:473)
at clojure.core$seq.invoke(core.clj:133)
at clojure.core$print_sequential.invoke(core_print.clj:46)
at clojure.core$eval1962$fn__1963.invoke(core_print.clj:140)
at clojure.lang.MultiFn.invoke(MultiFn.java:167)
at clojure.core$pr_on.invoke(core.clj:3266)
at clojure.lang.Var.invoke(Var.java:419)
at clojure.lang.RT.print(RT.java:1717)
at clojure.lang.RT.printString(RT.java:1696)
at com.offbytwo.iclojure.repl.IClojureRepl.print(IClojureRepl.java:134)
at com.offbytwo.iclojure.repl.IClojureRepl.loop(IClojureRepl.java:154)
at com.offbytwo.iclojure.Main.main(Main.java:63)

[user@host]$  # we're back at the shell, since Iclojure exited unexpectedly.
the repl does:

user=> (map vec :a)
IllegalArgumentException Don't know how to create ISeq from: clojure.lang.Keyword clojure.lang.RT.seqFrom (RT.java:494)

user=> ;; we're still inside the REPL..

IClojure crashes on TAB completion attempt

$ java -jar ~/bin/iclojure-latest.jar 
log4j:WARN No appenders could be found for logger (com.offbytwo.class_finder.ClassFinder).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Clojure 1.4.0

IClojure 1.1.1-SNAPSHOT -- an enhanced Interactive Clojure
.....
user[1]: (. qqqqq ;;TAB completion attempt here
Exception in thread "main" java.lang.RuntimeException: Unable to resolve symbol: qqqqq in this context,     compiling:(NO_SOURCE_PATH:0)

New release please?

I was wondering if you'd be willing to cut a new release now that you're using JLine 2.9. I'm working on a Java/Clojure project in a group, and I often update my local pom file to point to IClojure 1.2.0-SNAPSHOT so that I can take advantage of JLine, but I can't check that in without something to refer to -- we don't have a team maven repo yet.

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.