From: "Mattias Engdegård" <mattiase@acm.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: tom@tromey.com, simon@polaris64.net, 41544@debbugs.gnu.org
Subject: bug#41544: 26.3; Possible incorrect results from color-distance
Date: Thu, 4 Jun 2020 17:29:06 +0200 [thread overview]
Message-ID: <55D73CA5-1EFB-4B0A-8F8B-FDA1D39F51BF@acm.org> (raw)
In-Reply-To: <83o8pyc4bq.fsf@gnu.org>
4 juni 2020 kl. 16.07 skrev Eli Zaretskii <eliz@gnu.org>:
> Let's please discuss each problem in detail (I tried to understand
> them from the log message you posted, but couldn't find rationale
> there).
>
> And in any case, I will prefer solutions that fix any problems
> locally, not changes in low-level stuff used in many other places,
> because the latter run the risk of introducing new bugs. As the
> problems are quite minor, AFAICT, solving them in unsafe ways is
> something to be avoided.
I think we agree. There should be nothing unsafe here other than the code being replaced, but code should be scrutinised.
> You mean, the component that is 1.0393? What bad decisions caused
> that, what problems does this small deviation causes in itself?
Yes, this is as good a place to start as any, and the fix for this is a good change on its own. It goes something like this:
1. color-name-to-rgb calls (color-values "#ffffffffffff") as a means to get the range of the colour values.
2. With TERM=xterm-color, there are 8 colours. These are assumed to be the 8 first of xterm-standard-colors (xterm.el).
3. The colour closest to "#ffffffffffff" is "white", with the values (229 229 229), or translated to 16 bit/channel, (#e5e5 #e5e5 #e5e5) which color-values returns.
4. "blue" has the values (0 0 238), or (0 0 #xeeee).
5. Thus color-name-to-rgb returns #xeeee/#xe5e5 for the blue channel, or 1.039, which is a clear bug.
The main problem is trusting "#ffffffffffff" to match a colour with the maximum range. It could be argued that xterm.el shouldn't use subdued colours when only 8 are present; I didn't go far back in XTerm history to find out. Modern XTerm has default colours 0-7 that correspond to the assumptions of Emacs.
Since we already document that the colour channel maximum is either 65535 or 65280 depending on platform, taking the very roundabout way of trying to match a sufficiently white colour and using its components is demonstrably unsafe and error-prone, as well as unnecessarily slow. Hence color-component-max in the patch.
This also fixes a different problem: if the display hasn't been initialised fully, such as when running in batch mode, then (color-values "#ffffffffffff") returns nil, and as we shall see later, it may be useful to be able to call color-name-to-rgb at this stage without crashing.
next prev parent reply other threads:[~2020-06-04 15:29 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-26 16:29 bug#41544: 26.3; Possible incorrect results from color-distance Simon Pugnet
2020-05-28 17:31 ` Mattias Engdegård
2020-05-29 15:17 ` Mattias Engdegård
2020-05-29 15:36 ` Eli Zaretskii
2020-05-29 17:28 ` Mattias Engdegård
2020-05-29 17:52 ` Tom Tromey
2020-05-31 20:46 ` Mattias Engdegård
2020-06-01 16:32 ` Eli Zaretskii
2020-06-01 17:24 ` Mattias Engdegård
2020-06-01 17:35 ` Eli Zaretskii
2020-06-01 17:44 ` Eli Zaretskii
2020-06-02 15:27 ` Mattias Engdegård
2020-06-02 16:14 ` Eli Zaretskii
2020-06-02 20:41 ` Mattias Engdegård
2020-06-03 14:24 ` Eli Zaretskii
2020-06-03 15:01 ` Mattias Engdegård
2020-06-03 15:59 ` Eli Zaretskii
2020-06-03 20:08 ` Mattias Engdegård
2020-06-04 14:07 ` Eli Zaretskii
2020-06-04 15:29 ` Mattias Engdegård [this message]
2020-06-05 12:27 ` Eli Zaretskii
2020-06-05 15:50 ` Mattias Engdegård
2020-06-06 7:29 ` Eli Zaretskii
2020-06-06 10:59 ` Mattias Engdegård
2020-06-06 11:59 ` Eli Zaretskii
2020-06-06 13:29 ` Mattias Engdegård
2020-06-06 13:57 ` Eli Zaretskii
2020-06-06 16:54 ` Mattias Engdegård
2020-06-06 18:15 ` Drew Adams
2020-06-07 9:13 ` Mattias Engdegård
2020-06-07 14:30 ` Eli Zaretskii
2020-06-07 16:12 ` Drew Adams
2020-06-09 12:19 ` Mattias Engdegård
2020-06-07 16:00 ` Drew Adams
2020-06-06 18:27 ` Eli Zaretskii
2020-06-07 9:04 ` Simen Heggestøyl
[not found] ` <87pnabfdr5.fsf@simenheg@gmail.com>
2020-06-07 10:14 ` Mattias Engdegård
2020-06-07 19:23 ` Simen Heggestøyl
[not found] ` <87d06ar87d.fsf@simenheg@gmail.com>
2020-06-07 19:27 ` Mattias Engdegård
2020-06-08 18:39 ` Simen Heggestøyl
2020-06-07 14:26 ` Eli Zaretskii
2020-06-07 16:10 ` Drew Adams
2020-06-07 19:26 ` Simen Heggestøyl
2020-06-08 13:11 ` Mattias Engdegård
2020-06-08 14:30 ` Drew Adams
2020-06-08 19:53 ` Mattias Engdegård
2020-06-10 18:37 ` Drew Adams
2020-06-10 19:12 ` Mattias Engdegård
2020-06-09 16:20 ` Eli Zaretskii
2020-06-10 14:51 ` Mattias Engdegård
2020-06-10 15:08 ` Eli Zaretskii
2020-06-10 18:29 ` Mattias Engdegård
2020-06-10 18:45 ` Eli Zaretskii
2020-08-18 13:44 ` Lars Ingebrigtsen
2020-08-18 14:06 ` Eli Zaretskii
2020-08-18 14:10 ` Lars Ingebrigtsen
2020-08-18 14:19 ` Mattias Engdegård
2020-08-19 10:11 ` Lars Ingebrigtsen
2020-08-19 11:28 ` Mattias Engdegård
2020-08-19 11:34 ` Lars Ingebrigtsen
2020-08-18 14:51 ` Eli Zaretskii
2020-08-19 10:13 ` Lars Ingebrigtsen
2020-08-19 14:52 ` Eli Zaretskii
2020-08-19 15:03 ` Lars Ingebrigtsen
2020-08-19 17:15 ` Eli Zaretskii
2020-08-20 13:08 ` Lars Ingebrigtsen
2020-08-21 11:32 ` Mattias Engdegård
2020-08-22 13:22 ` Lars Ingebrigtsen
2020-06-04 6:15 ` Simon Pugnet
2020-06-04 8:57 ` Mattias Engdegård
2020-06-01 19:46 ` Basil L. Contovounesios
2020-06-02 15:08 ` Mattias Engdegård
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55D73CA5-1EFB-4B0A-8F8B-FDA1D39F51BF@acm.org \
--to=mattiase@acm.org \
--cc=41544@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=simon@polaris64.net \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.