[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

13.5 Message splitting

You can use elmo-split to split message in folder specified by the variable elmo-split-folder a la procmail according to some specified rules. To use this feature, set as follows in your `~/.emacs' at first.

 
(autoload 'elmo-split "elmo-split" "Split messages on the folder." t)

Set source folder like following.

 
(setq elmo-split-folder "%inbox")

And specify the rule in the variable elmo-split-rule (its format will be is described below). Then you can invoke M-x elmo-split to split messages according to elmo-split-rule. On the other hand, invoke C-u M-x elmo-split to do a rehearsal and show result (do not split actually).

We will describe how to specify the rule. First of all, see following example, please.

 
(setq elmo-split-rule
      ;; Store messages from spammers into `+junk'
      '(((or (address-equal from "i.am@spammer")
	     (address-equal from "dull-work@dull-boy")
	     (address-equal from "death-march@software")
	     (address-equal from "ares@aon.at")
	     (address-equal from "get-money@richman"))
	 "+junk")
	;; Store messages from mule mailing list into `%mule'
	((equal x-ml-name "mule") "%mule")
	;; Store messages from wanderlust mailing list into `%wanderlust'
	;; and continue evaluating following rules
	((equal x-ml-name "wanderlust") "%wanderlust" continue)
	;; Store messages from Yahoo user into `+yahoo-{username}'
	((match from "\\(.*\\)@yahoo\\.com")
	 "+yahoo-\\1")
	;; Store unmatched mails into `+inbox'
	(t "+inbox")))

The basic unit of the rule is a combination like

 
(`CONDITION' `ACTION' [continue])

If `CONDITION' is true, `ACTION' is performed. The 1st element `CONDITION' is a condition represented by a balanced expression (sexp). Its grammar will be explained below. The 2nd element `ACTION' is the name of the folder to split messages into, or a symbol. When the 3rd element continue is specified as symbol, evaluating rules is not stopped even when the condition is satisfied.

The grammar for `CONDITION' is as follows. See example above to learn how to write the condition practically.

  1. Functions which accept arguments `FIELD-NAME' and `VALUE'. (`FIELD-NAME' is a symbol that describes the field name)

    equal
    True if the field value equals to `VALUE'. Case of the letters are ignored.
    match
    True if the field value matches to VALUE. `VALUE' can contain \& and \N which will substitute from matching \(\) patterns in the previous `VALUE'.
    address-equal
    True if one of the addresses in the field equals to `VALUE'. Case of the letters are ignored.
    address-match
    True if one of the addresses in the field matches to `VALUE'. `VALUE' can contain \& and \N which will substitute from matching \(\) patterns in the previous `VALUE'.

  2. Functions which accept an integer argument (`SIZE').

    <
    True if the size of the message is less than `SIZE'.
    >
    True if the size of the message is greater than `SIZE'.

  3. Functions which accept any number of arguments.

    or
    True if one of the argument returns true.
    and
    True if all of the arguments return true.

  4. A symbol.

    When a symbol is specified, it is evaluated.

You can specify followings as 2nd `ACTION'.

  1. folder name

    If some string is specified, it will be regarded as the destination folder, and the message will be appended to it.

  2. `delete'

    If the symbol `delete' is specified, delete the substance of the message in elmo-split-folder

  3. `noop'

    If the symbol `noop' is specified, do nothing on the message and keep it as it is.

  4. function

    If some function is specified, execute it.

If the message passes all rules, it will be dealed along `ACTION' specified by elmo-split-default-action.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Yuuichi Teranishi on February, 19 2005 using texi2html