Subject: Re: bug#13425: close this bug?

From: Tom Tromey <[email-masked]>
Date: Mon, 30 Jan 2017 15:17:48 -0700

Stefan> What have you tried?  I don't know the CSS grammar well enough to know
Stefan> what we should do.

I've appended my first try, which also includes a test case.
(Though the last stanza of the test case is actually not indented
properly as-is, oops.)  Like yours mine failed on ":"s in selectors.

I had a second try but it worked even less well I think.

Stefan> So the question is mostly: whether it's easier to distinguish
Stefan> the two different kinds of commas, or whether it's easier to
Stefan> distinguish the two different kinds of colons.

In my view the simplest is treating ":" different inside and outside of
braces.

Outside of braces it acts as a separator in a selector, with the suffix
being a pseudo-class or pseudo-element:

    p::after {
      blah
    }

Inside braces it separates a property name from the value:

   p {
     property-name: value;
   }

Tom

diff --git a/lisp/emacs-lisp/smie.el b/lisp/emacs-lisp/smie.el
index 4d02b75..5cb9027 100644
--- a/lisp/emacs-lisp/smie.el
+++ b/lisp/emacs-lisp/smie.el
@@ -1140,7 +1140,7 @@ smie-rules-function
 - :before, in which case ARG is a token and the function should return the
   OFFSET to use to indent ARG itself.
 - :elem, in which case the function should return either:
-  - the offset to use to indent function arguments (ARG = `arg')
+  - the offset to use to indent function arguments (ARG = `args')
   - the basic indentation step (ARG = `basic').
   - the token to use (when ARG = `empty-line-token') when we don't know how
     to indent an empty line.
diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el
index c81c3f6..7f1b5ca 100644
--- a/lisp/textmodes/css-mode.el
+++ b/lisp/textmodes/css-mode.el
@@ -734,7 +734,7 @@ css-indent-offset
 
 (defconst css-smie-grammar
   (smie-prec2->grammar
-   (smie-precs->prec2 '((assoc ";") (assoc ",") (left ":")))))
+   (smie-precs->prec2 '((assoc ";") (left ":")))))
 
 (defun css-smie--forward-token ()
   (cond
@@ -764,6 +764,7 @@ css-smie--backward-token
 
 (defun css-smie-rules (kind token)
   (pcase (cons kind token)
+    (`(:list-intro . ":") t)
     (`(:elem . basic) css-indent-offset)
     (`(:elem . arg) 0)
     (`(:list-intro . ,(or `";" `"")) t) ;"" stands for BOB (bug#15467).
diff --git a/test/manual/indent/css-mode.css b/test/manual/indent/css-mode.css
index 3a00739..a7ee536 100644
--- a/test/manual/indent/css-mode.css
+++ b/test/manual/indent/css-mode.css
@@ -43,3 +43,44 @@ article:hover
 {
     color: black;
 }
+
+/* Example from bug#13425, with some changes.  */
+body {
+    color: #333;
+    font: 15px "Helvetica Neue",
+	  Helvetica,
+	  Arial,
+	  "Nimbus Sans L",
+	  sans-serif;
+    font-x-commas: 15px "Helvetica Neue"
+		   Helvetica
+		   Arial
+		   "Nimbus Sans L"
+		   sans-serif;
+    font-weight: 300;
+    line-height: 1.625;
+    a { /* It also handles SCSS */
+        font: 15px "Helvetica Neue",
+	      Helvetica,
+	      Arial,
+	      "Nimbus Sans L",
+	      sans-serif;
+        /* Some comment */
+	font-x-commas: 15px "Helvetica Neue"
+		       Helvetica
+		       Arial
+		       "Nimbus Sans L"
+		       sans-serif;
+    }
+    /* Some comment at the end of a block */
+}
+
+/* Ensure bug#13425 doesn't regress this.  */
+#navtable .current:link,
+#navtable .current:visited,
+#navtable .current:hover,
+#navtable .current:active {
+  background-color: grey;
+  color: white;
+  border: thin solid black;
+}