An Emacs Programming Challenge

In Converting S-Expressions To XML In Emacs, I showed how to take a log record expressed as Lisp and turn it into the equivalent XML. In More Fun With Log Files Stored As Lisp, I showed how to take that same log record and make it executable so that it transformed one of the fields when the record was executed.

Here is a challenge for Elisp programmers: take the record

  (date "2005-02-21T18:57:39")
  (millis 1109041059800)
  (sequence 1)
  (logger nil)
  (level 'SEVERE)
  (class "java.util.logging.LogManager$RootLogger")
  (method 'log)
  (thread 10)
  (emessage "A very very bad thing has happened!")
    (emessage "java.lang.Exception")
      (class "logtest")
      (method 'main)
      (line 30))))

and turn it into XML like this:

<emessage>A very very bad thing has happened!</emessage>

Do this by making the Lisp record executable so that it transforms itself into the XML when executed. Your XML doesn't have to be formatted exactly like mine and it's sufficient to have it print out in the echo area or the *Messages* buffer.

I'll give my solution in a few days so that you have time to work on it. If you get stuck, the wrap-up post has some techniques that may help.

This entry was posted in Programming and tagged , . Bookmark the permalink.