A Partial Inegration of Grammarly in Emacs

1 minute read


The Problem

I wanted to integrate grammarly into my day to day emacs life, so I can check notes, emails and papers directly from emacs. Comes out, there is no easy way to do this: there are no available APIs that can be called to pass text and get corrections. I have googled a bit and there are a few partial solutions (one that is OSX only) and others very interesting work arounds that makes the process a bit easier.

My Solution

To brush up my elisp skills, that I do not use much since I can often copy and modify stuff I find on the web, I decided to implement a very simple and partial integration of grammarly.

Essentially, the function does two things:

  • Kills the region (as copy), so we can paste it into grammarly
  • Opens the grammarly webpage, so we can paste the text

It is quite simple, but it is effective. Let’s see the function.

(defun open-grammarly-with-kill ()
"A function to open a new grammarly document"
       (if mark-active (copy-region-as-kill (region-beginning) (region-end)) nil)
       (browse-url "https://app.grammarly.com/docs/new")))

We check if the mark is active. If it is, we copy the region, otherwise we do not do anything. Eventually, we open grammarly. If we had the marker active, we now can yank the text (not that I am doing this in EXWM).

You might want to set this as a keybinding, I am currently using C-c C-g to do this.

(global-set-key (kbd "C-c C-g") #'open-grammarly-with-kill)