From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Hrvoje Niksic Newsgroups: gmane.emacs.bugs Subject: Re: Bug#127943: Bug in htmlize.el Date: Sun, 21 Sep 2003 14:19:57 +0200 Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: <87r8njey31.fsf@cachemir.echo-net.net> <1197.1063152238@mixed> <83k784rl0h.wl%algernon@bonehunter.rulez.org> <83ad8zryyx.wl%algernon@midgard.debian.net> <9003-Sun21Sep2003143629+0300-eliz@elta.co.il> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1064147204 25353 80.91.224.253 (21 Sep 2003 12:26:44 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 21 Sep 2003 12:26:44 +0000 (UTC) Cc: algernon@midgard.debian.net, bug-gnu-emacs@gnu.org, psg@debian.org, 127943@bugs.debian.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Sep 21 14:26:42 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1A13IX-0004pm-00 for ; Sun, 21 Sep 2003 14:26:41 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.22) id 1A13IC-0004Nx-Qa for geb-bug-gnu-emacs@m.gmane.org; Sun, 21 Sep 2003 08:26:20 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.22) id 1A13Cr-0001WK-TK for bug-gnu-emacs@gnu.org; Sun, 21 Sep 2003 08:20:49 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.22) id 1A13CZ-00018F-Kz for bug-gnu-emacs@gnu.org; Sun, 21 Sep 2003 08:20:32 -0400 Original-Received: from [213.191.128.10] (helo=mxout.iskon.hr) by monty-python.gnu.org with smtp (Exim 4.22) id 1A13BE-0007k3-E3 for bug-gnu-emacs@gnu.org; Sun, 21 Sep 2003 08:19:08 -0400 Original-Received: (qmail 21741 invoked from network); 21 Sep 2003 14:18:58 +0200 Original-Received: from mx.iskon.hr (qmailr@213.191.128.14) by mxout.iskon.hr with SMTP; 21 Sep 2003 14:18:58 +0200 Original-Received: (qmail 19755 invoked from network); 21 Sep 2003 14:18:57 +0200 Original-Received: from hniksic.iskon.hr (213.191.139.17) by mx.iskon.hr with SMTP; 21 Sep 2003 14:18:57 +0200 Original-To: Eli Zaretskii In-Reply-To: <9003-Sun21Sep2003143629+0300-eliz@elta.co.il> (Eli Zaretskii's message of "Sun, 21 Sep 2003 14:36:30 +0200") User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Rational FORTRAN, linux) X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Bug reports for GNU Emacs, the Swiss army knife of text editors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.bugs:5824 X-Report-Spam: http://spam.gmane.org/gmane.emacs.bugs:5824 "Eli Zaretskii" 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! :-)