Skip to content

Instantly share code, notes, and snippets.

@uwo
Last active June 28, 2018 14:32
Show Gist options
  • Save uwo/d702e3ceabd783ea7787afecdb0d470c to your computer and use it in GitHub Desktop.
Save uwo/d702e3ceabd783ea7787afecdb0d470c to your computer and use it in GitHub Desktop.
pspit
{:paths ["."]}
(ns pspit)
(def improved-pprint (. clojure.pprint/simple-dispatch addMethod datomic.db.DbId #(.write *out* (str %))))
(defn pformat
([data] (pformat data 72))
([data print-right-margin]
(clojure.pprint/with-pprint-dispatch improved-pprint
(with-out-str
(binding [clojure.pprint/*print-right-margin* print-right-margin]
(clojure.pprint/pprint data))))))
(defn pspit
([filename data] (spit filename (pformat data)))
([filename data print-right-margin] (spit filename (pformat data print-right-margin))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment