By looking at pprint.clj, I have come up with something that seems to work. 
No "hacking" is necessary - the code in pprint is impressively clear and 
extensible.  It's obviously designed to allow exactly this sort of 
extension to the printing mechanism.

user> (defn ppm [obj]
        (let [orig-dispatch pprint/*print-pprint-dispatch*]
          (pprint/with-pprint-dispatch 
            (fn [o]
              (when (meta o)
                (print "^")
                (orig-dispatch (meta o))
                (pprint/pprint-newline :fill))
              (orig-dispatch o))
            (pprint obj))))
#'user/ppm

user> (ppm elt)
^{:xmlns {"a" "http://aaa/"}, :xmlns-decls {"a" "http://aaa/"}}
{:tag :foo,
 :attrs {},
 :content
 [^{:prefix "a", :xmlns {"a" "http://aaa/"}}
  {:tag :bar, :attrs {}, :content [], :uri "http://aaa/"}
  ^{:xmlns {"a" "http://aaa/"}}
  {:tag :blah,
   :attrs {^{:prefix "a"}[:x "http://aaa/";] "y"},
   :content [],
   :uri nil}],
 :uri nil}
nil
user> 

Works great!  Tom F. is officially my clojure-hero-of-the-day.

thanks,

- Chris

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to