Posting to Movable Type from XEmacs

This documentation is obsolete. I've since switched to using all of my own software to generate journal pages and RSS feeds. It's kept only for historical interest.

I had a journal (blog, whatever) using Movable Type. Movable Type is nice and pretty, but I'm not a huge fan of entering text into browser forms rather than using a good editor. (Someday, I should figure out how to do that with a wiki as well....)

So since I used XEmacs for basically everything, I looked around for something that would let me just write journal entries inside it without ever having to go to the web interface. Otherwise, I was pretty sure I'd never actually write things, or at least wouldn't as frequently as I wanted to. Here's what I found out.

This will probably also work with Emacs, but I've not personally tried it. It should work with any journal or blog software that implements the Movable Type XML-RPC interface.

Elisp packages

To start, download the following elisp files:

Stick these somewhere in your XEmacs load path (and byte-compile them if you like doing that for everything like I do).

If you're not familiar with XEmacs load paths, the basic idea is that you add something like:

    (setq load-path (cons (expand-file-name "~/lisp") load-path))

to your .emacs file or the equivalent thereof, and then you drop all these extra elisp packages that you want to install into that directory (in the above example, ~/lisp).

Configure the packages

Now, you have to teach mt.el about your particular journal. Here's the text of a file that I named rra-mt.el:

    require 'custom)


     ;; Parameters for my basic journal on
     '(weblog-id "1")
     '(weblog-username "eagle")
     '(weblog-password "XXXX")
     '(weblog-url "")

     ;; Where to save local copies of entries.
     '(weblog-local-save-dir "~/data/journal")

     ;; Prompt for categories on new posts.
     '(weblog-auto-categories t))

Obviously, you need to customize this. The first parameter is the weblog-id; to figure this out in Movable Type, go to the main menu for your blog in the Movable Type interface. You should see some sort of string like mt.cgi?__mode=menu&blog_id=1 in the URL; the bit after blog_id= is your weblog-id. Username and password are self-explanatory. The URL needs to point to the mt-xmlrpc CGI script from Movable Type (yours probably ends in .cgi).

weblog-local-save-dir is where the code should stash some information; it's just an empty directory wherever you want to put such an empty directory. Finally, weblog-auto-categories is just a personal preference on my part. Read the beginning of mt.el for more details about customization and options.

Tying this into XEmacs

I then add the following to my .emacs equivalent:

    ;; Start a new weblog post.  There isn't a good hook in mt.el to load my
    ;; configuration file, so we do it the annoying, hard way.
    (defun rra-weblog-create-post ()
      "Create a new weblog post using weblog-create-post, but loading
    preferences first."
      (load "rra-mt")

    (global-set-key "\C-cw" 'rra-weblog-create-post)

Now I can just hit Ctrl-C w any time that I want to make a journal entry and get an editing window. Note that mt.el will do basic HTML formatting for you, so you want to go into your journal configuration and turn off any formatting of journal entries (otherwise they'll get formatted twice). Also, if you tell it to do the category thing like I do, note that the way to set a category is to move the cursor to the apporpriate line and then press p (this is rather underdocumented).


This interface isn't perfect and does have some problems. The main ones are that it's very mindless about HTML formatting; you still have to do all the regular HTML stuff like escape angle brackets and add explicit link markup and explicit line breaks if needed. It's not as nice as a wiki. And if I do anything like using <blockquote> or lists, I have to go in via the web interface and fix up the HTML after the fact because it puts <p> tags all over the place.

The other problem that I've encountered, which may be fixed in newer versions of Movable Type than 2.63, are that entries posted this way don't trigger entry notification and categories set after the post is made (the way that mt.el does it) don't trigger a front-page rebuild and therefore you can't have the category show up on the front page.

I'm guessing these are fixable problems either in the Movable Type code or in mt.el as appropriate, but I've not had a chance to look at them in detail.

Last spun 2022-02-06 from thread modified 2018-01-08