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

6.5.1 Splitting in IMAP

Splitting is something Gnus users have loved and used for years, and now the rest of the world is catching up. Yeah, dream on, not many IMAP servers have server side splitting and those that have splitting seem to use some non-standard protocol. This means that IMAP support for Gnus has to do its own splitting.

And it does.

(Incidentally, people seem to have been dreaming on, and Sieve has gaining a market share and is supported by several IMAP servers. Fortunately, Gnus support it too, See section 2.19.5 Sieve Commands.)

Here are the variables of interest:

nnimap-split-crosspost

If non-nil, do crossposting if several split methods match the mail. If nil, the first match in nnimap-split-rule found will be used.

Nnmail equivalent: nnmail-crosspost.

nnimap-split-inbox

A string or a list of strings that gives the name(s) of IMAP mailboxes to split from. Defaults to nil, which means that splitting is disabled!

 
(setq nnimap-split-inbox
      '("INBOX" ("~/friend/Mail" . "lists/*") "lists.imap"))

No nnmail equivalent.

nnimap-split-rule

New mail found in nnimap-split-inbox will be split according to this variable.

This variable contains a list of lists, where the first element in the sublist gives the name of the IMAP mailbox to move articles matching the regexp in the second element in the sublist. Got that? Neither did I, we need examples.

 
(setq nnimap-split-rule
      '(("INBOX.nnimap"
         "^Sender: owner-nnimap@vic20.globalcom.se")
        ("INBOX.junk"    "^Subject:.*MAKE MONEY")
        ("INBOX.private" "")))

This will put all articles from the nnimap mailing list into mailbox INBOX.nnimap, all articles containing MAKE MONEY in the Subject: line into INBOX.junk and everything else in INBOX.private.

The first string may contain `\\1' forms, like the ones used by replace-match to insert sub-expressions from the matched text. For instance:

 
("INBOX.lists.\\1"     "^Sender: owner-\\([a-z-]+\\)@")

The first element can also be the symbol junk to indicate that matching messages should simply be deleted. Use with care.

The second element can also be a function. In that case, it will be called with the first element of the rule as the argument, in a buffer containing the headers of the article. It should return a non-nil value if it thinks that the mail belongs in that group.

Nnmail users might recollect that the last regexp had to be empty to match all articles (like in the example above). This is not required in nnimap. Articles not matching any of the regexps will not be moved out of your inbox. (This might affect performance if you keep lots of unread articles in your inbox, since the splitting code would go over them every time you fetch new mail.)

These rules are processed from the beginning of the alist toward the end. The first rule to make a match will "win", unless you have crossposting enabled. In that case, all matching rules will "win".

This variable can also have a function as its value, the function will be called with the headers narrowed and should return a group where it thinks the article should be split to. See nnimap-split-fancy.

The splitting code tries to create mailboxes if it needs to.

To allow for different split rules on different virtual servers, and even different split rules in different inboxes on the same server, the syntax of this variable have been extended along the lines of:

 
(setq nnimap-split-rule
      '(("my1server"    (".*" (("ding"    "ding@gnus.org")
                               ("junk"    "From:.*Simon"))))
        ("my2server"    ("INBOX" nnimap-split-fancy))
        ("my[34]server" (".*" (("private" "To:.*Simon")
                               ("junk"    my-junk-func))))))

The virtual server name is in fact a regexp, so that the same rules may apply to several servers. In the example, the servers my3server and my4server both use the same rules. Similarly, the inbox string is also a regexp. The actual splitting rules are as before, either a function, or a list with group/regexp or group/function elements.

Nnmail equivalent: nnmail-split-methods.

nnimap-split-predicate

Mail matching this predicate in nnimap-split-inbox will be split, it is a string and the default is `UNSEEN UNDELETED'.

This might be useful if you use another IMAP client to read mail in your inbox but would like Gnus to split all articles in the inbox regardless of readedness. Then you might change this to `UNDELETED'.

nnimap-split-fancy

It's possible to set nnimap-split-rule to nnmail-split-fancy if you want to use fancy splitting. See section 6.3.6 Fancy Mail Splitting.

However, to be able to have different fancy split rules for nnmail and nnimap back ends you can set nnimap-split-rule to nnimap-split-fancy and define the nnimap specific fancy split rule in nnimap-split-fancy.

Example:

 
(setq nnimap-split-rule 'nnimap-split-fancy
      nnimap-split-fancy ...)

Nnmail equivalent: nnmail-split-fancy.

nnimap-split-download-body

Set to non-nil to download entire articles during splitting. This is generally not required, and will slow things down considerably. You may need it if you want to use an advanced splitting function that analyzes the body to split the article.


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

This document was generated by on September, 5 2010 using texi2html