So mew has special variable call mew-refile-guess-alist which lets you control how ‘refiling’ works.. i.e. how to guess the target folder of the ‘refile’ operation.
Mew seems to, in general, offer a different way to read mail that comes from many lists… it works better if you have them all come to your inbox, read them there, and then use the refile intelligence to sort them out to folders after the fact. They’re like filters except that you run them after you read the mail.
The way you specify a rule for refiling looks like this:

(setq mew-refile-guess-alist
      '(  ("Sender:"
           ("some_address@some_domain.com" . "%some/folder)))

Unfortunately, at VMware, our mailing list setup does some funny things:

  • If an e-mail is sent to a list, but your address is also in the To: or Cc: fields, then the mail comes directly to you.
  • If an e-mail is sent to a list, but your address is not included in To: or Cc:, then the email comes to you but the Sender: field contains information about the group.

Given this situation, for each mailing list, I have to add three entries like the one above, one for each of the fields. So instead of doing this for every list I’m subscribed to, instead I wrote a function:

(defun mymew-add-vmware-list-rules (liststring)
  "Add rules to filter lists Identified by liststring to mew-refile-guest-alist"
  (setq mew-refile-guess-alist
        (cons (list "To:"
               (cons (concat liststring "@vmware.com")
                     (list (cons t
                                 (concat "%lists/" liststring)))))
              mew-refile-guess-alist))
  (setq mew-refile-guess-alist
        (cons (list "Cc:"
               (cons (concat liststring "@vmware.com")
                     (list (cons t
                                 (concat "%lists/" liststring)))))
              mew-refile-guess-alist))
  (setq mew-refile-guess-alist
        (cons (list "Sender:"
               (cons (concat liststring "-bounces@vmware.com")
                     (list (cons t
                                 (concat "%lists/" liststring)))))
              mew-refile-guess-alist))
  (message (concat "Added rules for list: " liststring))
)

This function takes a single argument, the email alias that identifies the list, and adds three entries to mew-refile-guess-alist, one for each type of filter. The embedded (cons t foo) is a way to tell mew that if something matches, the specified folder should be added to a list of suggested folders, allowing several rules to match simultaneously. This allows, for example, an email that was sent to two lists to get filed such that a copy ends up in each of the folders for each list.
I’m sure there’s tons of better, more concise ways to write this, but hey, it’s a start.
Argh. On an unrelated note, WordPress screws up double quotes (“) in pre regions. You have to say " instead. Lame.

Leave a comment

Your email address will not be published. Required fields are marked *