Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Use less polluting imports.

  • Loading branch information...
commit c345b905de0579c6cb26ff0a294c38753b807e31 1 parent fe381f9
@mmcgrana authored
15 src/clj_stacktrace/core.clj
@@ -1,16 +1,17 @@
(ns clj-stacktrace.core
- (:use (clojure.contrib str-utils)
- (clj-stacktrace utils)))
+ (:require [clojure.contrib.str-utils :as str]
+ [clj-stacktrace.utils :as utils]))
(defn- clojure-code?
"Returns true if the filename is non-null and indicates a clj source file."
[class-name file]
- (or (re-match? #"^user" class-name) (and file (re-match? #"\.clj$" file))))
+ (or (utils/re-match? #"^user" class-name)
+ (and file (utils/re-match? #"\.clj$" file))))
(defn- clojure-ns
"Returns the clojure namespace name implied by the bytecode class name."
- (re-gsub #"_" "-" (re-get #"([^$]+)\$" class-name 1)))
+ (str/re-gsub #"_" "-" (utils/re-get #"([^$]+)\$" class-name 1)))
(def alpha-punc-subs
[[#"_QMARK_" "?"]
@@ -27,14 +28,14 @@
"Returns the clojure function name implied by the bytecode class name."
- (fn [base-name [alpha-punc punc]] (re-gsub alpha-punc punc base-name))
- (re-without #"(^[^$]+\$)|(__\d+(\$[^$]+)*$)" class-name)
+ (fn [base-name [alpha-punc punc]] (str/re-gsub alpha-punc punc base-name))
+ (utils/re-without #"(^[^$]+\$)|(__\d+(\$[^$]+)*$)" class-name)
(defn- clojure-annon-fn?
"Returns true if the bytecode class name implies an anonymous inner fn."
- (re-match? #"\$fn__" class-name))
+ (utils/re-match? #"\$fn__" class-name))
(defn parse-trace-elem
"Returns a map of information about the java trace element.
17 src/clj_stacktrace/repl.clj
@@ -1,5 +1,6 @@
(ns clj-stacktrace.repl
- (:use (clj-stacktrace core utils)))
+ (:use clj-stacktrace.core)
+ (:require [clj-stacktrace.utils :as utils]))
(def color-codes
{:red "\033[31m"
@@ -24,15 +25,15 @@
:magenta Anything else - i.e. Clojure libraries and app code."
(if (:java elem)
- (if (re-match? #"^clojure\." (:class elem))
+ (if (utils/re-match? #"^clojure\." (:class elem))
(nil? (:ns elem))
- (re-match? #"^(user|repl)" (:ns elem))
+ (utils/re-match? #"^(user|repl)" (:ns elem))
- (re-match? #"^clojure\." (:ns elem))
+ (utils/re-match? #"^clojure\." (:ns elem))
@@ -60,11 +61,12 @@
[on color? parsed-elems & [source-width]]
(let [print-width
(+ 6 (or source-width
- (high (map (memfn length) (map source-str parsed-elems)))))]
+ (utils/high (map (memfn length)
+ (map source-str parsed-elems)))))]
(doseq [parsed-elem parsed-elems]
(.append on
(colored color? (elem-color parsed-elem)
- (str (rjust print-width (source-str parsed-elem))
+ (str (utils/rjust print-width (source-str parsed-elem))
" " (method-str parsed-elem))))
(.append on "\n")
(.flush on))))
@@ -81,7 +83,8 @@
excp and its causes."
(let [this-source-width
- (high (map (memfn length) (map source-str (:trace-elems excp))))]
+ (utils/high (map (memfn length)
+ (map source-str (:trace-elems excp))))]
(if-let [cause (:cause excp)]
(max this-source-width (find-source-width cause))
4 src/clj_stacktrace/utils.clj
@@ -1,5 +1,5 @@
(ns clj-stacktrace.utils
- (:use (clojure.contrib str-utils)))
+ (:require [clojure.contrib.str-utils :as str]))
(defn mash
"Reduce a seq-able to a map. The given fn should return a 2-element tuple
@@ -14,7 +14,7 @@
(defn re-without
"Returns a String with the given pattern re-gsub'd out the given string."
[pattern string]
- (re-gsub pattern "" string))
+ (str/re-gsub pattern "" string))
(defn re-match?
"Returns true iff the given string contains a match for the given pattern."

0 comments on commit c345b90

Please sign in to comment.
Something went wrong with that request. Please try again.