Blogging with Emacs Org Mode
My blog is really in need of some love. One of the reasons I'm not posting very frequently (apart from just not having much to say or making time to say it) is that it is such a pain to write posts in WordPress' built in editor. I briefly considered editing in a text editor and then cut/pasting, but usually there's a mess to clean up anyway, so it's not much fun either.
I recently started looking for ways to blog offline in emacs and then publish posts up to WordPress. I won't say I was surprised to find more than one solution, but it was pleasant nonetheless… :)
The one I'm using to write this post with is a package called org2blog. It supports WordPress posts via it's XML RPC interface and can publish to as many different WordPress blogs as you like. This suits me because I also have an internal work blog at HP (they use WordPress MU, so it'll be interesting to find out how/if that works).
You can configure it fairly easily with some elisp. Here's mine:
;; Note - I installed org2blog with ELPA from Marmalade, so this
;; `require' declaration is probably just documentation
(require 'org2blog-autoloads)
(setq org2blog/wp-blog-alist
'(("sinewalker"
:url "http://sinewalker.wordpress.com/xmlrpc.php"
:username "sinewalker"
:default-categories ("hacking")
:tags-as-categories nil
:wp-code t)
("hp-hacks"
:url "http://blogs.hp.com/hphacks/xmlrpc.php"
:username "michael.lockhart@hp.com"
:track-posts "~/Documents/blogs/hp-hacks/posts.log")))
Note that the directive on line 12 is what causes the code above to be encased in Wordpress' sourcecode shortcut. In my org version of this post, the code is surrounded by "#+BEGIN_SRC emacs-lisp" and "#+END_SRC", which allows me to edit in emacs using emacs-lisp-mode, right inline of the rest of this post. Unfortunately the sourcecode shortcut in Wordpress doesn't understand emacs lisp, so there's no syntax highlighting.
There are still some things for me to figure out (such as how to mark code within the text of a paragraph, as above), but already this is looking a lot better.
This post was originally published at sinewalker.wordpress.com on 15 December 2011