Subject: bug#23383: [PATCH] Support completion of color functions in CSS mode

From: Etienne Prud'homme <[email-masked]>
Date: Wed, 27 Apr 2016 20:17:45 -0400

On Wed, 27 Apr 2016 21:16:58 +0200,
Simen Heggestøyl <[email-masked]> wrote:

> - In the completion definitions we've tried to stay as close as
> possible to the structure used in the CSS spec. This means that
> instead of introducing `color-functions' we should make `color'
> complete directly to "rgb()", "rgba()", and so on, then `hex-color',
> `named-color' and the literal `currentcolor' (I think we can skip
>   `deprecated-system-color'). `named-color' will then contain the
>   literal color names like `color' does now.
That’s a good point. Since I saw that `color' lacked most of
them, I wasn’t sure where we were going.

> - One of the tests in test/lisp/textmodes/css-mode-tests.el needs
>   updating. To see this, run `make lisp/textmodes/css-mode-tests' from
>   the test directory.
> 
> - Please wrap lines around column 70 or so to stay in line with the
> rest of the file.
Thanks for reminding me! I completely forgot. Much easier to read.

I’ve made a second patch according to your recommendations. Color
functions are now part of `color' and `named-color' is now a separate
entity. I’ve tried to follow CSSWG ordering, but it’s not always the
same order in the specifications. I also found two more functions not
present earlier.
>From 3e000ab30b3c6a4cd8cc1f76bd98c5f7c5aa0c30 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Etienne=20Prud=E2=80=99homme?= <[email-masked]>
Date: Wed, 27 Apr 2016 19:52:28 -0400
Subject: [PATCH] Add completion of colors in CSS mode

* lisp/textmodes/css-mode.el (css-value-class-alist): Add CSS colors
  candidates from "CSS Color Module Level 4".
---
 lisp/textmodes/css-mode.el | 38 ++++++++++++++++++++++++++++++++++----
 1 file changed, 34 insertions(+), 4 deletions(-)

diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el
index e30fb3e..3b795fd 100644
--- a/lisp/textmodes/css-mode.el
+++ b/lisp/textmodes/css-mode.el
@@ -460,10 +460,9 @@ css-value-class-alist
     (bg-layer bg-image position repeat-style attachment box)
     (bg-size length percentage "auto" "cover" "contain")
     (box "border-box" "padding-box" "content-box")
-    (color
-     "aqua" "black" "blue" "fuchsia" "gray" "green" "lime" "maroon"
-     "navy" "olive" "orange" "purple" "red" "silver" "teal" "white"
-     "yellow" "transparent")
+    (color "rgb()" "rgba()" "hsl()" "hsla()" "hwb()" "gray()" "lab()"
+           "lch()" "device-cmyk()" "color-mod()" "#" namedColor
+           "transparent" "currentColor")
     (common-lig-values "common-ligatures" "no-common-ligatures")
     (contextual-alt-values "contextual" "no-contextual")
     (counter "counter()" "counters()")
@@ -502,6 +501,37 @@ css-value-class-alist
     (line-width length "thin" "medium" "thick")
     (linear-gradient "linear-gradient()")
     (margin-width "auto" length percentage)
+    (named-color
+     "aliceblue" "antiquewhite" "aqua" "aquamarine" "azure" "beige"
+     "bisque" "black" "blanchedalmond" "blue" "blueviolet" "brown"
+     "burlywood" "cadetblue" "chartreuse" "chocolate" "coral"
+     "cornflowerblue" "cornsilk" "crimson" "cyan" "darkblue"
+     "darkcyan" "darkgoldenrod" "darkgray" "darkgreen" "darkgrey"
+     "darkkhaki" "darkmagenta" "darkolivegreen" "darkorange"
+     "darkorchid" "darkred" "darksalmon" "darkseagreen"
+     "darkslateblue" "darkslategray" "darkslategrey" "darkturquoise"
+     "darkviolet" "deeppink" "deepskyblue" "dimgray" "dimgrey"
+     "dodgerblue" "firebrick" "floralwhite" "forestgreen" "fuchsia"
+     "gainsboro" "ghostwhite" "gold" "goldenrod" "gray" "green"
+     "greenyellow" "grey" "honeydew" "hotpink" "indianred" "indigo"
+     "ivory" "khaki" "lavender" "lavenderblush" "lawn reen"
+     "lemonchiffon" "lightblue" "lightcoral" "lightcyan"
+     "lightgoldenrodyellow" "lightgray" "lightgreen" "lightgrey"
+     "lightpi k" "lightsalmon" "lightseagreen" "lightskyblue"
+     "lightslategray" "lightslategrey" "lightsteelblue" "lightyellow"
+     "lime" "limeg een" "linen" "magenta" "maroon" "mediumaquamarine"
+     "mediumblue" "mediumorchid" "mediumpurple" "mediumseagreen"
+     "mediumslateblu " "mediumspringgreen" "mediumturquoise"
+     "mediumvioletred" "midnightblue" "mintcream" "mistyrose"
+     "moccasin" "navajowhite" "nav " "oldlace" "olive" "olivedrab"
+     "orange" "orangered" "orchid" "palegoldenrod" "palegreen"
+     "paleturquoise" "palevioletred" "pap yawhip" "peachpuff" "peru"
+     "pink" "plum" "powderblue" "purple" "rebeccapurple" "red"
+     "rosybrown" "royalblue" "saddlebrown" "sa mon" "sandybrown"
+     "seagreen" "seashell" "sienna" "silver" "skyblue" "slateblue"
+     "slategray" "slategrey" "snow" "springgreen" " teelblue" "tan"
+     "teal" "thistle" "tomato" "turquoise" "violet" "wheat" "white"
+     "whitesmoke" "yellow" "yellowgreen")
     (number "calc()")
     (numeric-figure-values "lining-nums" "oldstyle-nums")
     (numeric-fraction-values "diagonal-fractions" "stacked-fractions")
-- 
2.8.1