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

Heime <[email protected]> Fri, 17 Jul 2026 11:02:17 +0000
Newsgroups gmane.emacs.help
Message-ID <oD80wRmdzpwhJFLtNQnVICNqrlmw3GKrJRQU-eE3mEL_50wsGHsrAzare6VDW1UXqIZ9fHfjgLkiZyiMSWnv_ZOySggDV-QLAD5Tv9rLOUs=@protonmail.com>
On Friday, July 17th, 2026 at 6:08 PM, Eli Zaretskii <[email protected]> wrote:

> > Date: Thu, 16 Jul 2026 20:50:36 +0000
> > From: Heime <[email protected]>
> > Cc: Eli Zaretskii <[email protected]>, [email protected]
> >
> > On Friday, July 17th, 2026 at 3:48 AM, packrat386 <[email protected]> w=
rote:
> >
> > > "Heime" <[email protected]> writes:
> > >
> > > > On Thursday, July 16th, 2026 at 5:42 PM, Eli Zaretskii <[email protected]=
g> wrote:
> > > >
> > > >> > Date: Thu, 16 Jul 2026 02:56:34 +0000
> > > >> > From: Heime <[email protected]>
> > > >> >
> > > >> >
> > > >> > How can I get list of colour names and hex numbers (list-colors-=
display)
> > > >> > that I can then use in my code with a loop.
> > > >>
> > > >> The function defined-colors will return the list of names of suppo=
rted
> > > >> colors.  The function color-values will return the RGB triplet for=
 the
> > > >> given color.
> > > >
> > > > How does the computation for white give 65535 ?
> > > >
> > > > "white" 65535 65535 65535
> > >
> > > 65535 is 0xFFFF. So the RGB values are 16 bit integers and "white" me=
ans
> > > the max of all three.
> >
> > I do not understand this.  If 16-bit numbers require a 4-digit hex valu=
e
> > like FFFF, why does the hex values for white when calling (list-color-d=
isplay)
> > display #FFFFFF - which is only a 2-big hex value for each colour?
> > When I look for white using (list-color-display) I get a hex value of
> > #ffffff.  I do not understand this because if each colour is 16-bit
>=20
> There are different representations for the RGB specification of a
> color, you can have 3 or 6 or 9 or 12 hex digits.  See "Color Names"
> in the ELisp manual.  The relations between them are somewhat complex,
> and you don't need or want to dig into this in almost all cases.  Just
> use 16 bits per component and 12-digit specs all the time, and Emacs
> will do the rest.
=20
When I look at the definition of faces, I almost always see people
using #RRGGBB - 6 hex digits, 2 digits per colour.  That is 256=20
shades per colour.  Furthermore, although (color-values colour-name)
gives values in the range 0-65535 per colour, the hex value displayed
at the end in still #RRGGBB - meaning that the actual colour is lost.