Re: ANN: A pretty printer for Clojure

2009-03-14 Thread budu
I just tried it, this is fantastic! We'll finally be able to debug macros while keeping our sanity. Many thanks for this and I hope it will be added directly into Clojure. On Mar 12, 3:05 am, Tom Faulhaber tomfaulha...@gmail.com wrote: I have now released the first version of my pretty printer

ANN: A pretty printer for Clojure

2009-03-12 Thread Tom Faulhaber
I have now released the first version of my pretty printer as part of my cl-format library. It is released under the EPL. The pretty printer has two functions that you probably care about: (pprint obj) will pretty print the given object, and (pp) at the REPL will pretty print the last result

Re: ANN: A pretty printer for Clojure

2009-03-12 Thread Rich Hickey
On Mar 12, 2009, at 3:05 AM, Tom Faulhaber wrote: I have now released the first version of my pretty printer as part of my cl-format library. It is released under the EPL. The pretty printer has two functions that you probably care about: (pprint obj) will pretty print the given object,

Re: ANN: A pretty printer for Clojure

2009-03-12 Thread Jeffrey Straszheim
Awesome! I expect I'll be trying it out tonight. Oh, and I hope this goes into contrib -- it'll keep my classpath shorter. On Thu, Mar 12, 2009 at 2:05 AM, Tom Faulhaber tomfaulha...@gmail.comwrote: I have now released the first version of my pretty printer as part of my cl-format library.

Re: ANN: A pretty printer for Clojure

2009-03-12 Thread David Nolen
Amazing stuff. In particular this finally makes debugging macros sane. For those of you that are using swank-clojure you only need to make minor modifications to swank-clojure to pretty-print your macro expansions to the macro expansion buffer. Even better you can move the cursor to subform

Re: ANN: A pretty printer for Clojure

2009-03-12 Thread Konrad Hinsen
On Mar 12, 2009, at 8:05, Tom Faulhaber wrote: I have now released the first version of my pretty printer as part of my cl-format library. It is released under the EPL. From what I have seen in my first tests, this is likely to become an essential part of my Clojure environment. Thanks!

Re: ANN: A pretty printer for Clojure

2009-03-12 Thread Tom Faulhaber
Rich, I would be happy to make it a contribution (it's the least I can do!). I've had a CA sitting on my desk unread and unsigned for about 3 weeks. It is now read, signed, and in an envelope. I'll send it off this morning. Everyone, Thanks for the kind words. I'm glad you like it. David's

Re: ANN: A pretty printer for Clojure

2009-03-12 Thread Tom Faulhaber
Expanding on David's earlier example of pretty printing, we can set the dispatch to *code-dispatch* and bind *print-suppress-namespaces* to true and get the following (apologies for google messing up my formatting): (do (defmacro dft2 [tree] (seq (concat (list '=dft2) (list '*cont*) (list

Re: ANN: A pretty printer for Clojure

2009-03-12 Thread Tom Faulhaber
Are you planning to include scripts at some point that support pretty printing a source file? For example, I'd like to do this from a terminal window: $ cljpp foo.clj foo2.clj Mark, Yeah, I've thought about that and the simple version is very straight- forward and I'm planning to do that

Re: ANN: A pretty printer for Clojure

2009-03-12 Thread David Nolen
So that people can copy and paste the change in basic.clj (defn- apply-macro-expander [expander string] (binding [*print-suppress-namespaces* true] (let [astr (with-out-str (with-pprint-dispatch *code-dispatch* (pprint (expander (read-from-string string)] (subs astr 0 (dec

Re: ANN: A pretty printer for Clojure

2009-03-12 Thread David Nolen
I suppose the following is more idiomatic: (defn- apply-macro-expander [expander string] (let [astr (with-out-str (binding [*print-suppress-namespaces* true] (with-pprint-dispatch *code-dispatch* (pprint (expander (read-from-string string))] (subs astr 0 (dec (count

Re: ANN: A pretty printer for Clojure

2009-03-12 Thread David Nolen
Works great. On Thu, Mar 12, 2009 at 3:30 PM, Tom Faulhaber tomfaulha...@gmail.comwrote: Write can produce pretty output directly to a string and without the trailing newline, making this a little shorter: (defn- apply-macro-expander [expander string] (binding