ams-clj/clansi — pull request #3 by pjlegato (2012-05-22 23:13:23+00:00)
Title: Add (with-ansi) and (without-ansi) convenience macros; upgrade to Clojure 1.3.0

I've added convenience macros to allow the user to toggle the production of ANSI color codes on and off. I also bumped the project version number, and changed the required Clojure version to 1.3.0.

From the README:

You can turn the production of ANSI codes on or off by rebinding the
`clansi.core/use-ansi` variable at runtime. This allows you to
maintain only one version of your code with the strings marked up for
color, and then turn ANSI on or off as desired, according to the
properties of each output device, user preference, execution context,
etc.

`(without-ansi)` and `(with-ansi)` convenience macros are provided for
this purpose:

(defn print-colorized []
(println (style "foo bar" :red)))

(print-colorized) ;; prints "foo bar" in red
(without-ansi (print-colorized)) ;; prints plain "foo bar", without any ANSI color codes
(without-ansi (with-ansi (print-colorized)) (print-colorized)) ;; prints a red "foo bar", then a plaintext "foo bar"