diff 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
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/rlm/rlm_commands.clj	Tue Oct 18 00:57:08 2011 -0700
     1.3 @@ -0,0 +1,126 @@
     1.4 +(ns rlm.rlm-commands
     1.5 +  (:require  [rlm ns-rlm shell-write]
     1.6 +	     [clojure.contrib [duck-streams :as ds]])
     1.7 +  (:use [clojure.contrib java-utils])
     1.8 +  (:use clojure.java.javadoc))
     1.9 +
    1.10 +
    1.11 +(defn current-directory [] (ds/file-str "/home/r/mobius"))
    1.12 +
    1.13 +(defn file-re [regex & {:keys [dir recurse] :or
    1.14 +			{dir (current-directory) recurse false}}]
    1.15 +  (let [dir (ds/file-str dir)]
    1.16 +    (filter (fn [file] (re-matches regex (.getName file)))
    1.17 +	    (if recurse
    1.18 +	      (file-seq dir)
    1.19 +	      (seq (.listFiles dir))))))
    1.20 +
    1.21 +(defmacro undef
    1.22 +  "removes symbol from the current namespace"
    1.23 +  [& symbols]
    1.24 + 
    1.25 +  `(dorun (map (partial ns-unmap *ns*) (quote ~symbols))))
    1.26 +
    1.27 +
    1.28 +(defn ns-reset-fn
    1.29 +  "unmaps all interned symbols from the current namespace (except in-ns and ns)"
    1.30 +  ([ns-name]
    1.31 +     (map (fn [s] (ns-unmap ns-name s))
    1.32 +	  (keys (ns-interns ns-name)))))
    1.33 +
    1.34 +(defmacro ns-reset
    1.35 +  "unmaps all symbols from the current namespace (except in-ns and ns)"
    1.36 +  ([ns-name] `(ns-clear-fn (quote ~ns-name)))
    1.37 +  ([] `(ns-clear-fn (quote ~(symbol (str *ns*))))))
    1.38 +
    1.39 +(defmacro ns-nuke-old
    1.40 +  ([]
    1.41 +     (let [current-ns# (symbol (str *ns*))]
    1.42 +       `(do 
    1.43 +	  (println "NUKING namespace" (quote ~current-ns#))
    1.44 +	  (clojure.lang.Namespace/remove  (quote ~current-ns#))
    1.45 +	  (ns ~current-ns#)))))
    1.46 +
    1.47 +(defmacro ns-nuke
    1.48 +  "Removes all symbols and all referenced symbols. Use as a last
    1.49 +   resort."
    1.50 +  ([]
    1.51 +     (let [current-ns# (symbol (str *ns*))]
    1.52 +       `(ns-nuke ~current-ns#)))
    1.53 +  ([ns]
    1.54 +     `(do
    1.55 +	(println "NUKING namespace" (quote ~ns))
    1.56 +	(clojure.lang.Namespace/remove  (quote ~ns))
    1.57 +	(ns ~ns))))
    1.58 +
    1.59 +(defmacro reload []
    1.60 +  `(do
    1.61 +     (rlm.ns-rlm/ns-clear)
    1.62 +     (use :reload-all (quote ~(symbol (str *ns*))))))
    1.63 +
    1.64 +(defmacro reload []
    1.65 +  `(do
    1.66 +     (rlm.rlm-commands/ns-nuke)
    1.67 +     (clojure.core/use
    1.68 +      :reload-all
    1.69 +      (clojure.core/symbol (clojure.core/str clojure.core/*ns*)))))
    1.70 +
    1.71 +(defmacro re "faster"
    1.72 +  []
    1.73 +  `(do
    1.74 +     (rlm.rlm-commands/ns-nuke)
    1.75 +     (clojure.core/use :reload
    1.76 +      (clojure.core/symbol (clojure.core/str clojure.core/*ns*)))))
    1.77 +
    1.78 +(defn keymap-clojure []
    1.79 +  (rlm.shell-write/sw "xmodmap" "/home/r/.xmodmap.clojure"))
    1.80 +
    1.81 +
    1.82 +
    1.83 +(defn keymap-normal []
    1.84 +  (rlm.shell-write/sw "xmodmap" "/home/r/.xmodmap.normal"))
    1.85 +
    1.86 +
    1.87 +(defn rlm []
    1.88 +  (clojure.core/require 'rlm.light-base)
    1.89 +  (rlm.ns-rlm/ns-clone rlm.light-base))
    1.90 +
    1.91 +
    1.92 +(defn help
    1.93 +  "load a bunch of really useful help functions"
    1.94 +  []
    1.95 +  (use
    1.96 +   '[rlm
    1.97 +     [function-utils :only [mix defmix runonce]]
    1.98 +     [rlm-commands :only [undef ns-reset ns-nuke reload keymap-clojure keymap-normal rlm]]
    1.99 +     [ns-rlm :only [ns-clear ns-clone ls]]
   1.100 +     [play-all :only [play-all-music]]
   1.101 +     [shell-inspect :only [command-line?]]
   1.102 +     [shell-write :only [sw]]
   1.103 +     [classpath-utils :only [classpath add-to-classpath]]
   1.104 +     [dreams :only [megadef silence]]
   1.105 +     [map-utils :only [map-keys map-vals filter-keys filter-vals]]
   1.106 +     [visualize :only [visual]]
   1.107 +     [identify :only [identify]]]
   1.108 +   '[abomination.no-parens :only [quit]]
   1.109 +   
   1.110 +   
   1.111 +   '[clojure.contrib
   1.112 +     [duck-streams :only [file-str read-lines]]
   1.113 +     [str-utils :only [re-split re-gsub str-join]]
   1.114 +     [repl-utils :only [show expression-info]]]
   1.115 +    '[clojure
   1.116 +      [repl :only [source]]]
   1.117 +     '[clojure.java
   1.118 +       [javadoc :only [javadoc add-local-javadoc]]])
   1.119 +  (clojure.java.javadoc/add-local-javadoc "/home/r/cortex/jme3/dist/javadoc")
   1.120 +  (clojure.java.javadoc/add-local-javadoc "/home/r/roBin/jdk6-docs/docs/api")
   1.121 +  (clojure.java.javadoc/add-local-javadoc 
   1.122 +   "/home/r/roBin/lpsolve-doc/lpsolve.sourceforge.net/5.5/Java/docs/api")
   1.123 +  (clojure.java.javadoc/add-local-javadoc 
   1.124 +   "/home/r/roBin/lpsolve-doc/lpsolve.sourceforge.net/5.5/Java/docs/api")
   1.125 +  
   1.126 +  nil)
   1.127 +
   1.128 + 
   1.129 +