jvm.tool

REPL hotkeys and development-tool injection

Configure numbered hotkey functions and expose commonly used reflection, build, test, documentation, and namespace tools in the short s namespace.

1    Overview

Loading jvm.tool prepares an interactive development environment. It links reflection macros into clojure.core, creates the s helper namespace, and resolves linked tool vars after their defining namespaces become available.

2    Walkthrough

2.1    Configure a hotkey

(require '[jvm.tool :as tool])

(tool/hotkey-set
 1
 (fn []
   (println "refreshing")))

(tool/hotkey-1)

2.2    Use the helper namespace

The injected s namespace provides short references to frequently used project, test, build, documentation, logging, and namespace-management functions. Treat it as a REPL convenience rather than an application dependency.

(s/force-require 'example.application)
(s/run :all)
(s/publish '[std])

3    Initialization behavior

Because this namespace intentionally modifies linked vars and print preferences, require it from a user or development profile rather than production library code.

4    API



+init+ ^

NONE
(def +init+
  (do 
    (prefer-method print-method clojure.lang.IDeref java.util.Map)
    (prefer-method print-method clojure.lang.IDeref clojure.lang.IPersistentMap)
    (prefer-method clojure.pprint/simple-dispatch clojure.lang.IDeref java.util.Map)
    (prefer-method clojure.pprint/simple-dispatch clojure.lang.IDeref clojure.lang.IPersistentMap)))
link

+inject-vars+ ^

NONE
(def +inject-vars+ (-> (do (inject-reflectors)
                           (inject-tools)
                           (l/link:resolve-all))
                       
                       (future/on:success
                        (fn [_]
                          ))))
link

hotkey-0 ^

NONE
(def hotkey-0 (fn []))
link

hotkey-1 ^

NONE
(def hotkey-1 (fn []))
link

hotkey-2 ^

NONE
(def hotkey-2 (fn []))
link

hotkey-3 ^

NONE
(def hotkey-3 (fn []))
link

hotkey-4 ^

NONE
(def hotkey-4 (fn []))
link

hotkey-5 ^

NONE
(def hotkey-5 (fn []))
link

hotkey-6 ^

NONE
(def hotkey-6 (fn []))
link

hotkey-7 ^

NONE
(def hotkey-7 (fn []))
link

hotkey-8 ^

NONE
(def hotkey-8 (fn []))
link

hotkey-9 ^

NONE
(def hotkey-9 (fn []))
link

hotkey-set ^

[idx f]
Added 4.0

set the hotkey function

v 4.0
(defn hotkey-set
  [idx f]
  (case (long idx)
    0 (alter-var-root #'hotkey-0 (fn [_] f))
    1 (alter-var-root #'hotkey-1 (fn [_] f))
    2 (alter-var-root #'hotkey-2 (fn [_] f))
    3 (alter-var-root #'hotkey-3 (fn [_] f))
    4 (alter-var-root #'hotkey-4 (fn [_] f))
    5 (alter-var-root #'hotkey-5 (fn [_] f))
    6 (alter-var-root #'hotkey-6 (fn [_] f))
    7 (alter-var-root #'hotkey-7 (fn [_] f))
    8 (alter-var-root #'hotkey-8 (fn [_] f))
    9 (alter-var-root #'hotkey-9 (fn [_] f))))
link
(let [original @#'hotkey-0] (try (hotkey-set 0 (constantly :ok)) [(fn? @#'hotkey-0) (@#'hotkey-0)] (finally (hotkey-set 0 original)))) => [true :ok]

inject-reflectors ^

[]

NONE
(defn- inject-reflectors
  []
  (l/link {:ns clojure.core}
          ;;jvm.tool/forange
          jvm.reflect/.%
          jvm.reflect/.%>
          jvm.reflect/.?
          jvm.reflect/.?*
          jvm.reflect/.?>
          jvm.reflect/.*
          jvm.reflect/.*>
          jvm.reflect/.&))
link

inject-tools ^

[]

NONE
(defn- inject-tools
  []
  (create-ns 's)
  (l/link {:ns s}
          jvm.tool/hotkey-0
          jvm.tool/hotkey-1
          jvm.tool/hotkey-2
          jvm.tool/hotkey-3
          jvm.tool/hotkey-4
          jvm.tool/hotkey-5
          jvm.tool/hotkey-6
          jvm.tool/hotkey-7
          jvm.tool/hotkey-8
          jvm.tool/hotkey-set
          jvm.require/force-require)
  
  (l/link {:ns s}
          std.log/with-logger-basic
          std.log/spy
          std.log/trace

          std.block/layout)
  
  (l/link {:ns s}
          lib.aether/pull
          lib.aether/push
          
          jvm.artifact.search/class-seq
          
          code.project/project
          code.project/all-files
          code.test/run
          code.test/run:interrupt
          code.test/run:load
          code.test/run:test
          code.test/run-errored
          code.tool.java.compile/javac

          code.tool.maven/linkage
          code.tool.maven/package
          code.tool.maven/install
          code.tool.maven/deploy
          code.tool.maven/deploy-lein
          code.manage/vars
          code.manage/locate-code
          code.manage/grep
          code.manage/grep-replace
          code.manage/incomplete
          code.manage/import
          code.manage/scaffold
          code.manage/arrange
          code.manage/create-tests
          code.manage/purge
          code.manage/orphaned
          code.manage/missing
          code.manage/todos
          code.manage/unchecked
          code.manage/commented
          code.manage/in-order?
          code.manage/pedantic
          code.manage/heal-code
          code.manage/transform-code
          code.manage/snapto

          hara.seedgen/seedgen-list
          hara.seedgen/seedgen-incomplete
          hara.seedgen/seedgen-benchadd
          hara.seedgen/seedgen-benchremove
          hara.seedgen/seedgen-benchlist
          hara.seedgen/seedgen-benchadd
          hara.seedgen/seedgen-root
          hara.seedgen/seedgen-langadd
          hara.seedgen/seedgen-langremove
          hara.seedgen/seedgen-readforms
          
          code.doc/publish
          code.doc/init-template
          code.doc/deploy-template
          jvm.namespace/reset
          jvm.namespace/reload
          jvm.namespace/reeval
          jvm.namespace/clear
          jvm.namespace/clear-aliases
          jvm.namespace/clear-interns
          jvm.namespace/clear-refers
          jvm.namespace/list-loaded))
link