vvvvalvalval / scope-capture

Project your Clojure(Script) REPL into the same context as your code when it ran
MIT License
576 stars 14 forks source link

doucmnet possibility to inject into `core.ns` ? #46

Open behrica opened 2 years ago

behrica commented 2 years ago

I have lately discovered that it can be very useful to dynamically inject the sc.api macros into clojure.core.

This makes them available in any ns.

Having this in a file "somewhere" and use load-lib or copy paste from somewhere into the repl, works very well and it might be worth to be documented under tips and tricks.

(ns clojure.core)

(require 'sc.api)
(intern 'clojure.core
        (with-meta 'spy {:macro true})
        @#'sc.api/spy)

(intern 'clojure.core
        (with-meta 'defsc {:macro true})
        @#'sc.api/defsc)

(intern 'clojure.core
        (with-meta 'undefsc {:macro true})
        @#'sc.api/undefsc)

...

This together with a deps.edn alias and some .locals-dir.el magic

makes the sc.api auto-available.