From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/40781 Path: main.gmane.org!not-for-mail From: Nevin Kapur Newsgroups: gmane.emacs.gnus.general Subject: Re: [PATCH] Expiry based on headers Date: Sat, 08 Dec 2001 13:56:00 -0500 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 1035176278 2714 80.91.224.250 (21 Oct 2002 04:57:58 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 21 Oct 2002 04:57:58 +0000 (UTC) Return-Path: Original-Received: (qmail 2802 invoked from network); 8 Dec 2001 18:57:15 -0000 Original-Received: from malifon.math.uh.edu (mail@129.7.128.13) by mastaler.com with SMTP; 8 Dec 2001 18:57: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 16Cme3-00006C-00; Sat, 08 Dec 2001 12:56:19 -0600 Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Sat, 08 Dec 2001 12:56:06 -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 MAA20691 for ; Sat, 8 Dec 2001 12:55:54 -0600 (CST) Original-Received: (qmail 2767 invoked by alias); 8 Dec 2001 18:56:01 -0000 Original-Received: (qmail 2762 invoked from network); 8 Dec 2001 18:56:01 -0000 Original-Received: from fermat.mts.jhu.edu (128.220.17.18) by gnus.org with SMTP; 8 Dec 2001 18:56:01 -0000 Original-Received: (from nevin@localhost) by fermat.mts.jhu.edu (8.11.6/8.11.6) id fB8Iu0C18919; Sat, 8 Dec 2001 13:56:00 -0500 X-Authentication-Warning: fermat.mts.jhu.edu: nevin set sender to nevin@jhu.edu using -f Original-To: Ding X-Face: H~?ZI_L2!bGIrH^iC0e8t85[S`lwpP_/-sOvkGnN[\)[S";}xM3[Ib!ljz-80yK9SIf9sz6/DcY?yKUq1=-&XdrLjA^wK1 In-Reply-To: (Simon Josefsson's message of "Sat, 08 Dec 2001 18:11:10 +0100") Mail-Copies-To: never Original-Lines: 83 User-Agent: Gnus/5.090004 (Oort Gnus v0.04) XEmacs/21.4 (Civil Service, i686-pc-linux) Precedence: list X-Majordomo: 1.94.jlt7 Xref: main.gmane.org gmane.emacs.gnus.general:40781 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:40781 Simon Josefsson writes: > 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? Yep. >> +;; 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? I would. This was a first pass. I imagine there is a simple custom :type that would suffice in this case. I just don't know what it is. >> +(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. I agree that this is a kludge. But I've noticed that nndrafts groups behave strangely with expiry. If I understand you correctly, would setting expiry-target to nil for a group bypass expiry for that group? > >> + ;; 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. Good idea. >> + (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"? Agreed. >> + (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. All these suggestions enhance the functionality I propose. I will work on a revised patch and submit it. Thanks for your review. -- Nevin