From: Stefan Monnier <monnier@iro.umontreal.ca>
To: "Simen Heggestøyl" <simenheg@gmail.com>
Cc: 21328@debbugs.gnu.org
Subject: bug#21328: 25.0.50; css-mode: Indenting brackets in presence of pseudo-selectors
Date: Tue, 25 Aug 2015 09:06:18 -0400 [thread overview]
Message-ID: <jwvd1yb350n.fsf-monnier+emacsbugs@gnu.org> (raw)
In-Reply-To: <1440327427.6295.0@smtp.gmail.com> ("Simen Heggestøyl"'s message of "Sun, 23 Aug 2015 12:57:07 +0200")
> main:first
> {
> background: green;
> }
> }
[...]
> (`(:before . "{")
> (when (smie-rule-hanging-p)
> (smie-backward-sexp ";")
> (smie-indent-virtual)))
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))
tho for the bolp case, maybe some people like
main:first
{
background: green;
}
since that's the "standard GNU style" in C/C++ (so for the bolp case, we
might like to add the indentation step to the return value of
smie-indent-virtual).
The current behavior is "almost" like this standard, except that it
indents relatively to the "first" instead of doing it relatively to the
"main", because it misparses the above as
main : (first {...})
i.s.o
(main : first) {...}
[ Where I added parentheses just to clarify the grouping. ]
> However I haven't been able to fully understand how SMIE works yet, so
> I'm not sure what that check was meant for in the first place, or
> whether it breaks some other cases (though I haven't been able to find
> such a case).
You could also remove the (smie-rule-hanging-p) test
altogether, indeed. This could lead to mis-indentations in some cases,
tho I can't think of any right now that would show up in CSS. E.g. things
where we'd want
main:first {toto}
(tutu)
because the "(tutu)" is like a "second argument" to "main:first", and
we'd instead get
main:first {toto}
(tutu)
because the `(:before . "{") case also triggers here when we compute the
(virtual) indentation of {toto}.
Stefan
next prev parent reply other threads:[~2015-08-25 13:06 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 [this message]
2015-08-26 20:55 ` Simen Heggestøyl
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=jwvd1yb350n.fsf-monnier+emacsbugs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=21328@debbugs.gnu.org \
--cc=simenheg@gmail.com \
/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.