From: Ted Zlatanov Date: Wed, 9 Nov 2011 13:54:09 +0000 (-0600) Subject: Fix spam.el to BBDB 2 and 3 glue. X-Git-Url: http://cgit.sxemacs.org/?p=gnus;a=commitdiff_plain;h=98b834dda1a5e9951164a302b630a48cc4a84e20 Fix spam.el to BBDB 2 and 3 glue. * spam.el: Move BBDB autoloads. (spam-exists-in-BBDB-p): New function to do the BBDB search directly in BBDB 2 and 3. (spam-check-BBDB): Use it. (spam-enter-ham-BBDB): Use it. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e5c241934..6a7dc0356 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2011-11-09 Teodor Zlatanov + + * spam.el: Move BBDB autoloads. + (spam-exists-in-BBDB-p): New function to do the BBDB search directly in BBDB 2 and 3. + (spam-check-BBDB): Use it. + (spam-enter-ham-BBDB): Use it. + 2011-10-31 Peter Münster (tiny change) * gnus-group.el (gnus-group-get-new-news): New parameter `one-level' diff --git a/lisp/spam.el b/lisp/spam.el index fa152f688..f76046df6 100644 --- a/lisp/spam.el +++ b/lisp/spam.el @@ -2088,11 +2088,6 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details." ;; all this is done inside a condition-case to trap errors -(eval-when-compile - (autoload 'bbdb-buffer "bbdb") - (autoload 'bbdb-create-internal "bbdb") - (autoload 'bbdb-search-simple "bbdb")) - ;; Autoloaded in message, which we require. (declare-function gnus-extract-address-components "gnus-util" (from)) @@ -2104,9 +2099,13 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details." (file-error ;; `bbdb-records' should not be bound as an autoload function ;; before loading bbdb because of `bbdb-hashtable-size'. + (defalias 'bbdb-buffer 'ignore) + (defalias 'bbdb-create-internal 'ignore) (defalias 'bbdb-records 'ignore) (defalias 'spam-BBDB-register-routine 'ignore) (defalias 'spam-enter-ham-BBDB 'ignore) + (defalias 'spam-exists-in-BBDB-p 'ignore) + (defalias 'bbdb-gethash 'ignore) nil)) ;; when the BBDB changes, we want to clear out our cache @@ -2126,7 +2125,7 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details." 'ignore)) (net-address (nth 1 parsed-address)) (record (and net-address - (bbdb-search-simple nil net-address)))) + (spam-exists-in-BBDB-p net-address)))) (when net-address (gnus-message 6 "%s address %s %s BBDB" (if remove "Deleting" "Adding") @@ -2148,15 +2147,17 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details." (defun spam-BBDB-unregister-routine (articles) (spam-BBDB-register-routine articles t)) + (defsubst spam-exists-in-BBDB-p (net) + (when (and (stringp net) (not (zerop (length net)))) + (bbdb-records) + (bbdb-gethash (downcase net)))) + (defun spam-check-BBDB () "Mail from people in the BBDB is classified as ham or non-spam" - (let ((who (message-fetch-field "from"))) - (when who - (setq who (nth 1 (gnus-extract-address-components who))) - (if - (if (fboundp 'bbdb-search) - (bbdb-search (bbdb-records) who) ;; v3 - (bbdb-search-simple nil who)) ;; v2 + (let ((net (message-fetch-field "from"))) + (when net + (setq net (nth 1 (gnus-extract-address-components net))) + (if (spam-exists-in-BBDB-p net) t (if spam-use-BBDB-exclusive spam-split-group