-
Notifications
You must be signed in to change notification settings - Fork 1
/
flymake-csslint.el
116 lines (84 loc) · 3.55 KB
/
flymake-csslint.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
;;; flymake-csslint.el --- making flymake work with CSSLint
;; Copyright (C) 2011, 2012 Arne Jørgensen <[email protected]>
;; Copyright (C) 2011 Wilfred Hughes <[email protected]>
;; Author: Arne Jørgensen <[email protected]>
;; URL: https://github.com/arnested/flymake-csslint
;; Created: 1 December 2011
;; Version: 1.1.0
;; Package-Requires: ((flymake "0.3"))
;; Keywords: flymake, csslint, css
;; This file is not part of GNU Emacs.
;; However, it is distributed under the same license.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;; To use CSSLint with emacs, you will need CSSLint installed and available on
;; your path. You should be able to do
;; $ csslint
;; without problem. To do this, you can install node.js, npm and
;; csslint by doing the following:
;; $ apt-get install nodejs # or your distro / OS equivalent
;; $ curl http://npmjs.org/install.sh | sh
;; $ npm install -g csslint
;; flymake-csslint.el is very much based on flymake-jshint.el by
;; Wilfred Hughes <[email protected]>.
;;; Usage:
;; Add to your emacs config:
;; (require 'flymake-csslint)
;; (add-hook 'css-mode-hook 'flymake-mode)
;; making sure that flymake-csslint.el is on your load-path. If not,
;; also add to your config:
;; (add-to-list 'load-path "~/.emacs.d/path/to/flymake-csslint.el")
;;; Debugging:
;; If CSSLint isn't working for any reason, execute
;; M-x set-variable flymake-log-level <RET> 3
;; and you will see what is going wrong listed in the *Messages*
;; buffer.
;;; Code:
(require 'flymake)
(defgroup flymake-csslint nil
"Flymake CCSlint configuration."
:group 'flymake)
(defcustom flymake-csslint-program (executable-find "csslint")
"Name of the CSSLint program."
:type '(choice (file :tag "Location of csslint")
(const :tag "csslint is not installed"))
:group 'flymake-csslint)
;;;###autoload
(defun flymake-csslint-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
(if (fboundp 'flymake-create-temp-copy)
'flymake-create-temp-copy
'flymake-create-temp-inplace)))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list flymake-csslint-program (list "--format=compact" local-file))))
;;;###autoload
(eval-after-load 'flymake
'(progn
(add-to-list 'flymake-allowed-file-name-masks
'(".+\\.css$"
flymake-csslint-init
flymake-simple-cleanup
flymake-get-real-file-name))
(add-to-list 'flymake-err-line-patterns
'("^\\(.*\\): line \\([[:digit:]]+\\), col \\([[:digit:]]+\\), \\(.+\\)$"
1 2 3 4))
;; load flymake automatically in CSS mode
(add-hook 'css-mode-hook (lambda() (flymake-mode 1)) t)))
(provide 'flymake-csslint)
;; Local Variables:
;; coding: utf-8
;; End:
;;; flymake-csslint.el ends here