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

Tassilo Horn <[email protected]> Thu, 16 Jul 2026 06:22:23 +0200
Newsgroups gmane.emacs.help
Message-ID <[email protected]>
Heime <[email protected]> writes:

> 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.

Have you looked at its code?  Basically, you get the color names with
`defined-colors` and for each color in the result, you can call
`color-name-to-rgb` to get its RGB value as list.  You can give that to
`color-rgb-to-hex` (like `(apply #'color-rgb-to-hex my-rgb-list)`) to
get the hex code of the color.

HTH,
Tassilo