config

Personal configuration.
git clone git://code.dwrz.net/config
Log | Files | Refs

rainbow-mode.el (40437B)


      1 ;;; rainbow-mode.el --- Colorize color names in buffers
      2 
      3 ;; Copyright (C) 2010-2020 Free Software Foundation, Inc
      4 
      5 ;; Author: Julien Danjou <julien@danjou.info>
      6 ;; Keywords: faces
      7 ;; Version: 1.0.6
      8 
      9 ;; This file is part of GNU Emacs.
     10 
     11 ;; GNU Emacs is free software: you can redistribute it and/or modify
     12 ;; it under the terms of the GNU General Public License as published by
     13 ;; the Free Software Foundation, either version 3 of the License, or
     14 ;; (at your option) any later version.
     15 
     16 ;; GNU Emacs is distributed in the hope that it will be useful,
     17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
     18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     19 ;; GNU General Public License for more details.
     20 
     21 ;; You should have received a copy of the GNU General Public License
     22 ;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
     23 
     24 ;;; Commentary:
     25 ;;
     26 ;; This minor mode sets background color to strings that match color
     27 ;; names, e.g. #0000ff is displayed in white with a blue background.
     28 ;;
     29 
     30 ;;; Code:
     31 
     32 (require 'cl-lib)
     33 (require 'regexp-opt)
     34 (require 'faces)
     35 (require 'color)
     36 
     37 (unless (require 'xterm-color nil t)
     38   (require 'ansi-color))
     39 
     40 (defgroup rainbow nil
     41   "Show color strings with a background color."
     42   :tag "Rainbow"
     43   :group 'help)
     44 
     45 ;;; Hexadecimal colors
     46 
     47 (defvar rainbow-hexadecimal-colors-font-lock-keywords
     48   '(("[^&]\\(#\\(?:[0-9a-fA-F]\\{3\\}\\)\\{1,4\\}\\)\\b"
     49      (1 (rainbow-colorize-itself 1)))
     50     ("^\\(#\\(?:[0-9a-fA-F]\\{3\\}\\)\\{1,4\\}\\)\\b"
     51      (0 (rainbow-colorize-itself)))
     52     ("[Rr][Gg][Bb]:[0-9a-fA-F]\\{1,4\\}/[0-9a-fA-F]\\{1,4\\}/[0-9a-fA-F]\\{1,4\\}"
     53      (0 (rainbow-colorize-itself)))
     54     ("[Rr][Gg][Bb][Ii]:[0-9.]+/[0-9.]+/[0-9.]+"
     55      (0 (rainbow-colorize-itself)))
     56     ("\\(?:[Cc][Ii][Ee]\\(?:[Xx][Yy][Zz]\\|[Uu][Vv][Yy]\\|[Xx][Yy][Yy]\\|[Ll][Aa][Bb]\\|[Ll][Uu][Vv]\\)\\|[Tt][Ee][Kk][Hh][Vv][Cc]\\):[+-]?[0-9.]+\\(?:[Ee][+-]?[0-9]+\\)?/[+-]?[0-9.]+\\(?:[Ee][+-]?[0-9]+\\)?/[+-]?[0-9.]+\\(?:[Ee][+-]?[0-9]+\\)?"
     57      (0 (rainbow-colorize-itself))))
     58   "Font-lock keywords to add for hexadecimal colors.")
     59 
     60 ;;; rgb() colors
     61 
     62 (defvar rainbow-html-rgb-colors-font-lock-keywords
     63   '(("rgb(\s*\\([0-9]\\{1,3\\}\\(?:\.[0-9]\\)?\\(?:\s*%\\)?\\)\s*,\s*\\([0-9]\\{1,3\\}\\(?:\\.[0-9]\\)?\\(?:\s*%\\)?\\)\s*,\s*\\([0-9]\\{1,3\\}\\(?:\\.[0-9]\\)?\\(?:\s*%\\)?\\)\s*)"
     64      (0 (rainbow-colorize-rgb)))
     65     ("rgba(\s*\\([0-9]\\{1,3\\}\\(?:\\.[0-9]\\)?\\(?:\s*%\\)?\\)\s*,\s*\\([0-9]\\{1,3\\}\\(?:\\.[0-9]\\)?\\(?:\s*%\\)?\\)\s*,\s*\\([0-9]\\{1,3\\}\\(?:\\.[0-9]\\)?\\(?:\s*%\\)?\\)\s*,\s*[0-9]*\.?[0-9]+\s*%?\s*)"
     66      (0 (rainbow-colorize-rgb)))
     67     ("hsl(\s*\\([0-9]\\{1,3\\}\\)\s*,\s*\\([0-9]\\{1,3\\}\\)\s*%\s*,\s*\\([0-9]\\{1,3\\}\\)\s*%\s*)"
     68      (0 (rainbow-colorize-hsl)))
     69     ("hsla(\s*\\([0-9]\\{1,3\\}\\)\s*,\s*\\([0-9]\\{1,3\\}\\)\s*%\s*,\s*\\([0-9]\\{1,3\\}\\)\s*%\s*,\s*[0-9]*\.?[0-9]+\s*%?\s*)"
     70      (0 (rainbow-colorize-hsl))))
     71   "Font-lock keywords to add for RGB colors.")
     72 
     73 ;;; HTML colors
     74 
     75 (defvar rainbow-html-colors-font-lock-keywords nil
     76   "Font-lock keywords to add for HTML colors.")
     77 (make-variable-buffer-local 'rainbow-html-colors-font-lock-keywords)
     78 
     79 (defcustom rainbow-html-colors-alist
     80   '(("AliceBlue" . "#F0F8FF")
     81     ("AntiqueWhite" . "#FAEBD7")
     82     ("Aqua" . "#00FFFF")
     83     ("Aquamarine" . "#7FFFD4")
     84     ("Azure" . "#F0FFFF")
     85     ("Beige" . "#F5F5DC")
     86     ("Bisque" . "#FFE4C4")
     87     ("Black" . "#000000")
     88     ("BlanchedAlmond" . "#FFEBCD")
     89     ("Blue" . "#0000FF")
     90     ("BlueViolet" . "#8A2BE2")
     91     ("Brown" . "#A52A2A")
     92     ("BurlyWood" . "#DEB887")
     93     ("CadetBlue" . "#5F9EA0")
     94     ("Chartreuse" . "#7FFF00")
     95     ("Chocolate" . "#D2691E")
     96     ("Coral" . "#FF7F50")
     97     ("CornflowerBlue" . "#6495ED")
     98     ("Cornsilk" . "#FFF8DC")
     99     ("Crimson" . "#DC143C")
    100     ("Cyan" . "#00FFFF")
    101     ("DarkBlue" . "#00008B")
    102     ("DarkCyan" . "#008B8B")
    103     ("DarkGoldenRod" . "#B8860B")
    104     ("DarkGray" . "#A9A9A9")
    105     ("DarkGrey" . "#A9A9A9")
    106     ("DarkGreen" . "#006400")
    107     ("DarkKhaki" . "#BDB76B")
    108     ("DarkMagenta" . "#8B008B")
    109     ("DarkOliveGreen" . "#556B2F")
    110     ("Darkorange" . "#FF8C00")
    111     ("DarkOrchid" . "#9932CC")
    112     ("DarkRed" . "#8B0000")
    113     ("DarkSalmon" . "#E9967A")
    114     ("DarkSeaGreen" . "#8FBC8F")
    115     ("DarkSlateBlue" . "#483D8B")
    116     ("DarkSlateGray" . "#2F4F4F")
    117     ("DarkSlateGrey" . "#2F4F4F")
    118     ("DarkTurquoise" . "#00CED1")
    119     ("DarkViolet" . "#9400D3")
    120     ("DeepPink" . "#FF1493")
    121     ("DeepSkyBlue" . "#00BFFF")
    122     ("DimGray" . "#696969")
    123     ("DimGrey" . "#696969")
    124     ("DodgerBlue" . "#1E90FF")
    125     ("FireBrick" . "#B22222")
    126     ("FloralWhite" . "#FFFAF0")
    127     ("ForestGreen" . "#228B22")
    128     ("Fuchsia" . "#FF00FF")
    129     ("Gainsboro" . "#DCDCDC")
    130     ("GhostWhite" . "#F8F8FF")
    131     ("Gold" . "#FFD700")
    132     ("GoldenRod" . "#DAA520")
    133     ("Gray" . "#808080")
    134     ("Grey" . "#808080")
    135     ("Green" . "#008000")
    136     ("GreenYellow" . "#ADFF2F")
    137     ("HoneyDew" . "#F0FFF0")
    138     ("HotPink" . "#FF69B4")
    139     ("IndianRed" . "#CD5C5C")
    140     ("Indigo" . "#4B0082")
    141     ("Ivory" . "#FFFFF0")
    142     ("Khaki" . "#F0E68C")
    143     ("Lavender" . "#E6E6FA")
    144     ("LavenderBlush" . "#FFF0F5")
    145     ("LawnGreen" . "#7CFC00")
    146     ("LemonChiffon" . "#FFFACD")
    147     ("LightBlue" . "#ADD8E6")
    148     ("LightCoral" . "#F08080")
    149     ("LightCyan" . "#E0FFFF")
    150     ("LightGoldenRodYellow" . "#FAFAD2")
    151     ("LightGray" . "#D3D3D3")
    152     ("LightGrey" . "#D3D3D3")
    153     ("LightGreen" . "#90EE90")
    154     ("LightPink" . "#FFB6C1")
    155     ("LightSalmon" . "#FFA07A")
    156     ("LightSeaGreen" . "#20B2AA")
    157     ("LightSkyBlue" . "#87CEFA")
    158     ("LightSlateGray" . "#778899")
    159     ("LightSlateGrey" . "#778899")
    160     ("LightSteelBlue" . "#B0C4DE")
    161     ("LightYellow" . "#FFFFE0")
    162     ("Lime" . "#00FF00")
    163     ("LimeGreen" . "#32CD32")
    164     ("Linen" . "#FAF0E6")
    165     ("Magenta" . "#FF00FF")
    166     ("Maroon" . "#800000")
    167     ("MediumAquaMarine" . "#66CDAA")
    168     ("MediumBlue" . "#0000CD")
    169     ("MediumOrchid" . "#BA55D3")
    170     ("MediumPurple" . "#9370D8")
    171     ("MediumSeaGreen" . "#3CB371")
    172     ("MediumSlateBlue" . "#7B68EE")
    173     ("MediumSpringGreen" . "#00FA9A")
    174     ("MediumTurquoise" . "#48D1CC")
    175     ("MediumVioletRed" . "#C71585")
    176     ("MidnightBlue" . "#191970")
    177     ("MintCream" . "#F5FFFA")
    178     ("MistyRose" . "#FFE4E1")
    179     ("Moccasin" . "#FFE4B5")
    180     ("NavajoWhite" . "#FFDEAD")
    181     ("Navy" . "#000080")
    182     ("OldLace" . "#FDF5E6")
    183     ("Olive" . "#808000")
    184     ("OliveDrab" . "#6B8E23")
    185     ("Orange" . "#FFA500")
    186     ("OrangeRed" . "#FF4500")
    187     ("Orchid" . "#DA70D6")
    188     ("PaleGoldenRod" . "#EEE8AA")
    189     ("PaleGreen" . "#98FB98")
    190     ("PaleTurquoise" . "#AFEEEE")
    191     ("PaleVioletRed" . "#D87093")
    192     ("PapayaWhip" . "#FFEFD5")
    193     ("PeachPuff" . "#FFDAB9")
    194     ("Peru" . "#CD853F")
    195     ("Pink" . "#FFC0CB")
    196     ("Plum" . "#DDA0DD")
    197     ("PowderBlue" . "#B0E0E6")
    198     ("Purple" . "#800080")
    199     ("Red" . "#FF0000")
    200     ("RosyBrown" . "#BC8F8F")
    201     ("RoyalBlue" . "#4169E1")
    202     ("SaddleBrown" . "#8B4513")
    203     ("Salmon" . "#FA8072")
    204     ("SandyBrown" . "#F4A460")
    205     ("SeaGreen" . "#2E8B57")
    206     ("SeaShell" . "#FFF5EE")
    207     ("Sienna" . "#A0522D")
    208     ("Silver" . "#C0C0C0")
    209     ("SkyBlue" . "#87CEEB")
    210     ("SlateBlue" . "#6A5ACD")
    211     ("SlateGray" . "#708090")
    212     ("SlateGrey" . "#708090")
    213     ("Snow" . "#FFFAFA")
    214     ("SpringGreen" . "#00FF7F")
    215     ("SteelBlue" . "#4682B4")
    216     ("Tan" . "#D2B48C")
    217     ("Teal" . "#008080")
    218     ("Thistle" . "#D8BFD8")
    219     ("Tomato" . "#FF6347")
    220     ("Turquoise" . "#40E0D0")
    221     ("Violet" . "#EE82EE")
    222     ("Wheat" . "#F5DEB3")
    223     ("White" . "#FFFFFF")
    224     ("WhiteSmoke" . "#F5F5F5")
    225     ("Yellow" . "#FFFF00")
    226     ("YellowGreen" . "#9ACD32"))
    227   "Alist of HTML colors.
    228 Each entry should have the form (COLOR-NAME . HEXADECIMAL-COLOR)."
    229   :type 'alist
    230   :group 'rainbow)
    231 
    232 (defcustom rainbow-html-colors-major-mode-list
    233   '(html-mode css-mode php-mode nxml-mode xml-mode)
    234   "List of major mode where HTML colors are enabled when
    235 `rainbow-html-colors' is set to auto."
    236   :type '(repeat (symbol :tag "Major-Mode"))
    237   :group 'rainbow)
    238 
    239 (defcustom rainbow-html-colors 'auto
    240   "When to enable HTML colors.
    241 If set to t, the HTML colors will be enabled.  If set to nil, the
    242 HTML colors will not be enabled.  If set to auto, the HTML colors
    243 will be enabled if a major mode has been detected from the
    244 `rainbow-html-colors-major-mode-list'."
    245   :type '(choice (symbol :tag "enable in certain modes" auto)
    246                  (symbol :tag "enable globally" t)
    247                  (symbol :tag "disable" nil))
    248   :group 'rainbow)
    249 
    250 ;;; X colors
    251 
    252 (defvar rainbow-x-colors-font-lock-keywords
    253   `((,(regexp-opt (x-defined-colors) 'words)
    254      (0 (rainbow-colorize-itself))))
    255   "Font-lock keywords to add for X colors.")
    256 
    257 (defcustom rainbow-x-colors-major-mode-list
    258   '(emacs-lisp-mode lisp-interaction-mode c-mode c++-mode java-mode)
    259   "List of major mode where X colors are enabled when
    260 `rainbow-x-colors' is set to auto."
    261   :type '(repeat (symbol :tag "Major-Mode"))
    262   :group 'rainbow)
    263 
    264 (defcustom rainbow-x-colors 'auto
    265   "When to enable X colors.
    266 If set to t, the X colors will be enabled.  If set to nil, the
    267 X colors will not be enabled.  If set to auto, the X colors
    268 will be enabled if a major mode has been detected from the
    269 `rainbow-x-colors-major-mode-list'."
    270   :type '(choice (symbol :tag "enable in certain modes" auto)
    271                  (symbol :tag "enable globally" t)
    272                  (symbol :tag "disable" nil))
    273   :group 'rainbow)
    274 
    275 ;;; LaTeX colors
    276 
    277 (defvar rainbow-latex-rgb-colors-font-lock-keywords
    278   '(("{rgb}{\\([0-9.]+\\),\s*\\([0-9.]+\\),\s*\\([0-9.]+\\)}"
    279      (0 (rainbow-colorize-rgb-float)))
    280     ("{RGB}{\\([0-9]\\{1,3\\}\\),\s*\\([0-9]\\{1,3\\}\\),\s*\\([0-9]\\{1,3\\}\\)}"
    281      (0 (rainbow-colorize-rgb)))
    282     ("{HTML}{\\([0-9A-Fa-f]\\{6\\}\\)}"
    283      (0 (rainbow-colorize-hexadecimal-without-sharp))))
    284   "Font-lock keywords to add for LaTeX colors.")
    285 
    286 (defcustom rainbow-latex-colors-major-mode-list
    287   '(latex-mode)
    288   "List of major mode where LaTeX colors are enabled when
    289 `rainbow-x-colors' is set to auto."
    290   :type '(repeat (symbol :tag "Major-Mode"))
    291   :group 'rainbow)
    292 
    293 (defcustom rainbow-latex-colors 'auto
    294   "When to enable LaTeX colors.
    295 If set to t, the LaTeX colors will be enabled. If set to nil, the
    296 LaTeX colors will not be enabled.  If set to auto, the LaTeX colors
    297 will be enabled if a major mode has been detected from the
    298 `rainbow-latex-colors-major-mode-list'."
    299   :type '(choice (symbol :tag "enable in certain modes" auto)
    300                  (symbol :tag "enable globally" t)
    301                  (symbol :tag "disable" nil))
    302   :group 'rainbow)
    303 
    304 ;;; Shell colors
    305 
    306 (defvar rainbow-ansi-colors-font-lock-keywords
    307   '(("\\(\\\\[eE]\\|\\\\033\\|\\\\x1[bB]\\|\033\\)\\[\\([0-9;]*m\\)"
    308      (0 (rainbow-colorize-ansi))))
    309   "Font-lock keywords to add for ANSI colors.")
    310 
    311 (defcustom rainbow-ansi-colors-major-mode-list
    312   '(sh-mode c-mode c++-mode)
    313   "List of major mode where ANSI colors are enabled when
    314 `rainbow-ansi-colors' is set to auto."
    315   :type '(repeat (symbol :tag "Major-Mode"))
    316   :group 'rainbow)
    317 
    318 (defcustom rainbow-ansi-colors 'auto
    319   "When to enable ANSI colors.
    320 If set to t, the ANSI colors will be enabled. If set to nil, the
    321 ANSI colors will not be enabled.  If set to auto, the ANSI colors
    322 will be enabled if a major mode has been detected from the
    323 `rainbow-ansi-colors-major-mode-list'."
    324   :type '(choice (symbol :tag "enable in certain modes" auto)
    325                  (symbol :tag "enable globally" t)
    326                  (symbol :tag "disable" nil))
    327   :group 'rainbow)
    328 
    329 ;;; R colors
    330 
    331 (defvar rainbow-r-colors-font-lock-keywords nil
    332   "Font-lock keywords to add for R colors.")
    333 (make-variable-buffer-local 'rainbow-r-colors-font-lock-keywords)
    334 
    335 ;; use the following code to generate the list in R
    336 ;; output_colors <- function(colors) {for(color in colors) {col <- col2rgb(color); cat(sprintf("(\"%s\" . \"#%02X%02X%02X\")\n",color,col[1],col[2],col[3]));}}
    337 ;; output_colors(colors())
    338 (defcustom rainbow-r-colors-alist
    339   '(("white" . "#FFFFFF")
    340     ("aliceblue" . "#F0F8FF")
    341     ("antiquewhite" . "#FAEBD7")
    342     ("antiquewhite1" . "#FFEFDB")
    343     ("antiquewhite2" . "#EEDFCC")
    344     ("antiquewhite3" . "#CDC0B0")
    345     ("antiquewhite4" . "#8B8378")
    346     ("aquamarine" . "#7FFFD4")
    347     ("aquamarine1" . "#7FFFD4")
    348     ("aquamarine2" . "#76EEC6")
    349     ("aquamarine3" . "#66CDAA")
    350     ("aquamarine4" . "#458B74")
    351     ("azure" . "#F0FFFF")
    352     ("azure1" . "#F0FFFF")
    353     ("azure2" . "#E0EEEE")
    354     ("azure3" . "#C1CDCD")
    355     ("azure4" . "#838B8B")
    356     ("beige" . "#F5F5DC")
    357     ("bisque" . "#FFE4C4")
    358     ("bisque1" . "#FFE4C4")
    359     ("bisque2" . "#EED5B7")
    360     ("bisque3" . "#CDB79E")
    361     ("bisque4" . "#8B7D6B")
    362     ("black" . "#000000")
    363     ("blanchedalmond" . "#FFEBCD")
    364     ("blue" . "#0000FF")
    365     ("blue1" . "#0000FF")
    366     ("blue2" . "#0000EE")
    367     ("blue3" . "#0000CD")
    368     ("blue4" . "#00008B")
    369     ("blueviolet" . "#8A2BE2")
    370     ("brown" . "#A52A2A")
    371     ("brown1" . "#FF4040")
    372     ("brown2" . "#EE3B3B")
    373     ("brown3" . "#CD3333")
    374     ("brown4" . "#8B2323")
    375     ("burlywood" . "#DEB887")
    376     ("burlywood1" . "#FFD39B")
    377     ("burlywood2" . "#EEC591")
    378     ("burlywood3" . "#CDAA7D")
    379     ("burlywood4" . "#8B7355")
    380     ("cadetblue" . "#5F9EA0")
    381     ("cadetblue1" . "#98F5FF")
    382     ("cadetblue2" . "#8EE5EE")
    383     ("cadetblue3" . "#7AC5CD")
    384     ("cadetblue4" . "#53868B")
    385     ("chartreuse" . "#7FFF00")
    386     ("chartreuse1" . "#7FFF00")
    387     ("chartreuse2" . "#76EE00")
    388     ("chartreuse3" . "#66CD00")
    389     ("chartreuse4" . "#458B00")
    390     ("chocolate" . "#D2691E")
    391     ("chocolate1" . "#FF7F24")
    392     ("chocolate2" . "#EE7621")
    393     ("chocolate3" . "#CD661D")
    394     ("chocolate4" . "#8B4513")
    395     ("coral" . "#FF7F50")
    396     ("coral1" . "#FF7256")
    397     ("coral2" . "#EE6A50")
    398     ("coral3" . "#CD5B45")
    399     ("coral4" . "#8B3E2F")
    400     ("cornflowerblue" . "#6495ED")
    401     ("cornsilk" . "#FFF8DC")
    402     ("cornsilk1" . "#FFF8DC")
    403     ("cornsilk2" . "#EEE8CD")
    404     ("cornsilk3" . "#CDC8B1")
    405     ("cornsilk4" . "#8B8878")
    406     ("cyan" . "#00FFFF")
    407     ("cyan1" . "#00FFFF")
    408     ("cyan2" . "#00EEEE")
    409     ("cyan3" . "#00CDCD")
    410     ("cyan4" . "#008B8B")
    411     ("darkblue" . "#00008B")
    412     ("darkcyan" . "#008B8B")
    413     ("darkgoldenrod" . "#B8860B")
    414     ("darkgoldenrod1" . "#FFB90F")
    415     ("darkgoldenrod2" . "#EEAD0E")
    416     ("darkgoldenrod3" . "#CD950C")
    417     ("darkgoldenrod4" . "#8B6508")
    418     ("darkgray" . "#A9A9A9")
    419     ("darkgreen" . "#006400")
    420     ("darkgrey" . "#A9A9A9")
    421     ("darkkhaki" . "#BDB76B")
    422     ("darkmagenta" . "#8B008B")
    423     ("darkolivegreen" . "#556B2F")
    424     ("darkolivegreen1" . "#CAFF70")
    425     ("darkolivegreen2" . "#BCEE68")
    426     ("darkolivegreen3" . "#A2CD5A")
    427     ("darkolivegreen4" . "#6E8B3D")
    428     ("darkorange" . "#FF8C00")
    429     ("darkorange1" . "#FF7F00")
    430     ("darkorange2" . "#EE7600")
    431     ("darkorange3" . "#CD6600")
    432     ("darkorange4" . "#8B4500")
    433     ("darkorchid" . "#9932CC")
    434     ("darkorchid1" . "#BF3EFF")
    435     ("darkorchid2" . "#B23AEE")
    436     ("darkorchid3" . "#9A32CD")
    437     ("darkorchid4" . "#68228B")
    438     ("darkred" . "#8B0000")
    439     ("darksalmon" . "#E9967A")
    440     ("darkseagreen" . "#8FBC8F")
    441     ("darkseagreen1" . "#C1FFC1")
    442     ("darkseagreen2" . "#B4EEB4")
    443     ("darkseagreen3" . "#9BCD9B")
    444     ("darkseagreen4" . "#698B69")
    445     ("darkslateblue" . "#483D8B")
    446     ("darkslategray" . "#2F4F4F")
    447     ("darkslategray1" . "#97FFFF")
    448     ("darkslategray2" . "#8DEEEE")
    449     ("darkslategray3" . "#79CDCD")
    450     ("darkslategray4" . "#528B8B")
    451     ("darkslategrey" . "#2F4F4F")
    452     ("darkturquoise" . "#00CED1")
    453     ("darkviolet" . "#9400D3")
    454     ("deeppink" . "#FF1493")
    455     ("deeppink1" . "#FF1493")
    456     ("deeppink2" . "#EE1289")
    457     ("deeppink3" . "#CD1076")
    458     ("deeppink4" . "#8B0A50")
    459     ("deepskyblue" . "#00BFFF")
    460     ("deepskyblue1" . "#00BFFF")
    461     ("deepskyblue2" . "#00B2EE")
    462     ("deepskyblue3" . "#009ACD")
    463     ("deepskyblue4" . "#00688B")
    464     ("dimgray" . "#696969")
    465     ("dimgrey" . "#696969")
    466     ("dodgerblue" . "#1E90FF")
    467     ("dodgerblue1" . "#1E90FF")
    468     ("dodgerblue2" . "#1C86EE")
    469     ("dodgerblue3" . "#1874CD")
    470     ("dodgerblue4" . "#104E8B")
    471     ("firebrick" . "#B22222")
    472     ("firebrick1" . "#FF3030")
    473     ("firebrick2" . "#EE2C2C")
    474     ("firebrick3" . "#CD2626")
    475     ("firebrick4" . "#8B1A1A")
    476     ("floralwhite" . "#FFFAF0")
    477     ("forestgreen" . "#228B22")
    478     ("gainsboro" . "#DCDCDC")
    479     ("ghostwhite" . "#F8F8FF")
    480     ("gold" . "#FFD700")
    481     ("gold1" . "#FFD700")
    482     ("gold2" . "#EEC900")
    483     ("gold3" . "#CDAD00")
    484     ("gold4" . "#8B7500")
    485     ("goldenrod" . "#DAA520")
    486     ("goldenrod1" . "#FFC125")
    487     ("goldenrod2" . "#EEB422")
    488     ("goldenrod3" . "#CD9B1D")
    489     ("goldenrod4" . "#8B6914")
    490     ("gray" . "#BEBEBE")
    491     ("gray0" . "#000000")
    492     ("gray1" . "#030303")
    493     ("gray2" . "#050505")
    494     ("gray3" . "#080808")
    495     ("gray4" . "#0A0A0A")
    496     ("gray5" . "#0D0D0D")
    497     ("gray6" . "#0F0F0F")
    498     ("gray7" . "#121212")
    499     ("gray8" . "#141414")
    500     ("gray9" . "#171717")
    501     ("gray10" . "#1A1A1A")
    502     ("gray11" . "#1C1C1C")
    503     ("gray12" . "#1F1F1F")
    504     ("gray13" . "#212121")
    505     ("gray14" . "#242424")
    506     ("gray15" . "#262626")
    507     ("gray16" . "#292929")
    508     ("gray17" . "#2B2B2B")
    509     ("gray18" . "#2E2E2E")
    510     ("gray19" . "#303030")
    511     ("gray20" . "#333333")
    512     ("gray21" . "#363636")
    513     ("gray22" . "#383838")
    514     ("gray23" . "#3B3B3B")
    515     ("gray24" . "#3D3D3D")
    516     ("gray25" . "#404040")
    517     ("gray26" . "#424242")
    518     ("gray27" . "#454545")
    519     ("gray28" . "#474747")
    520     ("gray29" . "#4A4A4A")
    521     ("gray30" . "#4D4D4D")
    522     ("gray31" . "#4F4F4F")
    523     ("gray32" . "#525252")
    524     ("gray33" . "#545454")
    525     ("gray34" . "#575757")
    526     ("gray35" . "#595959")
    527     ("gray36" . "#5C5C5C")
    528     ("gray37" . "#5E5E5E")
    529     ("gray38" . "#616161")
    530     ("gray39" . "#636363")
    531     ("gray40" . "#666666")
    532     ("gray41" . "#696969")
    533     ("gray42" . "#6B6B6B")
    534     ("gray43" . "#6E6E6E")
    535     ("gray44" . "#707070")
    536     ("gray45" . "#737373")
    537     ("gray46" . "#757575")
    538     ("gray47" . "#787878")
    539     ("gray48" . "#7A7A7A")
    540     ("gray49" . "#7D7D7D")
    541     ("gray50" . "#7F7F7F")
    542     ("gray51" . "#828282")
    543     ("gray52" . "#858585")
    544     ("gray53" . "#878787")
    545     ("gray54" . "#8A8A8A")
    546     ("gray55" . "#8C8C8C")
    547     ("gray56" . "#8F8F8F")
    548     ("gray57" . "#919191")
    549     ("gray58" . "#949494")
    550     ("gray59" . "#969696")
    551     ("gray60" . "#999999")
    552     ("gray61" . "#9C9C9C")
    553     ("gray62" . "#9E9E9E")
    554     ("gray63" . "#A1A1A1")
    555     ("gray64" . "#A3A3A3")
    556     ("gray65" . "#A6A6A6")
    557     ("gray66" . "#A8A8A8")
    558     ("gray67" . "#ABABAB")
    559     ("gray68" . "#ADADAD")
    560     ("gray69" . "#B0B0B0")
    561     ("gray70" . "#B3B3B3")
    562     ("gray71" . "#B5B5B5")
    563     ("gray72" . "#B8B8B8")
    564     ("gray73" . "#BABABA")
    565     ("gray74" . "#BDBDBD")
    566     ("gray75" . "#BFBFBF")
    567     ("gray76" . "#C2C2C2")
    568     ("gray77" . "#C4C4C4")
    569     ("gray78" . "#C7C7C7")
    570     ("gray79" . "#C9C9C9")
    571     ("gray80" . "#CCCCCC")
    572     ("gray81" . "#CFCFCF")
    573     ("gray82" . "#D1D1D1")
    574     ("gray83" . "#D4D4D4")
    575     ("gray84" . "#D6D6D6")
    576     ("gray85" . "#D9D9D9")
    577     ("gray86" . "#DBDBDB")
    578     ("gray87" . "#DEDEDE")
    579     ("gray88" . "#E0E0E0")
    580     ("gray89" . "#E3E3E3")
    581     ("gray90" . "#E5E5E5")
    582     ("gray91" . "#E8E8E8")
    583     ("gray92" . "#EBEBEB")
    584     ("gray93" . "#EDEDED")
    585     ("gray94" . "#F0F0F0")
    586     ("gray95" . "#F2F2F2")
    587     ("gray96" . "#F5F5F5")
    588     ("gray97" . "#F7F7F7")
    589     ("gray98" . "#FAFAFA")
    590     ("gray99" . "#FCFCFC")
    591     ("gray100" . "#FFFFFF")
    592     ("green" . "#00FF00")
    593     ("green1" . "#00FF00")
    594     ("green2" . "#00EE00")
    595     ("green3" . "#00CD00")
    596     ("green4" . "#008B00")
    597     ("greenyellow" . "#ADFF2F")
    598     ("grey" . "#BEBEBE")
    599     ("grey0" . "#000000")
    600     ("grey1" . "#030303")
    601     ("grey2" . "#050505")
    602     ("grey3" . "#080808")
    603     ("grey4" . "#0A0A0A")
    604     ("grey5" . "#0D0D0D")
    605     ("grey6" . "#0F0F0F")
    606     ("grey7" . "#121212")
    607     ("grey8" . "#141414")
    608     ("grey9" . "#171717")
    609     ("grey10" . "#1A1A1A")
    610     ("grey11" . "#1C1C1C")
    611     ("grey12" . "#1F1F1F")
    612     ("grey13" . "#212121")
    613     ("grey14" . "#242424")
    614     ("grey15" . "#262626")
    615     ("grey16" . "#292929")
    616     ("grey17" . "#2B2B2B")
    617     ("grey18" . "#2E2E2E")
    618     ("grey19" . "#303030")
    619     ("grey20" . "#333333")
    620     ("grey21" . "#363636")
    621     ("grey22" . "#383838")
    622     ("grey23" . "#3B3B3B")
    623     ("grey24" . "#3D3D3D")
    624     ("grey25" . "#404040")
    625     ("grey26" . "#424242")
    626     ("grey27" . "#454545")
    627     ("grey28" . "#474747")
    628     ("grey29" . "#4A4A4A")
    629     ("grey30" . "#4D4D4D")
    630     ("grey31" . "#4F4F4F")
    631     ("grey32" . "#525252")
    632     ("grey33" . "#545454")
    633     ("grey34" . "#575757")
    634     ("grey35" . "#595959")
    635     ("grey36" . "#5C5C5C")
    636     ("grey37" . "#5E5E5E")
    637     ("grey38" . "#616161")
    638     ("grey39" . "#636363")
    639     ("grey40" . "#666666")
    640     ("grey41" . "#696969")
    641     ("grey42" . "#6B6B6B")
    642     ("grey43" . "#6E6E6E")
    643     ("grey44" . "#707070")
    644     ("grey45" . "#737373")
    645     ("grey46" . "#757575")
    646     ("grey47" . "#787878")
    647     ("grey48" . "#7A7A7A")
    648     ("grey49" . "#7D7D7D")
    649     ("grey50" . "#7F7F7F")
    650     ("grey51" . "#828282")
    651     ("grey52" . "#858585")
    652     ("grey53" . "#878787")
    653     ("grey54" . "#8A8A8A")
    654     ("grey55" . "#8C8C8C")
    655     ("grey56" . "#8F8F8F")
    656     ("grey57" . "#919191")
    657     ("grey58" . "#949494")
    658     ("grey59" . "#969696")
    659     ("grey60" . "#999999")
    660     ("grey61" . "#9C9C9C")
    661     ("grey62" . "#9E9E9E")
    662     ("grey63" . "#A1A1A1")
    663     ("grey64" . "#A3A3A3")
    664     ("grey65" . "#A6A6A6")
    665     ("grey66" . "#A8A8A8")
    666     ("grey67" . "#ABABAB")
    667     ("grey68" . "#ADADAD")
    668     ("grey69" . "#B0B0B0")
    669     ("grey70" . "#B3B3B3")
    670     ("grey71" . "#B5B5B5")
    671     ("grey72" . "#B8B8B8")
    672     ("grey73" . "#BABABA")
    673     ("grey74" . "#BDBDBD")
    674     ("grey75" . "#BFBFBF")
    675     ("grey76" . "#C2C2C2")
    676     ("grey77" . "#C4C4C4")
    677     ("grey78" . "#C7C7C7")
    678     ("grey79" . "#C9C9C9")
    679     ("grey80" . "#CCCCCC")
    680     ("grey81" . "#CFCFCF")
    681     ("grey82" . "#D1D1D1")
    682     ("grey83" . "#D4D4D4")
    683     ("grey84" . "#D6D6D6")
    684     ("grey85" . "#D9D9D9")
    685     ("grey86" . "#DBDBDB")
    686     ("grey87" . "#DEDEDE")
    687     ("grey88" . "#E0E0E0")
    688     ("grey89" . "#E3E3E3")
    689     ("grey90" . "#E5E5E5")
    690     ("grey91" . "#E8E8E8")
    691     ("grey92" . "#EBEBEB")
    692     ("grey93" . "#EDEDED")
    693     ("grey94" . "#F0F0F0")
    694     ("grey95" . "#F2F2F2")
    695     ("grey96" . "#F5F5F5")
    696     ("grey97" . "#F7F7F7")
    697     ("grey98" . "#FAFAFA")
    698     ("grey99" . "#FCFCFC")
    699     ("grey100" . "#FFFFFF")
    700     ("honeydew" . "#F0FFF0")
    701     ("honeydew1" . "#F0FFF0")
    702     ("honeydew2" . "#E0EEE0")
    703     ("honeydew3" . "#C1CDC1")
    704     ("honeydew4" . "#838B83")
    705     ("hotpink" . "#FF69B4")
    706     ("hotpink1" . "#FF6EB4")
    707     ("hotpink2" . "#EE6AA7")
    708     ("hotpink3" . "#CD6090")
    709     ("hotpink4" . "#8B3A62")
    710     ("indianred" . "#CD5C5C")
    711     ("indianred1" . "#FF6A6A")
    712     ("indianred2" . "#EE6363")
    713     ("indianred3" . "#CD5555")
    714     ("indianred4" . "#8B3A3A")
    715     ("ivory" . "#FFFFF0")
    716     ("ivory1" . "#FFFFF0")
    717     ("ivory2" . "#EEEEE0")
    718     ("ivory3" . "#CDCDC1")
    719     ("ivory4" . "#8B8B83")
    720     ("khaki" . "#F0E68C")
    721     ("khaki1" . "#FFF68F")
    722     ("khaki2" . "#EEE685")
    723     ("khaki3" . "#CDC673")
    724     ("khaki4" . "#8B864E")
    725     ("lavender" . "#E6E6FA")
    726     ("lavenderblush" . "#FFF0F5")
    727     ("lavenderblush1" . "#FFF0F5")
    728     ("lavenderblush2" . "#EEE0E5")
    729     ("lavenderblush3" . "#CDC1C5")
    730     ("lavenderblush4" . "#8B8386")
    731     ("lawngreen" . "#7CFC00")
    732     ("lemonchiffon" . "#FFFACD")
    733     ("lemonchiffon1" . "#FFFACD")
    734     ("lemonchiffon2" . "#EEE9BF")
    735     ("lemonchiffon3" . "#CDC9A5")
    736     ("lemonchiffon4" . "#8B8970")
    737     ("lightblue" . "#ADD8E6")
    738     ("lightblue1" . "#BFEFFF")
    739     ("lightblue2" . "#B2DFEE")
    740     ("lightblue3" . "#9AC0CD")
    741     ("lightblue4" . "#68838B")
    742     ("lightcoral" . "#F08080")
    743     ("lightcyan" . "#E0FFFF")
    744     ("lightcyan1" . "#E0FFFF")
    745     ("lightcyan2" . "#D1EEEE")
    746     ("lightcyan3" . "#B4CDCD")
    747     ("lightcyan4" . "#7A8B8B")
    748     ("lightgoldenrod" . "#EEDD82")
    749     ("lightgoldenrod1" . "#FFEC8B")
    750     ("lightgoldenrod2" . "#EEDC82")
    751     ("lightgoldenrod3" . "#CDBE70")
    752     ("lightgoldenrod4" . "#8B814C")
    753     ("lightgoldenrodyellow" . "#FAFAD2")
    754     ("lightgray" . "#D3D3D3")
    755     ("lightgreen" . "#90EE90")
    756     ("lightgrey" . "#D3D3D3")
    757     ("lightpink" . "#FFB6C1")
    758     ("lightpink1" . "#FFAEB9")
    759     ("lightpink2" . "#EEA2AD")
    760     ("lightpink3" . "#CD8C95")
    761     ("lightpink4" . "#8B5F65")
    762     ("lightsalmon" . "#FFA07A")
    763     ("lightsalmon1" . "#FFA07A")
    764     ("lightsalmon2" . "#EE9572")
    765     ("lightsalmon3" . "#CD8162")
    766     ("lightsalmon4" . "#8B5742")
    767     ("lightseagreen" . "#20B2AA")
    768     ("lightskyblue" . "#87CEFA")
    769     ("lightskyblue1" . "#B0E2FF")
    770     ("lightskyblue2" . "#A4D3EE")
    771     ("lightskyblue3" . "#8DB6CD")
    772     ("lightskyblue4" . "#607B8B")
    773     ("lightslateblue" . "#8470FF")
    774     ("lightslategray" . "#778899")
    775     ("lightslategrey" . "#778899")
    776     ("lightsteelblue" . "#B0C4DE")
    777     ("lightsteelblue1" . "#CAE1FF")
    778     ("lightsteelblue2" . "#BCD2EE")
    779     ("lightsteelblue3" . "#A2B5CD")
    780     ("lightsteelblue4" . "#6E7B8B")
    781     ("lightyellow" . "#FFFFE0")
    782     ("lightyellow1" . "#FFFFE0")
    783     ("lightyellow2" . "#EEEED1")
    784     ("lightyellow3" . "#CDCDB4")
    785     ("lightyellow4" . "#8B8B7A")
    786     ("limegreen" . "#32CD32")
    787     ("linen" . "#FAF0E6")
    788     ("magenta" . "#FF00FF")
    789     ("magenta1" . "#FF00FF")
    790     ("magenta2" . "#EE00EE")
    791     ("magenta3" . "#CD00CD")
    792     ("magenta4" . "#8B008B")
    793     ("maroon" . "#B03060")
    794     ("maroon1" . "#FF34B3")
    795     ("maroon2" . "#EE30A7")
    796     ("maroon3" . "#CD2990")
    797     ("maroon4" . "#8B1C62")
    798     ("mediumaquamarine" . "#66CDAA")
    799     ("mediumblue" . "#0000CD")
    800     ("mediumorchid" . "#BA55D3")
    801     ("mediumorchid1" . "#E066FF")
    802     ("mediumorchid2" . "#D15FEE")
    803     ("mediumorchid3" . "#B452CD")
    804     ("mediumorchid4" . "#7A378B")
    805     ("mediumpurple" . "#9370DB")
    806     ("mediumpurple1" . "#AB82FF")
    807     ("mediumpurple2" . "#9F79EE")
    808     ("mediumpurple3" . "#8968CD")
    809     ("mediumpurple4" . "#5D478B")
    810     ("mediumseagreen" . "#3CB371")
    811     ("mediumslateblue" . "#7B68EE")
    812     ("mediumspringgreen" . "#00FA9A")
    813     ("mediumturquoise" . "#48D1CC")
    814     ("mediumvioletred" . "#C71585")
    815     ("midnightblue" . "#191970")
    816     ("mintcream" . "#F5FFFA")
    817     ("mistyrose" . "#FFE4E1")
    818     ("mistyrose1" . "#FFE4E1")
    819     ("mistyrose2" . "#EED5D2")
    820     ("mistyrose3" . "#CDB7B5")
    821     ("mistyrose4" . "#8B7D7B")
    822     ("moccasin" . "#FFE4B5")
    823     ("navajowhite" . "#FFDEAD")
    824     ("navajowhite1" . "#FFDEAD")
    825     ("navajowhite2" . "#EECFA1")
    826     ("navajowhite3" . "#CDB38B")
    827     ("navajowhite4" . "#8B795E")
    828     ("navy" . "#000080")
    829     ("navyblue" . "#000080")
    830     ("oldlace" . "#FDF5E6")
    831     ("olivedrab" . "#6B8E23")
    832     ("olivedrab1" . "#C0FF3E")
    833     ("olivedrab2" . "#B3EE3A")
    834     ("olivedrab3" . "#9ACD32")
    835     ("olivedrab4" . "#698B22")
    836     ("orange" . "#FFA500")
    837     ("orange1" . "#FFA500")
    838     ("orange2" . "#EE9A00")
    839     ("orange3" . "#CD8500")
    840     ("orange4" . "#8B5A00")
    841     ("orangered" . "#FF4500")
    842     ("orangered1" . "#FF4500")
    843     ("orangered2" . "#EE4000")
    844     ("orangered3" . "#CD3700")
    845     ("orangered4" . "#8B2500")
    846     ("orchid" . "#DA70D6")
    847     ("orchid1" . "#FF83FA")
    848     ("orchid2" . "#EE7AE9")
    849     ("orchid3" . "#CD69C9")
    850     ("orchid4" . "#8B4789")
    851     ("palegoldenrod" . "#EEE8AA")
    852     ("palegreen" . "#98FB98")
    853     ("palegreen1" . "#9AFF9A")
    854     ("palegreen2" . "#90EE90")
    855     ("palegreen3" . "#7CCD7C")
    856     ("palegreen4" . "#548B54")
    857     ("paleturquoise" . "#AFEEEE")
    858     ("paleturquoise1" . "#BBFFFF")
    859     ("paleturquoise2" . "#AEEEEE")
    860     ("paleturquoise3" . "#96CDCD")
    861     ("paleturquoise4" . "#668B8B")
    862     ("palevioletred" . "#DB7093")
    863     ("palevioletred1" . "#FF82AB")
    864     ("palevioletred2" . "#EE799F")
    865     ("palevioletred3" . "#CD6889")
    866     ("palevioletred4" . "#8B475D")
    867     ("papayawhip" . "#FFEFD5")
    868     ("peachpuff" . "#FFDAB9")
    869     ("peachpuff1" . "#FFDAB9")
    870     ("peachpuff2" . "#EECBAD")
    871     ("peachpuff3" . "#CDAF95")
    872     ("peachpuff4" . "#8B7765")
    873     ("peru" . "#CD853F")
    874     ("pink" . "#FFC0CB")
    875     ("pink1" . "#FFB5C5")
    876     ("pink2" . "#EEA9B8")
    877     ("pink3" . "#CD919E")
    878     ("pink4" . "#8B636C")
    879     ("plum" . "#DDA0DD")
    880     ("plum1" . "#FFBBFF")
    881     ("plum2" . "#EEAEEE")
    882     ("plum3" . "#CD96CD")
    883     ("plum4" . "#8B668B")
    884     ("powderblue" . "#B0E0E6")
    885     ("purple" . "#A020F0")
    886     ("purple1" . "#9B30FF")
    887     ("purple2" . "#912CEE")
    888     ("purple3" . "#7D26CD")
    889     ("purple4" . "#551A8B")
    890     ("red" . "#FF0000")
    891     ("red1" . "#FF0000")
    892     ("red2" . "#EE0000")
    893     ("red3" . "#CD0000")
    894     ("red4" . "#8B0000")
    895     ("rosybrown" . "#BC8F8F")
    896     ("rosybrown1" . "#FFC1C1")
    897     ("rosybrown2" . "#EEB4B4")
    898     ("rosybrown3" . "#CD9B9B")
    899     ("rosybrown4" . "#8B6969")
    900     ("royalblue" . "#4169E1")
    901     ("royalblue1" . "#4876FF")
    902     ("royalblue2" . "#436EEE")
    903     ("royalblue3" . "#3A5FCD")
    904     ("royalblue4" . "#27408B")
    905     ("saddlebrown" . "#8B4513")
    906     ("salmon" . "#FA8072")
    907     ("salmon1" . "#FF8C69")
    908     ("salmon2" . "#EE8262")
    909     ("salmon3" . "#CD7054")
    910     ("salmon4" . "#8B4C39")
    911     ("sandybrown" . "#F4A460")
    912     ("seagreen" . "#2E8B57")
    913     ("seagreen1" . "#54FF9F")
    914     ("seagreen2" . "#4EEE94")
    915     ("seagreen3" . "#43CD80")
    916     ("seagreen4" . "#2E8B57")
    917     ("seashell" . "#FFF5EE")
    918     ("seashell1" . "#FFF5EE")
    919     ("seashell2" . "#EEE5DE")
    920     ("seashell3" . "#CDC5BF")
    921     ("seashell4" . "#8B8682")
    922     ("sienna" . "#A0522D")
    923     ("sienna1" . "#FF8247")
    924     ("sienna2" . "#EE7942")
    925     ("sienna3" . "#CD6839")
    926     ("sienna4" . "#8B4726")
    927     ("skyblue" . "#87CEEB")
    928     ("skyblue1" . "#87CEFF")
    929     ("skyblue2" . "#7EC0EE")
    930     ("skyblue3" . "#6CA6CD")
    931     ("skyblue4" . "#4A708B")
    932     ("slateblue" . "#6A5ACD")
    933     ("slateblue1" . "#836FFF")
    934     ("slateblue2" . "#7A67EE")
    935     ("slateblue3" . "#6959CD")
    936     ("slateblue4" . "#473C8B")
    937     ("slategray" . "#708090")
    938     ("slategray1" . "#C6E2FF")
    939     ("slategray2" . "#B9D3EE")
    940     ("slategray3" . "#9FB6CD")
    941     ("slategray4" . "#6C7B8B")
    942     ("slategrey" . "#708090")
    943     ("snow" . "#FFFAFA")
    944     ("snow1" . "#FFFAFA")
    945     ("snow2" . "#EEE9E9")
    946     ("snow3" . "#CDC9C9")
    947     ("snow4" . "#8B8989")
    948     ("springgreen" . "#00FF7F")
    949     ("springgreen1" . "#00FF7F")
    950     ("springgreen2" . "#00EE76")
    951     ("springgreen3" . "#00CD66")
    952     ("springgreen4" . "#008B45")
    953     ("steelblue" . "#4682B4")
    954     ("steelblue1" . "#63B8FF")
    955     ("steelblue2" . "#5CACEE")
    956     ("steelblue3" . "#4F94CD")
    957     ("steelblue4" . "#36648B")
    958     ("tan" . "#D2B48C")
    959     ("tan1" . "#FFA54F")
    960     ("tan2" . "#EE9A49")
    961     ("tan3" . "#CD853F")
    962     ("tan4" . "#8B5A2B")
    963     ("thistle" . "#D8BFD8")
    964     ("thistle1" . "#FFE1FF")
    965     ("thistle2" . "#EED2EE")
    966     ("thistle3" . "#CDB5CD")
    967     ("thistle4" . "#8B7B8B")
    968     ("tomato" . "#FF6347")
    969     ("tomato1" . "#FF6347")
    970     ("tomato2" . "#EE5C42")
    971     ("tomato3" . "#CD4F39")
    972     ("tomato4" . "#8B3626")
    973     ("turquoise" . "#40E0D0")
    974     ("turquoise1" . "#00F5FF")
    975     ("turquoise2" . "#00E5EE")
    976     ("turquoise3" . "#00C5CD")
    977     ("turquoise4" . "#00868B")
    978     ("violet" . "#EE82EE")
    979     ("violetred" . "#D02090")
    980     ("violetred1" . "#FF3E96")
    981     ("violetred2" . "#EE3A8C")
    982     ("violetred3" . "#CD3278")
    983     ("violetred4" . "#8B2252")
    984     ("wheat" . "#F5DEB3")
    985     ("wheat1" . "#FFE7BA")
    986     ("wheat2" . "#EED8AE")
    987     ("wheat3" . "#CDBA96")
    988     ("wheat4" . "#8B7E66")
    989     ("whitesmoke" . "#F5F5F5")
    990     ("yellow" . "#FFFF00")
    991     ("yellow1" . "#FFFF00")
    992     ("yellow2" . "#EEEE00")
    993     ("yellow3" . "#CDCD00")
    994     ("yellow4" . "#8B8B00")
    995     ("yellowgreen" . "#9ACD32"))
    996   "Alist of R colors.
    997 Each entry should have the form (COLOR-NAME . HEXADECIMAL-COLOR)."
    998   :type 'alist
    999   :group 'rainbow)
   1000 
   1001 (defcustom rainbow-r-colors-major-mode-list
   1002   '(ess-mode)
   1003   "List of major mode where R colors are enabled when
   1004 `rainbow-r-colors' is set to auto."
   1005   :type '(repeat (symbol :tag "Major-Mode"))
   1006   :group 'rainbow)
   1007 
   1008 (defcustom rainbow-r-colors 'auto
   1009   "When to enable R colors.
   1010 If set to t, the R colors will be enabled.  If set to nil, the
   1011 R colors will not be enabled.  If set to auto, the R colors
   1012 will be enabled if a major mode has been detected from the
   1013 `rainbow-r-colors-major-mode-list'."
   1014   :type '(choice (symbol :tag "enable in certain modes" auto)
   1015                  (symbol :tag "enable globally" t)
   1016                  (symbol :tag "disable" nil))
   1017   :group 'rainbow)
   1018 
   1019 ;;; Functions
   1020 
   1021 (defun rainbow-colorize-match (color &optional match)
   1022   "Return a matched string propertized with a face whose
   1023 background is COLOR. The foreground is computed using
   1024 `rainbow-color-luminance', and is either white or black."
   1025   (let ((match (or match 0)))
   1026     (put-text-property
   1027      (match-beginning match) (match-end match)
   1028      'face `((:foreground ,(if (> 0.5 (rainbow-x-color-luminance color))
   1029                                "white" "black"))
   1030              (:background ,color)))))
   1031 
   1032 (defun rainbow-colorize-itself (&optional match)
   1033   "Colorize a match with itself."
   1034   (rainbow-colorize-match (match-string-no-properties (or match 0)) match))
   1035 
   1036 (defun rainbow-colorize-hexadecimal-without-sharp ()
   1037   "Colorize an hexadecimal colors and prepend # to it."
   1038   (rainbow-colorize-match (concat "#" (match-string-no-properties 1))))
   1039 
   1040 (defun rainbow-colorize-by-assoc (assoc-list)
   1041   "Colorize a match with its association from ASSOC-LIST."
   1042   (rainbow-colorize-match (cdr (assoc-string (match-string-no-properties 0)
   1043                                              assoc-list t))))
   1044 
   1045 (defun rainbow-rgb-relative-to-absolute (number)
   1046   "Convert a relative NUMBER to absolute. If NUMBER is absolute, return NUMBER.
   1047 This will convert \"80 %\" to 204, \"100 %\" to 255 but \"123\" to \"123\".
   1048 If the percentage value is above 100, it's converted to 100."
   1049   (let ((string-length (- (length number) 1)))
   1050     ;; Is this a number with %?
   1051     (if (eq (elt number string-length) ?%)
   1052         (/ (* (min (string-to-number (substring number 0 string-length)) 100) 255) 100)
   1053       (string-to-number number))))
   1054 
   1055 (defun rainbow-colorize-hsl ()
   1056   "Colorize a match with itself."
   1057   (let ((h (/ (string-to-number (match-string-no-properties 1)) 360.0))
   1058         (s (/ (string-to-number (match-string-no-properties 2)) 100.0))
   1059         (l (/ (string-to-number (match-string-no-properties 3)) 100.0)))
   1060     (rainbow-colorize-match
   1061      (cl-destructuring-bind (r g b)
   1062          (color-hsl-to-rgb h s l)
   1063        (format "#%02X%02X%02X" (* r 255) (* g 255) (* b 255))))))
   1064 
   1065 (defun rainbow-colorize-rgb ()
   1066   "Colorize a match with itself."
   1067   (let ((r (rainbow-rgb-relative-to-absolute (match-string-no-properties 1)))
   1068         (g (rainbow-rgb-relative-to-absolute (match-string-no-properties 2)))
   1069         (b (rainbow-rgb-relative-to-absolute (match-string-no-properties 3))))
   1070     (rainbow-colorize-match (format "#%02X%02X%02X" r g b))))
   1071 
   1072 (defun rainbow-colorize-rgb-float ()
   1073   "Colorize a match with itself, with relative value."
   1074   (let ((r (* (string-to-number (match-string-no-properties 1)) 255.0))
   1075         (g (* (string-to-number (match-string-no-properties 2)) 255.0))
   1076         (b (* (string-to-number (match-string-no-properties 3)) 255.0)))
   1077     (rainbow-colorize-match (format "#%02X%02X%02X" r g b))))
   1078 
   1079 (defvar ansi-color-context)
   1080 (defvar xterm-color-current)
   1081 
   1082 (defun rainbow-colorize-ansi ()
   1083   "Return a matched string propertized with ansi color face."
   1084   (let ((xterm-color? (featurep 'xterm-color))
   1085         (string (match-string-no-properties 0))
   1086         color)
   1087     (save-match-data
   1088       (let* ((replaced (concat
   1089                         (replace-regexp-in-string
   1090                          "^\\(\\\\[eE]\\|\\\\033\\|\\\\x1[bB]\\)"
   1091                          "\033" string) "x"))
   1092              xterm-color-current
   1093              ansi-color-context
   1094              (applied (funcall (if xterm-color?
   1095                                    'xterm-color-filter
   1096                                  'ansi-color-apply)
   1097                                replaced))
   1098              (face-property (get-text-property
   1099                              0
   1100                              (if xterm-color? 'face 'font-lock-face)
   1101                              applied)))
   1102         (unless (listp (or (car-safe face-property) face-property))
   1103           (setq face-property (list face-property)))
   1104         (setq color (funcall (if xterm-color? 'cadr 'cdr)
   1105                              (or (assq (if xterm-color?
   1106                                            :foreground
   1107                                          'foreground-color)
   1108                                        face-property)
   1109                                  (assq (if xterm-color?
   1110                                            :background
   1111                                          'background-color)
   1112                                        face-property))))))
   1113     (when color
   1114       (rainbow-colorize-match color))))
   1115 
   1116 (defun rainbow-color-luminance (red green blue)
   1117   "Calculate the relative luminance of color composed of RED, GREEN and BLUE.
   1118 Return a value between 0 and 1."
   1119   (/ (+ (* .2126 red) (* .7152 green) (* .0722 blue)) 255))
   1120 
   1121 (defun rainbow-x-color-luminance (color)
   1122   "Calculate the relative luminance of a color string (e.g. \"#ffaa00\", \"blue\").
   1123 Return a value between 0 and 1."
   1124   (let* ((values (x-color-values color))
   1125          (r (/ (car values) 256.0))
   1126          (g (/ (cadr values) 256.0))
   1127          (b (/ (caddr values) 256.0)))
   1128     (rainbow-color-luminance r g b)))
   1129 
   1130 ;;; Mode
   1131 
   1132 (defun rainbow-turn-on ()
   1133   "Turn on rainbow-mode."
   1134   (font-lock-add-keywords nil
   1135                           rainbow-hexadecimal-colors-font-lock-keywords
   1136                           t)
   1137   ;; Activate X colors?
   1138   (when (or (eq rainbow-x-colors t)
   1139             (and (eq rainbow-x-colors 'auto)
   1140                  (memq major-mode rainbow-x-colors-major-mode-list)))
   1141     (font-lock-add-keywords nil
   1142                             rainbow-x-colors-font-lock-keywords
   1143                             t))
   1144   ;; Activate LaTeX colors?
   1145   (when (or (eq rainbow-latex-colors t)
   1146             (and (eq rainbow-latex-colors 'auto)
   1147                  (memq major-mode rainbow-latex-colors-major-mode-list)))
   1148     (font-lock-add-keywords nil
   1149                             rainbow-latex-rgb-colors-font-lock-keywords
   1150                             t))
   1151   ;; Activate ANSI colors?
   1152   (when (or (eq rainbow-ansi-colors t)
   1153             (and (eq rainbow-ansi-colors 'auto)
   1154                  (memq major-mode rainbow-ansi-colors-major-mode-list)))
   1155     (font-lock-add-keywords nil
   1156                             rainbow-ansi-colors-font-lock-keywords
   1157                             t))
   1158   ;; Activate HTML colors?
   1159   (when (or (eq rainbow-html-colors t)
   1160             (and (eq rainbow-html-colors 'auto)
   1161                  (memq major-mode rainbow-html-colors-major-mode-list)))
   1162     (setq rainbow-html-colors-font-lock-keywords
   1163           `((,(regexp-opt (mapcar 'car rainbow-html-colors-alist) 'words)
   1164              (0 (rainbow-colorize-by-assoc rainbow-html-colors-alist)))))
   1165     (font-lock-add-keywords nil
   1166                             `(,@rainbow-html-colors-font-lock-keywords
   1167                               ,@rainbow-html-rgb-colors-font-lock-keywords)
   1168                             t))
   1169   ;; Activate R colors?
   1170   (when (or (eq rainbow-r-colors t)
   1171             (and (eq rainbow-r-colors 'auto)
   1172                  (memq major-mode rainbow-r-colors-major-mode-list)))
   1173     (setq rainbow-r-colors-font-lock-keywords
   1174           `((,(regexp-opt (mapcar 'car rainbow-r-colors-alist) 'words)
   1175              (0 (rainbow-colorize-by-assoc rainbow-r-colors-alist)))))
   1176     (font-lock-add-keywords nil
   1177                             rainbow-r-colors-font-lock-keywords
   1178                             t)))
   1179 
   1180 (defun rainbow-turn-off ()
   1181   "Turn off rainbow-mode."
   1182   (font-lock-remove-keywords
   1183    nil
   1184    `(,@rainbow-hexadecimal-colors-font-lock-keywords
   1185      ,@rainbow-x-colors-font-lock-keywords
   1186      ,@rainbow-latex-rgb-colors-font-lock-keywords
   1187      ,@rainbow-r-colors-font-lock-keywords
   1188      ,@rainbow-html-colors-font-lock-keywords
   1189      ,@rainbow-html-rgb-colors-font-lock-keywords)))
   1190 
   1191 (defvar rainbow-keywords-hook nil
   1192   "Hook used to add additional font-lock keywords.
   1193 This hook is called by `rainbow-mode' before it re-enables
   1194 `font-lock-mode'.  Hook functions must only add additional
   1195 keywords when `rainbow-mode' is non-nil.  When that is nil,
   1196 then they must remove those additional keywords again.")
   1197 
   1198 ;;;###autoload
   1199 (define-minor-mode rainbow-mode
   1200   "Colorize strings that represent colors.
   1201 This will fontify with colors the string like \"#aabbcc\" or \"blue\"."
   1202   :lighter " Rbow"
   1203   (if rainbow-mode
   1204       (rainbow-turn-on)
   1205     (rainbow-turn-off))
   1206   ;; We cannot use `rainbow-mode-hook' because this has
   1207   ;; to be done before `font-lock-mode' is re-enabled.
   1208   (run-hooks 'rainbow-keywords-hook)
   1209   ;; Call `font-lock-mode' to refresh the buffer when used
   1210   ;; e.g. interactively.
   1211   (font-lock-mode 1))
   1212 
   1213 (provide 'rainbow-mode)
   1214 
   1215 ;; Local Variables:
   1216 ;; indent-tabs-mode: nil
   1217 ;; End:
   1218 ;;; rainbow-mode.el ends here