28 Mar 2004 rzyjontko   » (Apprentice)


I have just implemented properties mechanism. We need some examples to see how it works. Recently I posted few messages to mailing lists from wrong mail account, and they have been bounced. This is how property solves my issue:

    property address.email (to) {
        '@lists.sourceforge.net' => "my_addr@poczta.fm"
        ''                       => "my_addr@other.host"

What I wanted to say, is that my email address depends on who I am writing to. But how is it going to be used? Each time you start composing a new message elmo opens a template, and replaces properties (indicated by $) with their actual values. Let's take a look at default template:

    From: "$address.name" <$address.email>
    To: $to
    Subject: $subject

In the first example we defined a property address.name, which will be replaced by an actual value depending on property to.

Now let's go to something more complicated. Let's redefine a quote to be different for different groups of people. In polish we need a different quotation depending on people's sex, so I made something like this:

    property quote (action
      'reply' 'yes' 'no' 'F' => "%e napisała:"
      'reply' 'yes' 'no' 'M' => "%e napisał:"
      'reply'                => "%e wrote:"
      ''                     => ""

The quote property depends on 5 other properties. It depends on action, (which may be new, forward or reply), and some flags for author of the message we are replying. The magic happens in the resulting string, where I use %e. As you can expect: an actual value of mail.from.name property will be used. All %x tokens will be replaced by arguments values (%a is first, %b - second, and so on).

There is one more thing you could notice - a special token $=. You may place it, where you'd like to have a cursor placed in your editor. Elmo counts offset, line, and column of this token in resulting file, and you may use them in your editor variable, e.g.:

    set editor "emacsclient +%l %f"

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!