ams-clj/clansi

Override clojure.core/doc

neotyk opened this issue · 3 comments

Figure out how and if it is possible to override clojure.core/doc.

In which context?

From the mailing list

On Apr 15, 1:38 pm, Jeff ros...@gmail.com wrote:

Does anyone know if there is some way we can make it easy to put
clansi into your user.clj, and have it overload clojure.core/doc so by
default the printed doc strings are colorized? I tried with set! and
def with no luck.

Since clojure.core/doc is a macro, your best bet is

(ns clojure.core)
(defmacro doc [v] `(clansi/color-doc ~v))

The problem is that clansi/color-doc calls clojure.core/doc, so this
will lead to a stack overflow.
It's arguably "best" to just copy the implementation of clojure.core/
doc into clansi/color-doc -
you're already overwriting core functionality anyway.

Also, the whole strategy of using (binding) to override clojure core
functions will not work in the
current clojure 1.2 branch. See the thread I started on the clojure
mailing list yesterday:

http://groups.google.com/group/clojure/t/7b9245a2ac09512d

Cheers,
Joost.

I changed my fork to such an implementation, and added some more stuff. Merge it in?