Skip to content

--format=compact outputs newlines before and after, this causes problems for editor integration (emacs) #165

@cillianderoiste

Description

@cillianderoiste

csslint works with emacs flymake mode if you strip the newlines from the output. Here's a sample configuration with the relevant matches:

(defun flymake-css-init ()
  (let* ((temp-file (flymake-init-create-temp-buffer-copy
             'flymake-create-temp-inplace))
     (local-file (file-relative-name
              temp-file
              (file-name-directory buffer-file-name))))

    ;; "ecsslint.sh" is a shell script, see below 
    (list "ecsslint.sh" (list temp-file))))

(add-to-list 'flymake-allowed-file-name-masks
         '("\\.css$" flymake-css-init))

;; The regexp for matching errors in the lint output
(add-to-list 'flymake-err-line-patterns
         '("^\\(\.+\.css\\): line \\([0-9]+\\), col \\([0-9]+\\), \\(.*\\)"
           1 2 3 4))

ecsslint.sh just contains:

#!/bin/sh
csslint --format=compact $1 | grep .

(grep . will return any line that has some characters, removing the empty lines)

I don't know enough emacs lisp to come up with a clever way to do this without the shell script, but perhaps this will also affect other editors.

I did have a look at the code (only 0.5.0, I couldn't figure out how to run the code from HEAD, does it require some kind of build tool?). I can see that startFormat and endFormat are both "", and they are printed. This produces one newline before and after the output. I couldn't figure out why there is also an additional newline at the very end.

There is one other tiny problem when providing full paths as the filename argument, I'll open a different ticket for that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions