Call `spam-initialize' automatically
authorLars Ingebrigtsen <larsi@building.gnus.org>
Thu, 30 Jan 2014 22:57:57 +0000 (14:57 -0800)
committerLars Ingebrigtsen <larsi@building.gnus.org>
Thu, 30 Jan 2014 22:57:57 +0000 (14:57 -0800)
* spam.el (spam-initialize): Allow calling repeatedly, but only run the
the code once (bug#9069).

* gnus-sum.el (gnus-summary-read-group-1): Initialize the spam code if
that's needed.

lisp/ChangeLog
lisp/gnus-sum.el
lisp/spam.el

index 100921b..6ae0a4a 100644 (file)
@@ -1,3 +1,11 @@
+2014-01-30  Lars Ingebrigtsen  <larsi@gnus.org>
+
+       * gnus-sum.el (gnus-summary-read-group-1): Initialize the spam code if
+       that's needed.
+
+       * spam.el (spam-initialize): Allow calling repeatedly, but only run the
+       the code once (bug#9069).
+
 2014-01-18  Steinar Bang  <sb@dod.no>
 
        * gnus-setup.el (gnus-use-sendmail): We never use sendmail for mail
index a1c0a0a..d6c801f 100644 (file)
@@ -4024,6 +4024,8 @@ If SELECT-ARTICLES, only select those articles from GROUP."
      ;; The group was successfully selected.
      (t
       (gnus-set-global-variables)
+      (when (boundp 'spam-install-hooks)
+       (spam-initialize))
       ;; Save the active value in effect when the group was entered.
       (setq gnus-newsgroup-active
            (gnus-copy-sequence
index d065596..82f98c4 100644 (file)
@@ -2903,25 +2903,27 @@ 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 the `spam' face is customized?
-  (push '((eq mark gnus-spam-mark) . spam)
-        gnus-summary-highlight)
-  ;; Add hooks for loading and saving the spam stats
-  (add-hook 'gnus-save-newsrc-hook 'spam-maybe-spam-stat-save)
-  (add-hook 'gnus-get-top-new-news-hook 'spam-maybe-spam-stat-load)
-  (add-hook 'gnus-startup-hook 'spam-maybe-spam-stat-load)
-  (add-hook 'gnus-summary-prepare-exit-hook 'spam-summary-prepare-exit)
-  (add-hook 'gnus-summary-prepare-hook 'spam-summary-prepare)
-  (add-hook 'gnus-get-new-news-hook 'spam-setup-widening)
-  (add-hook 'gnus-summary-prepared-hook 'spam-find-spam))
+  (when spam-install-hooks
+    (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))
+
+    ;; TODO: How do we redo this every time the `spam' face is customized?
+    (push '((eq mark gnus-spam-mark) . spam)
+         gnus-summary-highlight)
+    ;; Add hooks for loading and saving the spam stats
+    (add-hook 'gnus-save-newsrc-hook 'spam-maybe-spam-stat-save)
+    (add-hook 'gnus-get-top-new-news-hook 'spam-maybe-spam-stat-load)
+    (add-hook 'gnus-startup-hook 'spam-maybe-spam-stat-load)
+    (add-hook 'gnus-summary-prepare-exit-hook 'spam-summary-prepare-exit)
+    (add-hook 'gnus-summary-prepare-hook 'spam-summary-prepare)
+    (add-hook 'gnus-get-new-news-hook 'spam-setup-widening)
+    (add-hook 'gnus-summary-prepared-hook 'spam-find-spam)
+    ;; Don't install things more than once.
+    (setq spam-install-hooks nil)))
 
 (defun spam-unload-hook ()
   "Uninstall the spam.el hooks."
@@ -2936,8 +2938,6 @@ installed through `spam-necessary-extra-headers'."
 
 (add-hook 'spam-unload-hook 'spam-unload-hook)
 
-(when spam-install-hooks
-  (spam-initialize))
 ;;}}}
 
 (provide 'spam)