+2003-10-31 Teodor Zlatanov <tzz@beld.net>
+
+ * spam.el (autoload): autoload the gnus-registry functions we'll
+ need
+ (spam-log-to-registry): new variable for interfacing with the
+ gnus-registry
+ (spam-install-hooks): variable had the wrong customization group
+ (spam-fetch-field-message-id-fast): convenience function for fetch
+ a message ID quickly
+ (spam-log-processing-to-registry): new function
+ (spam-ifile-register-spam-routine)
+ (spam-ifile-register-ham-routine, spam-stat-register-spam-routine)
+ (spam-stat-register-ham-routine)
+ (spam-blacklist-register-routine)
+ (spam-whitelist-register-routine)
+ (spam-bogofilter-register-spam-routine)
+ (spam-bogofilter-register-ham-routine)
+ (spam-spamoracle-learn-ham, spam-spamoracle-learn-spam): add
+ spam-log-processing-to-registry invocations
+
+ * gnus-registry.el: fixed docs in the preface to mention
+ gnus-registry-initialize
+ (gnus-registry-store-extra): remove cached extra entry
+ information when new extra entry is stored
+
2003-10-29 Simon Josefsson <jas@extundo.com>
* message.el (message-forward-make-body-plain): Fix ARG=1 mode
;; Put this in your startup file (~/.gnus.el for instance)
-;; (setq gnus-registry-install t
-;; gnus-registry-max-entries 2500
-;; gnus-registry-use-long-group-names t)
+;; (setq gnus-registry-max-entries 2500
+;; gnus-registry-use-long-group-names t)
-;; (require 'gnus-registry)
+;; (gnus-registry-initialize)
;; Then use this in your fancy-split:
(when (gnus-registry-group-count id)
;; we now know the trail has at least 1 group name, so it's not empty
(let ((trail (gethash id gnus-registry-hashtb))
- (old-extra (gnus-registry-fetch-extra id)))
+ (old-extra (gnus-registry-fetch-extra id))
+ entry-cache)
+ (dolist (crumb trail)
+ (unless (stringp crumb)
+ (dolist (entry crumb)
+ (setq entry-cache (gethash (car entry) gnus-registry-hashtb))
+ (when entry-cache
+ (remhash id entry-cache))))
(puthash id (cons extra (delete old-extra trail))
gnus-registry-hashtb)
- (setq gnus-registry-dirty t))))
+ (setq gnus-registry-dirty t)))))
(defun gnus-registry-store-extra-entry (id key value)
"Put a specific entry in the extras field of the registry entry for id."
(eval-and-compile
(autoload 'spam-report-gmane "spam-report"))
+;; autoload gnus-registry
+(eval-and-compile
+ (autoload 'gnus-registry-store-extra-entry "gnus-registry")
+ (autoload 'gnus-registry-fetch-extra "gnus-registry"))
+
;; autoload query-dns
(eval-and-compile
(autoload 'query-dns "dns"))
:type 'boolean
:group 'spam)
+(defcustom spam-log-to-registry nil
+ "Whether spam/ham processing should be logged in the registry."
+ :type 'boolean
+ :group 'spam)
+
(defcustom spam-process-ham-in-spam-groups nil
"Whether ham should be processed in spam groups."
:type 'boolean
spam-use-spamoracle)
"Whether the spam hooks should be installed, default to t if one of
the spam-use-* variables is set."
- :group 'gnus-registry
+ :group 'spam
:type 'boolean)
(defcustom spam-split-group "spam"
(mail-header-subject (gnus-data-header (assoc article (gnus-data-list nil))))
nil))
+(defun spam-fetch-field-message-id-fast (article)
+ "Fetch the `subject' field quickly, using the internal gnus-data-list function"
+ (if (and (numberp article)
+ (assoc article (gnus-data-list nil)))
+ (mail-header-message-id (gnus-data-header (assoc article (gnus-data-list nil))))
+ nil))
+
\f
;;;; Spam determination.
(if (eq decision t)
nil
decision)))))))
-
+
+;;; log a spam-processor invocation to the registry
+(defun spam-log-processing-to-registry (id type classification check group)
+ (when spam-log-to-registry
+ (if (and (stringp id)
+ (stringp group)
+ (or (eq type 'incoming)
+ (eq type 'process))
+ (or (eq classification 'spam)
+ (eq classification 'ham))
+ (assoc check spam-list-of-checks))
+ (let ((cell-list (cdr-safe (gnus-registry-fetch-extra id type)))
+ (cell (list classification check group)))
+ (push cell cell-list)
+ (gnus-registry-store-extra-entry
+ id
+ type
+ cell-list))
+
+ (gnus-message 5 "spam-log-processing-to-registry called with bad ID, type, check, or group"))))
+
+;;; set up IMAP widening if it's necessary
(defun spam-setup-widening ()
(dolist (check spam-list-of-statistical-checks)
(when (symbol-value check)
nil
;; ham function
(lambda (article)
+ (spam-log-processing-to-registry
+ (spam-fetch-field-message-id-fast article)
+ 'process
+ 'ham
+ 'spam-processing-use-BBDB
+ gnus-newsgroup-name)
(spam-enter-ham-BBDB (spam-fetch-field-from-fast article)))))
(defun spam-check-BBDB ()
(defun spam-ifile-register-spam-routine ()
(spam-generic-register-routine
(lambda (article)
+ (spam-log-processing-to-registry
+ (spam-fetch-field-message-id-fast article)
+ 'process
+ 'spam
+ 'spam-processing-use-ifile-spam
+ gnus-newsgroup-name)
(spam-ifile-register-with-ifile
(spam-get-article-as-string article) spam-ifile-spam-category))
nil))
(spam-generic-register-routine
nil
(lambda (article)
+ (spam-log-processing-to-registry
+ (spam-fetch-field-message-id-fast article)
+ 'process
+ 'ham
+ 'spam-processing-use-ifile-ham
+ gnus-newsgroup-name)
(spam-ifile-register-with-ifile
(spam-get-article-as-string article) spam-ifile-ham-category))))
(defun spam-stat-register-spam-routine ()
(spam-generic-register-routine
(lambda (article)
+ (spam-log-processing-to-registry
+ (spam-fetch-field-message-id-fast article)
+ 'process
+ 'spam
+ 'spam-processing-use-stat-spam
+ gnus-newsgroup-name)
(let ((article-string (spam-get-article-as-string article)))
(with-temp-buffer
(insert article-string)
(spam-generic-register-routine
nil
(lambda (article)
+ (spam-log-processing-to-registry
+ (spam-fetch-field-message-id-fast article)
+ 'process
+ 'ham
+ 'spam-processing-use-stat-ham
+ gnus-newsgroup-name)
(let ((article-string (spam-get-article-as-string article)))
(with-temp-buffer
(insert article-string)
(spam-generic-register-routine
;; the spam function
(lambda (article)
+ (spam-log-processing-to-registry
+ (spam-fetch-field-message-id-fast article)
+ 'process
+ 'spam
+ 'spam-processing-use-blacklist
+ gnus-newsgroup-name)
(let ((from (spam-fetch-field-from-fast article)))
(when (stringp from)
(spam-enter-blacklist from))))
nil
;; the ham function
(lambda (article)
+ (spam-log-processing-to-registry
+ (spam-fetch-field-message-id-fast article)
+ 'process
+ 'ham
+ 'spam-processing-use-whitelist
+ gnus-newsgroup-name)
(let ((from (spam-fetch-field-from-fast article)))
(when (stringp from)
(spam-enter-whitelist from))))))
(defun spam-bogofilter-register-spam-routine ()
(spam-generic-register-routine
(lambda (article)
+ (spam-log-processing-to-registry
+ (spam-fetch-field-message-id-fast article)
+ 'process
+ 'spam
+ 'spam-processing-use-bogofilter-spam
+ gnus-newsgroup-name)
(spam-bogofilter-register-with-bogofilter
(spam-get-article-as-string article) t))
nil))
(spam-generic-register-routine
nil
(lambda (article)
+ (spam-log-processing-to-registry
+ (spam-fetch-field-message-id-fast article)
+ 'process
+ 'ham
+ 'spam-processing-use-bogofilter-ham
+ gnus-newsgroup-name)
(spam-bogofilter-register-with-bogofilter
(spam-get-article-as-string article) nil))))
(spam-generic-register-routine
nil
(lambda (article)
+ (spam-log-processing-to-registry
+ (spam-fetch-field-message-id-fast article)
+ 'process
+ 'ham
+ 'spam-processing-use-spamoracle-ham
+ gnus-newsgroup-name)
(spam-spamoracle-learn article nil))))
(defun spam-spamoracle-learn-spam ()
(spam-generic-register-routine
(lambda (article)
+ (spam-log-processing-to-registry
+ (spam-fetch-field-message-id-fast article)
+ 'process
+ 'spam
+ 'spam-processing-use-spamoracle-spam
+ gnus-newsgroup-name)
(spam-spamoracle-learn article t))
nil))
\f