From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Newsgroups: gmane.emacs.bugs Subject: bug#21328: 25.0.50; css-mode: Indenting brackets in presence of pseudo-selectors Date: Wed, 26 Aug 2015 22:55:47 +0200 Message-ID: <1440622547.21730.0@smtp.gmail.com> References: <1440327427.6295.0@smtp.gmail.com> <"Simen =?UTF-8?Q?Heggest=C3=B8yl?="'s message of "Sun, 23 Aug 2015 12:57:07 +0200"> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="=-fTs31CUy0p9iNvU1Iseu" X-Trace: ger.gmane.org 1440622589 27147 80.91.229.3 (26 Aug 2015 20:56:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 26 Aug 2015 20:56:29 +0000 (UTC) Cc: 21328@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Aug 26 22:56:18 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZUhjy-00069t-8V for geb-bug-gnu-emacs@m.gmane.org; Wed, 26 Aug 2015 22:56:14 +0200 Original-Received: from localhost ([::1]:41584 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUhjx-0003OE-C0 for geb-bug-gnu-emacs@m.gmane.org; Wed, 26 Aug 2015 16:56:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44353) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUhjr-0003Kb-K5 for bug-gnu-emacs@gnu.org; Wed, 26 Aug 2015 16:56:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZUhjm-0005ht-Jb for bug-gnu-emacs@gnu.org; Wed, 26 Aug 2015 16:56:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:47030) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUhjm-0005hk-GH for bug-gnu-emacs@gnu.org; Wed, 26 Aug 2015 16:56:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1ZUhjm-0002Co-5U for bug-gnu-emacs@gnu.org; Wed, 26 Aug 2015 16:56:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 26 Aug 2015 20:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21328 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 21328-submit@debbugs.gnu.org id=B21328.14406225538457 (code B ref 21328); Wed, 26 Aug 2015 20:56:02 +0000 Original-Received: (at 21328) by debbugs.gnu.org; 26 Aug 2015 20:55:53 +0000 Original-Received: from localhost ([127.0.0.1]:39240 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZUhjc-0002CL-QF for submit@debbugs.gnu.org; Wed, 26 Aug 2015 16:55:53 -0400 Original-Received: from mail-la0-f54.google.com ([209.85.215.54]:35538) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZUhja-0002CC-QD for 21328@debbugs.gnu.org; Wed, 26 Aug 2015 16:55:51 -0400 Original-Received: by labgv11 with SMTP id gv11so60277716lab.2 for <21328@debbugs.gnu.org>; Wed, 26 Aug 2015 13:55:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:subject:to:cc:message-id:in-reply-to:references :mime-version:content-type; bh=IbRi7Od/S62asj6QGNIM7KwIWrPzQXvoC5z7sIE3s5w=; b=MqVVerkYM8D/kjiiK/y1/7stuEPh9G33KMGEs+NKqgsKqgAERR/FI5BYfV9XyMTvFr EHncLbNDEwaQspizP/hXAqQOsG8CffiBtjOx16eJm1pwfgnzURY3RLGi17qZ+S8IOSfF zn/q44Y5TxPIG1hcdAoYQ6r4fIox1Dl4OA12JDHk6GO6jnYQc/UFxBO6Reg+mJv2XvTv /U12PR2CS9L4bh6jfeYwovDi0I964IKrBLAVZJo2bYofVqzmFH4UqqfAWcl2bt2YEjX7 fHxnO5PTu41isJOZvG+5+r+yprRRWsKgIafiZ3xkPac7nsMj2qaIFgSqZRU6LZ38NeEQ Jycg== X-Received: by 10.152.28.193 with SMTP id d1mr441614lah.72.1440622549688; Wed, 26 Aug 2015 13:55:49 -0700 (PDT) Original-Received: from [192.168.100.7] (cm-84.210.143.4.getinternet.no. [84.210.143.4]) by smtp.gmail.com with ESMTPSA id n8sm7043735lbk.8.2015.08.26.13.55.48 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Aug 2015 13:55:48 -0700 (PDT) In-Reply-To: X-Mailer: geary/0.10.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:105855 Archived-At: --=-fTs31CUy0p9iNvU1Iseu Content-Type: text/plain; charset=utf-8; format=flowed Thanks for the thorough explanations. On Tue, Aug 25, 2015 at 3:06 PM, Stefan Monnier wrote: > The (smie-rule-hanging-p) test checks if the "{" is at the end of the > line (and with text before it on the same line). I guess you could > use > something like > > (when (or (smie-rule-hanging-p) (smie-rule-bolp)) That sounds good! > tho for the bolp case, maybe some people like > > main:first > { > background: green; > } > > since that's the "standard GNU style" in C/C++ [...] I'm familiar with the GNU style for indenting C and C++ code, however I've never seen CSS or Sass code indented that way; it seems to me that CSS code is always indented in one of the two styles I described in the previous email. In sum, I propose the following patch: From cede79d7afe038290988070891367825f5b8c5d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simen=20Heggest=C3=B8yl?= Date: Sun, 23 Aug 2015 12:51:57 +0200 Subject: [PATCH] Fix indentation rule in css-mode * lisp/textmodes/css-mode.el (css-smie-rules): Fix indentation of brackets in presence of pseudo-selectors. --- lisp/textmodes/css-mode.el | 2 +- test/indent/css-mode.css | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index d73780c..639456d 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -344,7 +344,7 @@ (`(:elem . arg) 0) (`(:list-intro . ,(or `";" `"")) t) ;"" stands for BOB (bug#15467). (`(:before . "{") - (when (smie-rule-hanging-p) + (when (or (smie-rule-hanging-p) (smie-rule-bolp)) (smie-backward-sexp ";") (smie-indent-virtual))) (`(:before . ,(or "{" "(")) diff --git a/test/indent/css-mode.css b/test/indent/css-mode.css index 67a6b1e..2f04e96 100644 --- a/test/indent/css-mode.css +++ b/test/indent/css-mode.css @@ -36,3 +36,8 @@ a.b:c,d.e:f,g[h]:i,j[k]:l,.m.n:o,.p.q:r,.s[t]:u,.v[w]:x { /* bug:20282 */ div.x3 { } + +article:hover +{ + color: black; +} -- 2.5.0 --=-fTs31CUy0p9iNvU1Iseu Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable Thanks for the thorough explanations.

