Vivek Haldar

Editing Google Docs in Emacs

I recently submitted a few patches to T.V. Raman’s excellent g-client Emacs package (which is a sub-package of his emacspeak package) that allow me to edit Google Docs in Emacs.

You will need to get emacspeak from Google Code svn, synced at least to r6636.

Sign in with M-x gdocs-sign-in. It will prompt you for your Google email and password, authenticate you, and cache your authentication token.

Here are the important functions:

Publishing a new document

  • gdocs-publish-from-text Exports a buffer’s text to a new Google document.
  • gdocs-publish-from-html Exports a buffer containing HTML to a new Google document.
  • gdocs-publish-from-org Exports an org buffer as HTML to a new Google document.

Update an existing document: These functions prompt for which docid to update. The docid appears in the URL of the document. To save yourself entering the docid repeatedly, you can store it in a file variable called gdocs-docid.

Warning! These functions blindly update. If the document on the server has changes more recent than your buffer, they will be overwritten.

  • gdocs-update-from-text Exports a buffer’s text to an existing Google document.
  • gdocs-update-from-html Exports a buffer containing HTML to a new Google document.

Fetching an existing document: These also prompt for which docid to fetch. If you are in a buffer with a file variable called gdocs-docid defined, that will be used. The exported data goes into a buffer called *g scratch*.

  • gdocs-fetch-document-text Exports an existing Google document to plain text.
  • gdocs-fetch-document-html Exports an existing Google document to HTML.