]> code.delx.au - gnu-emacs/blobdiff - lisp/term/tty-colors.el
(ibuffer-compressed-file-name-regexp): Undo previous
[gnu-emacs] / lisp / term / tty-colors.el
index 0a818a5c7348625da14af325200fa485032a428e..c03aebf40682e403d27d6e829b3b68db807d60a5 100644 (file)
@@ -1,8 +1,9 @@
 ;;; tty-colors.el --- color support for character terminals
 
-;; Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004,
+;;   2005, 2006 Free Software Foundation, Inc.
 
-;; Author: Eli Zaretskii <eliz@is.elta.co.il>
+;; Author: Eli Zaretskii
 ;; Maintainer: FSF
 ;; Keywords: terminals, faces
 
@@ -20,8 +21,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
@@ -61,6 +62,8 @@
 
 ;;; Code:
 
+(defvar msdos-color-values)
+
 ;; The following list is taken from rgb.txt distributed with X.
 ;;
 ;; WARNING: Some colors, such as "lightred", do not appear in this
 ;; names such as "lightred" or "lightblue", because they will have
 ;; different effect on different displays.  Instead, use "red1" and
 ;; "blue1", respectively.
+;;
+;; Note: the RGB values below are in the range 0-65535, but are derived
+;; from the standard 8-bit X definitions (so the upper and lower bytes
+;; of each value are actually identical).
+;;
 (defvar color-name-rgb-alist
-  '(("snow"            255 250 250)
-    ("ghostwhite"      248 248 255)
-    ("whitesmoke"      245 245 245)
-    ("gainsboro"       220 220 220)
-    ("floralwhite"     255 250 240)
-    ("oldlace"         253 245 230)
-    ("linen"           250 240 230)
-    ("antiquewhite"    250 235 215)
-    ("papayawhip"      255 239 213)
-    ("blanchedalmond"  255 235 205)
-    ("bisque"          255 228 196)
-    ("peachpuff"       255 218 185)
-    ("navajowhite"     255 222 173)
-    ("moccasin"                255 228 181)
-    ("cornsilk"                255 248 220)
-    ("ivory"           255 255 240)
-    ("lemonchiffon"    255 250 205)
-    ("seashell"                255 245 238)
-    ("honeydew"                240 255 240)
-    ("mintcream"       245 255 250)
-    ("azure"           240 255 255)
-    ("aliceblue"       240 248 255)
-    ("lavender"                230 230 250)
-    ("lavenderblush"   255 240 245)
-    ("mistyrose"       255 228 225)
-    ("white"           255 255 255)
-    ("black"           0 0 0)
-    ("darkslategray"   47 79 79)
-    ("darkslategrey"   47 79 79)
-    ("dimgray"         105 105 105)
-    ("dimgrey"         105 105 105)
-    ("slategray"       112 128 144)
-    ("slategrey"       112 128 144)
-    ("lightslategray"  119 136 153)
-    ("lightslategrey"  119 136 153)
-    ("gray"            190 190 190)
-    ("grey"            190 190 190)
-    ("lightgrey"       211 211 211)
-    ("lightgray"       211 211 211)
-    ("midnightblue"    25 25 112)
-    ("navy"            0 0 128)
-    ("navyblue"                0 0 128)
-    ("cornflowerblue"  100 149 237)
-    ("darkslateblue"   72 61 139)
-    ("slateblue"       106 90 205)
-    ("mediumslateblue" 123 104 238)
-    ("lightslateblue"  132 112 255)
-    ("mediumblue"      0 0 205)
-    ("royalblue"       65 105 225)
-    ("blue"            0 0 255)
-    ("dodgerblue"      30 144 255)
-    ("deepskyblue"     0 191 255)
-    ("skyblue"         135 206 235)
-    ("lightskyblue"    135 206 250)
-    ("steelblue"       70 130 180)
-    ("lightsteelblue"  176 196 222)
-    ("lightblue"       173 216 230)
-    ("powderblue"      176 224 230)
-    ("paleturquoise"   175 238 238)
-    ("darkturquoise"   0 206 209)
-    ("mediumturquoise" 72 209 204)
-    ("turquoise"       64 224 208)
-    ("cyan"            0 255 255)
-    ("lightcyan"       224 255 255)
-    ("cadetblue"       95 158 160)
-    ("mediumaquamarine"        102 205 170)
-    ("aquamarine"      127 255 212)
-    ("darkgreen"       0 100 0)
-    ("darkolivegreen"  85 107 47)
-    ("darkseagreen"    143 188 143)
-    ("seagreen"                46 139 87)
-    ("mediumseagreen"  60 179 113)
-    ("lightseagreen"   32 178 170)
-    ("palegreen"       152 251 152)
-    ("springgreen"     0 255 127)
-    ("lawngreen"       124 252 0)
-    ("green"           0 255 0)
-    ("chartreuse"      127 255 0)
-    ("mediumspringgreen"       0 250 154)
-    ("greenyellow"     173 255 47)
-    ("limegreen"       50 205 50)
-    ("yellowgreen"     154 205 50)
-    ("forestgreen"     34 139 34)
-    ("olivedrab"       107 142 35)
-    ("darkkhaki"       189 183 107)
-    ("khaki"           240 230 140)
-    ("palegoldenrod"   238 232 170)
-    ("lightgoldenrodyellow"    250 250 210)
-    ("lightyellow"     255 255 224)
-    ("yellow"          255 255 0)
-    ("gold"            255 215 0)
-    ("lightgoldenrod"  238 221 130)
-    ("goldenrod"       218 165 32)
-    ("darkgoldenrod"   184 134 11)
-    ("rosybrown"       188 143 143)
-    ("indianred"       205 92 92)
-    ("saddlebrown"     139 69 19)
-    ("sienna"          160 82 45)
-    ("peru"            205 133 63)
-    ("burlywood"       222 184 135)
-    ("beige"           245 245 220)
-    ("wheat"           245 222 179)
-    ("sandybrown"      244 164 96)
-    ("tan"             210 180 140)
-    ("chocolate"       210 105 30)
-    ("firebrick"       178 34 34)
-    ("brown"           165 42 42)
-    ("darksalmon"      233 150 122)
-    ("salmon"          250 128 114)
-    ("lightsalmon"     255 160 122)
-    ("orange"          255 165 0)
-    ("darkorange"      255 140 0)
-    ("coral"           255 127 80)
-    ("lightcoral"      240 128 128)
-    ("tomato"          255 99 71)
-    ("orangered"       255 69 0)
-    ("red"             255 0 0)
-    ("hotpink"         255 105 180)
-    ("deeppink"                255 20 147)
-    ("pink"            255 192 203)
-    ("lightpink"       255 182 193)
-    ("palevioletred"   219 112 147)
-    ("maroon"          176 48 96)
-    ("mediumvioletred" 199 21 133)
-    ("violetred"       208 32 144)
-    ("magenta"         255 0 255)
-    ("violet"          238 130 238)
-    ("plum"            221 160 221)
-    ("orchid"          218 112 214)
-    ("mediumorchid"    186 85 211)
-    ("darkorchid"      153 50 204)
-    ("darkviolet"      148 0 211)
-    ("blueviolet"      138 43 226)
-    ("purple"          160 32 240)
-    ("mediumpurple"    147 112 219)
-    ("thistle"         216 191 216)
-    ("snow1"           255 250 250)
-    ("snow2"           238 233 233)
-    ("snow3"           205 201 201)
-    ("snow4"           139 137 137)
-    ("seashell1"       255 245 238)
-    ("seashell2"       238 229 222)
-    ("seashell3"       205 197 191)
-    ("seashell4"       139 134 130)
-    ("antiquewhite1"   255 239 219)
-    ("antiquewhite2"   238 223 204)
-    ("antiquewhite3"   205 192 176)
-    ("antiquewhite4"   139 131 120)
-    ("bisque1"         255 228 196)
-    ("bisque2"         238 213 183)
-    ("bisque3"         205 183 158)
-    ("bisque4"         139 125 107)
-    ("peachpuff1"      255 218 185)
-    ("peachpuff2"      238 203 173)
-    ("peachpuff3"      205 175 149)
-    ("peachpuff4"      139 119 101)
-    ("navajowhite1"    255 222 173)
-    ("navajowhite2"    238 207 161)
-    ("navajowhite3"    205 179 139)
-    ("navajowhite4"    139 121 94)
-    ("lemonchiffon1"   255 250 205)
-    ("lemonchiffon2"   238 233 191)
-    ("lemonchiffon3"   205 201 165)
-    ("lemonchiffon4"   139 137 112)
-    ("cornsilk1"       255 248 220)
-    ("cornsilk2"       238 232 205)
-    ("cornsilk3"       205 200 177)
-    ("cornsilk4"       139 136 120)
-    ("ivory1"          255 255 240)
-    ("ivory2"          238 238 224)
-    ("ivory3"          205 205 193)
-    ("ivory4"          139 139 131)
-    ("honeydew1"       240 255 240)
-    ("honeydew2"       224 238 224)
-    ("honeydew3"       193 205 193)
-    ("honeydew4"       131 139 131)
-    ("lavenderblush1"  255 240 245)
-    ("lavenderblush2"  238 224 229)
-    ("lavenderblush3"  205 193 197)
-    ("lavenderblush4"  139 131 134)
-    ("mistyrose1"      255 228 225)
-    ("mistyrose2"      238 213 210)
-    ("mistyrose3"      205 183 181)
-    ("mistyrose4"      139 125 123)
-    ("azure1"          240 255 255)
-    ("azure2"          224 238 238)
-    ("azure3"          193 205 205)
-    ("azure4"          131 139 139)
-    ("slateblue1"      131 111 255)
-    ("slateblue2"      122 103 238)
-    ("slateblue3"      105 89 205)
-    ("slateblue4"      71 60 139)
-    ("royalblue1"      72 118 255)
-    ("royalblue2"      67 110 238)
-    ("royalblue3"      58 95 205)
-    ("royalblue4"      39 64 139)
-    ("blue1"           0 0 255)
-    ("blue2"           0 0 238)
-    ("blue3"           0 0 205)
-    ("blue4"           0 0 139)
-    ("dodgerblue1"     30 144 255)
-    ("dodgerblue2"     28 134 238)
-    ("dodgerblue3"     24 116 205)
-    ("dodgerblue4"     16 78 139)
-    ("steelblue1"      99 184 255)
-    ("steelblue2"      92 172 238)
-    ("steelblue3"      79 148 205)
-    ("steelblue4"      54 100 139)
-    ("deepskyblue1"    0 191 255)
-    ("deepskyblue2"    0 178 238)
-    ("deepskyblue3"    0 154 205)
-    ("deepskyblue4"    0 104 139)
-    ("skyblue1"                135 206 255)
-    ("skyblue2"                126 192 238)
-    ("skyblue3"                108 166 205)
-    ("skyblue4"                74 112 139)
-    ("lightskyblue1"   176 226 255)
-    ("lightskyblue2"   164 211 238)
-    ("lightskyblue3"   141 182 205)
-    ("lightskyblue4"   96 123 139)
-    ("slategray1"      198 226 255)
-    ("slategray2"      185 211 238)
-    ("slategray3"      159 182 205)
-    ("slategray4"      108 123 139)
-    ("lightsteelblue1" 202 225 255)
-    ("lightsteelblue2" 188 210 238)
-    ("lightsteelblue3" 162 181 205)
-    ("lightsteelblue4" 110 123 139)
-    ("lightblue1"      191 239 255)
-    ("lightblue2"      178 223 238)
-    ("lightblue3"      154 192 205)
-    ("lightblue4"      104 131 139)
-    ("lightcyan1"      224 255 255)
-    ("lightcyan2"      209 238 238)
-    ("lightcyan3"      180 205 205)
-    ("lightcyan4"      122 139 139)
-    ("paleturquoise1"  187 255 255)
-    ("paleturquoise2"  174 238 238)
-    ("paleturquoise3"  150 205 205)
-    ("paleturquoise4"  102 139 139)
-    ("cadetblue1"      152 245 255)
-    ("cadetblue2"      142 229 238)
-    ("cadetblue3"      122 197 205)
-    ("cadetblue4"      83 134 139)
-    ("turquoise1"      0 245 255)
-    ("turquoise2"      0 229 238)
-    ("turquoise3"      0 197 205)
-    ("turquoise4"      0 134 139)
-    ("cyan1"           0 255 255)
-    ("cyan2"           0 238 238)
-    ("cyan3"           0 205 205)
-    ("cyan4"           0 139 139)
-    ("darkslategray1"  151 255 255)
-    ("darkslategray2"  141 238 238)
-    ("darkslategray3"  121 205 205)
-    ("darkslategray4"  82 139 139)
-    ("aquamarine1"     127 255 212)
-    ("aquamarine2"     118 238 198)
-    ("aquamarine3"     102 205 170)
-    ("aquamarine4"     69 139 116)
-    ("darkseagreen1"   193 255 193)
-    ("darkseagreen2"   180 238 180)
-    ("darkseagreen3"   155 205 155)
-    ("darkseagreen4"   105 139 105)
-    ("seagreen1"       84 255 159)
-    ("seagreen2"       78 238 148)
-    ("seagreen3"       67 205 128)
-    ("seagreen4"       46 139 87)
-    ("palegreen1"      154 255 154)
-    ("palegreen2"      144 238 144)
-    ("palegreen3"      124 205 124)
-    ("palegreen4"      84 139 84)
-    ("springgreen1"    0 255 127)
-    ("springgreen2"    0 238 118)
-    ("springgreen3"    0 205 102)
-    ("springgreen4"    0 139 69)
-    ("green1"          0 255 0)
-    ("green2"          0 238 0)
-    ("green3"          0 205 0)
-    ("green4"          0 139 0)
-    ("chartreuse1"     127 255 0)
-    ("chartreuse2"     118 238 0)
-    ("chartreuse3"     102 205 0)
-    ("chartreuse4"     69 139 0)
-    ("olivedrab1"      192 255 62)
-    ("olivedrab2"      179 238 58)
-    ("olivedrab3"      154 205 50)
-    ("olivedrab4"      105 139 34)
-    ("darkolivegreen1" 202 255 112)
-    ("darkolivegreen2" 188 238 104)
-    ("darkolivegreen3" 162 205 90)
-    ("darkolivegreen4" 110 139 61)
-    ("khaki1"          255 246 143)
-    ("khaki2"          238 230 133)
-    ("khaki3"          205 198 115)
-    ("khaki4"          139 134 78)
-    ("lightgoldenrod1" 255 236 139)
-    ("lightgoldenrod2" 238 220 130)
-    ("lightgoldenrod3" 205 190 112)
-    ("lightgoldenrod4" 139 129 76)
-    ("lightyellow1"    255 255 224)
-    ("lightyellow2"    238 238 209)
-    ("lightyellow3"    205 205 180)
-    ("lightyellow4"    139 139 122)
-    ("yellow1"         255 255 0)
-    ("yellow2"         238 238 0)
-    ("yellow3"         205 205 0)
-    ("yellow4"         139 139 0)
-    ("gold1"           255 215 0)
-    ("gold2"           238 201 0)
-    ("gold3"           205 173 0)
-    ("gold4"           139 117 0)
-    ("goldenrod1"      255 193 37)
-    ("goldenrod2"      238 180 34)
-    ("goldenrod3"      205 155 29)
-    ("goldenrod4"      139 105 20)
-    ("darkgoldenrod1"  255 185 15)
-    ("darkgoldenrod2"  238 173 14)
-    ("darkgoldenrod3"  205 149 12)
-    ("darkgoldenrod4"  139 101 8)
-    ("rosybrown1"      255 193 193)
-    ("rosybrown2"      238 180 180)
-    ("rosybrown3"      205 155 155)
-    ("rosybrown4"      139 105 105)
-    ("indianred1"      255 106 106)
-    ("indianred2"      238 99 99)
-    ("indianred3"      205 85 85)
-    ("indianred4"      139 58 58)
-    ("sienna1"         255 130 71)
-    ("sienna2"         238 121 66)
-    ("sienna3"         205 104 57)
-    ("sienna4"         139 71 38)
-    ("burlywood1"      255 211 155)
-    ("burlywood2"      238 197 145)
-    ("burlywood3"      205 170 125)
-    ("burlywood4"      139 115 85)
-    ("wheat1"          255 231 186)
-    ("wheat2"          238 216 174)
-    ("wheat3"          205 186 150)
-    ("wheat4"          139 126 102)
-    ("tan1"            255 165 79)
-    ("tan2"            238 154 73)
-    ("tan3"            205 133 63)
-    ("tan4"            139 90 43)
-    ("chocolate1"      255 127 36)
-    ("chocolate2"      238 118 33)
-    ("chocolate3"      205 102 29)
-    ("chocolate4"      139 69 19)
-    ("firebrick1"      255 48 48)
-    ("firebrick2"      238 44 44)
-    ("firebrick3"      205 38 38)
-    ("firebrick4"      139 26 26)
-    ("brown1"          255 64 64)
-    ("brown2"          238 59 59)
-    ("brown3"          205 51 51)
-    ("brown4"          139 35 35)
-    ("salmon1"         255 140 105)
-    ("salmon2"         238 130 98)
-    ("salmon3"         205 112 84)
-    ("salmon4"         139 76 57)
-    ("lightsalmon1"    255 160 122)
-    ("lightsalmon2"    238 149 114)
-    ("lightsalmon3"    205 129 98)
-    ("lightsalmon4"    139 87 66)
-    ("orange1"         255 165 0)
-    ("orange2"         238 154 0)
-    ("orange3"         205 133 0)
-    ("orange4"         139 90 0)
-    ("darkorange1"     255 127 0)
-    ("darkorange2"     238 118 0)
-    ("darkorange3"     205 102 0)
-    ("darkorange4"     139 69 0)
-    ("coral1"          255 114 86)
-    ("coral2"          238 106 80)
-    ("coral3"          205 91 69)
-    ("coral4"          139 62 47)
-    ("tomato1"         255 99 71)
-    ("tomato2"         238 92 66)
-    ("tomato3"         205 79 57)
-    ("tomato4"         139 54 38)
-    ("orangered1"      255 69 0)
-    ("orangered2"      238 64 0)
-    ("orangered3"      205 55 0)
-    ("orangered4"      139 37 0)
-    ("red1"            255 0 0)
-    ("red2"            238 0 0)
-    ("red3"            205 0 0)
-    ("red4"            139 0 0)
-    ("deeppink1"       255 20 147)
-    ("deeppink2"       238 18 137)
-    ("deeppink3"       205 16 118)
-    ("deeppink4"       139 10 80)
-    ("hotpink1"                255 110 180)
-    ("hotpink2"                238 106 167)
-    ("hotpink3"                205 96 144)
-    ("hotpink4"                139 58 98)
-    ("pink1"           255 181 197)
-    ("pink2"           238 169 184)
-    ("pink3"           205 145 158)
-    ("pink4"           139 99 108)
-    ("lightpink1"      255 174 185)
-    ("lightpink2"      238 162 173)
-    ("lightpink3"      205 140 149)
-    ("lightpink4"      139 95 101)
-    ("palevioletred1"  255 130 171)
-    ("palevioletred2"  238 121 159)
-    ("palevioletred3"  205 104 137)
-    ("palevioletred4"  139 71 93)
-    ("maroon1"         255 52 179)
-    ("maroon2"         238 48 167)
-    ("maroon3"         205 41 144)
-    ("maroon4"         139 28 98)
-    ("violetred1"      255 62 150)
-    ("violetred2"      238 58 140)
-    ("violetred3"      205 50 120)
-    ("violetred4"      139 34 82)
-    ("magenta1"                255 0 255)
-    ("magenta2"                238 0 238)
-    ("magenta3"                205 0 205)
-    ("magenta4"                139 0 139)
-    ("orchid1"         255 131 250)
-    ("orchid2"         238 122 233)
-    ("orchid3"         205 105 201)
-    ("orchid4"         139 71 137)
-    ("plum1"           255 187 255)
-    ("plum2"           238 174 238)
-    ("plum3"           205 150 205)
-    ("plum4"           139 102 139)
-    ("mediumorchid1"   224 102 255)
-    ("mediumorchid2"   209 95 238)
-    ("mediumorchid3"   180 82 205)
-    ("mediumorchid4"   122 55 139)
-    ("darkorchid1"     191 62 255)
-    ("darkorchid2"     178 58 238)
-    ("darkorchid3"     154 50 205)
-    ("darkorchid4"     104 34 139)
-    ("purple1"         155 48 255)
-    ("purple2"         145 44 238)
-    ("purple3"         125 38 205)
-    ("purple4"         85 26 139)
-    ("mediumpurple1"   171 130 255)
-    ("mediumpurple2"   159 121 238)
-    ("mediumpurple3"   137 104 205)
-    ("mediumpurple4"   93 71 139)
-    ("thistle1"                255 225 255)
-    ("thistle2"                238 210 238)
-    ("thistle3"                205 181 205)
-    ("thistle4"                139 123 139)
-    ("gray0"           0 0 0)
-    ("grey0"           0 0 0)
-    ("gray1"           3 3 3)
-    ("grey1"           3 3 3)
-    ("gray2"           5 5 5)
-    ("grey2"           5 5 5)
-    ("gray3"           8 8 8)
-    ("grey3"           8 8 8)
-    ("gray4"           10 10 10)
-    ("grey4"           10 10 10)
-    ("gray5"           13 13 13)
-    ("grey5"           13 13 13)
-    ("gray6"           15 15 15)
-    ("grey6"           15 15 15)
-    ("gray7"           18 18 18)
-    ("grey7"           18 18 18)
-    ("gray8"           20 20 20)
-    ("grey8"           20 20 20)
-    ("gray9"           23 23 23)
-    ("grey9"           23 23 23)
-    ("gray10"          26 26 26)
-    ("grey10"          26 26 26)
-    ("gray11"          28 28 28)
-    ("grey11"          28 28 28)
-    ("gray12"          31 31 31)
-    ("grey12"          31 31 31)
-    ("gray13"          33 33 33)
-    ("grey13"          33 33 33)
-    ("gray14"          36 36 36)
-    ("grey14"          36 36 36)
-    ("gray15"          38 38 38)
-    ("grey15"          38 38 38)
-    ("gray16"          41 41 41)
-    ("grey16"          41 41 41)
-    ("gray17"          43 43 43)
-    ("grey17"          43 43 43)
-    ("gray18"          46 46 46)
-    ("grey18"          46 46 46)
-    ("gray19"          48 48 48)
-    ("grey19"          48 48 48)
-    ("gray20"          51 51 51)
-    ("grey20"          51 51 51)
-    ("gray21"          54 54 54)
-    ("grey21"          54 54 54)
-    ("gray22"          56 56 56)
-    ("grey22"          56 56 56)
-    ("gray23"          59 59 59)
-    ("grey23"          59 59 59)
-    ("gray24"          61 61 61)
-    ("grey24"          61 61 61)
-    ("gray25"          64 64 64)
-    ("grey25"          64 64 64)
-    ("gray26"          66 66 66)
-    ("grey26"          66 66 66)
-    ("gray27"          69 69 69)
-    ("grey27"          69 69 69)
-    ("gray28"          71 71 71)
-    ("grey28"          71 71 71)
-    ("gray29"          74 74 74)
-    ("grey29"          74 74 74)
-    ("gray30"          77 77 77)
-    ("grey30"          77 77 77)
-    ("gray31"          79 79 79)
-    ("grey31"          79 79 79)
-    ("gray32"          82 82 82)
-    ("grey32"          82 82 82)
-    ("gray33"          84 84 84)
-    ("grey33"          84 84 84)
-    ("gray34"          87 87 87)
-    ("grey34"          87 87 87)
-    ("gray35"          89 89 89)
-    ("grey35"          89 89 89)
-    ("gray36"          92 92 92)
-    ("grey36"          92 92 92)
-    ("gray37"          94 94 94)
-    ("grey37"          94 94 94)
-    ("gray38"          97 97 97)
-    ("grey38"          97 97 97)
-    ("gray39"          99 99 99)
-    ("grey39"          99 99 99)
-    ("gray40"          102 102 102)
-    ("grey40"          102 102 102)
-    ("gray41"          105 105 105)
-    ("grey41"          105 105 105)
-    ("gray42"          107 107 107)
-    ("grey42"          107 107 107)
-    ("gray43"          110 110 110)
-    ("grey43"          110 110 110)
-    ("gray44"          112 112 112)
-    ("grey44"          112 112 112)
-    ("gray45"          115 115 115)
-    ("grey45"          115 115 115)
-    ("gray46"          117 117 117)
-    ("grey46"          117 117 117)
-    ("gray47"          120 120 120)
-    ("grey47"          120 120 120)
-    ("gray48"          122 122 122)
-    ("grey48"          122 122 122)
-    ("gray49"          125 125 125)
-    ("grey49"          125 125 125)
-    ("gray50"          127 127 127)
-    ("grey50"          127 127 127)
-    ("gray51"          130 130 130)
-    ("grey51"          130 130 130)
-    ("gray52"          133 133 133)
-    ("grey52"          133 133 133)
-    ("gray53"          135 135 135)
-    ("grey53"          135 135 135)
-    ("gray54"          138 138 138)
-    ("grey54"          138 138 138)
-    ("gray55"          140 140 140)
-    ("grey55"          140 140 140)
-    ("gray56"          143 143 143)
-    ("grey56"          143 143 143)
-    ("gray57"          145 145 145)
-    ("grey57"          145 145 145)
-    ("gray58"          148 148 148)
-    ("grey58"          148 148 148)
-    ("gray59"          150 150 150)
-    ("grey59"          150 150 150)
-    ("gray60"          153 153 153)
-    ("grey60"          153 153 153)
-    ("gray61"          156 156 156)
-    ("grey61"          156 156 156)
-    ("gray62"          158 158 158)
-    ("grey62"          158 158 158)
-    ("gray63"          161 161 161)
-    ("grey63"          161 161 161)
-    ("gray64"          163 163 163)
-    ("grey64"          163 163 163)
-    ("gray65"          166 166 166)
-    ("grey65"          166 166 166)
-    ("gray66"          168 168 168)
-    ("grey66"          168 168 168)
-    ("gray67"          171 171 171)
-    ("grey67"          171 171 171)
-    ("gray68"          173 173 173)
-    ("grey68"          173 173 173)
-    ("gray69"          176 176 176)
-    ("grey69"          176 176 176)
-    ("gray70"          179 179 179)
-    ("grey70"          179 179 179)
-    ("gray71"          181 181 181)
-    ("grey71"          181 181 181)
-    ("gray72"          184 184 184)
-    ("grey72"          184 184 184)
-    ("gray73"          186 186 186)
-    ("grey73"          186 186 186)
-    ("gray74"          189 189 189)
-    ("grey74"          189 189 189)
-    ("gray75"          191 191 191)
-    ("grey75"          191 191 191)
-    ("gray76"          194 194 194)
-    ("grey76"          194 194 194)
-    ("gray77"          196 196 196)
-    ("grey77"          196 196 196)
-    ("gray78"          199 199 199)
-    ("grey78"          199 199 199)
-    ("gray79"          201 201 201)
-    ("grey79"          201 201 201)
-    ("gray80"          204 204 204)
-    ("grey80"          204 204 204)
-    ("gray81"          207 207 207)
-    ("grey81"          207 207 207)
-    ("gray82"          209 209 209)
-    ("grey82"          209 209 209)
-    ("gray83"          212 212 212)
-    ("grey83"          212 212 212)
-    ("gray84"          214 214 214)
-    ("grey84"          214 214 214)
-    ("gray85"          217 217 217)
-    ("grey85"          217 217 217)
-    ("gray86"          219 219 219)
-    ("grey86"          219 219 219)
-    ("gray87"          222 222 222)
-    ("grey87"          222 222 222)
-    ("gray88"          224 224 224)
-    ("grey88"          224 224 224)
-    ("gray89"          227 227 227)
-    ("grey89"          227 227 227)
-    ("gray90"          229 229 229)
-    ("grey90"          229 229 229)
-    ("gray91"          232 232 232)
-    ("grey91"          232 232 232)
-    ("gray92"          235 235 235)
-    ("grey92"          235 235 235)
-    ("gray93"          237 237 237)
-    ("grey93"          237 237 237)
-    ("gray94"          240 240 240)
-    ("grey94"          240 240 240)
-    ("gray95"          242 242 242)
-    ("grey95"          242 242 242)
-    ("gray96"          245 245 245)
-    ("grey96"          245 245 245)
-    ("gray97"          247 247 247)
-    ("grey97"          247 247 247)
-    ("gray98"          250 250 250)
-    ("grey98"          250 250 250)
-    ("gray99"          252 252 252)
-    ("grey99"          252 252 252)
-    ("gray100"         255 255 255)
-    ("grey100"         255 255 255)
-    ("darkgrey"                169 169 169)
-    ("darkgray"                169 169 169)
-    ("darkblue"                0 0 139)
-    ("darkcyan"                0 139 139) ; no "lightmagenta", see the comment above
-    ("darkmagenta"     139 0 139)
-    ("darkred"         139 0 0)  ; but no "lightred", see the comment above
-    ("lightgreen"      144 238 144))
-  "An alist of X color names and associated 8-bit RGB values.")
+  '(("snow"            65535 64250 64250)
+    ("ghostwhite"      63736 63736 65535)
+    ("whitesmoke"      62965 62965 62965)
+    ("gainsboro"       56540 56540 56540)
+    ("floralwhite"     65535 64250 61680)
+    ("oldlace"         65021 62965 59110)
+    ("linen"           64250 61680 59110)
+    ("antiquewhite"    64250 60395 55255)
+    ("papayawhip"      65535 61423 54741)
+    ("blanchedalmond"  65535 60395 52685)
+    ("bisque"          65535 58596 50372)
+    ("peachpuff"       65535 56026 47545)
+    ("navajowhite"     65535 57054 44461)
+    ("moccasin"                65535 58596 46517)
+    ("cornsilk"                65535 63736 56540)
+    ("ivory"           65535 65535 61680)
+    ("lemonchiffon"    65535 64250 52685)
+    ("seashell"                65535 62965 61166)
+    ("honeydew"                61680 65535 61680)
+    ("mintcream"       62965 65535 64250)
+    ("azure"           61680 65535 65535)
+    ("aliceblue"       61680 63736 65535)
+    ("lavender"                59110 59110 64250)
+    ("lavenderblush"   65535 61680 62965)
+    ("mistyrose"       65535 58596 57825)
+    ("white"           65535 65535 65535)
+    ("black"               0     0     0)
+    ("darkslategray"   12079 20303 20303)
+    ("darkslategrey"   12079 20303 20303)
+    ("dimgray"         26985 26985 26985)
+    ("dimgrey"         26985 26985 26985)
+    ("slategray"       28784 32896 37008)
+    ("slategrey"       28784 32896 37008)
+    ("lightslategray"  30583 34952 39321)
+    ("lightslategrey"  30583 34952 39321)
+    ("gray"            48830 48830 48830)
+    ("grey"            48830 48830 48830)
+    ("lightgrey"       54227 54227 54227)
+    ("lightgray"       54227 54227 54227)
+    ("midnightblue"     6425  6425 28784)
+    ("navy"                0     0 32896)
+    ("navyblue"                    0     0 32896)
+    ("cornflowerblue"  25700 38293 60909)
+    ("darkslateblue"   18504 15677 35723)
+    ("slateblue"       27242 23130 52685)
+    ("mediumslateblue" 31611 26728 61166)
+    ("lightslateblue"  33924 28784 65535)
+    ("mediumblue"          0     0 52685)
+    ("royalblue"       16705 26985 57825)
+    ("blue"                0     0 65535)
+    ("dodgerblue"       7710 37008 65535)
+    ("deepskyblue"         0 49087 65535)
+    ("skyblue"         34695 52942 60395)
+    ("lightskyblue"    34695 52942 64250)
+    ("steelblue"       17990 33410 46260)
+    ("lightsteelblue"  45232 50372 57054)
+    ("lightblue"       44461 55512 59110)
+    ("powderblue"      45232 57568 59110)
+    ("paleturquoise"   44975 61166 61166)
+    ("darkturquoise"       0 52942 53713)
+    ("mediumturquoise" 18504 53713 52428)
+    ("turquoise"       16448 57568 53456)
+    ("cyan"                0 65535 65535)
+    ("lightcyan"       57568 65535 65535)
+    ("cadetblue"       24415 40606 41120)
+    ("mediumaquamarine"        26214 52685 43690)
+    ("aquamarine"      32639 65535 54484)
+    ("darkgreen"           0 25700     0)
+    ("darkolivegreen"  21845 27499 12079)
+    ("darkseagreen"    36751 48316 36751)
+    ("seagreen"                11822 35723 22359)
+    ("mediumseagreen"  15420 46003 29041)
+    ("lightseagreen"    8224 45746 43690)
+    ("palegreen"       39064 64507 39064)
+    ("springgreen"         0 65535 32639)
+    ("lawngreen"       31868 64764     0)
+    ("green"               0 65535     0)
+    ("chartreuse"      32639 65535     0)
+    ("mediumspringgreen"    0 64250 39578)
+    ("greenyellow"     44461 65535 12079)
+    ("limegreen"       12850 52685 12850)
+    ("yellowgreen"     39578 52685 12850)
+    ("forestgreen"      8738 35723  8738)
+    ("olivedrab"       27499 36494  8995)
+    ("darkkhaki"       48573 47031 27499)
+    ("khaki"           61680 59110 35980)
+    ("palegoldenrod"   61166 59624 43690)
+    ("lightgoldenrodyellow" 64250 64250 53970)
+    ("lightyellow"     65535 65535 57568)
+    ("yellow"          65535 65535     0)
+    ("gold"            65535 55255     0)
+    ("lightgoldenrod"  61166 56797 33410)
+    ("goldenrod"       56026 42405  8224)
+    ("darkgoldenrod"   47288 34438  2827)
+    ("rosybrown"       48316 36751 36751)
+    ("indianred"       52685 23644 23644)
+    ("saddlebrown"     35723 17733  4883)
+    ("sienna"          41120 21074 11565)
+    ("peru"            52685 34181 16191)
+    ("burlywood"       57054 47288 34695)
+    ("beige"           62965 62965 56540)
+    ("wheat"           62965 57054 46003)
+    ("sandybrown"      62708 42148 24672)
+    ("tan"             53970 46260 35980)
+    ("chocolate"       53970 26985  7710)
+    ("firebrick"       45746  8738  8738)
+    ("brown"           42405 10794 10794)
+    ("darksalmon"      59881 38550 31354)
+    ("salmon"          64250 32896 29298)
+    ("lightsalmon"     65535 41120 31354)
+    ("orange"          65535 42405     0)
+    ("darkorange"      65535 35980     0)
+    ("coral"           65535 32639 20560)
+    ("lightcoral"      61680 32896 32896)
+    ("tomato"          65535 25443 18247)
+    ("orangered"       65535 17733     0)
+    ("red"             65535     0     0)
+    ("hotpink"         65535 26985 46260)
+    ("deeppink"                65535  5140 37779)
+    ("pink"            65535 49344 52171)
+    ("lightpink"       65535 46774 49601)
+    ("palevioletred"   56283 28784 37779)
+    ("maroon"          45232 12336 24672)
+    ("mediumvioletred" 51143  5397 34181)
+    ("violetred"       53456  8224 37008)
+    ("magenta"         65535     0 65535)
+    ("violet"          61166 33410 61166)
+    ("plum"            56797 41120 56797)
+    ("orchid"          56026 28784 54998)
+    ("mediumorchid"    47802 21845 54227)
+    ("darkorchid"      39321 12850 52428)
+    ("darkviolet"      38036     0 54227)
+    ("blueviolet"      35466 11051 58082)
+    ("purple"          41120  8224 61680)
+    ("mediumpurple"    37779 28784 56283)
+    ("thistle"         55512 49087 55512)
+    ("snow1"           65535 64250 64250)
+    ("snow2"           61166 59881 59881)
+    ("snow3"           52685 51657 51657)
+    ("snow4"           35723 35209 35209)
+    ("seashell1"       65535 62965 61166)
+    ("seashell2"       61166 58853 57054)
+    ("seashell3"       52685 50629 49087)
+    ("seashell4"       35723 34438 33410)
+    ("antiquewhite1"   65535 61423 56283)
+    ("antiquewhite2"   61166 57311 52428)
+    ("antiquewhite3"   52685 49344 45232)
+    ("antiquewhite4"   35723 33667 30840)
+    ("bisque1"         65535 58596 50372)
+    ("bisque2"         61166 54741 47031)
+    ("bisque3"         52685 47031 40606)
+    ("bisque4"         35723 32125 27499)
+    ("peachpuff1"      65535 56026 47545)
+    ("peachpuff2"      61166 52171 44461)
+    ("peachpuff3"      52685 44975 38293)
+    ("peachpuff4"      35723 30583 25957)
+    ("navajowhite1"    65535 57054 44461)
+    ("navajowhite2"    61166 53199 41377)
+    ("navajowhite3"    52685 46003 35723)
+    ("navajowhite4"    35723 31097 24158)
+    ("lemonchiffon1"   65535 64250 52685)
+    ("lemonchiffon2"   61166 59881 49087)
+    ("lemonchiffon3"   52685 51657 42405)
+    ("lemonchiffon4"   35723 35209 28784)
+    ("cornsilk1"       65535 63736 56540)
+    ("cornsilk2"       61166 59624 52685)
+    ("cornsilk3"       52685 51400 45489)
+    ("cornsilk4"       35723 34952 30840)
+    ("ivory1"          65535 65535 61680)
+    ("ivory2"          61166 61166 57568)
+    ("ivory3"          52685 52685 49601)
+    ("ivory4"          35723 35723 33667)
+    ("honeydew1"       61680 65535 61680)
+    ("honeydew2"       57568 61166 57568)
+    ("honeydew3"       49601 52685 49601)
+    ("honeydew4"       33667 35723 33667)
+    ("lavenderblush1"  65535 61680 62965)
+    ("lavenderblush2"  61166 57568 58853)
+    ("lavenderblush3"  52685 49601 50629)
+    ("lavenderblush4"  35723 33667 34438)
+    ("mistyrose1"      65535 58596 57825)
+    ("mistyrose2"      61166 54741 53970)
+    ("mistyrose3"      52685 47031 46517)
+    ("mistyrose4"      35723 32125 31611)
+    ("azure1"          61680 65535 65535)
+    ("azure2"          57568 61166 61166)
+    ("azure3"          49601 52685 52685)
+    ("azure4"          33667 35723 35723)
+    ("slateblue1"      33667 28527 65535)
+    ("slateblue2"      31354 26471 61166)
+    ("slateblue3"      26985 22873 52685)
+    ("slateblue4"      18247 15420 35723)
+    ("royalblue1"      18504 30326 65535)
+    ("royalblue2"      17219 28270 61166)
+    ("royalblue3"      14906 24415 52685)
+    ("royalblue4"      10023 16448 35723)
+    ("blue1"               0     0 65535)
+    ("blue2"               0     0 61166)
+    ("blue3"               0     0 52685)
+    ("blue4"               0     0 35723)
+    ("dodgerblue1"      7710 37008 65535)
+    ("dodgerblue2"      7196 34438 61166)
+    ("dodgerblue3"      6168 29812 52685)
+    ("dodgerblue4"      4112 20046 35723)
+    ("steelblue1"      25443 47288 65535)
+    ("steelblue2"      23644 44204 61166)
+    ("steelblue3"      20303 38036 52685)
+    ("steelblue4"      13878 25700 35723)
+    ("deepskyblue1"        0 49087 65535)
+    ("deepskyblue2"        0 45746 61166)
+    ("deepskyblue3"        0 39578 52685)
+    ("deepskyblue4"        0 26728 35723)
+    ("skyblue1"                34695 52942 65535)
+    ("skyblue2"                32382 49344 61166)
+    ("skyblue3"                27756 42662 52685)
+    ("skyblue4"                19018 28784 35723)
+    ("lightskyblue1"   45232 58082 65535)
+    ("lightskyblue2"   42148 54227 61166)
+    ("lightskyblue3"   36237 46774 52685)
+    ("lightskyblue4"   24672 31611 35723)
+    ("slategray1"      50886 58082 65535)
+    ("slategray2"      47545 54227 61166)
+    ("slategray3"      40863 46774 52685)
+    ("slategray4"      27756 31611 35723)
+    ("lightsteelblue1" 51914 57825 65535)
+    ("lightsteelblue2" 48316 53970 61166)
+    ("lightsteelblue3" 41634 46517 52685)
+    ("lightsteelblue4" 28270 31611 35723)
+    ("lightblue1"      49087 61423 65535)
+    ("lightblue2"      45746 57311 61166)
+    ("lightblue3"      39578 49344 52685)
+    ("lightblue4"      26728 33667 35723)
+    ("lightcyan1"      57568 65535 65535)
+    ("lightcyan2"      53713 61166 61166)
+    ("lightcyan3"      46260 52685 52685)
+    ("lightcyan4"      31354 35723 35723)
+    ("paleturquoise1"  48059 65535 65535)
+    ("paleturquoise2"  44718 61166 61166)
+    ("paleturquoise3"  38550 52685 52685)
+    ("paleturquoise4"  26214 35723 35723)
+    ("cadetblue1"      39064 62965 65535)
+    ("cadetblue2"      36494 58853 61166)
+    ("cadetblue3"      31354 50629 52685)
+    ("cadetblue4"      21331 34438 35723)
+    ("turquoise1"          0 62965 65535)
+    ("turquoise2"          0 58853 61166)
+    ("turquoise3"          0 50629 52685)
+    ("turquoise4"          0 34438 35723)
+    ("cyan1"               0 65535 65535)
+    ("cyan2"               0 61166 61166)
+    ("cyan3"               0 52685 52685)
+    ("cyan4"               0 35723 35723)
+    ("darkslategray1"  38807 65535 65535)
+    ("darkslategray2"  36237 61166 61166)
+    ("darkslategray3"  31097 52685 52685)
+    ("darkslategray4"  21074 35723 35723)
+    ("aquamarine1"     32639 65535 54484)
+    ("aquamarine2"     30326 61166 50886)
+    ("aquamarine3"     26214 52685 43690)
+    ("aquamarine4"     17733 35723 29812)
+    ("darkseagreen1"   49601 65535 49601)
+    ("darkseagreen2"   46260 61166 46260)
+    ("darkseagreen3"   39835 52685 39835)
+    ("darkseagreen4"   26985 35723 26985)
+    ("seagreen1"       21588 65535 40863)
+    ("seagreen2"       20046 61166 38036)
+    ("seagreen3"       17219 52685 32896)
+    ("seagreen4"       11822 35723 22359)
+    ("palegreen1"      39578 65535 39578)
+    ("palegreen2"      37008 61166 37008)
+    ("palegreen3"      31868 52685 31868)
+    ("palegreen4"      21588 35723 21588)
+    ("springgreen1"        0 65535 32639)
+    ("springgreen2"        0 61166 30326)
+    ("springgreen3"        0 52685 26214)
+    ("springgreen4"        0 35723 17733)
+    ("green1"              0 65535     0)
+    ("green2"              0 61166     0)
+    ("green3"              0 52685     0)
+    ("green4"              0 35723     0)
+    ("chartreuse1"     32639 65535     0)
+    ("chartreuse2"     30326 61166     0)
+    ("chartreuse3"     26214 52685     0)
+    ("chartreuse4"     17733 35723     0)
+    ("olivedrab1"      49344 65535 15934)
+    ("olivedrab2"      46003 61166 14906)
+    ("olivedrab3"      39578 52685 12850)
+    ("olivedrab4"      26985 35723  8738)
+    ("darkolivegreen1" 51914 65535 28784)
+    ("darkolivegreen2" 48316 61166 26728)
+    ("darkolivegreen3" 41634 52685 23130)
+    ("darkolivegreen4" 28270 35723 15677)
+    ("khaki1"          65535 63222 36751)
+    ("khaki2"          61166 59110 34181)
+    ("khaki3"          52685 50886 29555)
+    ("khaki4"          35723 34438 20046)
+    ("lightgoldenrod1" 65535 60652 35723)
+    ("lightgoldenrod2" 61166 56540 33410)
+    ("lightgoldenrod3" 52685 48830 28784)
+    ("lightgoldenrod4" 35723 33153 19532)
+    ("lightyellow1"    65535 65535 57568)
+    ("lightyellow2"    61166 61166 53713)
+    ("lightyellow3"    52685 52685 46260)
+    ("lightyellow4"    35723 35723 31354)
+    ("yellow1"         65535 65535     0)
+    ("yellow2"         61166 61166     0)
+    ("yellow3"         52685 52685     0)
+    ("yellow4"         35723 35723     0)
+    ("gold1"           65535 55255     0)
+    ("gold2"           61166 51657     0)
+    ("gold3"           52685 44461     0)
+    ("gold4"           35723 30069     0)
+    ("goldenrod1"      65535 49601  9509)
+    ("goldenrod2"      61166 46260  8738)
+    ("goldenrod3"      52685 39835  7453)
+    ("goldenrod4"      35723 26985  5140)
+    ("darkgoldenrod1"  65535 47545  3855)
+    ("darkgoldenrod2"  61166 44461  3598)
+    ("darkgoldenrod3"  52685 38293  3084)
+    ("darkgoldenrod4"  35723 25957  2056)
+    ("rosybrown1"      65535 49601 49601)
+    ("rosybrown2"      61166 46260 46260)
+    ("rosybrown3"      52685 39835 39835)
+    ("rosybrown4"      35723 26985 26985)
+    ("indianred1"      65535 27242 27242)
+    ("indianred2"      61166 25443 25443)
+    ("indianred3"      52685 21845 21845)
+    ("indianred4"      35723 14906 14906)
+    ("sienna1"         65535 33410 18247)
+    ("sienna2"         61166 31097 16962)
+    ("sienna3"         52685 26728 14649)
+    ("sienna4"         35723 18247  9766)
+    ("burlywood1"      65535 54227 39835)
+    ("burlywood2"      61166 50629 37265)
+    ("burlywood3"      52685 43690 32125)
+    ("burlywood4"      35723 29555 21845)
+    ("wheat1"          65535 59367 47802)
+    ("wheat2"          61166 55512 44718)
+    ("wheat3"          52685 47802 38550)
+    ("wheat4"          35723 32382 26214)
+    ("tan1"            65535 42405 20303)
+    ("tan2"            61166 39578 18761)
+    ("tan3"            52685 34181 16191)
+    ("tan4"            35723 23130 11051)
+    ("chocolate1"      65535 32639  9252)
+    ("chocolate2"      61166 30326  8481)
+    ("chocolate3"      52685 26214  7453)
+    ("chocolate4"      35723 17733  4883)
+    ("firebrick1"      65535 12336 12336)
+    ("firebrick2"      61166 11308 11308)
+    ("firebrick3"      52685  9766  9766)
+    ("firebrick4"      35723  6682  6682)
+    ("brown1"          65535 16448 16448)
+    ("brown2"          61166 15163 15163)
+    ("brown3"          52685 13107 13107)
+    ("brown4"          35723  8995  8995)
+    ("salmon1"         65535 35980 26985)
+    ("salmon2"         61166 33410 25186)
+    ("salmon3"         52685 28784 21588)
+    ("salmon4"         35723 19532 14649)
+    ("lightsalmon1"    65535 41120 31354)
+    ("lightsalmon2"    61166 38293 29298)
+    ("lightsalmon3"    52685 33153 25186)
+    ("lightsalmon4"    35723 22359 16962)
+    ("orange1"         65535 42405     0)
+    ("orange2"         61166 39578     0)
+    ("orange3"         52685 34181     0)
+    ("orange4"         35723 23130     0)
+    ("darkorange1"     65535 32639     0)
+    ("darkorange2"     61166 30326     0)
+    ("darkorange3"     52685 26214     0)
+    ("darkorange4"     35723 17733     0)
+    ("coral1"          65535 29298 22102)
+    ("coral2"          61166 27242 20560)
+    ("coral3"          52685 23387 17733)
+    ("coral4"          35723 15934 12079)
+    ("tomato1"         65535 25443 18247)
+    ("tomato2"         61166 23644 16962)
+    ("tomato3"         52685 20303 14649)
+    ("tomato4"         35723 13878  9766)
+    ("orangered1"      65535 17733     0)
+    ("orangered2"      61166 16448     0)
+    ("orangered3"      52685 14135     0)
+    ("orangered4"      35723  9509     0)
+    ("red1"            65535     0     0)
+    ("red2"            61166     0     0)
+    ("red3"            52685     0     0)
+    ("red4"            35723     0     0)
+    ("deeppink1"       65535  5140 37779)
+    ("deeppink2"       61166  4626 35209)
+    ("deeppink3"       52685  4112 30326)
+    ("deeppink4"       35723  2570 20560)
+    ("hotpink1"                65535 28270 46260)
+    ("hotpink2"                61166 27242 42919)
+    ("hotpink3"                52685 24672 37008)
+    ("hotpink4"                35723 14906 25186)
+    ("pink1"           65535 46517 50629)
+    ("pink2"           61166 43433 47288)
+    ("pink3"           52685 37265 40606)
+    ("pink4"           35723 25443 27756)
+    ("lightpink1"      65535 44718 47545)
+    ("lightpink2"      61166 41634 44461)
+    ("lightpink3"      52685 35980 38293)
+    ("lightpink4"      35723 24415 25957)
+    ("palevioletred1"  65535 33410 43947)
+    ("palevioletred2"  61166 31097 40863)
+    ("palevioletred3"  52685 26728 35209)
+    ("palevioletred4"  35723 18247 23901)
+    ("maroon1"         65535 13364 46003)
+    ("maroon2"         61166 12336 42919)
+    ("maroon3"         52685 10537 37008)
+    ("maroon4"         35723  7196 25186)
+    ("violetred1"      65535 15934 38550)
+    ("violetred2"      61166 14906 35980)
+    ("violetred3"      52685 12850 30840)
+    ("violetred4"      35723  8738 21074)
+    ("magenta1"                65535     0 65535)
+    ("magenta2"                61166     0 61166)
+    ("magenta3"                52685     0 52685)
+    ("magenta4"                35723     0 35723)
+    ("orchid1"         65535 33667 64250)
+    ("orchid2"         61166 31354 59881)
+    ("orchid3"         52685 26985 51657)
+    ("orchid4"         35723 18247 35209)
+    ("plum1"           65535 48059 65535)
+    ("plum2"           61166 44718 61166)
+    ("plum3"           52685 38550 52685)
+    ("plum4"           35723 26214 35723)
+    ("mediumorchid1"   57568 26214 65535)
+    ("mediumorchid2"   53713 24415 61166)
+    ("mediumorchid3"   46260 21074 52685)
+    ("mediumorchid4"   31354 14135 35723)
+    ("darkorchid1"     49087 15934 65535)
+    ("darkorchid2"     45746 14906 61166)
+    ("darkorchid3"     39578 12850 52685)
+    ("darkorchid4"     26728  8738 35723)
+    ("purple1"         39835 12336 65535)
+    ("purple2"         37265 11308 61166)
+    ("purple3"         32125  9766 52685)
+    ("purple4"         21845  6682 35723)
+    ("mediumpurple1"   43947 33410 65535)
+    ("mediumpurple2"   40863 31097 61166)
+    ("mediumpurple3"   35209 26728 52685)
+    ("mediumpurple4"   23901 18247 35723)
+    ("thistle1"                65535 57825 65535)
+    ("thistle2"                61166 53970 61166)
+    ("thistle3"                52685 46517 52685)
+    ("thistle4"                35723 31611 35723)
+    ("gray0"               0     0     0)
+    ("grey0"               0     0     0)
+    ("gray1"             771   771   771)
+    ("grey1"             771   771   771)
+    ("gray2"            1285  1285  1285)
+    ("grey2"            1285  1285  1285)
+    ("gray3"            2056  2056  2056)
+    ("grey3"            2056  2056  2056)
+    ("gray4"            2570  2570  2570)
+    ("grey4"            2570  2570  2570)
+    ("gray5"            3341  3341  3341)
+    ("grey5"            3341  3341  3341)
+    ("gray6"            3855  3855  3855)
+    ("grey6"            3855  3855  3855)
+    ("gray7"            4626  4626  4626)
+    ("grey7"            4626  4626  4626)
+    ("gray8"            5140  5140  5140)
+    ("grey8"            5140  5140  5140)
+    ("gray9"            5911  5911  5911)
+    ("grey9"            5911  5911  5911)
+    ("gray10"           6682  6682  6682)
+    ("grey10"           6682  6682  6682)
+    ("gray11"           7196  7196  7196)
+    ("grey11"           7196  7196  7196)
+    ("gray12"           7967  7967  7967)
+    ("grey12"           7967  7967  7967)
+    ("gray13"           8481  8481  8481)
+    ("grey13"           8481  8481  8481)
+    ("gray14"           9252  9252  9252)
+    ("grey14"           9252  9252  9252)
+    ("gray15"           9766  9766  9766)
+    ("grey15"           9766  9766  9766)
+    ("gray16"          10537 10537 10537)
+    ("grey16"          10537 10537 10537)
+    ("gray17"          11051 11051 11051)
+    ("grey17"          11051 11051 11051)
+    ("gray18"          11822 11822 11822)
+    ("grey18"          11822 11822 11822)
+    ("gray19"          12336 12336 12336)
+    ("grey19"          12336 12336 12336)
+    ("gray20"          13107 13107 13107)
+    ("grey20"          13107 13107 13107)
+    ("gray21"          13878 13878 13878)
+    ("grey21"          13878 13878 13878)
+    ("gray22"          14392 14392 14392)
+    ("grey22"          14392 14392 14392)
+    ("gray23"          15163 15163 15163)
+    ("grey23"          15163 15163 15163)
+    ("gray24"          15677 15677 15677)
+    ("grey24"          15677 15677 15677)
+    ("gray25"          16448 16448 16448)
+    ("grey25"          16448 16448 16448)
+    ("gray26"          16962 16962 16962)
+    ("grey26"          16962 16962 16962)
+    ("gray27"          17733 17733 17733)
+    ("grey27"          17733 17733 17733)
+    ("gray28"          18247 18247 18247)
+    ("grey28"          18247 18247 18247)
+    ("gray29"          19018 19018 19018)
+    ("grey29"          19018 19018 19018)
+    ("gray30"          19789 19789 19789)
+    ("grey30"          19789 19789 19789)
+    ("gray31"          20303 20303 20303)
+    ("grey31"          20303 20303 20303)
+    ("gray32"          21074 21074 21074)
+    ("grey32"          21074 21074 21074)
+    ("gray33"          21588 21588 21588)
+    ("grey33"          21588 21588 21588)
+    ("gray34"          22359 22359 22359)
+    ("grey34"          22359 22359 22359)
+    ("gray35"          22873 22873 22873)
+    ("grey35"          22873 22873 22873)
+    ("gray36"          23644 23644 23644)
+    ("grey36"          23644 23644 23644)
+    ("gray37"          24158 24158 24158)
+    ("grey37"          24158 24158 24158)
+    ("gray38"          24929 24929 24929)
+    ("grey38"          24929 24929 24929)
+    ("gray39"          25443 25443 25443)
+    ("grey39"          25443 25443 25443)
+    ("gray40"          26214 26214 26214)
+    ("grey40"          26214 26214 26214)
+    ("gray41"          26985 26985 26985)
+    ("grey41"          26985 26985 26985)
+    ("gray42"          27499 27499 27499)
+    ("grey42"          27499 27499 27499)
+    ("gray43"          28270 28270 28270)
+    ("grey43"          28270 28270 28270)
+    ("gray44"          28784 28784 28784)
+    ("grey44"          28784 28784 28784)
+    ("gray45"          29555 29555 29555)
+    ("grey45"          29555 29555 29555)
+    ("gray46"          30069 30069 30069)
+    ("grey46"          30069 30069 30069)
+    ("gray47"          30840 30840 30840)
+    ("grey47"          30840 30840 30840)
+    ("gray48"          31354 31354 31354)
+    ("grey48"          31354 31354 31354)
+    ("gray49"          32125 32125 32125)
+    ("grey49"          32125 32125 32125)
+    ("gray50"          32639 32639 32639)
+    ("grey50"          32639 32639 32639)
+    ("gray51"          33410 33410 33410)
+    ("grey51"          33410 33410 33410)
+    ("gray52"          34181 34181 34181)
+    ("grey52"          34181 34181 34181)
+    ("gray53"          34695 34695 34695)
+    ("grey53"          34695 34695 34695)
+    ("gray54"          35466 35466 35466)
+    ("grey54"          35466 35466 35466)
+    ("gray55"          35980 35980 35980)
+    ("grey55"          35980 35980 35980)
+    ("gray56"          36751 36751 36751)
+    ("grey56"          36751 36751 36751)
+    ("gray57"          37265 37265 37265)
+    ("grey57"          37265 37265 37265)
+    ("gray58"          38036 38036 38036)
+    ("grey58"          38036 38036 38036)
+    ("gray59"          38550 38550 38550)
+    ("grey59"          38550 38550 38550)
+    ("gray60"          39321 39321 39321)
+    ("grey60"          39321 39321 39321)
+    ("gray61"          40092 40092 40092)
+    ("grey61"          40092 40092 40092)
+    ("gray62"          40606 40606 40606)
+    ("grey62"          40606 40606 40606)
+    ("gray63"          41377 41377 41377)
+    ("grey63"          41377 41377 41377)
+    ("gray64"          41891 41891 41891)
+    ("grey64"          41891 41891 41891)
+    ("gray65"          42662 42662 42662)
+    ("grey65"          42662 42662 42662)
+    ("gray66"          43176 43176 43176)
+    ("grey66"          43176 43176 43176)
+    ("gray67"          43947 43947 43947)
+    ("grey67"          43947 43947 43947)
+    ("gray68"          44461 44461 44461)
+    ("grey68"          44461 44461 44461)
+    ("gray69"          45232 45232 45232)
+    ("grey69"          45232 45232 45232)
+    ("gray70"          46003 46003 46003)
+    ("grey70"          46003 46003 46003)
+    ("gray71"          46517 46517 46517)
+    ("grey71"          46517 46517 46517)
+    ("gray72"          47288 47288 47288)
+    ("grey72"          47288 47288 47288)
+    ("gray73"          47802 47802 47802)
+    ("grey73"          47802 47802 47802)
+    ("gray74"          48573 48573 48573)
+    ("grey74"          48573 48573 48573)
+    ("gray75"          49087 49087 49087)
+    ("grey75"          49087 49087 49087)
+    ("gray76"          49858 49858 49858)
+    ("grey76"          49858 49858 49858)
+    ("gray77"          50372 50372 50372)
+    ("grey77"          50372 50372 50372)
+    ("gray78"          51143 51143 51143)
+    ("grey78"          51143 51143 51143)
+    ("gray79"          51657 51657 51657)
+    ("grey79"          51657 51657 51657)
+    ("gray80"          52428 52428 52428)
+    ("grey80"          52428 52428 52428)
+    ("gray81"          53199 53199 53199)
+    ("grey81"          53199 53199 53199)
+    ("gray82"          53713 53713 53713)
+    ("grey82"          53713 53713 53713)
+    ("gray83"          54484 54484 54484)
+    ("grey83"          54484 54484 54484)
+    ("gray84"          54998 54998 54998)
+    ("grey84"          54998 54998 54998)
+    ("gray85"          55769 55769 55769)
+    ("grey85"          55769 55769 55769)
+    ("gray86"          56283 56283 56283)
+    ("grey86"          56283 56283 56283)
+    ("gray87"          57054 57054 57054)
+    ("grey87"          57054 57054 57054)
+    ("gray88"          57568 57568 57568)
+    ("grey88"          57568 57568 57568)
+    ("gray89"          58339 58339 58339)
+    ("grey89"          58339 58339 58339)
+    ("gray90"          58853 58853 58853)
+    ("grey90"          58853 58853 58853)
+    ("gray91"          59624 59624 59624)
+    ("grey91"          59624 59624 59624)
+    ("gray92"          60395 60395 60395)
+    ("grey92"          60395 60395 60395)
+    ("gray93"          60909 60909 60909)
+    ("grey93"          60909 60909 60909)
+    ("gray94"          61680 61680 61680)
+    ("grey94"          61680 61680 61680)
+    ("gray95"          62194 62194 62194)
+    ("grey95"          62194 62194 62194)
+    ("gray96"          62965 62965 62965)
+    ("grey96"          62965 62965 62965)
+    ("gray97"          63479 63479 63479)
+    ("grey97"          63479 63479 63479)
+    ("gray98"          64250 64250 64250)
+    ("grey98"          64250 64250 64250)
+    ("gray99"          64764 64764 64764)
+    ("grey99"          64764 64764 64764)
+    ("gray100"         65535 65535 65535)
+    ("grey100"         65535 65535 65535)
+    ("darkgrey"                43433 43433 43433)
+    ("darkgray"                43433 43433 43433)
+    ("darkblue"                    0     0 35723)
+    ("darkcyan"                    0 35723 35723) ; no "lightmagenta", see comment above
+    ("darkmagenta"     35723     0 35723)
+    ("darkred"         35723     0     0)  ; but no "lightred", see comment above
+    ("lightgreen"      37008 61166 37008))
+  "An alist of X color names and associated 16-bit RGB values.")
 
 (defvar tty-standard-colors
-  '(("white"   7 65535 65535 65535)
-    ("cyan"    6     0 65535 65535)
-    ("magenta" 5 65535     0 65535)
-    ("blue"    4     0     0 65535)
-    ("yellow"  3 65535 65535     0)
-    ("green"   2     0 65535     0)
+  '(("black"   0     0     0     0)
     ("red"     1 65535     0     0)
-    ("black"   0     0     0     0))
+    ("green"   2     0 65535     0)
+    ("yellow"  3 65535 65535     0)
+    ("blue"    4     0     0 65535)
+    ("magenta" 5 65535     0 65535)
+    ("cyan"    6     0 65535 65535)
+    ("white"   7 65535 65535 65535))
   "An alist of 8 standard tty colors, their indices and RGB values.")
 
