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:
- Languagetool desktop off app from https://languagetool.org/download/1.
- 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:
- Get the package, Emacs-langtool (also in MELPA).
- Follow the instructions to add the right lines to your .emacs config and relaunch Emacs.
- Highlight the text you want.
- Check the buffer for warnings:
- Then correct them with:
- Can also go to point to check:
- Clean highlights with
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.
I found 5 grammar/style mistakes In a recent post. Since I checked it with Emacs-langtool before I published it, I decided to check the Emacs package against the web version of langue tool and then check both of those against Grammarly.
It was clear right away that there’s virtually no difference between the web version and the Emacs extension. This is good, but the fact remains that langaugetool failed to pick up the 5 issues I found later. Grammarly managed to do a better job, and found 3 out of the 5 issues. It also suggested a correction I did not pick up.
Below are the original quotes with the issues, with my explanations below for each one3.
In the fediverse, all instances are connected, and since fosstodon.org quickly offered to adopt us, Mastodon-tech folks, I’m now on that instance along with my followees and followers, chatting about CASIO watches, as us nerds do.
No comma after “adopt us.” A comma there breaks the rhythm, and it puts emphasis on Mastodon-folks that it shouldn’t have. Grammarly didn’t pick up on that, which I didn’t expect it to since a comma there is still correct.
They did not copy Twitter directly. If they were, I doubt Mastodon would be as successful as it is today
“…if they did, I doubt…” If they were is wrong. In itself, the sentence holds, but if you read it in context, it sounds broken. Grammarly didn’t find this one, I guess because it takes one sentence at a time.
Thank you for allowing me and many other folks experience this.
To experience this. Grammarly found this mistake.
Some could argue that other common factors of federated services are technological superior.
Technologically superior. That’s an obvious mistake, Languagetool should have picked this one up. Grammarly found this mistake.
That might be true, but the point I’m making is improvement and changes to core functions of the app
To the core functions of the app. Another clear mistake that I feel languagetool should have found, but didn’t. Grammarly found this mistake.
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. ↩︎
I am obvioulsy not a grammar expert, if I need tools such as grammarly and langtools. I just know what “sounds right” and what doesn’t mostly from experience. Don’t consider me to be a grammar authority please, I’m far from it. ↩︎