On Tue, Aug 25, 2015 at 3:06 P= M, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
The (= smie-rule-hanging-p) test checks if the "{" is at the end of the line (and with text before it on the same line). I guess you could use something like (when (or (smie-rule-hanging-p) (smie-rule-bolp))

That sounds good!

tho for the bolp case, = maybe some people like main:first { background: green; } since that's the "standard GNU style" in C/C++ [...]

=
I'm familiar with the GNU style for indenting C and C++ code, how= ever
I've never seen CSS or Sass code indented that way; it seems= to me
that CSS code is always indented in one of the two styles = I described
in the previous email.

In su= m, I propose the following patch:


F= rom cede79d7afe038290988070891367825f5b8c5d8 Mon Sep 17 00:00:00 2001
=
From: =3D?UTF-8?q?Simen=3D20Heggest=3DC3=3DB8yl?=3D <simenheg@gmail= .com>
Date: Sun, 23 Aug 2015 12:51:57 +0200
Subject:= [PATCH] Fix indentation rule in css-mode

* lisp/t= extmodes/css-mode.el (css-smie-rules): Fix indentation of
bracket= s in presence of pseudo-selectors.
---
 lisp/textm= odes/css-mode.el | 2 +-
 test/indent/css-mode.css   | 5= +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/lisp/textmodes/css-mode.el b/lisp/textmod= es/css-mode.el
index d73780c..639456d 100644
--- a/lisp= /textmodes/css-mode.el
+++ b/lisp/textmodes/css-mode.el
@@ -344,7 +344,7 @@
     (`(:elem . arg) 0)
=
     (`(:list-intro . ,(or `";" `"")) t) ;"" stands for= BOB (bug#15467).
     (`(:before . "{")
-     (when (smie-rule-hanging-p)
+     (whe= n (or (smie-rule-hanging-p) (smie-rule-bolp))
     = ;   (smie-backward-sexp ";")
        (sm= ie-indent-virtual)))
     (`(:before . ,(or "{" "(= "))
diff --git a/test/indent/css-mode.css b/test/indent/css-mode.= css
index 67a6b1e..2f04e96 100644
--- a/test/indent/css= -mode.css
+++ b/test/indent/css-mode.css
@@ -36,3 +36,8= @@ a.b:c,d.e:f,g[h]:i,j[k]:l,.m.n:o,.p.q:r,.s[t]:u,.v[w]:x { /* bug:20282 = */
 div.x3
 {
 }
+
+article:hover
+{
+    color: black;=
+}
-- 
2.5.0

= --=-fTs31CUy0p9iNvU1Iseu--