diff options
author | Franck Cuny <franck.cuny@gmail.com> | 2016-10-29 13:16:01 -0700 |
---|---|---|
committer | Franck Cuny <franck.cuny@gmail.com> | 2016-10-29 13:16:01 -0700 |
commit | 67ed23729de89ffabff6047859f55e829f855224 (patch) | |
tree | b6583ae2f4360fbe7ee1a1a908b790c5f16119f3 | |
parent | [emacs] Make sure .py and .aurora files are marked as python. (diff) | |
download | emacs.d-67ed23729de89ffabff6047859f55e829f855224.tar.gz |
[emacs] Fix configuration for `flycheck'.
-rw-r--r-- | emacs.d/init.el | 80 |
1 files changed, 41 insertions, 39 deletions
diff --git a/emacs.d/init.el b/emacs.d/init.el index d8f462a..86eb179 100644 --- a/emacs.d/init.el +++ b/emacs.d/init.el @@ -83,47 +83,49 @@ (use-package flycheck :ensure t :config - (use-package flycheck-pos-tip - :config - (setq flycheck-display-errors-function #'flycheck-pos-tip-error-messages)) - - (defun check-source-predicate () - (and (executable-find "check.pex") - (buffer-file-name) - (string-match "src/source/.*\.py$" (buffer-file-name)))) - - (add-hook 'prog-mode-hook 'flycheck-mode) - (setq-default flycheck-disabled-checkers '(emacs-lisp-checkdoc)) - - (setq flycheck-mode-line - '(:eval - (pcase flycheck-last-status-change - (`not-checked nil) - (`no-checker (propertize " -" 'face 'warning)) - (`running "") - (`errored (propertize " ✘" 'face 'error)) - (`finished - (if flycheck-current-errors - (let* ((error-counts (flycheck-count-errors flycheck-current-errors)) - (no-errors (cdr (assq 'error error-counts))) - (no-warnings (cdr (assq 'warning error-counts))) - (flycheck-face (cond (no-errors 'error) - (no-warnings 'warning)))) - (propertize (format " [✗:%s/%s]" (or no-errors 0) (or no-warnings 0)) 'face flycheck-face)) - (propertize " [✓]" 'face 'success))) - (`interrupted " -") - (`suspicious '(propertize " ?" 'face 'warning))))) - - (flycheck-define-checker source-check - "A syntax checker for python source code in Source, using `check.pex'" - :command ("check.pex" source) + (progn + (use-package flycheck-pos-tip + :ensure t + :config + (setq flycheck-display-errors-function #'flycheck-pos-tip-error-messages)) + + (defun check-source-predicate () + (and (executable-find "check.pex") + (buffer-file-name) + (string-match "src/source/.*\.py$" (buffer-file-name)))) + + (add-hook 'prog-mode-hook 'flycheck-mode) + (setq-default flycheck-disabled-checkers '(emacs-lisp-checkdoc)) + + (setq flycheck-mode-line + '(:eval + (pcase flycheck-last-status-change + (`not-checked nil) + (`no-checker (propertize " -" 'face 'warning)) + (`running "") + (`errored (propertize " ✘" 'face 'error)) + (`finished + (if flycheck-current-errors + (let* ((error-counts (flycheck-count-errors flycheck-current-errors)) + (no-errors (cdr (assq 'error error-counts))) + (no-warnings (cdr (assq 'warning error-counts))) + (flycheck-face (cond (no-errors 'error) + (no-warnings 'warning)))) + (propertize (format " [✗:%s/%s]" (or no-errors 0) (or no-warnings 0)) 'face flycheck-face)) + (propertize " [✓]" 'face 'success))) + (`interrupted " -") + (`suspicious '(propertize " ?" 'face 'warning))))) + + (flycheck-define-checker source-check + "A syntax checker for python source code in Source, using `check.pex'" + :command ("check.pex" source) ;;; errors are reported like this: ;;; E241:ERROR <file name>:<line> <message> - :error-patterns ((error line-start (id (1+ nonl)) ":ERROR" (1+ nonl) ":" line (message) line-end) - (warning line-start (id (1+ nonl)) ":WARNING" (1+ nonl) ":" line (message) line-end)) - :predicate check-source-predicate - :modes (python-mode)) - (add-to-list 'flycheck-checkers 'source-check)) + :error-patterns ((error line-start (id (1+ nonl)) ":ERROR" (1+ nonl) ":" line (message) line-end) + (warning line-start (id (1+ nonl)) ":WARNING" (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 |