view src/rlm/rlm_commands.clj @ 3:c8e35134bf8e

working on qotd.
author Robert McIntyre <rlm@mit.edu>
date Wed, 18 Jan 2012 05:18:57 -0700
parents c7df1ea6fd71
children 12d1367cf1aa
line wrap: on
line source
1 (ns rlm.rlm-commands
2 (:require [rlm ns-rlm shell-write]
3 [clojure.contrib [duck-streams :as ds]])
4 (:use [clojure.contrib java-utils])
5 (:require clojure.java.javadoc))
8 (defn current-directory [] (ds/file-str "/home/r/mobius"))
10 (defn file-re [regex & {:keys [dir recurse] :or
11 {dir (current-directory) recurse false}}]
12 (let [dir (ds/file-str dir)]
13 (filter (fn [file] (re-matches regex (.getName file)))
14 (if recurse
15 (file-seq dir)
16 (seq (.listFiles dir))))))
18 (defmacro undef
19 "removes symbol from the current namespace"
20 [& symbols]
22 `(dorun (map (partial ns-unmap *ns*) (quote ~symbols))))
25 (defn ns-reset-fn
26 "unmaps all interned symbols from the current namespace (except in-ns and ns)"
27 ([ns-name]
28 (map (fn [s] (ns-unmap ns-name s))
29 (keys (ns-interns ns-name)))))
31 (defmacro ns-reset
32 "unmaps all symbols from the current namespace (except in-ns and ns)"
33 ([ns-name] `(ns-clear-fn (quote ~ns-name)))
34 ([] `(ns-clear-fn (quote ~(symbol (str *ns*))))))
36 (defmacro ns-nuke-old
37 ([]
38 (let [current-ns# (symbol (str *ns*))]
39 `(do
40 (println "NUKING namespace" (quote ~current-ns#))
41 (clojure.lang.Namespace/remove (quote ~current-ns#))
42 (ns ~current-ns#)))))
44 (defmacro ns-nuke
45 "Removes all symbols and all referenced symbols. Use as a last
46 resort."
47 ([]
48 (let [current-ns# (symbol (str *ns*))]
49 `(ns-nuke ~current-ns#)))
50 ([ns]
51 `(do
52 (println "NUKING namespace" (quote ~ns))
53 (clojure.lang.Namespace/remove (quote ~ns))
54 (ns ~ns))))
56 (defmacro reload []
57 `(do
58 (rlm.ns-rlm/ns-clear)
59 (use :reload-all (quote ~(symbol (str *ns*))))))
61 (defmacro reload []
62 `(do
63 (rlm.rlm-commands/ns-nuke)
64 (clojure.core/use
65 :reload-all
66 (clojure.core/symbol (clojure.core/str clojure.core/*ns*)))))
68 (defmacro re "faster"
69 []
70 `(do
71 (rlm.rlm-commands/ns-nuke)
72 (clojure.core/use :reload
73 (clojure.core/symbol (clojure.core/str clojure.core/*ns*)))))
75 (defn keymap-clojure []
76 (rlm.shell-write/sw "xmodmap" "/home/r/.xmodmap.clojure"))
78 (defn keymap-normal []
79 (rlm.shell-write/sw "xmodmap" "/home/r/.xmodmap.normal"))
82 (defn rlm []
83 (clojure.core/require 'rlm.light-base)
84 (rlm.ns-rlm/ns-clone rlm.light-base))
86 (defn javadoc [target]
87 (binding
88 [clojure.java.browse/*open-url-script*
89 "/home/r/proj/repl/get-webpage.pl"]
90 (clojure.java.javadoc/javadoc target)))
93 (defn help
94 "load a bunch of really useful help functions"
95 []
96 (use
97 '[rlm
98 [function-utils :only [mix defmix runonce]]
99 [rlm-commands :only [undef ns-reset ns-nuke reload keymap-clojure
100 keymap-normal rlm javadoc]]
101 [ns-rlm :only [ns-clear ns-clone ls]]
102 [play-all :only [play-all-music]]
103 [shell-inspect :only [command-line?]]
104 [shell-write :only [sw]]
105 [classpath-utils :only [classpath add-to-classpath]]
106 [dreams :only [megadef silence]]
107 [map-utils :only [map-keys map-vals filter-keys filter-vals]]
108 [visualize :only [visual]]
109 [identify :only [identify]]]
110 '[abomination.no-parens :only [quit]]
113 '[clojure.contrib
114 [duck-streams :only [file-str read-lines]]
115 [str-utils :only [re-split re-gsub str-join]]
116 [repl-utils :only [show expression-info]]]
117 '[clojure
118 [repl :only [source]]])
119 (clojure.java.javadoc/add-local-javadoc
120 "/home/r/proj/jMonkeyEngine3/dist/javadoc")
121 (clojure.java.javadoc/add-local-javadoc
122 "/home/r/java/jdk6u30-docs/api")
123 (clojure.java.javadoc/add-local-javadoc
124 "/home/r/java/jdk6u30-docs/jdk/api")
125 (clojure.java.javadoc/add-local-javadoc
126 "/home/r/java/jdk6u30-docs/jre/api")
127 (clojure.java.javadoc/add-local-javadoc
128 "/home/r/proj/jmeCapture/docs")
130 nil)