Skip to content

Commit e58c11c

Browse files
committed
Lot of cleanup and improvements.
1 parent 45d08c6 commit e58c11c

File tree

3 files changed

+63
-39
lines changed

3 files changed

+63
-39
lines changed

README.md

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,50 @@
1-
# flymake-csslint.el
1+
# flymake-csslint
22

3-
To use [CSSLint](https://github.com/stubbornella/csslint) with emacs,
4-
you will need CSSLint installed and available on your path. You should
5-
be able to do
3+
flymake-csslint.el is an [Emacs](http://www.gnu.org/software/emacs)
4+
integration of [CSSLint](https://github.com/stubbornella/csslint). The
5+
implementation is very much based on
6+
[flymake-jshint.el](http://marmalade-repo.org/packages/flymake-jshint)
7+
by [Wilfred Hughes](http://wilfred.me.uk).
68

7-
$ csslint
9+
## Installation and usage
810

9-
without problem. To do this, you can install node.js, npm and
10-
csslint by doing the following:
11+
The easiest way to install flymake-csslint is probably to install it
12+
via the ELPA archive at
13+
[Marmalade](http://marmalade-repo.org/packages/flymake-csslint).
1114

12-
$ apt-get install nodejs # or your distro / OS equivalent
13-
$ curl http://npmjs.org/install.sh | sh
14-
$ npm install -g csslint
15+
ELPA (package.el) is part of Emacs 24. For Emacs 23 see
16+
[Marmalade](http://marmalade-repo.org) for installation instructions.
1517

16-
flymake-csslint.el is very much based on flymake-jshint.el by
17-
[Wilfred Hughes](<me@wilfred.me.uk>).
18+
If you don't install via ELPA make sure that flymake-csslint.el is in
19+
your load-path and require the library
1820

19-
## Usage
21+
(add-to-list 'load-path "~/.emacs.d/path/to/flymake-csslint")
22+
(require 'flymake-csslint)
2023

21-
Add to your emacs config:
24+
## Requirements
2225

23-
(require 'flymake-csslint)
24-
(add-hook 'css-mode-hook 'flymake-mode)
26+
To use [CSSLint](https://github.com/stubbornella/csslint) with emacs,
27+
you will need to have a command line version of CSSLint installed, see
28+
installation instructions at
29+
https://github.com/stubbornella/csslint/wiki/Command-line-interface.
2530

26-
making sure that flymake-csslint.el is on your load-path. If not,
27-
also add to your config:
31+
If the `csslint` executable is not available on your PATH your need to
32+
configure the flymake-csslint-program variable and let it point to the
33+
executable.
2834

29-
(add-to-list 'load-path "~/.emacs.d/path/to/flymake-csslint.el")
35+
M-x customize-variable <RET> flymake-csslint-program <RET>
3036

3137
## Debugging
3238

3339
If CSSLint isn't working for any reason, execute
3440

35-
M-x set-variable flymake-log-level <RET> 3
41+
M-x set-variable <RET> flymake-log-level <RET> 3 <RET>
3642

3743
and you will see what is going wrong listed in the *Messages*
3844
buffer.
45+
46+
## Development of flymake-csslint
47+
48+
flymake-csslint.el is developed at
49+
[GitHub](https://github.com/arnested/flymake-csslint). Feature
50+
requests, ideas, bug reports, and pull request are more that welcome!

dir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ File: dir, Node: Top This is the top of the INFO tree
1515
* Menu:
1616

1717
Programming
18-
* Flymake CSSLinr: (flymake-csslint). Making flymake work with CSSLint.
18+
* Flymake CSSLint: (flymake-csslint). Making flymake work with CSSLint.

flymake-csslint.el

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
;;; flymake-csslint.el --- making flymake work with CSSLint
22

3+
;; Copyright (C) 2011, 2012 Arne Jørgensen <arne@arnested.dk>
34
;; Copyright (C) 2011 Wilfred Hughes <me@wilfred.me.uk>
4-
;; Copyright (C) 2011 Arne Jørgensen <arne@arnested.dk>
55

66
;; Author: Arne Jørgensen <arne@arnested.dk>
77
;; URL: https://github.com/arnested/flymake-csslint
@@ -70,28 +70,40 @@
7070

7171
(require 'flymake)
7272

73+
(defgroup flymake-csslint nil
74+
"Flymake CCSlint configuration."
75+
:group 'flymake)
76+
77+
(defcustom flymake-csslint-program (executable-find "csslint")
78+
"Name of the CSSLint program."
79+
:type '(choice (file :tag "Location of csslint")
80+
(const :tag "csslint is not installed"))
81+
:group 'flymake-csslint)
82+
83+
;;;###autoload
7384
(defun flymake-csslint-init ()
7485
(let* ((temp-file (flymake-init-create-temp-buffer-copy
75-
'flymake-create-temp-inplace))
86+
(if (fboundp 'flymake-create-temp-copy)
87+
'flymake-create-temp-copy
88+
'flymake-create-temp-inplace)))
7689
(local-file (file-relative-name
7790
temp-file
7891
(file-name-directory buffer-file-name))))
79-
(list "csslint" (list "--format=compact" local-file))))
80-
81-
(setq flymake-allowed-file-name-masks
82-
(cons '(".+\\.css$"
83-
flymake-csslint-init
84-
flymake-simple-cleanup
85-
flymake-get-real-file-name)
86-
flymake-allowed-file-name-masks))
87-
88-
(setq flymake-err-line-patterns
89-
(cons '("^\\(.*\\): line \\([[:digit:]]+\\), col \\([[:digit:]]+\\), \\(.+\\)$"
90-
1 2 3 4)
91-
flymake-err-line-patterns))
92-
93-
; load flymake automatically in CSS mode
94-
(add-hook 'css-mode-hook 'flymake-mode)
92+
(list flymake-csslint-program (list "--format=compact" local-file))))
93+
94+
;;;###autoload
95+
(eval-after-load 'flymake
96+
'(progn
97+
(add-to-list 'flymake-allowed-file-name-masks
98+
'(".+\\.css$"
99+
flymake-csslint-init
100+
flymake-simple-cleanup
101+
flymake-get-real-file-name))
102+
(add-to-list 'flymake-err-line-patterns
103+
'("^\\(.*\\): line \\([[:digit:]]+\\), col \\([[:digit:]]+\\), \\(.+\\)$"
104+
1 2 3 4))
105+
;; load flymake automatically in CSS mode
106+
(add-hook 'css-mode-hook (lambda() (flymake-mode 1)) t)))
95107

96108

97109

0 commit comments

Comments
 (0)