Re: Retrieving color names and hex values using list-colors-display for coding purposes

Eli Zaretskii <[email protected]> Fri, 17 Jul 2026 18:37:26 +0300
Newsgroups gmane.emacs.help
Message-ID <[email protected]>
> Date: Fri, 17 Jul 2026 14:55:28 +0000
> From: Heime <[email protected]>
> Cc: [email protected], [email protected], [email protected]
> 
> 
> 
> 
> 
> Sent with Proton Mail secure email.
> 
> On Saturday, July 18th, 2026 at 2:34 AM, Eli Zaretskii <[email protected]> wrote:
> 
> > > Date: Fri, 17 Jul 2026 14:28:11 +0000
> > > From: Heime <[email protected]>
> > > Cc: uzibalqa <[email protected]>, [email protected], [email protected]
> > >
> > >
> > >
> > >
> > >
> > > Sent with Proton Mail secure email.
> > >
> > > On Saturday, July 18th, 2026 at 1:33 AM, Eli Zaretskii <[email protected]> wrote:
> > >
> > > > > Date: Fri, 17 Jul 2026 13:22:13 +0000
> > > > > From: uzibalqa <[email protected]>
> > > > > Cc: Heime <[email protected]>, [email protected], [email protected]
> > > > >
> > > > > If the advice is always to use #RRRRGGGGBBBB, which is also always the advice
> > > > > for my cases,  then how (list-colors-display) showing me #RRGGBB follows the
> > > > > advice you described?  To follow your advice, display #RRRRGGGGBBBB, not
> > > > > the currently displayed #RRGGBB.
> > > >
> > > > Are you writing list-colors-display?  If not, why is it important that
> > > > it shows 6-digit RGB values?
> > >
> > > Because colour-values on the name are in range 0-65535, a range that
> > > definitly requires hex RRRR and not hex RR.  The hex value is unique,
> > > consequently using  RR instead of RRRR is incorrect.
> > >
> > > Multiple (0-65535) values map to the same #RR value, breaking uniqueness
> > > and accuracy.  Colour accuracy matters for contrast calculations, accessibility,
> > > and precise colour matching.  The emphasis on the importance of 6-digit
> > > hex values is that they uniquely and accurately represent the colour in
> > > the standard hex format.
> > 
> > All of the above are reasons to use 16-bit values for each RGB
> > component.  That way, you don't lose accuracy when specifying a color.
> 
> 
> list-colors-display is an interactive function in facemenu.el, which is
> part of GNU Emacs.  It should look at the range of values and determine
> whether #RRRRGGGGBBBB should be used as display.  

Not necessarily.  It works with a list of 256 colors, so the full list
available on the platform is not relevant.

Once again, please don't look at that command as guidance for which
RGB specifications to use in your programs.