Mercurial > rlm
comparison src/rlm/rlm_commands.clj @ 0:78a630e650d2
initial import
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 18 Oct 2011 00:57:08 -0700 |
parents | |
children | 8565803376a4 c7df1ea6fd71 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:78a630e650d2 |
---|---|
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 (:use clojure.java.javadoc)) | |
6 | |
7 | |
8 (defn current-directory [] (ds/file-str "/home/r/mobius")) | |
9 | |
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)))))) | |
17 | |
18 (defmacro undef | |
19 "removes symbol from the current namespace" | |
20 [& symbols] | |
21 | |
22 `(dorun (map (partial ns-unmap *ns*) (quote ~symbols)))) | |
23 | |
24 | |
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))))) | |
30 | |
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*)))))) | |
35 | |
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#))))) | |
43 | |
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)))) | |
55 | |
56 (defmacro reload [] | |
57 `(do | |
58 (rlm.ns-rlm/ns-clear) | |
59 (use :reload-all (quote ~(symbol (str *ns*)))))) | |
60 | |
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*))))) | |
67 | |
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*))))) | |
74 | |
75 (defn keymap-clojure [] | |
76 (rlm.shell-write/sw "xmodmap" "/home/r/.xmodmap.clojure")) | |
77 | |
78 | |
79 | |
80 (defn keymap-normal [] | |
81 (rlm.shell-write/sw "xmodmap" "/home/r/.xmodmap.normal")) | |
82 | |
83 | |
84 (defn rlm [] | |
85 (clojure.core/require 'rlm.light-base) | |
86 (rlm.ns-rlm/ns-clone rlm.light-base)) | |
87 | |
88 | |
89 (defn help | |
90 "load a bunch of really useful help functions" | |
91 [] | |
92 (use | |
93 '[rlm | |
94 [function-utils :only [mix defmix runonce]] | |
95 [rlm-commands :only [undef ns-reset ns-nuke reload keymap-clojure keymap-normal rlm]] | |
96 [ns-rlm :only [ns-clear ns-clone ls]] | |
97 [play-all :only [play-all-music]] | |
98 [shell-inspect :only [command-line?]] | |
99 [shell-write :only [sw]] | |
100 [classpath-utils :only [classpath add-to-classpath]] | |
101 [dreams :only [megadef silence]] | |
102 [map-utils :only [map-keys map-vals filter-keys filter-vals]] | |
103 [visualize :only [visual]] | |
104 [identify :only [identify]]] | |
105 '[abomination.no-parens :only [quit]] | |
106 | |
107 | |
108 '[clojure.contrib | |
109 [duck-streams :only [file-str read-lines]] | |
110 [str-utils :only [re-split re-gsub str-join]] | |
111 [repl-utils :only [show expression-info]]] | |
112 '[clojure | |
113 [repl :only [source]]] | |
114 '[clojure.java | |
115 [javadoc :only [javadoc add-local-javadoc]]]) | |
116 (clojure.java.javadoc/add-local-javadoc "/home/r/cortex/jme3/dist/javadoc") | |
117 (clojure.java.javadoc/add-local-javadoc "/home/r/roBin/jdk6-docs/docs/api") | |
118 (clojure.java.javadoc/add-local-javadoc | |
119 "/home/r/roBin/lpsolve-doc/lpsolve.sourceforge.net/5.5/Java/docs/api") | |
120 (clojure.java.javadoc/add-local-javadoc | |
121 "/home/r/roBin/lpsolve-doc/lpsolve.sourceforge.net/5.5/Java/docs/api") | |
122 | |
123 nil) | |
124 | |
125 | |
126 |