1

I have been writing lots of text in Org-mode and would like to lint the text before exporting it. I have flycheck and proselint installed. Is it possible to get proselint to run in org-mode? I tried using M-x flycheck-select-checker and then proselint I get the error:

`org-mode' not supported

I suppose proselint only supports markdown or txt files. I am a beginner with writing my own functions in elisp. Is there a way I can get proselint running inside org-mode?

1

See http://unconj.ca/blog/linting-prose-in-emacs.html.

It looks like code like this may turn it on for org-mode:

(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) line-end))
  :modes (text-mode markdown-mode gfm-mode org-mode))
  • I had come across this blog post before posting my question. I think the current flycheck version already has the functionality present in this code snippet. i.e. Defining poselint. Anyway, adding this code snippet to my .emacs files gives the error: Lisp error: (void-variable org-mode) – Thejeswi Preetham Mar 30 '18 at 17:48
1

This function defines the proselint parser in the current flycheck.el:

(flycheck-define-checker proselint
  "Flycheck checker using Proselint.

See URL `http://proselint.com/'."
  :command ("proselint" "--json" "-")
  :standard-input t
  :error-parser flycheck-proselint-parse-errors
  :modes (text-mode markdown-mode gfm-mode message-mode))

Add org-mode to the modes list and evaluate the modified function. This seems to work at least for some simple org-mode files that I tested.

  • I get -Lisp error: (void-variable org-mode) Do I have to define a variable named org-mode? If so, how do I do that? – Thejeswi Preetham Mar 30 '18 at 17:45
  • Answers to questions that do not specify versions generally assume that you are using the latest version of the software. Are you running at least emacs version 25 and org version 9? To have symbol org-mode defined, you need to run (require 'org) first. – Heikki Mar 31 '18 at 5:27
0

An alternative to re-defining the proselint checker as proposed in Heikki's answer is modifying it:

(require 'flycheck) ;; for (flycheck-define-checker proselint ...)
(cl-pushnew 'org-mode (get 'proselint 'flycheck-modes))

That works because flycheck-define-checker does with the :modes argument not much more than (setf (get symbol 'flycheck-modes) modes) (see relevant section in the definition of flycheck-define-generic-checker ).

It has the advantage that improvements to the proselint checker that do not introduce new actions on the :modes argument are not effected by this modification.

It has the disadvantage that if they introduce actions on the :modes argument then those actions are not performed on the newly added modes.

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.