[MlMt] Neet help for the query language in MailMate

Glenn Parker glenn.parker at comcast.net
Wed Oct 12 12:22:10 EDT 2022


On 10 Oct 2022, at 8:23, Mike Brasch wrote:

> I don't really understand what the above query does. I think I had 
> copied it from the mailing list here a long time ago. Is this a known 
> query language? Can I read about it somewhere? And how do I know what 
> the possible queryable attributes are?

There is some documentation buried in the builtin help under the 
“Hidden Preferences” section. If you search for “format string” 
in that section, under “Other”, and follow the link, you’ll get 
this (and only this):

     Format String Syntax

     ${«var»:?«if»:«else»}
     ${«var»:+«if»}
     ${«var»:-«else»}
     ${«var»:«else»}
     ${«var»/«regexp»/«format»/«options»}
     ${«var»:[/upcase][/downcase][/capitalize][/asciify]}

In case it’s not instantly obvious :), this syntax allows the 
construction of nested conditionals using regular expression matching on 
various elements of a message. AFAIK, this is proprietary to MailMate, 
except for the regular expressions (regexp) part. It looks like a 
typical yacc-style grammar to me, if that helps in any way.

The “var” will be one of the elements of a message that MailMate 
automatically parses. If you look at all the options you have for the 
first component of a Conditions rule for a folder (e.g. Date-Received, 
 From • Address, etc.), those are all accessible as $variables in a 
format string. You can access the complete element, e.g. “subject”, 
or some very particular sub-elements, e.g. “subject.blob”. In this 
case, ${subject.blob} captures just the little “[MlMt]” marker in 
the subject for this mailing list, which is a common feature of many 
mailing list systems.

Breaking down your original format string, I get this:

     — IF the subject.blob exists, e.g. “[MlMt]”
     ${subject.blob:?
         — Yield it capitalized
         ${subject.blob:/capitalize}:
         — ELSE IF the list-id.description exists
         ${list-id.description:?
             — …and it matches the regexp
             ${list-id.description/^[a-z]*\d.*/
                 — BEGIN FORMAT
                 — IF the from.name exists, yield it
                 ${from.name:
                     — ELSE IF the list-id.identifier.final-level 
exists
                     ${list-id.identifier.final-level:?
                         — Yield it capitalized
                         ${list-id.identifier.final-level:/capitalize}:
                         — ELSE yield from.address
                         ${from.address}
                      }
                  }
                 — END FORMAT
             /}: // no options for regexp match
             — ELSE (no list-id.description) IF from.name exists
             ${from.name:
                 — IF list-id.identifier.final-level exists
                 ${list-id.identifier.final-level:?
                     — Yield it capitalized
                     ${list-id.identifier.final-level:/capitalize}:
                     — ELSE yield from.address
                     ${from.address}
                 }
             }
         }
     }

Glenn P. Parker
glenn.parker at comcast.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freron.com/pipermail/mailmate/attachments/20221012/3607a5ec/attachment.htm>


More information about the mailmate mailing list