On Thursday, June 26, 2014 8:03:44 AM UTC-4, Samuel Colvin wrote: > > One thing that's confusing me is that if I define "function > Base.writemime(io::IO, ::MIME"text/plain", plot::Plot)" for a new type > it's not being used by by show, or it's used after printing the standard > show text. >
writemime is used to display the output in the REPL (and IJulia etc.). writemime(io, "text/plain", x) defaults to calling showlimited(io, x), which defaults to calling show(io, x). So, overriding show for a new type will effectively override writemime for "text/plain". (See also https://github.com/JuliaLang/julia/issues/5709 for some discussion of the various show-like functions.) You should never override display unless you are defining a new Display type. julia> type Foo; end Base.writemime(io::IO, ::MIME"text/plain", f::Foo) = print(io, "FOOOOO") writemime (generic function with 15 methods) julia> Foo() FOOOOO julia> show(Foo()) Foo()
