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

Eli Zaretskii <[email protected]> Sun, 19 Jul 2026 14:32:08 +0300
Newsgroups gmane.emacs.help
Message-ID <[email protected]>
> Date: Sun, 19 Jul 2026 11:27:13 +0000
> From: Heime <[email protected]>
> Cc: [email protected], [email protected], [email protected]
> 
> On Sunday, July 19th, 2026 at 4:27 PM, Eli Zaretskii <[email protected]> wrote:
> 
> > > I have a difficulty.  How can I define a face that would be supported
> > > by Emacs on some terminal?
> > 
> > Any color definition of a face will always be supported on all
> > terminals.  You don't need to worry about that, as Emacs solves the
> > problem automatically, by choosing the closest color supported by the
> > terminal.
>  
> Would you suggest for me to define a face using a colour name from
> list-colors-display on an Emacs GUI frame?

Yes.

> What does one do when the name is not in the list returned by
> defined-colors.

Emacs will automatically find the best approximation.

> You were correct in the statement that using colours is complicated.
> Initially, I had the plan to define actual colours for each terminal
> capability, detect which to use and apply accordingly during the Emacs
> initialisation phase.

That is a significant complication that is entirely unnecessary.  The
automatic color approximation was added to Emacs precisely for this
purpose: so that defface specifications will not have endless
terminal-dependent parts.  More importantly, it was so a face doesn't
fail to display because someone forgot to mention some terminal type.