Mercurial > rlm
view 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 source
1 (ns rlm.rlm-commands2 (:require [rlm ns-rlm shell-write]3 [clojure.contrib [duck-streams :as ds]])4 (:use [clojure.contrib java-utils])5 (:use clojure.java.javadoc))8 (defn current-directory [] (ds/file-str "/home/r/mobius"))10 (defn file-re [regex & {:keys [dir recurse] :or11 {dir (current-directory) recurse false}}]12 (let [dir (ds/file-str dir)]13 (filter (fn [file] (re-matches regex (.getName file)))14 (if recurse15 (file-seq dir)16 (seq (.listFiles dir))))))18 (defmacro undef19 "removes symbol from the current namespace"20 [& symbols]22 `(dorun (map (partial ns-unmap *ns*) (quote ~symbols))))25 (defn ns-reset-fn26 "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-reset32 "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-old37 ([]38 (let [current-ns# (symbol (str *ns*))]39 `(do40 (println "NUKING namespace" (quote ~current-ns#))41 (clojure.lang.Namespace/remove (quote ~current-ns#))42 (ns ~current-ns#)))))44 (defmacro ns-nuke45 "Removes all symbols and all referenced symbols. Use as a last46 resort."47 ([]48 (let [current-ns# (symbol (str *ns*))]49 `(ns-nuke ~current-ns#)))50 ([ns]51 `(do52 (println "NUKING namespace" (quote ~ns))53 (clojure.lang.Namespace/remove (quote ~ns))54 (ns ~ns))))56 (defmacro reload []57 `(do58 (rlm.ns-rlm/ns-clear)59 (use :reload-all (quote ~(symbol (str *ns*))))))61 (defmacro reload []62 `(do63 (rlm.rlm-commands/ns-nuke)64 (clojure.core/use65 :reload-all66 (clojure.core/symbol (clojure.core/str clojure.core/*ns*)))))68 (defmacro re "faster"69 []70 `(do71 (rlm.rlm-commands/ns-nuke)72 (clojure.core/use :reload73 (clojure.core/symbol (clojure.core/str clojure.core/*ns*)))))75 (defn keymap-clojure []76 (rlm.shell-write/sw "xmodmap" "/home/r/.xmodmap.clojure"))80 (defn keymap-normal []81 (rlm.shell-write/sw "xmodmap" "/home/r/.xmodmap.normal"))84 (defn rlm []85 (clojure.core/require 'rlm.light-base)86 (rlm.ns-rlm/ns-clone rlm.light-base))89 (defn help90 "load a bunch of really useful help functions"91 []92 (use93 '[rlm94 [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]]108 '[clojure.contrib109 [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 '[clojure113 [repl :only [source]]]114 '[clojure.java115 [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-javadoc119 "/home/r/roBin/lpsolve-doc/lpsolve.sourceforge.net/5.5/Java/docs/api")120 (clojure.java.javadoc/add-local-javadoc121 "/home/r/roBin/lpsolve-doc/lpsolve.sourceforge.net/5.5/Java/docs/api")123 nil)