Blogging from Emacs
October 20, 2008
After switching to WordPress, I can now post entries from Emacs, thanks to weblogger.el.
Note that there seems to be several “weblogger mode” packages for Emacs. Follow the link above to see how I got it working.
weblogger.el had a few problems, most of which were fixed by ciju. Thanks for that! However, it did require a few additional hacks to get it working in the way I wanted to.
Below is the diff between ciju’s version and mine.
2a3,6 > ;; NOTE: Modified by ciju as described here: > ;; http://ciju.wordpress.com/2008/06/06/twiddling-with-webloggerel-emacs-wordpress/ > ;; Also, further hacking by Chopmo > 584c588,589 ; (list "Subject" title) ; fixed by chopmo > (list "Subject" (or title"\n")) 938,939c943,945 < (if (buffer-modified-p) ;; modified by ciju, disabled by chopmo > ;; (if (buffer-modified-p) > ;; (weblogger-prepare-and-send nil nil)) ;; ciju's modification
You can also download the patched weblogger.el here.
The diff above tweaks the weblogger feature in two ways:
- Fixes a small bug which caused the newline after “Subject:” to be missing when starting a new entry.
- Reverts a change made by ciju which caused the current entry to be saved as a draft when navigating to the next (with C-c C-n) or the previous (with C-c C-p) entry.
The second change means that published entries stay published and that navigation between entries is very fast, but also that you need to actively save a modified entry before leaving it. This is done with C-c C-s to save it as published or C-c C-c to save it as draft.
Both commands simply overwrite the previous published/draft state of the entry, so there’s not explicit “publish” step. You just save the entry as published. Also, both commands can be used for initially saving the entry.
Another small tip: Note that after initially saving an entry, the URL to the entry is displayed in the header:
As long as you’re logged into your WordPress account, you can use this URL to see a preview of the entry as you work on it. The preview is updated as soon as you save the entry in Emacs.