From 85ccd184568b6c490a271f288d9941e9b3e315c5 Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Sun, 16 Aug 2015 22:05:12 -0700 Subject: [emacs] Add custom checker for Python. Use `dist.pex` on Python code. --- emacs.d/packages.el | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/emacs.d/packages.el b/emacs.d/packages.el index 57e4098..bec8e5a 100644 --- a/emacs.d/packages.el +++ b/emacs.d/packages.el @@ -35,14 +35,29 @@ (use-package flycheck :ensure t :defer t + :preface (progn + (defun check-source-predicate () + (and (executable-find "check.pex") + (buffer-file-name) + (string-match "src/source/.*\.py$" (buffer-file-name))))) :init (progn (add-hook 'prog-mode-hook 'flycheck-mode) - (setq-default flycheck-disabled-checkers '(emacs-lisp-checkdoc)))) + (setq-default flycheck-disabled-checkers '(emacs-lisp-checkdoc))) + :config + (progn + (flycheck-define-checker source-check + "A syntax checker for python source code in Source, using `dist.pex'" + :command ("check.pex" source) + ;;; errors are reported like this: + ;;; E241:ERROR : + :error-patterns ((error line-start (1+ nonl) ":ERROR" (1+ nonl) ":" line (message) line-end)) + :predicate check-source-predicate + :modes (python-mode)) + (add-to-list 'flycheck-checkers 'source-check))) (use-package flyspell :ensure t - :diminish flyspell-mode "✓" :defer t :init (progn -- cgit 1.4.1