Index: files/clj-jline.sh
===================================================================
--- files/clj-jline.sh	(revision 48862)
+++ files/clj-jline.sh	(working copy)
@@ -5,6 +5,7 @@
 
 cljjar='lib/clojure.jar'
 cljclass='clojure.lang.Repl'
+cljscript='clojure.lang.Script'
 jlineclass='jline.ConsoleRunner'
 
 dir=$0
@@ -24,4 +25,11 @@
 cljjar="$dir/../$cljjar"
 jlinejar="$dir/../../jline.jar"
 
-exec java -classpath $jlinejar:$cljjar $jlineclass $cljclass
+
+if [ -z "$1" ]; then
+  exec java -classpath $jlinejar:$cljjar $jlineclass $cljclass
+else
+  scriptname=$1
+  exec java -classpath $jlinejar:$cljjar $jlineclass $cljscript $scriptname --$*
+fi
+
Index: files/clj.sh
===================================================================
--- files/clj.sh	(revision 48862)
+++ files/clj.sh	(working copy)
@@ -5,6 +5,7 @@
 
 cljjar='lib/clojure.jar'
 cljclass='clojure.lang.Repl'
+cljscript='clojure.lang.Script'
 
 dir=$0
 while [ -h "$dir" ]; do
@@ -22,4 +23,9 @@
 dir=`cd "$dir" > /dev/null && pwd`
 cljjar="$dir/../$cljjar"
 
