diff options
author | Tom Faulhaber <git_net@infolace.com> | 2009-05-09 22:20:30 +0000 |
---|---|---|
committer | Tom Faulhaber <git_net@infolace.com> | 2009-05-09 22:20:30 +0000 |
commit | 817fcfd8647d4e195347251b74d65cbb4a5e4c95 (patch) | |
tree | a0cba2588094ca42ff9e6145b4b9684f66fb278e | |
parent | 02831af62ead8f8a1ae5163956f64af8bac41488 (diff) |
Support for setting *print-right-margin* to nil to indicate
infinite-length lines.
-rw-r--r-- | src/clojure/contrib/pprint/PrettyWriter.clj | 15 | ||||
-rw-r--r-- | src/clojure/contrib/pprint/pprint_base.clj | 4 |
2 files changed, 12 insertions, 7 deletions
diff --git a/src/clojure/contrib/pprint/PrettyWriter.clj b/src/clojure/contrib/pprint/PrettyWriter.clj index aef8a27f..9e99ad9e 100644 --- a/src/clojure/contrib/pprint/PrettyWriter.clj +++ b/src/clojure/contrib/pprint/PrettyWriter.clj @@ -174,9 +174,11 @@ (defn- tokens-fit? [#^clojure.contrib.pprint.PrettyWriter this tokens] -; (prlabel tf? (.getColumn this) (buffer-length tokens)) - (< (+ (.getColumn this) (buffer-length tokens)) - (.getMaxColumn this))) +;;; (prlabel tf? (.getColumn this) (buffer-length tokens)) + (let [maxcol (.getMaxColumn this)] + (or + (nil? maxcol) + (< (+ (.getColumn this) (buffer-length tokens)) maxcol)))) (defn- linear-nl? [this lb section] ; (prlabel lnl? @(:done-nl lb) (tokens-fit? this section)) @@ -184,9 +186,10 @@ (not (tokens-fit? this section)))) (defn- miser-nl? [#^clojure.contrib.pprint.PrettyWriter this lb section] - (let [miser-width (.getMiserWidth this)] - (and miser-width - (>= @(:start-col lb) (- (.getMaxColumn this) miser-width)) + (let [miser-width (.getMiserWidth this) + maxcol (.getMaxColumn this)] + (and miser-width maxcol + (>= @(:start-col lb) (- maxcol miser-width)) (linear-nl? this lb section)))) (defmulti emit-nl? (fn [t _ _ _] (:type t))) diff --git a/src/clojure/contrib/pprint/pprint_base.clj b/src/clojure/contrib/pprint/pprint_base.clj index eb876e4f..87816310 100644 --- a/src/clojure/contrib/pprint/pprint_base.clj +++ b/src/clojure/contrib/pprint/pprint_base.clj @@ -36,7 +36,9 @@ to modify."} *print-pprint-dispatch* nil) (def - #^{ :doc "Pretty printing will try to avoid anything going beyond this column."} + #^{ :doc "Pretty printing will try to avoid anything going beyond this column. +Set it to nil to have pprint let the line be arbitrarily long. This will ignore all +non-mandatory newlines."} *print-right-margin* 72) (def |