Grammar check in Emacs

For the longest time, I wanted to have grammar check inside Emacs. I finally figured out how to use Emacs-langtool. It’s pretty easy to set up; It’s just that finding basic instructions is hard to find.

Here’s the rundown:

Requirements:

  1. Languagetool desktop off app from https://languagetool.org/download/1.
  2. Langaugetool require java. To install: sudo apt install default-jre.

The standalone GUI tool: java -jar languagetool-commandline.jar, or for command line, java -jar languagetool-commandline.jar (use –help to see what’s available).

To use in Emacs:

  1. Get the package, Emacs-langtool (also in MELPA).
  2. Follow the instructions to add the right lines to your .emacs config and relaunch Emacs.

Then:

  1. Highlight the text you want.
  2. Check the buffer for warnings: M-x langtool-check.
  3. Then correct them with: M-x langtool-correct-buffer.
  4. Can also go to point to check: M-x langtool-show-message-at-point.
  5. Clean highlights with M-x langtool-check-done.

Languagetool work well enough, but the Emacs version is not as dynamic as the standalone tool or the website. You have to follow the sequence above each time to conducts checks.

For now, I find the langtool-check option to be enough. It highlights mistakes and then move the pointer over the highlights shows the errors the minibuffer below. There’s no option to save a personal dictionary to allow you to add words you know are not mistakes.

Overall, the quality of the corrections is somewhat less than Grammarly (especially if you pay for the premium version), which I’ve been using for years2.

But. I have grammar check in Emacs. I can now write emails and Reddit posts inside org-mode without copy-pasting into the Grammarly webpage. That’s the other thing: privacy. I am not logged into a user account. Grammarly defiantly collect a lot of information, which makes checking personal texts for grammar awkward. Langaugetool is a FOSS project that doesn’t (as far as I know) need ads. I also don’t have to deal with annoying captchas and logging in each time, copy paste text from and then back into Emacs, and get an email later from Grammarly that “someone” accessed my account.

I have a feeling this will become a go-to method for most of my writings. I will still use Grammarly for more polished and professional looking things. As I learn more how to utilize it, I will probably add macros and keyboard shortcuts with langaugetool to improve my workflow.

Comments?

Reply to this post on Mastodon, Twitter, or you can always email me: taonaw<at>protonmail<dot>ch (for GPG, click the lock icon on the navbar to the left).

Footnotes


  1. For some reason, the languagetool website does not list their desktop client. I’m not sure why. I found the download link in one of the “dummy” guides that helped me run it. ↩︎

  2. I’m aware there’s a emacs-grammarly package. Instructions, as usual, are the problem. I asked several times if anyone got this package to work, and even reached out to the creator via email, but so far no answers. It seems this package requires access to the API, which means a paid Grammarly account. ↩︎