all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Simen Heggestøyl" <simenheg@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 21328@debbugs.gnu.org
Subject: bug#21328: 25.0.50; css-mode: Indenting brackets in presence of pseudo-selectors
Date: Wed, 26 Aug 2015 22:55:47 +0200	[thread overview]
Message-ID: <1440622547.21730.0@smtp.gmail.com> (raw)
In-Reply-To: <jwvd1yb350n.fsf-monnier+emacsbugs@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 2082 bytes --]

Thanks for the thorough explanations.

On Tue, Aug 25, 2015 at 3:06 PM, 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, 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?= <simenheg@gmail.com>
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



[-- Attachment #2: Type: text/html, Size: 3000 bytes --]

  reply	other threads:[~2015-08-26 20:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-23 10:57 bug#21328: 25.0.50; css-mode: Indenting brackets in presence of pseudo-selectors Simen Heggestøyl
2015-08-25 13:06 ` Stefan Monnier
2015-08-26 20:55   ` Simen Heggestøyl [this message]
2015-08-28  1:36     ` Stefan Monnier
2015-08-28 18:14       ` Simen Heggestøyl

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1440622547.21730.0@smtp.gmail.com \
    --to=simenheg@gmail.com \
    --cc=21328@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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.