PREV UP NEXT GNU Emacs Lisp Reference Manual

26.19: Color Names

Function: x-color-defined-p color
This function reports whether a color name is meaningful. It returns t if so; otherwise, nil.

Note that this does not tell you whether the display you are using really supports that color. You can ask for any defined color on any kind of display, and you will get some result---that is how the X server works. Here's an approximate way to test whether your display supports the color color:

(defun x-color-supported-p (color)
  (and (x-color-defined-p color)
       (or (x-display-color-p)
           (member color '("black" "white"))
           (and (> (x-display-planes) 1)
                (equal color "gray")))))
Function: x-color-values color
This function returns a value that describes what color should ideally look like. If color is defined, the value is a list of three integers, which give the amount of red, the amount of green, and the amount of blue. Each integer ranges in principle from 0 to 65535, but in practice no value seems to be above 65280. If color is not defined, the value is nil.
(x-color-values "black")
     => (0 0 0)
(x-color-values "white")
     => (65280 65280 65280)
(x-color-values "red")
     => (65280 0 0)
(x-color-values "pink")
     => (65280 49152 51968)
(x-color-values "hungry")
     => nil