Override clojure.core/doc #1

Open
neotyk opened this Issue Apr 15, 2010 · 3 comments

Projects

None yet

2 participants

@neotyk
Member
neotyk commented Apr 15, 2010

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

@LaPingvino
Contributor

In which context?

@LaPingvino
Contributor

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.

@LaPingvino
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment