www.delorie.com/gnu/docs/emacs/gnus_187.html   search  
Buy the book!

Gnus Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ] 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.

Here are the variables of interest:


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.


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.


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
         "^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.spam and everything else in INBOX.private.

The first string may contain `\\digit' 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 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 to where it thinks the article should be split. See nnimap-split-fancy.

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

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 has 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.


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'.


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.


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

Nnmail equivalent: nnmail-split-fancy.

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

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003