From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/54593 Path: main.gmane.org!not-for-mail From: Adrian Lanz Newsgroups: gmane.emacs.gnus.general Subject: new variable nnmail-fancy-expiry-target-with-arrival-time? Date: Fri, 31 Oct 2003 16:28:51 +0100 Sender: ding-owner@lists.math.uh.edu Message-ID: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1067614178 11813 80.91.224.253 (31 Oct 2003 15:29:38 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 31 Oct 2003 15:29:38 +0000 (UTC) Original-X-From: ding-owner+M3134@lists.math.uh.edu Fri Oct 31 16:29:36 2003 Return-path: Original-Received: from malifon.math.uh.edu ([129.7.128.13]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AFbDT-0002mK-00 for ; Fri, 31 Oct 2003 16:29:35 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by malifon.math.uh.edu with smtp (Exim 3.20 #1) id 1AFbD9-0006PN-00; Fri, 31 Oct 2003 09:29:15 -0600 Original-Received: from justine.libertine.org ([66.139.78.221]) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 1AFbCz-0006Oz-00 for ding@lists.math.uh.edu; Fri, 31 Oct 2003 09:29:05 -0600 Original-Received: from quimby.gnus.org (quimby.gnus.org [80.91.224.244]) by justine.libertine.org (Postfix) with ESMTP id 37A993A004C for ; Fri, 31 Oct 2003 09:29:05 -0600 (CST) Original-Received: from news by quimby.gnus.org with local (Exim 3.35 #1 (Debian)) id 1AFbCy-0000ju-00 for ; Fri, 31 Oct 2003 16:29:04 +0100 Original-To: ding@gnus.org Original-Path: not-for-mail Original-Newsgroups: gnus.ding Original-Lines: 121 Original-NNTP-Posting-Host: 193.134.205.252 Original-X-Trace: quimby.gnus.org 1067614144 2845 193.134.205.252 (31 Oct 2003 15:29:04 GMT) Original-X-Complaints-To: usenet@quimby.gnus.org Original-NNTP-Posting-Date: Fri, 31 Oct 2003 15:29:04 +0000 (UTC) User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (usg-unix-v) Cancel-Lock: sha1:SBnQup1A4EWIDBhn3tdE0X2X4EE= Precedence: bulk Xref: main.gmane.org gmane.emacs.gnus.general:54593 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:54593 Here a propsal for a small addition to the expiry rules applied with nnmail-fancy-expiry-target: The idea is to allow fancy splitting articles into expiry groups not parsing the Date field but the X-Gnus-Article-Number field for a valid time/date. This functionality only applies when expiring articles kept in the nnfolder mail back end (and does nothing [harmful] for other mail back ends). One (my) reason to add this new functionality, was that I get sometimes messages with illegal (for instance "internationization" of month an day names) or (actually quite often) wrong Date fields (a date/time entry somewhere in the future or in the past or simply a missing date/time entry), especially in spam messages. These messages either block the summary-exit process with an error message (see the FIXME comments in the below function) or create stupid/unwanted/wrong archive (expiry) group names, if I use a TARGET like "mail-%Y-%b" for storing (archiving) mail messages by year-month. I propose a simple boolean type variable nnmail-fancy-expiry-target-with-arrival-time defined in nnmail.el (feel free to find a better name!), which is documented below, and a minor change in the nnmail-fancy-expiry-target function (it is only a change in the definition of the local variable date, and a comment concerning the missing fix for invalid Date header entry). If the functionality is considered to be useful for more people, it would be nice to see it implemented in the CVS version for testing, Adrian. PS: Not very programers like, here the proposed changes (please correct wording...): +++ Changes in the documentation (texinfo) +++ Under "Expiring Mail" and just after the nnmail-fancy-expiry-targets example: [...] With this setup, any mail that has `IMPORTANT' in its Subject header and was sent in the year `YYYY' and month `MMM', will get expired to the group `nnfolder:IMPORTANT.YYYY.MMM'. If its From or To header contains the string `boss', it will get expired to `nnfolder:Work'. All other mail will get expired to `nnfolder:Archive-YYYY'. ++ BEGIN NEW ++ If you expire articles from a nnfolder back end, you can set `nnmail-fancy-expiry-target-with-arrival-time' to t (default is nil). Then, year and month in the above example would be read from the articles' nnfolder inserted X-Gnus-Article-Number header field instead of the articles' original Date field, and articles will get expired in chronological year-month groups using the (always correct, well at least valid) articles' date and time of arrival in your nnfolder group rather than the (sometimes wrong and/or invalid) articles' date of sending. Invalid and/or simply wrong time/date values in the original Date field are particularly known for spam mail. ++ END NEW ++ If `nnmail-keep-last-article' is non-`nil', Gnus will never expire the final article in a mail newsgroup. This is to make life easier for procmail users. [...] +++ Changes in nnmail.el +++ ++ new variable ++ (defcustom nnmail-fancy-expiry-target-with-arrival-time nil "`nnmail-fancy-expiry-target' determines the expiry group of an article by invoking `format-time-string' on the target given in variable `nnmail-fancy-expiry-targets'. Now, if this variable is t (default is nil) and the articles' X-Gnus-Article-Number header field exist, `format-time-string' extracts date/time from the articles' X-Gnus-Article-Number header field (if missing the current date/time is used). The X-Gnus-Article-Number header field is automatically inserted by the nnfolder mail back end. It includes a date/time string indicating arrival of the article in the current nnfolder group. This variable has no effect under other mail back ends. If this variable is not t, `format-time-string' extracts the date/time from the articles' Date header field (if missing the current date/time is used). If you set this variable to t and use format strings in `nnmail-fancy-expiry-targets', `nnmail-fancy-expiry-target' expires articles into expiry groups named chronologically by the articles' date/time of arrival in the nnfolder groups. This variable is particularly useful, if you expire articles with invalid, wrong or missing Date header fields (mainly spam)." :group 'nnmail-expire :type 'boolean) ++ changed function ++ (defun nnmail-fancy-expiry-target (group) "Returns a target expiry group determined by `nnmail-fancy-expiry-targets'." (let* (header (case-fold-search nil) (from (or (message-fetch-field "from") "")) (to (or (message-fetch-field "to") "")) (date (date-to-time (if nnmail-fancy-expiry-target-with-arrival-time (or (message-fetch-field "x-gnus-article-number") (current-time-string)) (or (message-fetch-field "date") (current-time-string))))) (target 'delete)) (dolist (regexp-target-pair (reverse nnmail-fancy-expiry-targets) target) (setq header (car regexp-target-pair)) (cond ;; If the header is to-from then match against the ;; To or From header ((and (equal header 'to-from) (or (string-match (cadr regexp-target-pair) from) (and (string-match message-dont-reply-to-names from) (string-match (cadr regexp-target-pair) to)))) ;;; fixme: below, format-time-string returns an error for illegal ;;; fixme: date strings like, e.g. Mit 12 Mai 2003 12:34:23 ;;; fixme: We would like to return a proper error message ;;; fixme: or apply the current date/time if an illegal date? (setq target (format-time-string (caddr regexp-target-pair) date))) ((and (not (equal header 'to-from)) (string-match (cadr regexp-target-pair) (or (message-fetch-field header) ""))) (setq target (format-time-string (caddr regexp-target-pair) date)))))))