Hi Group,

does anybody else think that clojure.repl/apropos should indicate
which namespaces the Vars whose names it returns reside in? In other
words, should (apropos "ref") return

    (swank.commands.inspector/ref-pop
swank.commands.inspector/ns-refers-by-ns ...)

rather than the current

    (ref-pop ns-refers-by-ns ...)

(note presence of the namespace component in the symbols in the
proposed output and the lack thereof in the current output)?

Here's a modified version which acts as proposed:

(defn apropos*
  [str-or-pattern]
  (let [matches? (if (instance? java.util.regex.Pattern str-or-pattern)
                   #(re-find str-or-pattern (str %))
                   #(.contains (str %) (str str-or-pattern)))]
    (mapcat (fn [ns]
              (->> (ns-publics ns)
                   keys
                   (filter matches?)
                   (map #(symbol (name (.name ns)) (name %)))))
            (all-ns))))

I was thinking about allowing symbols to be used in place of strings
too, but that's less important in my eyes.

Sincerely,
Michał

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