From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/41327 Path: main.gmane.org!not-for-mail From: prj@po.cwru.edu (Paul Jarc) Newsgroups: gmane.emacs.gnus.general Subject: patch: automatic NOV regeneration for nnmaildir Date: Tue, 01 Jan 2002 05:23:00 -0500 Organization: What did you have in mind? A short, blunt, human pyramid? 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 1035176740 5541 80.91.224.250 (21 Oct 2002 05:05:40 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 21 Oct 2002 05:05:40 +0000 (UTC) Return-Path: Original-Received: (qmail 2757 invoked from network); 1 Jan 2002 10:23:45 -0000 Original-Received: from malifon.math.uh.edu (mail@129.7.128.13) by mastaler.com with SMTP; 1 Jan 2002 10:23:45 -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 16LM4l-0001Q7-00; Tue, 01 Jan 2002 04:23:19 -0600 Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Tue, 01 Jan 2002 04:23:10 -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 EAA15452 for ; Tue, 1 Jan 2002 04:22:59 -0600 (CST) Original-Received: (qmail 2747 invoked by alias); 1 Jan 2002 10:23:02 -0000 Original-Received: (qmail 2742 invoked from network); 1 Jan 2002 10:23:01 -0000 Original-Received: from multivac.student.cwru.edu (HELO multivac.cwru.edu) (qmail-remote@129.22.96.25) by gnus.org with SMTP; 1 Jan 2002 10:23:01 -0000 Original-Received: (qmail 3733 invoked by uid 500); 1 Jan 2002 10:23:22 -0000 Original-To: ding@gnus.org Mail-Copies-To: nobody Mail-Followup-To: ding@gnus.org Original-Lines: 12 User-Agent: Gnus/5.090005 (Oort Gnus v0.05) Emacs/20.7 (i386-redhat-linux-gnu) Precedence: list X-Majordomo: 1.94.jlt7 Xref: main.gmane.org gmane.emacs.gnus.general:41327 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:41327 --=-=-= This patch makes nnmaildir automatically regenerate NOV data when nnmail-extra-headers has changed. (It already automatically regenerates when the message has been edited, so I think that covers all regeneration needs.) * nnmaildir.el (nnmaildir--update-nov): automatically parse NOV data out of the message again if nnmail-extra-headers has changed. paul --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=nnmaildir.patch Index: lisp/nnmaildir.el =================================================================== RCS file: /usr/local/cvsroot/gnus/lisp/nnmaildir.el,v retrieving revision 6.4 diff -u -r6.4 nnmaildir.el --- lisp/nnmaildir.el 2001/12/26 17:12:23 6.4 +++ lisp/nnmaildir.el 2002/01/01 10:21:10 @@ -30,17 +30,15 @@ ;; ;; Some goals of nnmaildir: ;; * Everything Just Works, and correctly. E.g., stale NOV data is -;; ignored when articles have been edited; no need for -;; -generate-nov-databases. +;; ignored; no need for -generate-nov-databases. ;; * Perfect reliability: [C-g] will never corrupt its data in memory, ;; and SIGKILL will never corrupt its data in the filesystem. ;; * We make it easy to manipulate marks, etc., from outside Gnus. ;; * All information about a group is stored in the maildir, for easy -;; backup and restoring. +;; backup, copying, restoring, etc. ;; * We use the filesystem as a database. ;; ;; Todo: -;; * Ignore old NOV data when gnus-extra-headers has changed. ;; * Don't force article renumbering, so nnmaildir can be used with ;; the cache and agent. Alternatively, completely rewrite the Gnus ;; backend interface, which would have other advantages. @@ -136,7 +134,9 @@ ["subject\tfrom\tdate" "references\tchars\lines" "extra" - article-file-modtime]] + article-file-modtime + ;; The value of nnmail-extra-headers when this NOV data was parsed: + (to in-reply-to)]] (defmacro nnmaildir--srv-new () '(make-vector 11 nil)) (defmacro nnmaildir--srv-get-name (server) `(aref ,server 0)) @@ -213,15 +213,17 @@ (defmacro nnmaildir--art-set-msgid (article val) `(aset ,article 3 ,val)) (defmacro nnmaildir--art-set-nov (article val) `(aset ,article 4 ,val)) -(defmacro nnmaildir--nov-new () '(make-vector 4 nil)) +(defmacro nnmaildir--nov-new () '(make-vector 5 nil)) (defmacro nnmaildir--nov-get-beg (nov) `(aref ,nov 0)) (defmacro nnmaildir--nov-get-mid (nov) `(aref ,nov 1)) (defmacro nnmaildir--nov-get-end (nov) `(aref ,nov 2)) (defmacro nnmaildir--nov-get-mtime (nov) `(aref ,nov 3)) +(defmacro nnmaildir--nov-get-neh (nov) `(aref ,nov 4)) (defmacro nnmaildir--nov-set-beg (nov val) `(aset ,nov 0 ,val)) (defmacro nnmaildir--nov-set-mid (nov val) `(aset ,nov 1 ,val)) (defmacro nnmaildir--nov-set-end (nov val) `(aset ,nov 2 ,val)) (defmacro nnmaildir--nov-set-mtime (nov val) `(aset ,nov 3 ,val)) +(defmacro nnmaildir--nov-set-neh (nov val) `(aset ,nov 4 ,val)) (defmacro nnmaildir--srv-grp-dir (srv-dir gname) `(file-name-as-directory (concat ,srv-dir ,gname))) @@ -289,7 +291,8 @@ (defun nnmaildir--update-nov (srv-dir group article) (let ((nnheader-file-coding-system 'binary) dir gname pgname msgdir prefix suffix file attr mtime novdir novfile - nov msgid nov-beg nov-mid nov-end field pos extra val deactivate-mark) + nov msgid nov-beg nov-mid nov-end field pos extra val old-neh new-neh + deactivate-mark) (catch 'return (setq suffix (nnmaildir--art-get-suffix article)) (if (stringp suffix) nil @@ -315,17 +318,35 @@ novfile (concat novdir prefix)) (save-excursion (set-buffer (get-buffer-create " *nnmaildir nov*")) - (when (file-exists-p novfile) - (and nov - (equal mtime (nnmaildir--nov-get-mtime nov)) - (throw 'return nov)) - (erase-buffer) - (nnheader-insert-file-contents novfile) - (setq nov (read (current-buffer))) - (nnmaildir--art-set-msgid article (car nov)) - (setq nov (cadr nov)) - (and (equal mtime (nnmaildir--nov-get-mtime nov)) - (throw 'return nov))) + (when (file-exists-p novfile) ;; If not, force reparsing the message. + (if nov nil ;; It's already in memory. + ;; Else read the data from the NOV file. + (erase-buffer) + (nnheader-insert-file-contents novfile) + (setq nov (read (current-buffer))) + (nnmaildir--art-set-msgid article (car nov)) + (setq nov (cadr nov))) + ;; If the NOV's modtime matches the file's current modtime, + ;; and it has the right length (i.e., it wasn't produced by + ;; a too-much older version of nnmaildir), then we may use + ;; this NOV data rather than parsing the message file, + ;; unless nnmail-extra-headers has been augmented since this + ;; data was last parsed. + (when (and (equal mtime (nnmaildir--nov-get-mtime nov)) + (= (length nov) (length (nnmaildir--nov-new)))) + ;; This NOV data is potentially up-to-date. + (setq old-neh (nnmaildir--nov-get-neh nov) + new-neh nnmail-extra-headers) + (if (equal new-neh old-neh) (throw 'return nov)) ;; Common case. + ;; They're not equal, but maybe the new is a subset of the old... + (if (null new-neh) (throw 'return nov)) + (while new-neh + (if (memq (car new-neh) old-neh) + (progn + (setq new-neh (cdr new-neh)) + (if new-neh nil (throw 'return nov))) + (setq new-neh nil))))) + ;; Parse the NOV data out of the message. (erase-buffer) (nnheader-insert-file-contents file) (insert "\n") @@ -399,6 +420,7 @@ (nnmaildir--nov-set-mid nov nov-mid) (nnmaildir--nov-set-end nov nov-end) (nnmaildir--nov-set-mtime nov mtime) + (nnmaildir--nov-set-neh nov (copy-sequence nnmail-extra-headers)) (prin1 (list msgid nov) (current-buffer)) (setq file (concat novdir ":")) (nnmaildir--unlink file) --=-=-=--