Gnus development mailing list
 help / color / mirror / Atom feed
From: Simon Josefsson <jas@extundo.com>
Subject: Re: [PATCH] Expiry based on headers
Date: Sat, 08 Dec 2001 18:11:10 +0100	[thread overview]
Message-ID: <iluadwtwsb5.fsf@dhcp128.extundo.com> (raw)
In-Reply-To: <m3adwtislv.fsf@fermat.mts.jhu.edu> (Nevin Kapur's message of "Sat, 08 Dec 2001 11:42:44 -0500")

Nevin Kapur <nevin@jhu.edu> 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.




  reply	other threads:[~2001-12-08 17:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-12-08 16:42 Nevin Kapur
2001-12-08 17:11 ` Simon Josefsson [this message]
2001-12-08 18:56   ` Nevin Kapur
2001-12-08 21:01   ` [PATCH] Expiry based on headers (Take 2) Nevin Kapur
2001-12-08 22:20     ` Simon Josefsson
2001-12-08 23:35       ` Nevin Kapur
2001-12-09  0:33         ` Simon Josefsson
2001-12-08 23:53       ` Nevin Kapur

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=iluadwtwsb5.fsf@dhcp128.extundo.com \
    --to=jas@extundo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).