This is very useful. For me it was useful to be able to limit the
output to lines that contained a few selected letters.

(show String "pper")
===  public final java.lang.String  ===
[82] toUpperCase : String ()
[83] toUpperCase : String (Locale)
nil

I could always C-C C-O to flush the long output, but I still
had to look through it. The change is obvious, but I'll copy it in
anyway. If you do change it, I can learn how to do it right. Thanks
again.

(defn show
  "With one arg, lists all static and instance members of the given
  class, or the class of the given object.  Each entry is listed with
  a number.  Use that number as the second argument, and that member
  will be returned which at the REPL can be used to get  more detail
  Use a String as the second argument to limit output to strings
  that contain the second argument.

  Examples: (show Integer)  (show [])  (show String 23) (show String
substr)"
  ([x] (show x nil))
  ([x int-or-str]
      (let [c (if (class? x) x (class x))
            items (sort (for [m (concat (.getFields c)
                                        (.getMethods c)
                                        (.getConstructors c))]
                          (member-vec m)))]
        (if (instance? Number int-or-str)
          (last (nth items int-or-str))
          (do
            (println "=== " (Modifier/toString (.getModifiers c)) c "
===")
            (doseq [[i e] (indexed items)]
                (if (or (nil? int-or-str) (.contains (second e) int-or-str))
                  (printf "[%2d] %s\n" i (second e)))))))))


--~--~---------~--~----~------------~-------~--~----~
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
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