Skip to content

Instantly share code, notes, and snippets.

@mkcode
Created May 13, 2016 15:34
Show Gist options
  • Save mkcode/d40dfe8fcd0e854b611055f63d276fd3 to your computer and use it in GitHub Desktop.
Save mkcode/d40dfe8fcd0e854b611055f63d276fd3 to your computer and use it in GitHub Desktop.
(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