annotate src/rlm/rlm_commands.clj @ 1:8565803376a4

upgrading source to work with clojure 1.4
author Robert McIntyre <rlm@mit.edu>
date Tue, 28 Feb 2012 13:26:34 -0600
parents 78a630e650d2
children b8bbb0dbda7b
rev   line source
rlm@0 1 (ns rlm.rlm-commands
rlm@1 2 (:use rlm.ns-rlm)
rlm@0 3 (:use clojure.java.javadoc))
rlm@0 4
rlm@0 5
rlm@1 6 ;; (defn current-directory [] (ds/file-str "/home/r/mobius"))
rlm@0 7
rlm@1 8 ;; (defn file-re [regex & {:keys [dir recurse] :or
rlm@1 9 ;; {dir (current-directory) recurse false}}]
rlm@1 10 ;; (let [dir (ds/file-str dir)]
rlm@1 11 ;; (filter (fn [file] (re-matches regex (.getName file)))
rlm@1 12 ;; (if recurse
rlm@1 13 ;; (file-seq dir)
rlm@1 14 ;; (seq (.listFiles dir))))))
rlm@0 15
rlm@0 16 (defmacro undef
rlm@0 17 "removes symbol from the current namespace"
rlm@0 18 [& symbols]
rlm@0 19 `(dorun (map (partial ns-unmap *ns*) (quote ~symbols))))
rlm@0 20
rlm@0 21 (defn ns-reset-fn
rlm@0 22 "unmaps all interned symbols from the current namespace (except in-ns and ns)"
rlm@0 23 ([ns-name]
rlm@0 24 (map (fn [s] (ns-unmap ns-name s))
rlm@0 25 (keys (ns-interns ns-name)))))
rlm@0 26
rlm@0 27 (defmacro ns-reset
rlm@0 28 "unmaps all symbols from the current namespace (except in-ns and ns)"
rlm@0 29 ([ns-name] `(ns-clear-fn (quote ~ns-name)))
rlm@0 30 ([] `(ns-clear-fn (quote ~(symbol (str *ns*))))))
rlm@0 31
rlm@0 32 (defmacro ns-nuke-old
rlm@0 33 ([]
rlm@0 34 (let [current-ns# (symbol (str *ns*))]
rlm@0 35 `(do
rlm@0 36 (println "NUKING namespace" (quote ~current-ns#))
rlm@0 37 (clojure.lang.Namespace/remove (quote ~current-ns#))
rlm@0 38 (ns ~current-ns#)))))
rlm@0 39
rlm@0 40 (defmacro ns-nuke
rlm@0 41 "Removes all symbols and all referenced symbols. Use as a last
rlm@0 42 resort."
rlm@0 43 ([]
rlm@0 44 (let [current-ns# (symbol (str *ns*))]
rlm@0 45 `(ns-nuke ~current-ns#)))
rlm@0 46 ([ns]
rlm@0 47 `(do
rlm@0 48 (println "NUKING namespace" (quote ~ns))
rlm@0 49 (clojure.lang.Namespace/remove (quote ~ns))
rlm@0 50 (ns ~ns))))
rlm@0 51
rlm@0 52 (defmacro reload []
rlm@0 53 `(do
rlm@0 54 (rlm.rlm-commands/ns-nuke)
rlm@0 55 (clojure.core/use
rlm@0 56 :reload-all
rlm@0 57 (clojure.core/symbol (clojure.core/str clojure.core/*ns*)))))
rlm@0 58
rlm@0 59 (defmacro re "faster"
rlm@0 60 []
rlm@0 61 `(do
rlm@0 62 (rlm.rlm-commands/ns-nuke)
rlm@0 63 (clojure.core/use :reload
rlm@0 64 (clojure.core/symbol (clojure.core/str clojure.core/*ns*)))))
rlm@0 65
rlm@1 66 ;; (defn keymap-clojure []
rlm@1 67 ;; (rlm.shell-write/sw "xmodmap" "/home/r/.xmodmap.clojure"))
rlm@0 68
rlm@1 69 ;; (defn keymap-normal []
rlm@1 70 ;; (rlm.shell-write/sw "xmodmap" "/home/r/.xmodmap.normal"))
rlm@0 71
rlm@1 72 ;; (defn rlm []
rlm@1 73 ;; (clojure.core/require 'rlm.light-base)
rlm@1 74 ;; (rlm.ns-rlm/ns-clone rlm.light-base))
rlm@0 75
rlm@0 76 (defn help
rlm@0 77 "load a bunch of really useful help functions"
rlm@0 78 []
rlm@0 79 (use
rlm@0 80 '[rlm
rlm@1 81 [function-utils :only [mix defmix]]
rlm@1 82 [rlm-commands :only
rlm@1 83 [undef ns-reset ns-nuke reload re]]
rlm@1 84 [ns-rlm :only [ls]]
rlm@1 85 ;;[play-all :only [play-all-music]]
rlm@0 86 [shell-inspect :only [command-line?]]
rlm@1 87 ;;[shell-write :only [sw]]
rlm@1 88 ;;[classpath-utils :only [classpath add-to-classpath]]
rlm@0 89 [dreams :only [megadef silence]]
rlm@0 90 [map-utils :only [map-keys map-vals filter-keys filter-vals]]
rlm@0 91 [visualize :only [visual]]
rlm@0 92 [identify :only [identify]]]
rlm@1 93
rlm@1 94 ;;'[abomination.no-parens :only [quit]]
rlm@0 95
rlm@1 96 ;; TODO find replacement for show
rlm@0 97 '[clojure
rlm@0 98 [repl :only [source]]]
rlm@1 99 '[clojure.java
rlm@1 100 [javadoc :only [javadoc add-local-javadoc]]])
rlm@0 101 (clojure.java.javadoc/add-local-javadoc "/home/r/cortex/jme3/dist/javadoc")
rlm@0 102 (clojure.java.javadoc/add-local-javadoc "/home/r/roBin/jdk6-docs/docs/api")
rlm@0 103 (clojure.java.javadoc/add-local-javadoc
rlm@0 104 "/home/r/roBin/lpsolve-doc/lpsolve.sourceforge.net/5.5/Java/docs/api")
rlm@0 105 (clojure.java.javadoc/add-local-javadoc
rlm@0 106 "/home/r/roBin/lpsolve-doc/lpsolve.sourceforge.net/5.5/Java/docs/api")
rlm@0 107
rlm@0 108 nil)
rlm@0 109
rlm@0 110
rlm@0 111