Last active
December 21, 2015 15:49
-
-
Save sabof/6329267 to your computer and use it in GitHub Desktop.
Customizing flymake output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defadvice flymake-post-syntax-check (before coffee-no-spaces activate) | |
"Warn about space indentation when in coffee-mode." | |
(when (eq major-mode 'coffee-mode) | |
(let (bad-spaces) | |
(save-excursion | |
(goto-char (point-min)) | |
(while (re-search-forward | |
"^[[:blank:]]*\\(?1: \\)[[:blank:]]*[^[:blank:]\n]" | |
nil t) | |
(let (( ppss (syntax-ppss (match-beginning 1)))) | |
(unless (or (nth 4 ppss) (nth 3 ppss)) | |
(push (match-beginning 1) bad-spaces))))) | |
(mapc (lambda (space) | |
(let* (( linum (line-number-at-pos space)) | |
( ler (flymake-ler-make-ler | |
buffer-file-name | |
linum | |
"w" | |
"Line contains space indentation."))) | |
(if (assoc linum flymake-new-err-info) | |
(push ler (cadr (assoc linum flymake-new-err-info))) | |
(push (list linum (list ler)) flymake-new-err-info)))) | |
bad-spaces) | |
(setq flymake-new-err-info | |
(sort flymake-new-err-info | |
(lambda (a b) (< (car a) (car b))))) | |
))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment