6.1 Color

The color of the foreground (things that are drawn, such as lines or characters) is set by:

(window-set-color w rgb &optional background)
(window-set-color-rgb w r g b &optional background)
rgb is a list (red green blue) of 16-bit unsigned integers in the range 0 to 65535. background is non-nil to set the background color rather than the foreground color.

(window-reset-color w)
window-reset-color resets a window’s colors to the default values.

Colors are a scarce resource; there is only a finite number of available colors, such as 256 colors. If you only use a small, fixed set of colors, the finite set of colors will not be a problem. However, if you create a lot of colors that are used only briefly, it will be necessary to release them after they are no longer needed. window-set-color will leave the global variable window-xcolor* set to an integer value that denotes an X color; this value should be saved and used as the argument to window-free-color to release the color after it is no longer needed.

(window-free-color w &optional xcolor)
window-free-color frees either the last color used, as given by window-xcolor*, or the specified color.