Welcome! Please see the About page for a little more info on how this works.

+4 votes
in REPL by
edited by

Having access to a list of every interned keyword in the runtime is useful for implementing editor auto-completion and other editor integration features.

Currently, most tooling does something like this:

user=> (let [field (.getDeclaredField clojure.lang.Keyword "table")] (.setAccessible field true) (map keyword (.keySet (.get field nil))))
(:target :clojure.main/message :clojure.spec.alpha/unknown :datafy :clojure.core.specs.alpha/prefix :dir :clojure.core.specs.alpha/binding-form :allow ...)

However, this approach relies on reflection to grab hold of a private, static field. The underlying bits are presumably (albeit unlikely) subject to change without notice.

Would it be possible to add a function into clojure.core that returns a list of all keywords in the runtime? Perhaps (all-keywords) (like (all-ns)). Or perhaps a public static method to clojure.lang.Keyword?

See also grep.app results for this pattern.

1 Answer

0 votes
selected by