diff options
author | Ben Smith-Mannschott <bsmith.occs@gmail.com> | 2010-08-28 19:00:22 +0200 |
---|---|---|
committer | Stuart Sierra <mail@stuartsierra.com> | 2010-09-03 12:23:37 -0400 |
commit | 67e85be147095c87a3cec82a64455974f29c7fd7 (patch) | |
tree | 546ef4949e3db2111b79f60e19d76d5e03722c3a /modules/repl-utils | |
parent | 9a05c1c70a1070f5a631dfc81ed98d6c70b33a9d (diff) |
removed deprecated source, get-source, apropos from clojure.contrib.repl-utils.
available in clojure.repl as source, source-fn, and apropos, respectively.
Signed-off-by: Stuart Sierra <mail@stuartsierra.com>
Diffstat (limited to 'modules/repl-utils')
-rw-r--r-- | modules/repl-utils/src/main/clojure/clojure/contrib/repl_utils.clj | 49 | ||||
-rw-r--r-- | modules/repl-utils/src/test/clojure/clojure/contrib/test_repl_utils.clj | 20 |
2 files changed, 0 insertions, 69 deletions
diff --git a/modules/repl-utils/src/main/clojure/clojure/contrib/repl_utils.clj b/modules/repl-utils/src/main/clojure/clojure/contrib/repl_utils.clj index 39195ea0..e9bdb669 100644 --- a/modules/repl-utils/src/main/clojure/clojure/contrib/repl_utils.clj +++ b/modules/repl-utils/src/main/clojure/clojure/contrib/repl_utils.clj @@ -116,55 +116,6 @@ (printf "[%2d] %s\n" i (:text m))))))))) ;; ---------------------------------------------------------------------- -;; Examine Clojure functions (Vars, really) - -(defn get-source - "Returns a string of the source code for the given symbol, if it can - find it. This requires that the symbol resolve to a Var defined in - a namespace for which the .clj is in the classpath. Returns nil if - it can't find the source. For most REPL usage, 'source' is more - convenient. - - Example: (get-source 'filter)" - {:deprecated "1.2"} - [x] - (when-let [v (resolve x)] - (when-let [filepath (:file (meta v))] - (when-let [strm (.getResourceAsStream (RT/baseLoader) filepath)] - (with-open [rdr (LineNumberReader. (InputStreamReader. strm))] - (dotimes [_ (dec (:line (meta v)))] (.readLine rdr)) - (let [text (StringBuilder.) - pbr (proxy [PushbackReader] [rdr] - (read [] (let [i (proxy-super read)] - (.append text (char i)) - i)))] - (read (PushbackReader. pbr)) - (str text))))))) - -(defmacro source - "Prints the source code for the given symbol, if it can find it. - This requires that the symbol resolve to a Var defined in a - namespace for which the .clj is in the classpath. - - Example: (source filter)" - {:deprecated "1.2"} - [n] - `(println (or (get-source '~n) (str "Source not found")))) - -(defn apropos - "Given a regular expression or stringable thing, return a seq of -all definitions in all currently-loaded namespaces that match the -str-or-pattern." - {:deprecated "1.2"} - [str-or-pattern] - (let [matches? (if (instance? java.util.regex.Pattern str-or-pattern) - #(re-find str-or-pattern (str %)) - #(.contains (str %) (str str-or-pattern)))] - (mapcat (fn [ns] - (filter matches? (keys (ns-publics ns)))) - (all-ns)))) - -;; ---------------------------------------------------------------------- ;; Handle Ctrl-C keystrokes (def ^{:doc "Threads to stop when Ctrl-C is pressed. See 'add-break-thread!'"} diff --git a/modules/repl-utils/src/test/clojure/clojure/contrib/test_repl_utils.clj b/modules/repl-utils/src/test/clojure/clojure/contrib/test_repl_utils.clj deleted file mode 100644 index 6fa12ed7..00000000 --- a/modules/repl-utils/src/test/clojure/clojure/contrib/test_repl_utils.clj +++ /dev/null @@ -1,20 +0,0 @@ -(ns clojure.contrib.test-repl-utils - (:use clojure.test - clojure.contrib.repl-utils)) - -(deftest test-apropos - (testing "with a regular expression" - (is (= '[defmacro] (apropos #"^defmacro$"))) - (is (some '#{defmacro} (apropos #"def.acr."))) - (is (= [] (apropos #"nothing-has-this-name")))) - - - (testing "with a string" - (is (some '#{defmacro} (apropos "defmacro"))) - (is (some '#{defmacro} (apropos "efmac"))) - (is (= [] (apropos "nothing-has-this-name")))) - - (testing "with a symbol" - (is (some '#{defmacro} (apropos 'defmacro))) - (is (some '#{defmacro} (apropos 'efmac))) - (is (= [] (apropos 'nothing-has-this-name))))) |