From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/39859 Path: main.gmane.org!not-for-mail From: Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai =?iso-8859-1?q?Gro=DFjohann?=) Newsgroups: gmane.emacs.gnus.general Subject: per-message automatic splitting (with Sieve) Date: Fri, 02 Nov 2001 17:32:16 +0100 Sender: owner-ding@hpc.uh.edu Message-ID: NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: main.gmane.org 1035175502 30211 80.91.224.250 (21 Oct 2002 04:45:02 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 21 Oct 2002 04:45:02 +0000 (UTC) Return-Path: Original-Received: (qmail 7487 invoked from network); 2 Nov 2001 16:35:15 -0000 Original-Received: from malifon.math.uh.edu (mail@129.7.128.13) by mastaler.com with SMTP; 2 Nov 2001 16:35:15 -0000 Original-Received: from sina.hpc.uh.edu ([129.7.128.10] ident=lists) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 15zhFo-0004r9-00; Fri, 02 Nov 2001 10:33:12 -0600 Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Fri, 02 Nov 2001 10:32:53 -0600 (CST) Original-Received: from sclp3.sclp.com (qmailr@sclp3.sclp.com [209.196.61.66]) by sina.hpc.uh.edu (8.9.3/8.9.3) with SMTP id KAA26856 for ; Fri, 2 Nov 2001 10:32:40 -0600 (CST) Original-Received: (qmail 7455 invoked by alias); 2 Nov 2001 16:32:49 -0000 Original-Received: (qmail 7450 invoked from network); 2 Nov 2001 16:32:48 -0000 Original-Received: from waldorf.cs.uni-dortmund.de (129.217.4.42) by gnus.org with SMTP; 2 Nov 2001 16:32:48 -0000 Original-Received: from lothlorien.cs.uni-dortmund.de (lothlorien [129.217.19.67]) by waldorf.cs.uni-dortmund.de with ESMTP id fA2GWMk00358 for ; Fri, 2 Nov 2001 17:32:22 +0100 (MET) Original-Received: from lucy.cs.uni-dortmund.de (lucy [129.217.19.80]) by lothlorien.cs.uni-dortmund.de id RAA27639; Fri, 2 Nov 2001 17:32:17 +0100 (MET) Original-Received: by lucy.cs.uni-dortmund.de (Postfix, from userid 6104) id AECB0201A; Fri, 2 Nov 2001 17:32:16 +0100 (CET) Original-To: ding@gnus.org User-Agent: Gnus/5.090004 (Oort Gnus v0.04) Emacs/21.1.50 (i686-pc-linux-gnu) Precedence: list X-Majordomo: 1.94.jlt7 Original-Lines: 79 Xref: main.gmane.org gmane.emacs.gnus.general:39859 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:39859 --=-=-= I wonder if anybody is interested in the following which I've cooked up for better use of nnimap with Sieve splitting on the Cyrus server. You know, I used to be a great fan of nnmail-split-fancy-with-parent which split a followup into the same group as the original. I wanted to have this for Sieve splitting, too, but there it is not so simple. So I came up with the following method: I create custom Message-ID headers which contain the right group name, and I do some Sieve rules which grok this special Message-ID format. Here's the code which creates my Message-ID headers: --=-=-= Content-Type: application/emacs-lisp Content-Disposition: inline Content-Transfer-Encoding: 8bit ;; Insert token into message id (defadvice message-make-fqdn (around group-token activate) "Insert a token for the current group into the message id." (let ((fqdn ad-do-it) (gcc (save-restriction (message-narrow-to-headers-or-head) (message-fetch-field "gcc")))) (cond ((and gcc (string-match "^nnimap:\\(.*\\)$" gcc)) (setq ad-return-value (concat (match-string 1 gcc) ".tok." fqdn))) ((and gnus-newsgroup-name (string-match "^nnimap:\\(.*\\)$" gnus-newsgroup-name)) (setq ad-return-value (concat (match-string 1 gnus-newsgroup-name) ".tok." fqdn))) (t (setq ad-return-value fqdn))))) --=-=-= Content-Disposition: inline So this means that a Gcc field triggers the `right' token in the message id, and if there is no Gcc field, Gnus looks at the current group name. It might be useful to look at the To/Cc headers, too. --=-=-= Content-Type: application/emacs-lisp Content-Disposition: inline (defun kai-sieve-write-token-rules () "Write token rules into the current buffer." (interactive) (let ((boxes (save-excursion (set-buffer nnimap-server-buffer) (remove "INBOX" (imap-mailbox-list "*"))))) (goto-char (point-min)) (re-search-forward "^#-begin token\n") (delete-region (point) (re-search-forward "^#-end token\n")) (mapcar (lambda (g) (insert "if header :contains \"references\" " "\"@" g ".tok.\" {\n" " fileinto \"" g "\";\n" " stop;\n" "}\n\n")) (sort boxes 'string<)) (insert "if header :matches \"references\" \"@INBOX.tok.\" {\n" " fileinto \"INBOX\";\n" " stop;\n" "}\n\n") (insert "if header :matches \"references\" \"@*.tok.\" {\n" " fileinto \"INBOX.token\";\n" " stop;\n" "}\n\n" "#-end token\n"))) --=-=-= Content-Disposition: inline This piece of code takes a Sieve script and inserts rules which split incoming messages based on the tokens in the Message-ID. Hm. I wonder, I should probably have used plus addressing, instead, but our mail server does not grok plus addressing. Argh :-( Is anybody else doing something similar? What do you do? kai -- Lisp is kinda like tpircstsoP --=-=-=--