unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Mark Oteiza <mvoteiza@udel.edu>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: Doc string and operation of color-distance
Date: Fri, 15 Sep 2017 12:45:43 -0400	[thread overview]
Message-ID: <20170915164543.GA19268@holos.localdomain> (raw)
In-Reply-To: <83377om6n6.fsf@gnu.org>

On 15/09/17 at 04:30pm, Eli Zaretskii wrote:
> > Date: Thu, 14 Sep 2017 15:12:26 -0400
> > From: Mark Oteiza <mvoteiza@udel.edu>
> > Cc: emacs-devel@gnu.org
> > 
> > On 14/09/17 at 09:45pm, Eli Zaretskii wrote:
> > > Mark, the new color-distance says something strange in its doc string:
> > > 
> > >   (color-distance COLOR1 COLOR2 &optional FRAME METRIC)
> > > 
> > >   Return an integer distance between COLOR1 and COLOR2 on FRAME.
> > >   COLOR1 and COLOR2 may be either strings containing the color name,
> > >   or lists of the form (RED GREEN BLUE), each in the range 0 to 65535 inclusive.
> > >   If FRAME is unspecified or nil, the current frame is used.
> > >   If METRIC is unspecified or nil, a modified L*u*v* metric is used.
> > > 
> > > The last sentence should say "non-nil", I think
> > 
> > No, the 'nil' is correct--if no metric is given as an argument,
> > color_distance is used which, as the comments say, is a modified L*u*v*
> > metric.
> 
> Yes, but the comments also reference the article which describes the
> metric, whereas the doc string doesn't.
> 
> I think we should either leave the nil case alone -- it wasn't
> documented before in such detail -- or add more explanations and
> perhaps the reference.
> 
> What's important is to describe the non-nil case.

OK, I agree.  How about the following?

diff --git a/src/xfaces.c b/src/xfaces.c
index 012de4e7af..b309c16127 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -4093,7 +4093,8 @@ DEFUN ("color-distance", Fcolor_distance, Scolor_distance, 2, 4, 0,
 COLOR1 and COLOR2 may be either strings containing the color name,
 or lists of the form (RED GREEN BLUE), each in the range 0 to 65535 inclusive.
 If FRAME is unspecified or nil, the current frame is used.
-If METRIC is unspecified or nil, a modified L*u*v* metric is used.  */)
+If METRIC is specified, it should be a function that accepts
+two lists of the form (RED GREEN BLUE) aforementioned. */)
   (Lisp_Object color1, Lisp_Object color2, Lisp_Object frame,
    Lisp_Object metric)
 {
@@ -4112,7 +4113,13 @@ If METRIC is unspecified or nil, a modified L*u*v* metric is used.  */)
   if (NILP (metric))
     return make_number (color_distance (&cdef1, &cdef2));
   else
-    return call2 (metric, color1, color2);
+    return call2 (metric,
+                  list3 (make_number (cdef1.red),
+                         make_number (cdef1.green),
+                         make_number (cdef1.blue)),
+                  list3 (make_number (cdef2.red),
+                         make_number (cdef2.green),
+                         make_number (cdef2.blue)));
 }
 
 \f



  reply	other threads:[~2017-09-15 16:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-14 18:45 Doc string and operation of color-distance Eli Zaretskii
2017-09-14 19:12 ` Mark Oteiza
2017-09-15 13:30   ` Eli Zaretskii
2017-09-15 16:45     ` Mark Oteiza [this message]
2017-09-15 17:24       ` Eli Zaretskii
2017-09-14 19:43 ` Mark Oteiza
2017-09-14 20:23   ` Mark Oteiza
2017-09-15 13:41     ` Eli Zaretskii
2017-09-15 13:40   ` Eli Zaretskii
2017-09-15 15:15     ` Mark Oteiza
2017-09-15 16:32     ` Mark Oteiza
2017-09-15 17:26       ` Eli Zaretskii

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170915164543.GA19268@holos.localdomain \
    --to=mvoteiza@udel.edu \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).