Created
February 9, 2016 07:10
-
-
Save mithrandi/15fca4367e878b6b88cd to your computer and use it in GitHub Desktop.
Twistedchecker for flycheck (Emacs)
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
;; Define the checker | |
(flycheck-define-checker python-twistedchecker | |
"A Python syntax and style checker using twistedchecker." | |
:command ("twistedchecker" | |
;; Need `source-inplace' for relative imports (e.g. `from .foo | |
;; import bar'), see https://github.com/flycheck/flycheck/issues/280 | |
source-inplace) | |
:error-filter | |
(lambda (errors) | |
(flycheck-sanitize-errors (flycheck-increment-error-columns errors))) | |
:error-patterns | |
((error line-start (or "E" "F") (id (one-or-more (not (any ":")))) ":" | |
(zero-or-more " ") line "," column ":" (message) line-end) | |
(warning line-start (or "W" "R" "C") (id (one-or-more (not (any ":")))) ":" | |
(zero-or-more " ") line "," column ":" (message) line-end)) | |
:modes python-mode) | |
(add-to-list 'flycheck-checkers 'python-twistedchecker 'append) | |
;; Chain to another checker (I use flake8, for example) | |
(flycheck-add-next-checker 'python-twistedchecker 'python-flake8) | |
;; Activate this checker for all Python files (you probably don't want this | |
;; unless you only work on Twisted) | |
(add-hook 'python-mode-hook | |
(lambda () (flycheck-select-checker 'python-twistedchecker))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment