Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

More work on flychecker syntax checkers

  • Loading branch information...
commit d5e5d1e93456383beea1c9bed381c24ce966e250 1 parent d784b9f
John Wiegley authored
Showing with 84 additions and 14 deletions.
  1. +83 −12 init.el
  2. +0 −1  settings.el
  3. +1 −1  site-lisp/flycheck
View
95 init.el
@@ -2053,11 +2053,15 @@ FORM => (eval FORM)."
:init
(progn
(flycheck-declare-checker haskell-ghc
- "Haskell checker using ghc"
+ "Haskell checker using ghc"
:command '("ghc" "-fno-code" "-v0" source-inplace)
:error-patterns
+ `((,(concat "^\\(?1:.*?\\):\\(?2:[0-9]+\\):\\(?3:[0-9]+\\):[ \t\n\r]*"
"\\(?5:Warning: \\)?"
- "\\(?4:\\(.\\|[ \t\n\r]\\)+?\\)\\(^\n\\|\\'\\)")
+ "\\(?4:\\(.\\|[ \t\n\r]\\)+?\\)\\(^\n\\|\\'\\)")
+ (if (let ((out (match-string 5 output)))
+ (and out (string= out "Warning: ")))
+ 'warning
'error)))
:modes 'haskell-mode)
@@ -2067,8 +2071,12 @@ FORM => (eval FORM)."
"Haskell checker using hdevtools"
:command '("hdevtools" "check" source-inplace)
:error-patterns
+ `((,(concat "^\\(?1:.*?\\):\\(?2:[0-9]+\\):\\(?3:[0-9]+\\):[ \t\n\r]*"
"\\(?5:Warning: \\)?"
- "\\(?4:\\(.\\|[ \t\n\r]\\)+?\\)\\(^\n\\|\\'\\)")
+ "\\(?4:\\(.\\|[ \t\n\r]\\)+?\\)\\(^\n\\|\\'\\)")
+ (if (let ((out (match-string 5 output)))
+ (and out (string= out "Warning: ")))
+ 'warning
'error)))
:modes 'haskell-mode)
@@ -2097,27 +2105,90 @@ FORM => (eval FORM)."
:predicate '(eq sh-shell 'bash))
(push 'bash flycheck-checkers)
-
+
+ (flycheck-declare-checker xmllint
+ "xmllint checker"
+ :command '("xmllint" "--noout" "--postvalid" source)
+ :error-patterns
+ '(("^\\(?1:.*\\):\\(?2:[0-9]+\\): parser error : \\(?4:.*\\)$" error))
+ :modes 'nxml-mode)
+
+ (push 'xmllint flycheck-checkers)
+
+ (flycheck-declare-checker jslint
+ "jslint checker"
+ :command '("jsl" "-process" source)
+ :error-patterns
+ '(("^\\(?1:.*\\)(\\(?2:[0-9]+\\)): error: \\(?4:.*\\)$" error)
+ ("^\\(?1:.*\\)(\\(?2:[0-9]+\\)): \\(\\(lint \\)?warning\\): \\(?4:.*\\)$"
+ warning))
+ :modes 'js2-mode)
+
+ (push 'jslint flycheck-checkers)
+
+ (flycheck-declare-checker clang++-ledger
+ "Clang++ checker for Ledger"
+ :command
+ '("clang++" "-Wall" "-fsyntax-only"
+ "-I/Users/johnw/Products/ledger/debug" "-I../lib"
+ "-I../lib/utfcpp/source"
+ "-I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7"
+ "-include" "system.hh" "-c" source-inplace)
+ :error-patterns
+ '(("^\\(?1:.*\\):\\(?2:[0-9]+\\):\\(?3:[0-9]+\\): warning:\\s-*\\(?4:.*\\)"
+ warning)
+ ("^\\(?1:.*\\):\\(?2:[0-9]+\\):\\(?3:[0-9]+\\): error:\\s-*\\(?4:.*\\)"
+ error))
+ :modes 'c++-mode
+ :predicate '(string-match "/ledger/" (buffer-file-name)))
+
+ (push 'clang++-ledger flycheck-checkers)
+
+ (defun my-flycheck-show-error-in-window ()
+ (interactive)
+ (flycheck-cancel-error-display-timer)
+ (when flycheck-mode
+ (let ((buf (get-buffer-create "*Flycheck Info*"))
+ (message (car (flycheck-overlay-messages-at (point)))))
+ (with-current-buffer buf
+ (delete-region (point-min) (point-max))
+ (insert message))
+ (display-buffer buf)
+ (fit-window-to-buffer (get-buffer-window buf)))))
+
+ (defun flycheck-show-error-at-point ()
"Show the first error message at point in minibuffer."
- (interactive)
- (let ((inhibit-redisplay t)
- (errs (ghc-flymake-err-list)))
- (if (= 1 (length errs))
- (message (car errs))
- (ghc-flymake-display-errors)
+ (interactive)
+ (flycheck-cancel-error-display-timer)
+ (when flycheck-mode
+ (if (flycheck-may-show-message)
+ (let* ((buf (get-buffer-create "*Flycheck Info*"))
+ (wind (get-buffer-window buf))
+ (message (car (flycheck-overlay-messages-at (point)))))
+ (if message
+ (if (> (length (split-string message "\n")) 8)
+ (my-flycheck-show-error-in-window)
+ (if wind (delete-window wind))
+ (message "%s" message))
+ (message nil)))
+ ;; Try again if the minibuffer is busy at the moment
(flycheck-show-error-at-point-soon))))
- (defun my-flycheck-mode-hook ()
+ (defun my-flycheck-mode-hook ()
(bind-key "M-?" 'my-flycheck-show-error-in-window flycheck-mode-map)
(bind-key "M-p" 'previous-error flycheck-mode-map)
(bind-key "M-n" 'next-error flycheck-mode-map))
(add-hook 'flycheck-mode-hook 'my-flycheck-mode-hook)
+ (add-hook 'prog-mode-hook 'flycheck-mode)
+ (add-hook 'nxml-mode-hook 'flycheck-mode)
(add-hook 'js2-mode-hook 'flycheck-mode)
(add-hook 'haskell-mode-hook 'flycheck-mode))
- :config
+ :config
+ (progn
+ (defalias 'flycheck-show-error-at-point-soon 'flycheck-show-error-at-point)
(defalias 's-collapse-whitespace 'identity)))
;;;_ , flyspell
View
1  settings.el
@@ -168,7 +168,6 @@
'(haskell-indentation-ifte-offset 4)
'(haskell-indentation-layout-offset 4)
'(haskell-indentation-left-offset 4)
- '(haskell-mode-hook (quote (turn-on-haskell-indentation turn-on-font-lock turn-on-haskell-decl-scan ghc-init my-haskell-mode-hook)))
'(haskell-program-name "ghci")
'(haskell-saved-check-command "~/.cabal/bin/hlint" t)
'(hippie-expand-try-functions-list (quote (yas/hippie-try-expand try-complete-file-name-partially try-complete-file-name try-expand-all-abbrevs try-expand-list try-expand-line try-expand-dabbrev try-expand-dabbrev-all-buffers try-expand-dabbrev-from-kill try-complete-lisp-symbol-partially try-complete-lisp-symbol)))
2  site-lisp/flycheck
@@ -1 +1 @@
-Subproject commit 6584513170b12e8903fc69ed9219b03bd79d2403
+Subproject commit 164c416a7db1632511a2d60256410bf1c4d9464d
Please sign in to comment.
Something went wrong with that request. Please try again.