bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug#127943: Bug in htmlize.el


From: Hrvoje Niksic
Subject: Re: Bug#127943: Bug in htmlize.el
Date: Sun, 21 Sep 2003 14:19:57 +0200
User-agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Rational FORTRAN, linux)

"Eli Zaretskii" <eliz@elta.co.il> writes:

> No, Emacs [uses those names] by design.  unspecified-fg and
> unspecified-bg are the two colors that the color support uses on
> text terminal for the foreground and background colors that the
> terminal used before Emacs starts.  IIRC (and AFAIK) most Unix text
> terminals don't allow you to query them about those colors, so their
> names and RGB values are unknown to Emacs.

Ah, that does clear things up.  That also explains why this hasn't
been reported before -- not that many people use `htmlize' on an Emacs
started in a text terminal.

>> How is a Lisp program supposed to interpret "unspecified-fg" as
>> color?
>
> It depends on the context; I don't think there's one answer to that
> question.  Please tell more about the context in this particular
> case.  Specifically, why do you need to interpret the color names at
> all?

htmlize is generating HTML that, when rendered on a color-enabled
browser, looks like the contents of the buffer.  Specifically, it
inspect buffer's fonts and colors and encodes them to HTML as closely
as possible.  Since HTML colors are in RGB, htmlize must convert a
"face" to the corresponding foreground and background RGB string.  For
example, to format the RGB components of a face's foreground color, it
calls something like:

  (apply 'format "#%02x%02x%02x"
         (mapcar (lambda (arg) (/ arg 256))
                 (x-color-values (face-foreground FACE))))

The actual code is somewhat more complex, dealing with different Emacs
versions, and supporting `face-foreground' returning nil.

So far I haven't seen face-foreground report "unspecified-*".  I think
I'll just handle it like I do nil -- default to something a bit more
sensible than throwing an error at the user.

Thanks for the explanation.

>> Why don't these functions return nil instead?
>
> Because nil means no color at all.

I'm curious -- how is "no color" different than "default (unspecified)
color"?  Is the distinction ever useful?  After all, every terminal
has some form of color, even when you can't change it!  :-)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]