From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/40780 Path: main.gmane.org!not-for-mail From: Simon Josefsson Newsgroups: gmane.emacs.gnus.general Subject: Re: [PATCH] Expiry based on headers Date: Sat, 08 Dec 2001 18:11:10 +0100 Sender: owner-ding@hpc.uh.edu Message-ID: References: NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1035176277 2705 80.91.224.250 (21 Oct 2002 04:57:57 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 21 Oct 2002 04:57:57 +0000 (UTC) Return-Path: Original-Received: (qmail 1183 invoked from network); 8 Dec 2001 17:12:58 -0000 Original-Received: from malifon.math.uh.edu (mail@129.7.128.13) by mastaler.com with SMTP; 8 Dec 2001 17:12:58 -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 16Cl1g-0008JI-00; Sat, 08 Dec 2001 11:12:36 -0600 Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Sat, 08 Dec 2001 11:12:23 -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 LAA20433 for ; Sat, 8 Dec 2001 11:12:12 -0600 (CST) Original-Received: (qmail 1177 invoked by alias); 8 Dec 2001 17:12:19 -0000 Original-Received: (qmail 1170 invoked from network); 8 Dec 2001 17:12:19 -0000 Original-Received: from dolk.extundo.com (195.42.214.242) by gnus.org with SMTP; 8 Dec 2001 17:12:19 -0000 Original-Received: from dhcp128.extundo.com (slipsten.extundo.com [195.42.214.241]) (authenticated bits=0) by dolk.extundo.com (8.12.1/8.12.1) with ESMTP id fB8HCOsX004711 for ; Sat, 8 Dec 2001 18:12:24 +0100 Original-To: Ding In-Reply-To: (Nevin Kapur's message of "Sat, 08 Dec 2001 11:42:44 -0500") Mail-Copies-To: nobody Original-Lines: 61 User-Agent: Gnus/5.090004 (Oort Gnus v0.04) Emacs/21.1 (i686-pc-linux-gnu) Precedence: list X-Majordomo: 1.94.jlt7 Xref: main.gmane.org gmane.emacs.gnus.general:40780 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:40780 Nevin Kapur writes: > Recently, I've seen a few requests for a function that will expire > articles based on their headers. I've been using such a function for > a while. I am proposing it for inclusion into Gnus. Looks useful. Have you signed papers? > +;; Need to make this a defcustom > +(defvar nnmail-fancy-expiry-targets nil > + "A list of (\"header\" \"regexp\" \"target\" \"date format\"). If > +`nnmail-expiry-target' is set to `nnmail-fancy-expiry-target' and the > +header matches the regexp, the message will be expired to the target > +group with the date in the specified format, appended. If no date > +format is specified the %Y is assumed. In the special cases that > +header is from, the regexp will match the from or to header. See > +the manual for examples.") > + Would you like to work on the custom :type? > +(defun nnmail-fancy-expiry-target (group) > + "Returns a target expiry group depending on the last match in nnmail-fancy-expiry-targets." > + (if (or (string= group "drafts") (string= group "queue")) > + 'delete Is this necessary? I happen to actually have a group named "queue" that isn't the same as the nndraft:queue one (which I assume is intended). If the user doesn't want expiry-target for drafts/queue groups, she should make sure the expiry-target is nil for those groups. > + ;; Note that last match will be returned. > + (dolist (regexp-target-pair nnmail-fancy-expiry-targets target) Maybe a (reverse ...) is good here? Splitting code in Gnus usually take the first match, I think. > + (setq header (car regexp-target-pair)) > + (cond > + ;; If the header is "from" or "to" match either field > + ((and (or (string-match header "from") (string-match header "to")) > + (or (string-match (cadr regexp-target-pair) from) > + (and (string-match message-dont-reply-to-names from) > + (string-match (cadr regexp-target-pair) to)))) Perhaps this logic could be used only when the regexp-target-pair is the symbol `to-from' instead of the strings "from" or "to"? > + (setq target (concat (caddr regexp-target-pair) > + "-" If you remove the "-" you can use something like: (setq nnmail-expiry-target 'nnmail-fancy-expiry-target nnmail-fancy-expiry-targets '(("subject" "IMPORTANT" "nnfolder:IMPORTANT" "") and have the resulting folder look like "nnfolder:IMPORTANT". Also, some people (like me) would want to use "." as a separator instead of "-" so making it part of the regexp-target-pair is probably easier.