summaryrefslogtreecommitdiff
path: root/vim/bundle/slimv/swank-clojure/swank/clj_contrib
diff options
context:
space:
mode:
Diffstat (limited to 'vim/bundle/slimv/swank-clojure/swank/clj_contrib')
-rw-r--r--vim/bundle/slimv/swank-clojure/swank/clj_contrib/macroexpand.clj17
-rw-r--r--vim/bundle/slimv/swank-clojure/swank/clj_contrib/pprint.clj34
2 files changed, 51 insertions, 0 deletions
diff --git a/vim/bundle/slimv/swank-clojure/swank/clj_contrib/macroexpand.clj b/vim/bundle/slimv/swank-clojure/swank/clj_contrib/macroexpand.clj
new file mode 100644
index 0000000..8cb052b
--- /dev/null
+++ b/vim/bundle/slimv/swank-clojure/swank/clj_contrib/macroexpand.clj
@@ -0,0 +1,17 @@
+(ns swank.clj-contrib.macroexpand)
+
+(def
+ #^{:private true}
+ walk-enabled?
+ (.getResource (clojure.lang.RT/baseLoader) "clojure/contrib/macro_utils.clj"))
+
+(when walk-enabled?
+ (require 'clojure.contrib.macro-utils))
+
+(defmacro macroexpand-all* [form]
+ (if walk-enabled?
+ `(clojure.contrib.macro-utils/mexpand-all ~form)
+ `(macroexpand ~form)))
+
+(defn macroexpand-all [form]
+ (macroexpand-all* form)) \ No newline at end of file
diff --git a/vim/bundle/slimv/swank-clojure/swank/clj_contrib/pprint.clj b/vim/bundle/slimv/swank-clojure/swank/clj_contrib/pprint.clj
new file mode 100644
index 0000000..b10df5f
--- /dev/null
+++ b/vim/bundle/slimv/swank-clojure/swank/clj_contrib/pprint.clj
@@ -0,0 +1,34 @@
+(ns swank.clj-contrib.pprint)
+
+(def #^{:private true} pprint-enabled?
+ (try ;; 1.2+
+ (.getResource (clojure.lang.RT/baseLoader) "clojure/pprint")
+ (require '[clojure.pprint :as pp])
+ (defmacro #^{:private true} pretty-pr-code*
+ ([code]
+ (if pprint-enabled?
+ `(binding [pp/*print-suppress-namespaces* true]
+ (pp/with-pprint-dispatch pp/code-dispatch
+ (pp/write ~code :pretty true :stream nil)))
+ `(pr-str ~code))))
+ true
+ (catch Exception e
+ (try ;; 1.0, 1.1
+ (.loadClass (clojure.lang.RT/baseLoader)
+ "clojure.contrib.pprint.PrettyWriter")
+ (require '[clojure.contrib.pprint :as pp])
+ (defmacro #^{:private true} pretty-pr-code*
+ ([code]
+ (if pprint-enabled?
+ `(binding [pp/*print-suppress-namespaces* true]
+ (pp/with-pprint-dispatch pp/*code-dispatch*
+ (pp/write ~code :pretty true :stream nil)))
+ `(pr-str ~code))))
+ true
+ ;; if you just don't have contrib, be silent.
+ (catch ClassNotFoundException _)
+ (catch Exception e
+ (println e))))))
+
+(defn pretty-pr-code [code]
+ (pretty-pr-code* code))