From: Tom Tromey <tom@tromey.com>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: 13425@debbugs.gnu.org, Tom Tromey <tom@tromey.com>
Subject: bug#13425: close this bug?
Date: Mon, 30 Jan 2017 15:17:48 -0700 [thread overview]
Message-ID: <877f5cchv7.fsf@tromey.com> (raw)
In-Reply-To: <jwvmve9hjps.fsf-monnier+bug#13425@gnu.org> (Stefan Monnier's message of "Sun, 29 Jan 2017 12:16:20 -0500")
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;
+}
next prev parent reply other threads:[~2017-01-30 22:17 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-13 7:43 bug#13425: new css-mode indenter E Sabof
2013-01-15 5:00 ` Stefan Monnier
2013-01-15 19:32 ` E Sabof
2013-01-17 0:17 ` E Sabof
2017-01-25 23:06 ` bug#13425: close this bug? Tom Tromey
2017-01-29 14:01 ` Simen Heggestøyl
2017-01-29 17:16 ` Stefan Monnier
2017-01-29 17:38 ` Simen Heggestøyl
2017-01-29 18:15 ` Stefan Monnier
2017-02-02 19:12 ` Simen Heggestøyl
2017-02-03 0:02 ` Stefan Monnier
2017-02-04 19:31 ` Simen Heggestøyl
2017-01-30 22:17 ` Tom Tromey [this message]
2017-01-30 22:28 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877f5cchv7.fsf@tromey.com \
--to=tom@tromey.com \
--cc=13425@debbugs.gnu.org \
--cc=monnier@IRO.UMontreal.CA \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).