From c012f55efda29f09179e921cf148d79deb57616e Mon Sep 17 00:00:00 2001 From: Nick Shipp Date: Sun, 7 May 2017 09:04:01 -0400 Subject: Much maturering of vim configs --- .../swank/clj_contrib/macroexpand.clj | 17 +++++++++++ .../swank-clojure/swank/clj_contrib/pprint.clj | 34 ++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 vim/bundle/slimv/swank-clojure/swank/clj_contrib/macroexpand.clj create mode 100644 vim/bundle/slimv/swank-clojure/swank/clj_contrib/pprint.clj (limited to 'vim/bundle/slimv/swank-clojure/swank/clj_contrib') 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)) -- cgit v1.2.3-70-g09d2