Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Major changes to simplify cljenv:

      renamed clojure back to clj to save on typing.
      added support for specifying clojure and clojure contrib versions instead of path to jar, using Maven to download the specified artifacts.
      added ability to start a swank server with clj swank.
      simplified cljenv implementation, less environment variables exported. clj script will now source CLJENV_FILE

    Removed emacs related pieces:

      slime, swank-clojure and clojure-mode since those can now be installed from ELPA
      cljenv.el and cljenv-autoload.el since there is nothing left in emacs to manage. From now on will start swank from the command line
      removed emacs related bits from install.sh
  • Loading branch information...
commit 39f6615be4e77e6180ad6d3d376438b7f4cca8c3 1 parent dd3b94e
@cosmin authored
View
9 .gitmodules
@@ -1,9 +0,0 @@
-[submodule "emacs/swank-clojure"]
- path = emacs/swank-clojure
- url = git://github.com/jochu/swank-clojure.git
-[submodule "emacs/clojure-mode"]
- path = emacs/clojure-mode
- url = git://github.com/jochu/clojure-mode.git
-[submodule "emacs/slime"]
- path = emacs/slime
- url = git://github.com/nablaone/slime.git
View
42 README
@@ -2,19 +2,21 @@ CLJENV
Installation:
Currently only BASH 3 or later or ZSH are supported.
-
- Run install.sh to initialize submodules the very first time.
- Then source setup.sh to get cljenv shell functionality.
+ Source activate.sh to get cljenv shell functionality.
-Emacs Support:
- Place the following in your .emacs to get support for cljenv inside of Emacs.
+ This will call cljenv autostart NOPS1 to initialize the default clojure
+ environment.
- (load (concat (getenv "CLJENV_HOME") "/" "setup.el"))
+Starting Clojure:
+ clj # starts a new clojure repl
+ clj swank # starts a clojure swank server, so you can attach
+ clj path/to/file.clj # starts a new repl after running the following file
- This will configure Clojure, Slime and swank-clojure to use the same
- environment that you have activated before starting emacs. Note that at the
- moment you will need to start Emacs from within a shell where cljenv is
- activated.
+Emacs Support:
+ ELPA is a much better way to deal with what you need for Clojure in Emacs.
+ Install ELPA and from it you can install clojure-mode and slime. Then start
+ a swank server from the command line by running 'clj swank' and then
+ use M-x slime-connect from Emacs to connect to it.
Default environments:
@@ -24,26 +26,26 @@ Default environments:
Activating an environment:
- cljenv_autostart # activate the first environment of USER, SYSTEM, DEFAULT
- cljenv_autostart NOPS1 # activate the first env, but surpress PS1 modification
+ cljenv autostart # activate the first environment of USER, SYSTEM, DEFAULT
+ cljenv autostart NOPS1 # activate the first env, but surpress PS1 modification
- cljenv_user # activate the user environment
- cljenv_system # activate the system environment
- cljenv_default # activate the default environment
+ cljenv user # activate the user environment
+ cljenv system # activate the system environment
+ cljenv default # activate the default environment
# use the following commmands to activate environments you create (see below)
- cljenv_activate # activate the environment in the current directory
- cljenv_activate path/to/env/folder # activate the given environment
+ cljenv activate # activate the environment in the current directory
+ cljenv activate path/to/env/folder # activate the given environment
Creating a new environment:
- cljenv_create # create a new environment in the current folder
- cljenv_create path_to_folder # create a new environment in the given folder
+ cljenv create # create a new environment in the current folder
+ cljenv create path_to_folder # create a new environment in the given folder
After running cljenv_create edit the .cljenv file in either the current or
specified folders to set your options for java, clojure, and clojure-contrib
Deactivating an environment:
- cljenv_deactivate # deactivate the currently active environment
+ cljenv deactivate # deactivate the currently active environment
View
102 source.sh → activate.sh
@@ -5,6 +5,7 @@ else
fi
export CLJENV_HOME
+export PATH="$CLJENV_HOME/bin:$PATH"
USER_CLJENV_PATH="$HOME/.cljenv"
SYSTEM_CLJENV_PATH="/etc/cljenv/system_cljenv"
@@ -48,55 +49,13 @@ function cljenv_create() {
function cljenv_activate() {
cljenv_deactivate () {
-
- unset CLOJURE_JAR
- unset CLOJURE_CONTRIB_JAR
- unset CLOJURE_JAVA_PATH
- unset CLOJURE_CLASSPATH
- unset CLOJURE_VM_ARGS
- unset CLOJURE_NATIVE_LIBRARY_PATH
unset CLJENV_NAME
+ unset CLJENV_FILE
- if [ -n "$_OLD_CLJENV_PATH" ] ; then
- PATH="$_OLD_CLJENV_PATH"
- export PATH
- unset _OLD_CLJENV_PATH
- fi
-
- if [ -n "$_OLD_CLJENV_CLOJURE_JAR" ] ; then
- CLOJURE_JAR="$_OLD_CLJENV_CLOJURE_JAR"
- export CLOJURE_JAR
- unset _OLD_CLJENV_CLOJURE_JAR
- fi
-
- if [ -n "$_OLD_CLJENV_CLOJURE_CONTRIB_JAR" ] ; then
- CLOJURE_CONTRIB_JAR="$_OLD_CLJENV_CLOJURE_CONTRIB_JAR"
- export CLOJURE_CONTRIB_JAR
- unset _OLD_CLJENV_CLOJURE_CONTRIB_JAR
- fi
-
- if [ -n "$_OLD_CLJENV_CLOJURE_JAVA_PATH" ] ; then
- CLOJURE_JAVA_PATH="$_OLD_CLJENV_CLOJURE_JAVA_PATH"
- export CLOJURE_JAVA_PATH
- unset _OLD_CLJENV_CLOJURE_JAVA_PATH
- fi
-
- if [ -n "$_OLD_CLJENV_CLOJURE_CLASSPATH" ] ; then
- CLOJURE_CLASSPATH="$_OLD_CLJENV_CLOJURE_CLASSPATH"
- export CLOJURE_CLASSPATH
- unset _OLD_CLJENV_CLOJURE_CLASSPATH
- fi
-
- if [ -n "$_OLD_CLJENV_CLOJURE_VM_ARGS" ] ; then
- CLOJURE_VM_ARGS="$_OLD_CLJENV_CLOJURE_VM_ARGS"
- export CLOJURE_VM_ARGS
- unset _OLD_CLJENV_CLOJURE_VM_ARGS
- fi
-
- if [ -n "$_OLD_CLJENV_CLOJURE_NATIVE_LIBRARY_PATH" ] ; then
- CLOJURE_NATIVE_LIBRARY_PATH="$_OLD_CLJENV_CLOJURE_NATIVE_LIBRARY_PATH"
- export CLOJURE_NATIVE_LIBRARY_PATH
- unset _OLD_CLJENV_CLOJURE_NATIVE_LIBRARY_PATH
+ if [ -n "$_OLD_CLJENV_FILE" ] ; then
+ CLJENV_FILE="$_OLD_CLJENV_FILE"
+ export CLJENV_FILE
+ unset _OLD_CLJENV_FILE
fi
if [ -n "$_OLD_CLJENV_NAME" ] ; then
@@ -116,27 +75,10 @@ function cljenv_activate() {
fi
unset CLJENV
- if [ ! "$1" = "nondestructive" ] ; then
- # Self destruct!
- unset cljenv_deactivate
-
- if [ -n "$_CLJENV_AUTOSTART" ] ; then
- if [ ! "$_CLJENV_AUTOSTART" = "$CLJENV_FILE" ] ; then
- echo 'Going back to autostart'
- unset CLJENV_FILE
- cljenv_autostart $_CLJENV_AUTOSTART $_CLJENV_AUTOSTART_NAME
- else
- echo 'Unloading autostart'
- unset _CLJENV_AUTOSTART_NAME
- unset _CLJENV_AUTOSTART
- fi
- fi
- fi
}
- cljenv_deactivate nondestructive
_OLD_CLJENV_NAME="$CLJENV_NAME"
- _OLD_CLJENV_PATH="$PATH"
+ _OLD_CLJENV_FILE="$CLJENV_FILE"
if [ -z "$1" ]; then
ENVFILE="`pwd`/.cljenv"
@@ -152,34 +94,12 @@ function cljenv_activate() {
export CLJENV_NAME
if [ -f $ENVFILE ] ; then
-
- CLJENV_ROOT=$(dirname $ENVFILE)
-
- _OLD_CLJENV_CLOJURE_JAVA_PATH="$CLOJURE_JAVA_PATH"
- _OLD_CLJENV_CLOJURE_JAR="$CLOJURE_JAR"
- _OLD_CLJENV_CLOJURE_CONTRIB_JAR="$CLOJURE_CONTRIB_JAR"
- _OLD_CLJENV_CLOJURE_CLASSPATH="$CLOJURE_CLASSPATH"
- _OLD_CLJENV_CLOJURE_VM_ARGS="$CLOJURE_VM_ARGS"
- _OLD_CLJENV_CLOJURE_NATIVE_LIBRARY_PATH="$CLOJURE_NATIVE_LIBRARY_PATH"
- _OLD_CLJENV_FILE="$CLJENV_FILE"
-
- . $ENVFILE
-
export CLJENV_FILE=$ENVFILE
-
- export CLOJURE_JAVA_PATH
- export CLOJURE_JAR
- export CLOJURE_CONTRIB_JAR
- export CLOJURE_CLASSPATH
- export CLOJURE_VM_ARGS
- export CLOJURE_NATIVE_LIBRARY_PATH
else
echo "ERROR: Cannot locate CLJENV definition at $ENVFILE"
return 1
fi
- export PATH="$CLJENV_HOME/bin:$PATH"
-
if [ "$CLJENV_NAME" != "NOPS1" ] ; then
_OLD_CLJENV_PS1="$PS1"
if [ "`basename \"$CLJENV_NAME\"`" = "__" ] ; then
@@ -227,3 +147,11 @@ function cljenv_autostart() {
cljenv_activate `_cljenv_path_for_create` $ENV_NAME
}
+
+function cljenv() {
+ command=$1
+ shift
+ cljenv_$command $*
+}
+
+cljenv autostart NOPS1
View
74 bin/clj
@@ -0,0 +1,74 @@
+#!/usr/bin/env bash
+
+source $CLJENV_FILE
+
+CLOJURE_REPO=http://build.clojure.org/releases
+SWANK_REPO=http://offbytwo.github.com/repo/releases # should be clojars, but for me clojars is blocked
+
+function mvn_file_path() {
+ GROUP=$1
+ ARTIFACT=$2
+ VERSION=$3
+ echo "$HOME/.m2/repository/${GROUP//.//}/$ARTIFACT/$VERSION/$ARTIFACT-$VERSION.jar"
+}
+
+function mvn_get() {
+ REPO=$1
+ GROUP=$2
+ ARTIFACT=$3
+ VERSION=$4
+ MVN_FILE_PATH=`mvn_file_path $GROUP $ARTIFACT $VERSION`
+
+ if [ ! -e $MVN_FILE_PATH ]; then
+ mvn org.apache.maven.plugins:maven-dependency-plugin:2.1:get -DrepoUrl=$REPO -Dartifact=$GROUP:$ARTIFACT:$VERSION:jar
+ fi
+}
+
+CLOJURE_CLASSPATH=""
+for el in "CLOJURE" "CLOJURE_CONTRIB" "SWANK_CLOJURE"; do
+ version_var_name="${el}_VERSION"
+ version=${!version_var_name}
+ jar_var_name="${el}_JAR"
+ jar=${!jar_var_name}
+ if [ -z $jar ]; then
+ artifact=`echo $el | tr '[A-Z]_' '[a-z]-'`
+ case $artifact in
+ clojure*)
+ group="org.clojure"
+ repo=$CLOJURE_REPO
+ ;;
+ swank*)
+ group="swank-clojure"
+ repo=$SWANK_REPO
+ ;;
+ *)
+ echo "Cannot determine group and repo for $artifact"
+ exit 1
+ ;;
+ esac
+ mvn_get $repo $group $artifact $version
+ jar=$(mvn_file_path $group $artifact $version)
+ fi
+ CLOJURE_CLASSPATH="$CLOJURE_CLASSPATH${jar}:"
+done
+
+echo "Starting clojure with classpath"
+echo $CLOJURE_CLASSPATH
+echo
+
+INVOKE_LINE="$CLOJURE_JAVA_PATH $CLOJURE_VM_ARGS $CLOJURE_NATIVE_LIBRARY_PATH -cp $CLOJURE_CLASSPATH"
+
+if [ -z "$1" ] ; then
+ $INVOKE_LINE$CLJENV_HOME/lib/jline-0.9.94.jar jline.ConsoleRunner clojure.main
+else
+ case $1 in
+ swank)
+ shift
+ $INVOKE_LINE clojure.main $CLJENV_HOME/start-swank.clj "$@"
+ ;;
+ *)
+ $INVOKE_LINE clojure.main "$@"
+ ;;
+ esac
+fi
+
View
11 bin/clojure
@@ -1,11 +0,0 @@
-#!/usr/bin/env bash
-
-CLOJURE_PATH=$CLOJURE_JAR:$CLOJURE_CONTRIB_JAR:$CLOJURE_CLASSPATH:"$(dirname $0)/../lib/jline-0.9.94.jar"
-
-INVOKE_LINE="$CLOJURE_JAVA_PATH $CLOJURE_VM_ARGS $CLOJURE_NATIVE_LIBRARY_PATH -cp $CLOJURE_PATH"
-
-if [ -z "$1" ] ; then
- $INVOKE_LINE jline.ConsoleRunner clojure.main
-else
- $INVOKE_LINE clojure.main "$@"
-fi
View
15 default_cljenv
@@ -1,7 +1,14 @@
-CLOJURE_JAR="$CLJENV_HOME/lib/clojure-1.1.0.jar" # path to clojure.jar
-CLOJURE_CONTRIB_JAR="$CLJENV_HOME/lib/clojure-contrib-1.1.0.jar" # path to clojure-contrib.jar
-CLOJURE_CLASSPATH="$CLJENV_HOME/emacs/swank-clojure/src/main/clojure" # classpath to launch clojure with
+CLOJURE_VERSION="1.2.0"
+#CLOJURE_JAR=/path/to/clojure.jar # if you want to specify a custom built version of clojure
+
+CLOJURE_CONTRIB_VERSION="1.2.0"
+#CLOJURE_CONTRIB_JAR=/path/to/clojure-contrib.jar # if you want to specify a custom build version of contrib
+
+SWANK_CLOJURE_VERSION="1.2.1"
+#SWANK_CLOJURE_JAR=/path/to/swank-clojure.jar # if you want to specify a custom built version of swank clojure
+
+CLOJURE_LIBS="$CLJENV/lib/"
CLOJURE_JAVA_PATH="java" # path to java executable to use
-CLOJURE_VM_ARGS="" # virtual machine arguments when starting JVM
+CLOJURE_JVM_ARGS="" # virtual machine arguments when starting JVM
CLOJURE_NATIVE_LIBRARY_PATH="" # path to native libraries for JVM
View
7 emacs/cljenv-autoload.el
@@ -1,7 +0,0 @@
-(autoload 'cljenv-init "cljenv" "Initialize CLJENV")
-
-(cljenv-init)
-(require 'slime)
-(slime-setup '(slime-repl))
-
-(provide 'cljenv-autoload)
View
23 emacs/cljenv.el
@@ -1,23 +0,0 @@
-(eval-and-compile
- (defvar cljenv-emacs-path
- (let ((path (file-truename (or (locate-library "cljenv")
- load-file-name))))
- (and path (file-name-directory path)))))
-
-
-(defun cljenv-init ()
- (add-to-list 'load-path (concat cljenv-emacs-path "swank-clojure/src/emacs/"))
- (add-to-list 'load-path (concat cljenv-emacs-path "clojure-mode/"))
-
- (if (getenv "CLJENV_HOME")
- (progn
- (add-to-list 'load-path (concat shared-profile-elisp "swank-clojure/"))
- (add-to-list 'load-path (concat shared-profile-elisp "clojure-mode/"))
-
- (setq swank-clojure-binary "clojure")
-
- (require 'clojure-mode)
- (require 'swank-clojure-autoload)
- )))
-
-(provide 'cljenv)
1  emacs/clojure-mode
@@ -1 +0,0 @@
-Subproject commit c8c684e3eddfc3f5294ef70030007393cf077dfc
1  emacs/slime
@@ -1 +0,0 @@
-Subproject commit e02c6c8b67099b3fed372c1a3594e5d2ad2f82b3
1  emacs/swank-clojure
@@ -1 +0,0 @@
-Subproject commit d020202cbbe4f805ceeab764bc764f94e30d2f0d
View
15 install.sh
@@ -3,21 +3,10 @@
OS="`uname`"
INSTALL_LOCATION="`pwd`"
-echo "Initializing submodules"
-git submodule update --init
touch ~/.clj_completions # this file must exist or bad things happen
-echo ""
-echo "= Put the following in your .bashrc or similar ="
-echo ""
-echo "source $INSTALL_LOCATION/setup.sh"
-echo "cljenv_autostart NOPS1"
+echo "# Put the following in your .bashrc or similar #"
echo ""
+echo "source $INSTALL_LOCATION/activate.sh"
echo ""
-echo "= Put the following in your .emacs to get emacs support"
-echo ""
-echo "(load (concat (getenv \"CLJENV_HOME\") \"/\" \"setup.el\"))"
-echo ""
-echo ""
-echo "Done."
View
BIN  lib/clojure-1.1.0.jar
Binary file not shown
View
BIN  lib/clojure-contrib-1.1.0.jar
Binary file not shown
View
11 setup.el
@@ -1,11 +0,0 @@
-(set-language-environment "UTF-8")
-
-(setq home-directory (getenv "HOME"))
-(setq cljenv-home (getenv "CLJENV_HOME"))
-(setq cljenv-emacs (concat cljenv-home "/emacs/"))
-
-(add-to-list 'load-path cljenv-emacs)
-(add-to-list 'load-path (concat cljenv-emacs "slime/"))
-
-(require 'cljenv-autoload)
-(setq slime-net-coding-system 'utf-8-unix)
View
5 start-swank.clj
@@ -0,0 +1,5 @@
+(in-ns 'user)
+
+(use 'swank.swank)
+
+(swank.swank/start-repl)
Please sign in to comment.
Something went wrong with that request. Please try again.