From: yamaoka Date: Thu, 22 Apr 2004 22:10:46 +0000 (+0000) Subject: Synch to No Gnus 200404221837. X-Git-Tag: t-gnus-6_17_4-quimby-~962 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=cf1b71a64db2ede7b450211e3e7b3ee7fce41dbd;p=elisp%2Fgnus.git- Synch to No Gnus 200404221837. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index abd9713..02bd0fe 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,17 @@ +2004-04-22 Teodor Zlatanov + + * spam.el (spam-necessary-extra-headers): get the extra headers we + may need for spam sorting and scoring + (spam-user-format-function-S): a user format function suitable for + general use + (spam-article-sort-by-spam-status): sorting function for summary + sorting + (spam-extra-header-to-number): get a score from a header + (spam-summary-score): get a numeric score from the headers + (spam-generic-score): oops, function doc in wrong place + (spam-initialize): take symbols when it's run, and install the + extra headers that spam-necessary-extra-headers thinks we need + 2004-04-21 Teodor Zlatanov * spam.el (spam-summary-prepare-exit): logic and message fix. diff --git a/lisp/spam.el b/lisp/spam.el index e6a1d8f..ab351d9 100644 --- a/lisp/spam.el +++ b/lisp/spam.el @@ -686,9 +686,59 @@ Respects the process/prefix convention." (gnus-summary-remove-process-mark article) (spam-report-gmane article))) +(defun spam-necessary-extra-headers () + "Return the extra headers spam.el thinks are necessary." + (let (list) + (when (or spam-use-spamassassin + spam-use-spamassassin-headers + spam-use-regex-headers) + (push 'X-Spam-Status list)) + list)) + +(defun spam-user-format-function-S (headers) + (when headers + (spam-summary-score headers))) + +(defun spam-article-sort-by-spam-status (h1 h2) + "Sort articles by score." + (let (result) + (dolist (header (spam-necessary-extra-headers)) + (let ((s1 (spam-summary-score h1 header)) + (s2 (spam-summary-score h2 header))) + (unless (= s1 s2) + (setq result (< s1 s2)) + (return)))) + result)) + +(defun spam-extra-header-to-number (header headers) + "Transform an extra header to a number." + (if (gnus-extra-header header headers) + (cond + ((eq header 'X-Spam-Status) + (string-to-number (gnus-replace-in-string + (gnus-extra-header header headers) + ".*hits=" ""))) + (t nil)) + nil)) + +(defun spam-summary-score (headers &optional specific-header) + "Score an article for the summary buffer, as fast as possible. +With SPECIFIC-HEADER, returns only that header's score. +Will not return a nil score." + (let (score) + (dolist (header + (if specific-header + (list specific-header) + (spam-necessary-extra-headers))) + (setq score + (spam-extra-header-to-number header headers)) + (when score + (return))) + (or score 0))) + (defun spam-generic-score () - (interactive) "Invoke whatever scoring method we can." + (interactive) (if (or spam-use-spamassassin spam-use-spamassassin-headers) @@ -2166,9 +2216,21 @@ REMOVE not nil, remove the ADDRESSES." ;;;; Hooks ;;;###autoload -(defun spam-initialize () - "Install the spam.el hooks and do other initialization" +(defun spam-initialize (&rest symbols) + "Install the spam.el hooks and do other initialization. +When SYMBOLS is given, set those variables to t. This is so you +can call spam-initialize before you set spam-use-* variables on +explicitly, and matters only if you need the extra headers +installed through spam-necessary-extra-headers." (interactive) + + (dolist (var symbols) + (set var t)) + + (dolist (header (spam-necessary-extra-headers)) + (add-to-list 'nnmail-extra-headers header) + (add-to-list 'gnus-extra-headers header)) + (setq spam-install-hooks t) ;; TODO: How do we redo this every time spam-face is customized? (push '((eq mark gnus-spam-mark) . spam-face)