+;; This is used by term.c
+(defvar tty-color-mode-alist
+  '((never . -1)
+    (no . -1)
+    (default . 0)
+    (auto . 0)
+    (ansi8 . 8)
+    (always . 8)
+    (yes . 8))
+  "An alist of supported standard tty color modes and their aliases.")
+
 (defvar tty-defined-color-alist nil
   "An alist of defined terminal colors and their RGB values.
 
@@ -773,24 +792,47 @@ color."
   tty-defined-color-alist)
 
 (defun tty-modify-color-alist (elt &optional frame)
-  "Put the association ELT int the alist of terminal colors for FRAME.
+  "Put the association ELT into the alist of terminal colors for FRAME.
 ELT should be of the form  \(NAME INDEX R G B\) (see `tty-color-alist'
 for details).
+If the association for NAME already exists in the color alist, it is
+modified to specify \(INDEX R G B\) as its cdr.  Otherwise, ELT is
+appended to the end of the color alist.
 If FRAME is unspecified or nil, it defaults to the selected frame.
 Value is the modified color alist for FRAME."
   (let* ((entry (assoc (car elt) (tty-color-alist frame))))
     (if entry
        (setcdr entry (cdr elt))
-      (setq tty-defined-color-alist (cons elt tty-defined-color-alist)))
+      ;; Keep the colors in the order they are registered.
+      (setq entry
+           (list (append (list (car elt)
+                               (cadr elt))
+                         (copy-sequence (cddr elt)))))
+      (setq tty-defined-color-alist (nconc tty-defined-color-alist entry)))
     tty-defined-color-alist))
 
+(defun tty-register-default-colors ()
+  "Register the default set of colors for a character terminal."
+  (let* ((colors (cond ((eq window-system 'pc)
+                       msdos-color-values)
+                      ((eq system-type 'windows-nt)
+                       w32-tty-standard-colors)
+                      (t tty-standard-colors)))
+        (color (car colors)))
+    (while colors
+      (tty-color-define (car color) (cadr color) (cddr color))
+      (setq colors (cdr colors) color (car colors)))
+    ;; Modifying color mappings means realized faces don't
+    ;; use the right colors, so clear them.
+    (clear-face-cache)))
+
 (defun tty-color-canonicalize (color)
   "Return COLOR in canonical form.
 A canonicalized color name is all-lower case, with any blanks removed."
-  (let ((color (downcase color)))
-    (while (string-match " +" color)
-      (setq color (replace-match "" nil nil color)))
-    color))
+  (let ((case-fold-search nil))
+    (if (string-match "[A-Z ]" color)
+       (replace-regexp-in-string " +" "" (downcase color))
+      color)))
 
 (defun tty-color-define (name index &optional rgb frame)
   "Specify a tty color by its NAME, terminal INDEX and RGB values.
@@ -825,26 +867,26 @@ of gray, thus the name."
     (if (< mag 1) 0 (acos (/ (+ r g b) mag)))))
 
 (defun tty-color-approximate (rgb &optional frame)
-  "Given a list of 3 rgb values in RGB, find the color in `tty-color-alist'
-which is the best approximation in the 3-dimensional RGB space,
-and return the index associated with the approximating color.
-Each value of the RGB triplet has to be scaled to the 0..255 range.
+  "Find the color in `tty-color-alist' that best approximates RGB.
+Value is a list of the form \(NAME INDEX R G B\).
+The argument RGB should be an rgb value, that is, a list of three
+integers in the 0..65535 range.
 FRAME defaults to the selected frame."
   (let* ((color-list (tty-color-alist frame))
         (candidate (car color-list))
         (best-distance 195076) ;; 3 * 255^2 + 15
+        (r (ash (car rgb) -8))
+        (g (ash (cadr rgb) -8))
+        (b (ash (nth 2 rgb) -8))
         best-color)
     (while candidate
-      (let* ((try-rgb (cddr candidate))
-            (r (car rgb))
-            (g (cadr rgb))
-            (b (nth 2 rgb))
-            ;; If the approximated color is not close enough to the
-            ;; gray diagonal of the RGB cube, favor non-gray colors.
-            ;; (The number 0.065 is an empirical ad-hoc'ery.)
-            (favor-non-gray (>= (tty-color-off-gray-diag r g b) 0.065))
-            try-r try-g try-b
-            dif-r dif-g dif-b dist)
+      (let ((try-rgb (cddr candidate))
+           ;; If the approximated color is not close enough to the
+           ;; gray diagonal of the RGB cube, favor non-gray colors.
+           ;; (The number 0.065 is an empirical ad-hoc'ery.)
+           (favor-non-gray (>= (tty-color-off-gray-diag r g b) 0.065))
+           try-r try-g try-b
+           dif-r dif-g dif-b dist)
        ;; If the RGB values of the candidate color are unknown, we
        ;; never consider it for approximating another color.
        (if try-rgb
@@ -852,9 +894,9 @@ FRAME defaults to the selected frame."
              (setq try-r (lsh (car try-rgb) -8)
                    try-g (lsh (cadr try-rgb) -8)
                    try-b (lsh (nth 2 try-rgb) -8))
-             (setq dif-r (- (car rgb) try-r)
-                   dif-g (- (cadr rgb) try-g)
-                   dif-b (- (nth 2 rgb) try-b))
+             (setq dif-r (- r try-r)
+                   dif-g (- g try-g)
+                   dif-b (- b try-b))
              (setq dist (+ (* dif-r dif-r) (* dif-g dif-g) (* dif-b dif-b)))
              (if (and (< dist best-distance)
                       ;; The candidate color is on the gray diagonal
@@ -865,7 +907,68 @@ FRAME defaults to the selected frame."
                        best-color candidate)))))
       (setq color-list (cdr color-list))
       (setq candidate (car color-list)))
-    (cadr best-color)))
+    best-color))
+
+(defun tty-color-standard-values (color)
+"Return standard RGB values of the color COLOR.
+
+The result is a list of integer RGB values--(RED GREEN BLUE).
+These values range from 0 to 65535; white is (65535 65535 65535).
+
+The returned value reflects the standard X definition of COLOR,
+regardless of whether the terminal can display it, so the return value
+should be the same regardless of what display is being used."
+  (let ((len (length color)))
+    (cond ((and (>= len 4) ;; X-style "#XXYYZZ" color spec
+               (eq (aref color 0) ?#)
+               (member (aref color 1)
+                       '(?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9
+                            ?a ?b ?c ?d ?e ?f)))
+          ;; Translate the string "#XXYYZZ" into a list
+          ;; of numbers (XX YY ZZ).  If the primary colors
+          ;; are specified with less than 4 hex digits,
+          ;; the used digits represent the most significant
+          ;; bits of the value (e.g. #XYZ = #X000Y000Z000).
+          (let* ((ndig (/ (- len 1) 3))
+                 (i1 1)
+                 (i2 (+ i1 ndig))
+                 (i3 (+ i2 ndig)))
+            (list
+             (lsh
+              (string-to-number (substring color i1 i2) 16)
+              (* 4 (- 4 ndig)))
+             (lsh
+              (string-to-number (substring color i2 i3) 16)
+              (* 4 (- 4 ndig)))
+             (lsh
+              (string-to-number (substring color i3) 16)
+              (* 4 (- 4 ndig))))))
+         ((and (>= len 9) ;; X-style RGB:xx/yy/zz color spec
+               (string= (substring color 0 4) "rgb:"))
+          ;; Translate the string "RGB:XX/YY/ZZ" into a list
+          ;; of numbers (XX YY ZZ).  If fewer than 4 hex
+          ;; digits are used, they represent the fraction
+          ;; of the maximum value (RGB:X/Y/Z = #XXXXYYYYZZZZ).
+          (let* ((ndig (/ (- len 3) 3))
+                 (maxval (1- (ash 1 (* 4 (- ndig 1)))))
+                 (i1 4)
+                 (i2 (+ i1 ndig))
+                 (i3 (+ i2 ndig)))
+            (list
+             (/ (* (string-to-number
+                    (substring color i1 (- i2 1)) 16)
+                   255)
+                maxval)
+             (/ (* (string-to-number
+                    (substring color i2 (- i3 1)) 16)
+                   255)
+                maxval)
+             (/ (* (string-to-number
+                    (substring color i3) 16)
+                   255)
+                maxval))))
+         (t
+          (cdr (assoc color color-name-rgb-alist))))))
 
 (defun tty-color-translate (color &optional frame)
   "Given a color COLOR, return the index of the corresponding TTY color.
@@ -884,65 +987,7 @@ If COLOR is neither a valid X RGB specification of the color, nor a
 name of a color in `color-name-rgb-alist', the returned value is nil.
 
 If FRAME is unspecified or nil, it defaults to the selected frame."
-  (and (stringp color)
-       (let* ((color (tty-color-canonicalize color))
-             (idx (cadr (assoc color (tty-color-alist frame)))))
-        (or idx
-            (let* ((len (length color))
-                   (maxval 256)
-                   (rgb
-                    (cond
-                     ((and (>= len 4)  ;; X-style "#XXYYZZ" color spec
-                           (eq (aref color 0) ?#)
-                           (member (aref color 1)
-                                   '(?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9
-                                        ?a ?b ?c ?d ?e ?f)))
-                      ;; Translate the string "#XXYYZZ" into a list
-                      ;; of numbers (XX YY ZZ).  If the primary colors
-                      ;; are specified with less than 4 hex digits,
-                      ;; the used digits represent the most significant
-                      ;; bits of the value (e.g. #XYZ = #X000Y000Z000).
-                      (let* ((ndig (/ (- len 1) 3))
-                             (i1 1)
-                             (i2 (+ i1 ndig))
-                             (i3 (+ i2 ndig)))
-                        (list
-                         (lsh
-                          (string-to-number (substring color i1 i2) 16)
-                          (* 4 (- 2 ndig)))
-                         (lsh
-                          (string-to-number (substring color i2 i3) 16)
-                          (* 4 (- 2 ndig)))
-                         (lsh
-                          (string-to-number (substring color i3) 16)
-                          (* 4 (- 2 ndig))))))
-                     ((and (>= len 9)  ;; X-style RGB:xx/yy/zz color spec
-                           (string= (substring color 0 4) "rgb:"))
-                      ;; Translate the string "RGB:XX/YY/ZZ" into a list
-                      ;; of numbers (XX YY ZZ).  If fewer than 4 hex
-                      ;; digits are used, they represent the fraction
-                      ;; of the maximum value (RGB:X/Y/Z = #XXXXYYYYZZZZ).
-                      (let* ((ndig (/ (- len 3) 3))
-                             (maxval (1- (expt 16 (- ndig 1))))
-                             (i1 4)
-                             (i2 (+ i1 ndig))
-                             (i3 (+ i2 ndig)))
-                        (list
-                         (/ (* (string-to-number
-                                (substring color i1 (- i2 1)) 16)
-                               255)
-                            maxval)
-                         (/ (* (string-to-number
-                                (substring color i2 (- i3 1)) 16)
-                               255)
-                            maxval)
-                         (/ (* (string-to-number
-                                (substring color i3) 16)
-                               255)
-                            maxval))))
-                     (t
-                      (cdr (assoc color color-name-rgb-alist))))))
-              (and rgb (tty-color-approximate rgb frame)))))))
+  (cadr (tty-color-desc color frame)))
 
 (defun tty-color-by-index (idx &optional frame)
   "Given a numeric index of a tty color, return its description.
@@ -967,27 +1012,18 @@ values for a supported color that is its best approximation.
 The value is a list of integer RGB values--\(RED GREEN BLUE\).
 These values range from 0 to 65535; white is (65535 65535 65535).
 If FRAME is omitted or nil, use the selected frame."
-  (let* ((frame (or frame (selected-frame)))
-        (color (tty-color-canonicalize color))
-        (supported (assoc color (tty-color-alist frame))))
-    (or (and supported (cddr supported)) ; full spec in tty-color-alist
-       (and supported  ; no RGB values in tty-color-alist: use X RGB values
-            (assoc color color-name-rgb-alist)
-            (cddr
-             (tty-color-by-index
-              (tty-color-approximate
-               (cdr (assoc color color-name-rgb-alist)) frame) frame)))
-       (cddr (tty-color-by-index (tty-color-translate color frame) frame)))))
+  (cddr (tty-color-desc color frame)))
 
 (defun tty-color-desc (color &optional frame)
   "Return the description of the color COLOR for a character terminal.
-
-FRAME, if unspecified or nil, defaults to the selected frame.
-Value is a list of the form \(NAME INDEX R G B\).  Note that the returned
-NAME is not necessarily the same string as the argument COLOR, because
-the latter might need to be approximated if it is not supported directly."
-  (let ((idx (tty-color-translate color frame)))
-    (tty-color-by-index idx frame)))
+Value is a list of the form \(NAME INDEX R G B\).  The returned NAME or
+RGB value may not be the same as the argument COLOR, because the latter
+might need to be approximated if it is not supported directly."
+  (and (stringp color)
+       (let ((color (tty-color-canonicalize color)))
+         (or (assoc color (tty-color-alist frame))
+             (let ((rgb (tty-color-standard-values color)))
+               (and rgb (tty-color-approximate rgb frame)))))))
 
 (defun tty-color-gray-shades (&optional display)
   "Return the number of gray colors supported by DISPLAY's terminal.
@@ -1009,4 +1045,5 @@ A color is considered gray if the 3 components of its RGB value are equal."
       (setq colors (cdr colors)))
     count))
 
+;;; arch-tag: 84d5c3ef-ae22-4754-99ac-e6350c0967ae
 ;;; tty-colors.el ends here