summaryrefslogtreecommitdiff
path: root/vim/bundle/slimv/swank-clojure/leiningen
diff options
context:
space:
mode:
Diffstat (limited to 'vim/bundle/slimv/swank-clojure/leiningen')
-rw-r--r--vim/bundle/slimv/swank-clojure/leiningen/swank.clj30
1 files changed, 30 insertions, 0 deletions
diff --git a/vim/bundle/slimv/swank-clojure/leiningen/swank.clj b/vim/bundle/slimv/swank-clojure/leiningen/swank.clj
new file mode 100644
index 0000000..d3875b8
--- /dev/null
+++ b/vim/bundle/slimv/swank-clojure/leiningen/swank.clj
@@ -0,0 +1,30 @@
+(ns leiningen.swank
+ "Launch swank server for Emacs to connect."
+ (:use [leiningen.compile :only [eval-in-project]])
+ (:import [java.io File]))
+
+(defn swank-form [project port host opts]
+ ;; bootclasspath workaround: http://dev.clojure.org/jira/browse/CLJ-673
+ (when (:eval-in-leiningen project)
+ (require '[clojure walk template stacktrace]))
+ `(do
+ (let [is# ~(:repl-init-script project)]
+ (when (.exists (File. (str is#)))
+ (load-file is#)))
+ (require '~'swank.swank)
+ (require '~'swank.commands.basic)
+ (@(ns-resolve '~'swank.swank '~'start-repl)
+ (Integer. ~port) ~@(concat (map read-string opts)
+ [:host host]))
+ ;; This exits immediately when using :eval-in-leiningen; must block
+ (when ~(:eval-in-leiningen project)
+ (doseq [t# ((ns-resolve '~'swank.commands.basic
+ '~'get-thread-list))]
+ (.join t#)))))
+
+(defn swank
+ "Launch swank server for Emacs to connect. Optionally takes PORT and HOST."
+ ([project port host & opts]
+ (eval-in-project project (swank-form project port host opts)))
+ ([project port] (swank project port "localhost"))
+ ([project] (swank project 4005)))