14 August 2009

Publishing to Blogger with... Emacs!

Here is how I write blog entries using Emacs, and publish them to Blogger:

I write raw entries using the amazing Org-Mode for Emacs. I'll not take you to Org Mode kindergarten; there are dozens of good summaries and introductions out there. I keep an outline of blog entries - ideas, notes and in-progress drafts - and work on the just as I would any other project.

The Org export function can generate beautiful HTML – for example I can preformat code examples using font-lock-mode with simple tags. My .emacs defines a simple wrapper around org-export-as-html which only exports the body code without the header and footer:

(defun bloggerPublish()
"Render the region as HTML for publishing."
(interactive)
(org-export-as-html 0 nil nil nil t nil))

I highlight (using transient-mark-mode) the "body" of the post, invoke that function, and paste the result into a new Blogger post. Fill in the title, add some keywords, and I'm done. Blogger takes care of the CSS and if I cared about presentation enough I could modify the element classes that Org spits out.

Since I basically live in Emacs, I can get a heck of a lot more writing done by just tearing open a Remember template to jot down the idea for a post, intermingle my drafts/notes/etc. with the rest of my Real Work, and basically draft a post as quickly as an email or project notes or whatever.

Here's a public thanks to Carsten for such an awesome package!

No comments:

Followers