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

Eli Zaretskii <[email protected]> Thu, 16 Jul 2026 20:17:18 +0300
Newsgroups gmane.emacs.help
Message-ID <[email protected]>
> Date: Thu, 16 Jul 2026 16:35:09 +0000
> From: Heime <[email protected]>
> Cc: Eli Zaretskii <[email protected]>, [email protected]
> 
> On Friday, July 17th, 2026 at 3:48 AM, packrat386 <[email protected]> wrote:
> 
> > "Heime" <[email protected]> writes:
> > 
> > > On Thursday, July 16th, 2026 at 5:42 PM, Eli Zaretskii <[email protected]> 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 supported
> > >> 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" means
> > the max of all three.
> 
> Then the maximum value should be 2^16 as listed.  I expected 
> the 24-bit true colour palette.

24-bit TrueColor uses 8 bits per component, so 16 bits per component
we use in Emacs is more than enough.

> How could I determine the number of bits used for each colour on the
> system?

In Emacs, it is always 16 bits per component.  If you want to know how
many distinct colors are actually available, use display-color-cells.