Index: lisp/ChangeLog =================================================================== RCS file: /usr/local/cvsroot/gnus/lisp/ChangeLog,v retrieving revision 7.554 diff -u -u -b -r7.554 ChangeLog --- lisp/ChangeLog 3 Dec 2004 15:58:17 -0000 7.554 +++ lisp/ChangeLog 5 Dec 2004 21:40:55 -0000 @@ -1,3 +1,9 @@ +2004-12-05 Nelson Ferreira + + * spam-stat.el (spam-stat-save): Load the hashtable from disk only + if there is no hashtable in memory or file modification time is + newer than cached timestamp. + 2004-12-03 Reiner Steib * gnus-sum.el (gnus-summary-limit-to-recipient): Implement Index: lisp/spam-stat.el =================================================================== RCS file: /usr/local/cvsroot/gnus/lisp/spam-stat.el,v retrieving revision 7.19 diff -u -u -b -r7.19 spam-stat.el --- lisp/spam-stat.el 2 Nov 2004 02:54:22 -0000 7.19 +++ lisp/spam-stat.el 5 Dec 2004 21:40:55 -0000 @@ -186,6 +186,9 @@ this filter, re-training spam-stat with several thousand messages will start to take a very long time.") +(defvar spam-stat-last-saved-at nil + "Time stamp of last change of spam-stat-file on this run") + (defvar spam-stat-syntax-table (let ((table (copy-syntax-table text-mode-syntax-table))) (modify-syntax-entry ?- "w" table) @@ -389,6 +392,7 @@ (interactive "P") (when (or force spam-stat-dirty) (let ((coding-system-for-write spam-stat-coding-system)) + (message "Saving %s..." spam-stat-file) (with-temp-file spam-stat-file (let ((standard-output (current-buffer)) (font-lock-maximum-size 0)) @@ -401,14 +405,25 @@ (spam-stat-bad entry)))) spam-stat) (insert ")))")))) - (setq spam-stat-dirty nil))) + (message "Saved %s." spam-stat-file) + (setq spam-stat-dirty nil + spam-stat-last-saved-at (nth 5 (file-attributes spam-stat-file))))) (defun spam-stat-load () "Read the `spam-stat' hash table from disk." ;; TODO: maybe we should warn the user if spam-stat-dirty is t? (let ((coding-system-for-read spam-stat-coding-system)) - (load-file spam-stat-file)) - (setq spam-stat-dirty nil)) + (cond (spam-stat-dirty (message "Spam stat not loaded: spam-stat-dirty t")) + ((or (not (boundp 'spam-stat-last-saved-at)) + (null spam-stat-last-saved-at) + (not (equal spam-stat-last-saved-at + (nth 5 (file-attributes spam-stat-file))))) + (progn + (load-file spam-stat-file) + (setq spam-stat-dirty nil + spam-stat-last-saved-at + (nth 5 (file-attributes spam-stat-file))))) + (t (message "Spam stat file not loaded: no change in disk.."))))) (defun spam-stat-to-hash-table (entries) "Turn list ENTRIES into a hash table and store as `spam-stat'.