GNU bug report logs - #25525
25.1.90; add color highlighting to css mode

Previous Next

Package: emacs;

Reported by: Tom Tromey <tom <at> tromey.com>

Date: Wed, 25 Jan 2017 08:08:01 UTC

Severity: wishlist

Tags: patch

Found in version 25.1.90

Done: Tom Tromey <tom <at> tromey.com>

Bug is archived. No further changes may be made.

Full log


Message #68 received at 25525 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tom Tromey <tom <at> tromey.com>
Cc: 25525 <at> debbugs.gnu.org, simenheg <at> gmail.com
Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode
Date: Sun, 05 Mar 2017 17:34:41 +0200
> From: Tom Tromey <tom <at> tromey.com>
> Cc: Tom Tromey <tom <at> tromey.com>,  25525 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
> Date: Sat, 04 Mar 2017 19:42:34 -0700
> 
> >>>>> "Simen" == Simen Heggestøyl <simenheg <at> gmail.com> writes:
> 
> Simen> There is also a test failure when you rebase the patch on the latest
> Simen> master due to the changes in 7b00e956b4. It can be fixed by passing 2
> Simen> as the last argument to `color-rgb-to-hex' in `css--hsl-color'.
> 
> This happens due to the change in 7b00e956b485d8ade03c870cbdd0ae086348737b,
> which changed color-name-to-rgb in a backward-incompatible way.
> Eli, you made this change -- it seems to me that it would be safer if it
> defaulted to 2 digits, which was how it worked previously.  This would
> be backward-compatible and allow the new functionality as well.

If we leave the default at 2, people will never discover they need to
use 4 there, and the original problem which prompted those changes
will be still with us years from now.  The reasons for using 4-digit
(i.e. 16 bits per component) hex specifications are subtle and buried
deep in the Emacs internals related to color calculations.  I don't
expect Lisp programmers to understand those reasons.  I actually
forgot about this subtlety myself, until that bug surfaced.

When I worked on the change, it seemed harmless: the function has only
one caller outside of color.el, and I changed that single caller to
use the optional argument.  css-mode is the second such caller, and if
the code was there when I made the changes, I'd have fixed that as
well.  Both shr-color and css-mode manipulate Web-related color specs,
where 2 hex digits per component are the rule.  That's a niche
application, as far as color management in Emacs is concerned, so,
unfortunate as it is, it's up to the people who develop such
applications to know that they need 2 digits rather than the default
4.

If the change I made is nevertheless deemed too drastic, then what are
our alternatives?  The only one I could think of is to define a new
function and deprecate color-name-to-rgb in favor of that new
function, which will then display warnings when code using it is
compiled, and eventually cause them to make changes in their code
anyway.  Is that better?  Or are there any better ideas?




This bug report was last modified 8 years and 98 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.