Skip to content

Commit a64ab2c

Browse files
mfikesdnolen
authored andcommitted
CLJS-1903: Remove anonymous vars from dir and apropos output
1 parent 7751a39 commit a64ab2c

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/main/clojure/cljs/repl.cljc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,13 @@ itself (not its value) is returned. The reader macro #'x expands to (var x)."}})
12101210
[n]
12111211
`(println ~(or (source-fn &env n) (str "Source not found"))))
12121212

1213+
(defn- named-publics-vars
1214+
"Gets the public vars in a namespace that are not anonymous."
1215+
[ns]
1216+
(->> (ana-api/ns-publics ns)
1217+
(remove (comp :anonymous val))
1218+
(map key)))
1219+
12131220
(defmacro apropos
12141221
"Given a regular expression or stringable thing, return a seq of all
12151222
public definitions in all currently-loaded namespaces that match the
@@ -1224,13 +1231,13 @@ str-or-pattern."
12241231
(fn [ns]
12251232
(let [ns-name (str ns)]
12261233
(map #(symbol ns-name (str %))
1227-
(filter matches? (keys (ana-api/ns-publics ns))))))
1234+
(filter matches? (named-publics-vars ns)))))
12281235
(ana-api/all-ns))))))
12291236

12301237
(defmacro dir
12311238
"Prints a sorted directory of public vars in a namespace"
12321239
[ns]
1233-
`(doseq [sym# (quote ~(sort (keys (ana-api/ns-publics ns))))]
1240+
`(doseq [sym# (quote ~(sort (named-publics-vars ns)))]
12341241
(println sym#)))
12351242

12361243
(defmacro pst

0 commit comments

Comments
 (0)