-exec java -classpath $cljjar $cljclass
+if [ -z "$1" ]; then
+  exec java -classpath $cljjar $cljclass
+else
+  scriptname=$1
+  exec java -classpath $cljjar $cljscript $scriptname --$*
+fi
Index: files/completions-contrib.clj
===================================================================
--- files/completions-contrib.clj	(revision 0)
+++ files/completions-contrib.clj	(revision 0)
@@ -0,0 +1,6 @@
+(def completions
+    (reduce concat (map (fn [p] (keys (ns-publics (find-ns p))))
+                        '(clojure.core clojure.set clojure.xml clojure.zip))))
+ 
+(with-open [f (java.io.BufferedWriter. (java.io.FileWriter. ".clj_completions"))]
+    (.write f (apply str (interleave completions (repeat "\n")))))
\ No newline at end of file
Index: files/.clj_completions
===================================================================
--- files/.clj_completions	(revision 0)
+++ files/.clj_completions	(revision 0)
@@ -0,0 +1,505 @@
+sorted-map
+read-line
+re-pattern
+keyword?
+val
+*compile-path*
+max-key
+list*
+ns-aliases
+the-ns
+==
+longs
+special-form-anchor
+instance?
+syntax-symbol-anchor
+format
+sequential?
+fn?
+empty
+dorun
+time
+remove-method
+gensym
+not=
+*3
+unchecked-multiply
+doseq
+bit-or
+aset-byte
+if-not
+hash-set
+add-watch
+unchecked-dec
+some
+nil?
+string?
+second
+letfn
+keys
+for
+*2
+long-array
+cond
+bit-set
+fn
+sorted?
+ns-unalias
+ns-publics
+dosync
+all-ns
+long
+with-open
+init-proxy
+add-classpath
+false?
+await1
+true?
+gen-interface
+sync
+short
+ns-unmap
+repeat
+zipmap
+distinct
+get-in
+bit-xor
+char-escape-string
+complement
+let
+get-validator
+dotimes
+print-namespace-doc
+*ns*
+defmethod
+derive
+aset-float
+lazy-cat
+commute
+defstruct
+with-in-str
+rem
+odd?
+symbol?
+*print-level*
+*allow-unresolved-vars*
+*macro-meta*
+proxy-call-with-super
+ns-interns
+re-matches
+split-with
+find-doc
+loop
+remove-watcher
+next
+import
+symbol
+vals
+print-doc
+select-keys
+re-matcher
+rand
+deref
+unchecked-inc
+*math-context*
+read
+sequence
+make-hierarchy
++
+number?
+descendants
+into-array
+last
+unchecked-negate
+integer?
+alter
+prn
+with-meta
+with-out-str
+floats
+*
+*compile-files*
+when-not
+butlast
+-
+reversible?
+rseq
+send-off
+seq?
+refer-clojure
+identical?
+..
+print
+vary-meta
+*command-line-args*
+bit-flip
+zero?
+bit-and
+unquote-splicing
+future
+re-groups
+*warn-on-reflection*
+newline
+replicate
+distinct?
+remove-ns
+ratio?
+xml-seq
+vec
+concat
+update-in
+vector
+conj
+bases
+/
+unchecked-add
+ref-set
+assoc
+seque
+aset-char
+boolean
+read-string
+neg?
+float-array
+doubles
+isa?
+future-call
+doto
+remove-watch
+print-str
+*e
+rsubseq
+*flush-on-newline*
+*out*
+vector?
+split-at
+ns-refers
+create-struct
+proxy-super
+int-array
+float
+assert
+map
+counted?
+memfn
+double-array
+accessor
+*print-length*
+class?
+rand-int
+*1
+aset-short
+prn-str
+iterate
+add-watcher
+when-first
+slurp
+mapcat
+assoc-in
+special-symbol?
+ref
+find-var
+inc
+definline
+unchecked-subtract
+ns-name
+defn-
+*file*
+re-find
+bit-not
+construct-proxy
+destructure
+seq
+intern
+pvalues
+to-array-2d
+sorted-map-by
+filter
+var?
+alter-meta!
+comment
+key
+class
+re-seq
+ns
+empty?
+test
+print-dup
+create-ns
+name
+list?
+aset
+nnext
+doall
+macroexpand-1
+not-any?
+resultset-seq
+into
+with-precision
+*use-context-classloader*
+ffirst
+bit-clear
+proxy-name
+load-reader
+or
+hash
+print-ctor
+associative?
+float?
+drop-last
+replace
+decimal?
+defn
+parents
+map?
+prefers
+condp
+quot
+file-seq
+send
+with-local-vars
+reverse
+count
+get-proxy-class
+set
+when-let
+comp
+nth
+byte
+*err*
+constantly
+load
+namespace
+pr-str
+<
+rationalize
+sort-by
+cycle
+peek
+reduce
+interleave
+amap
+->
+cons
+macroexpand
+var-set
+str
+aset-boolean
+ns-imports
+while
+first
+bean
+=
+memoize
+var-get
+range
+tree-seq
+defmacro
+set-validator!
+aset-double
+enumeration-seq
+prefer-method
+ensure
+find-ns
+not-every?
+struct-map
+>
+max
+proxy-mappings
+identity
+ints
+fnext
+min-key
+reset-meta!
+subs
+compile
+agent-errors
+clear-agent-errors
+printf
+ns-resolve
+method-sig
+>=
+shutdown-agents
+reset!
+even?
+require
+bit-shift-left
+methods
+compare
+cast
+supers
+pcalls
+load-string
+get
+<=
+await
+resolve
+print-method
+loaded-libs
+force
+partial
+pmap
+if-let
+comparator
+pos?
+char
+take-while
+and
+refer
+underive
+in-ns
+iterator-seq
+declare
+ancestors
+locking
+partition
+contains?
+update-proxy
+interpose
+aset-int
+ifn?
+load-file
+delay
+apply
+swap!
+defmulti
+proxy
+subvec
+rest
+keyword
+ns-map
+unquote
+int
+release-pending-sends
+mod
+bigdec
+nfirst
+nthnext
+*agent*
+aset-long
+struct
+array-map
+bigint
+dec
+println
+aget
+pr
+drop
+*print-dup*
+gen-class
+eval
+unchecked-remainder
+aclone
+char-name-string
+pop
+primitives-classnames
+atom
+defonce
+bit-shift-right
+delay?
+num
+disj
+io!
+*print-readably*
+rational?
+merge-with
+take-nth
+*print-meta*
+double
+lazy-seq
+*in*
+line-seq
+take
+when
+areduce
+set?
+make-array
+alias
+use
+if
+alength
+*source-path*
+to-array
+hash-map
+bit-and-not
+compare-and-set!
+type
+repeatedly
+trampoline
+remove
+find
+coll?
+drop-while
+not-empty
+print-special-doc
+println-str
+list
+every?
+flush
+sort
+dissoc
+not
+binding
+doc
+agent
+sorted-set
+alter-var-root
+merge
+subseq
+min
+print-simple
+bit-test
+await-for
+meta
+unchecked-divide
+rename-keys
+union
+select
+project
+join
+intersection
+map-invert
+difference
+rename
+index
+content-handler
+*stack*
+attrs
+element
+tag
+startparse-sax
+*current*
+content
+*state*
+parse
+emit-element
+*sb*
+emit
+lefts
+down
+insert-left
+up
+next
+path
+children
+vector-zip
+append-child
+zipper
+branch?
+end?
+leftmost
+edit
+replace
+insert-right
+root
+insert-child
+prev
+seq-zip
+xml-zip
+make-node
+rights
+node
+right
+left
+remove
+rightmost
Index: files/completions.clj
===================================================================
--- files/completions.clj	(revision 0)
+++ files/completions.clj	(revision 0)
@@ -0,0 +1,4 @@
+(def completions (keys (ns-publics (find-ns 'clojure.core))))
+ 
+(with-open [f (java.io.BufferedWriter. (java.io.FileWriter. ".clj_completions"))]
+    (.write f (apply str (interleave completions (repeat "\n")))))
\ No newline at end of file
Index: files/clj-rlwrap.sh
===================================================================
--- files/clj-rlwrap.sh	(revision 0)
+++ files/clj-rlwrap.sh	(revision 0)
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+# clj - Clojure launcher script
+
+BREAK_CHARS="\(\){}[],^%$#@\"\";:''|\\"
+
+cljjar='lib/clojure.jar'
+cljclass='clojure.lang.Repl'
+cljscript='clojure.lang.Script'
+cljcompletions='.clj_completions'
+
+dir=$0
+while [ -h "$dir" ]; do
+    ls=`ls -ld "$dir"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+
+    if expr "$link" : '/.*' > /dev/null; then
+        dir="$link"
+    else
+        dir=`dirname "$dir"`"/$link"
+    fi
+done
+
+dir=`dirname $dir`
+dir=`cd "$dir" > /dev/null && pwd`
+cljjar="$dir/../$cljjar"
+cljcompletions="$dir/../$cljcompletions"
+
+if [ $# -eq 0 ]; then
+  rlwrap --remember -c -b $BREAK_CHARS -f $cljcompletions \
+           java -cp $cljjar $cljclass
+else
+  scriptname=$1
+  exec java -classpath $cljjar $cljscript $scriptname --$*
+fi
+
Index: Portfile
===================================================================
--- Portfile	(revision 48862)
+++ Portfile	(working copy)
@@ -3,7 +3,7 @@
 PortSystem          1.0
 
 name                clojure
-version             20081217
+version             20090320
 categories          lang java
 maintainers         cs.wm.edu:mpd
 description         The Clojure programming language
@@ -17,9 +17,9 @@
 distname            clojure_${version}
 master_sites        googlecode:clojure
 
-checksums           md5 cf0f4c27d30ae7cd675f401e169b17e7 \
-                    sha1 b05ada05a975d3f54fbd58e333417af773853c94 \
-                    rmd160 ed132b4b755f5fc14b11f491a0eb9acbd8d8dd45
+checksums           md5 0bbd1f6f889dded06ce0fe18381f150c \
+                    sha1 b3c4db893a2d619fca7ba302301baaab93e9211a \
+                    rmd160 b4d278aaf80cbe3fc5ea89c58244f81ba12e07ae
 distname            ${name}_${version}
 use_zip             yes
 
@@ -30,6 +30,10 @@
     depends_run-append port:jline
 }
 
+variant rlwrap description {Use rlwrap support for tab completion, parenthesis matching} {
+    depends_run-append port:rlwrap
+}
+
 destroot {
     set javadir ${destroot}${prefix}/share/java
     set clojuredir ${javadir}/clojure
@@ -43,11 +47,20 @@
         set clojuresh clj-jline.sh
     }
     
+    if {[variant_isset rlwrap]} {
+        set clojuresh clj-rlwrap.sh
+    }
+    
     xinstall -m 0755 -d ${javadir}
     xinstall -m 0755 -d ${clojuredir}
     xinstall -m 0755 -d ${clojuredir}/lib
     xinstall -m 0755 -d ${clojuredir}/bin
     xinstall -m 0644 -W ${workpath} ${name}/clojure.jar ${clojurejar}
     xinstall -m 0755 -W ${filespath} ${clojuresh} ${clojurebin}
+    
+    if {[variant_isset rlwrap]} {
+        xinstall -m 0644 -W ${filespath} .clj_completions  ${clojuredir}/.clj_completions
+    }
+    
     ln -s ${clojurelink} ${bindir}/clj
 }
