As a learning exercise, I wrote Erblog (the software this site runs on) in Erlang as a Mochiweb app (one lesson I learned: CSS is annoying). This means I can make RPC's to the server from a remote Erlang node. Using Distel, this remote Erlang node can be an instance of Emacs. This is my setup.
Blog posts are written as a sequence of Elisp functions that output the Distel equivalent of Mochiweb HTML tokens (scroll down to end to see the source code for this post). For example,
(defpara "This is a paragraph.")returns
[p () ("This is a paragraph.")] which is the Distel form of the Erlang tuple {p, [], ["This is a pragraph."]} (in Distel, Erlang tuples map to Elisp vectors since Emacs
doesn't have a built-in tuple type. Lists, of course, map to
lists). In turn, Mochiweb on the server turns this into <p>This
is a paragraph.</p>.There are three major advantages to this:
Once I am ready to post, I hit C-c C-b p (that's Ctrl-c-b p). I've bound this keycombo to an Elisp function that takes my blog post in its Elisp form, wraps it in a list (preserving the sequence of calls), then evaluates each element of this list. The resultant list is then passed to an RPC that publishes it on the server.
All of Erblog's code is on Github. It is in an early stage of development, thus quite dumb and elementary (not to mention disjoint); this is either a testament to the skills of the authors of Erlang, Mochiweb, and Distel in hiding complex implementations under straightforward API's, or I could just be doing something wrong. Or both.
Besides adding features, clarity, error checking, and documentation (hah) to the code, here are some questions for the future:
You can find the source code for this post here.