Created
May 13, 2016 15:34
-
-
Save mkcode/d40dfe8fcd0e854b611055f63d276fd3 to your computer and use it in GitHub Desktop.
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
(defvar-local prose-proselint-enabled nil | |
"Buffer local proselint enabled status") | |
(defun prose-proselint-enabled-p () | |
"Workaround for proselint flycheck checker predicate" | |
prose-proselint-enabled) | |
(flycheck-define-checker proselint | |
"A linter for prose." | |
:command ("proselint" source-inplace) | |
:error-patterns | |
((warning line-start (file-name) ":" line ":" column ": " | |
(id (one-or-more (not (any " ")))) | |
(message (one-or-more not-newline) | |
(zero-or-more "\n" (any " ") (one-or-more not-newline))) | |
line-end)) | |
:predicate prose-proselint-enabled-p) | |
;; :modes (text-mode markdown-mode gfm-mode)) | |
(add-to-list 'flycheck-checkers 'proselint) | |
(defun prose-reset-proselint-next-checkers () | |
"Adds the usual mode checkers as next checkers to the proselint checker" | |
;; Reset the proselint next-checkers prop to nil | |
(setf (flycheck-checker-get 'proselint 'next-checkers) nil) | |
;; Add the regular mode and predicate checkers for this buffer | |
(dolist (checker (flycheck-possibly-suitable-checkers)) | |
(unless (eq checker 'proselint) | |
(flycheck-add-next-checker 'proselint (cons t checker) t)))) | |
(add-hook 'flycheck-before-syntax-check-hook 'prose-reset-proselint-next-checkers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment