Reputation: 4513
I have namespace with debug utilities that are used only in development. I'd like to make them accessible in all namespaces without qualifier (same as symbols from clojure.core
).
Let's say my project structure is as follows:
dbg_utils.clj:
(ns project.dbg-utils)
(defmacro dbg ...)
db.clj
(ns project.db)
(defn create-entity [...]
...)
After I'd like to fire up REPL and type something like this:
> (require 'project.db)
> (require 'project.dbg-utils)
> (globalize-symbol 'project.dbg-utils/dbg)
And after use dbg
macro without qualifier:
(ns project.db) ;; no require of project.dbg-utils
(defn create-entity [...]
(dbg ...) ;; and no qualifier here
...)
Is anything like globalize-symbol
(or close to this) available?
Upvotes: 2
Views: 172
Reputation: 9930
Leiningen provides the :injections
feature and the :user
profile for that.
This article shares some pointers on how to do that. It basically works by adding the debugging functions you want to clojure.core
and since all public vars from this namespace are always included when using the ns
macro (unless you specify otherwise), you will have them available in all your namespaces.
Upvotes: 2