AbhinavOmprakash / snitch

Snitch injects inline defs in your functions and multimethods. This enables a repl-based, editor-agnostic, clojure and clojurescript debugging workflow. It is inline-defs on steroids.
Other
137 stars 2 forks source link

globally define `defn*` #33

Closed Sohalt closed 1 year ago

Sohalt commented 1 year ago

(if you know a way to globally define defn* for all namespaces let me know yesterday!)

How about

(doseq [ns (all-ns)]
  (binding [*ns* ns]
    (require '[snitch.core :refer [defn*]])))

?

AbhinavOmprakash commented 1 year ago

Hey, That is a good suggestion. I hadn't thought about that.

I solved it a while back by interning the macros in the clj.core namespace

#?(:clj (do (intern 'clojure.core (with-meta 'defn* (meta #'defn*)) #'defn*)
            (intern 'clojure.core (with-meta '*fn (meta #'*fn)) #'*fn)
            (intern 'clojure.core (with-meta 'defmethod* (meta #'defmethod*)) #'defmethod*)
            (intern 'clojure.core (with-meta '*let (meta #'*let)) #'*let)
            (try
              (intern 'cljs.core (with-meta 'defn* (meta #'defn*)) #'defn*)
              (intern 'cljs.core (with-meta '*fn (meta #'*fn)) #'*fn)
              (intern 'cljs.core (with-meta 'defmethod* (meta #'defmethod*)) #'defmethod*)
              (intern 'cljs.core (with-meta '*let (meta #'*let)) #'*let)
              (catch Exception _))))

I still need to create a release with these changes.