Emacs CSS modes - most feature complete and maintained?

7

1

According to EmacsWiki there are bunch of CSS modes for Emacs, but none of them seems to be very actively developed or even that feature complete. Which one is the most feature complete so far and is being maybe even maintained?

Features

  • Syntax highlighting
  • Well behaved indentation
  • Commenting
    • Region
    • Line
  • Validation
    • Error reporting

Problems with the default CSS mode

One of the reason why the current CSS mode doesn't cut it for me is because it indents selectors NOT like this

div.bar input,
div.bar select {
    float: left;
}

, but like this

div.bar input,
        div.bar select {
                float: left;
        }

which is simply unbearable.

Bleadof

Posted 2012-01-24T13:24:51.117

Reputation: 171

Answers

3

I'm using the css-mode that comes with GNU Emacs 24 and it indents fine (the way you want). It does all what you want except validation, and it's part of GNU Emacs so it's maintained. I haven't tried it, but I think css-tidy.el can do validation.

The only customizations I have are

(setq cssm-indent-function #'cssm-c-style-indenter)
(setq cssm-indent-level 2)

but I think those are remnants of some former css mode since neither is defined anywhere. What Emacs are you using and what command is being used to indent (C-h k TAB)?

Ivan Andrus

Posted 2012-01-24T13:24:51.117

Reputation: 696

1I'm using the Emacs 23.3. (9.0) on Mac OS X which I installed with homebrew. It might be that I ought to update the CSS mode from the upstream. Someone else told me about those customizations as well, but they don't seem to work. – Bleadof – 2012-01-31T12:18:54.147

It looks like neither css-indent-function nor css-indent-calculate has changed since 2007 when the file was initially imported. It seems like something must be messed up. What is the value of indent-line-function? – Ivan Andrus – 2012-01-31T18:10:27.047

1

if you are doing inline where you have both html and css code look into nxhtml mode, its one mode that will have the proper syntax editing and highlighting for both css and html.

Shantanu

Posted 2012-01-24T13:24:51.117

Reputation: 1 085

Sadly that's not what I'm looking for... – Bleadof – 2012-03-06T15:08:19.600

0

If you're using Spacemacs (develop), you need to add this to your (defun dotspacemacs/user-config ():

(setq-default css-indent-offset 2)

asymmetric

Posted 2012-01-24T13:24:51.117

Reputation: 130