proselint is a prose linter which returns error/warning messages like this:

2020-09-09-still-processing.md:18:14: typography.symbols.curly_quotes Use curly quotes “”, not straight quotes "".

I know there is a proselint checker in Flycheck, but I am trying to configure Flymake. For this task, I am using flymake-easy like this:

(defconst flymake-proselint-err-line-patterns
  '(("^\\(.*\.md\\):\\([0-9]+\\):\\([0-9]+\\): \\(.*\\)$" 1 2 3 4)))

(defvar flymake-proselint-executable "proselint"
  "The proselint executable to use for syntax checking.")

(defun flymake-proselint-command (filename)
  "Construct a command that flymake can use to check Markdown in FILENAME."
  (list flymake-proselint-executable filename))

(defun flymake-proselint-load ()
  "Configure flymake mode to check the current buffer's ruby syntax."
  (flymake-easy-load 'flymake-proselint-command

(defun flymake-proselint-maybe-load ()
  "Call `flymake-proselint-load' if this file appears to be Markdown."
  (if (and buffer-file-name
           (string= "md" (file-name-extension buffer-file-name)))

I added flymake-proselint-maybe-load to markdown-mode-hook but flymake-show-diagnostics-buffer shows an empty buffer instead of the above-mentioned message from proselint.

My guess is I am setting flymake-proselint-err-line-patterns, but I am not sure if this is the problem.


I took another approach, using flymake-quickdef, so as to leverage flymake-diagnostic-functions:

(require 'flymake-quickdef)
  :pre-let ((proselint-exec (executable-find "proselint")))
  :pre-check (unless proselint-exec (error "proselint not found on PATH"))
  :write-type 'pipe
  :proc-form (list proselint-exec "-")
  :search-regexp "^.+:\\([[:digit:]]+\\):\\([[:digit:]]+\\): \\(.+\\)$"
  (let* ((lnum (string-to-number (match-string 1)))
         (lcol (string-to-number (match-string 2)))
         (msg (match-string 3))
         (pos (flymake-diag-region fmqd-source lnum lcol))
         (beg (car pos))
         (end (cdr pos)))
    (list fmqd-source beg end :warning msg)))

(defun flymake-proselint-setup ()
  "Enable flymake backend."
  (add-hook 'flymake-diagnostic-functions #'flymake-proselint-backend nil t))

Then it's just a matter of adding flymake-proselint-setup to markdown-mode-hook:

(add-hook 'markdown-mode-hook #'flymake-proselint-setup)
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.