Synch to Gnus 200305302005.
authoryamaoka <yamaoka>
Sat, 31 May 2003 00:40:58 +0000 (00:40 +0000)
committeryamaoka <yamaoka>
Sat, 31 May 2003 00:40:58 +0000 (00:40 +0000)
lisp/ChangeLog
lisp/gnus-registry.el
lisp/spam-stat.el
lisp/spam.el

index dde1285..7ac7013 100644 (file)
@@ -1,3 +1,21 @@
+2003-05-30  Teodor Zlatanov  <tzz@lifelogs.com>
+
+       * gnus-registry.el (gnus-registry-use-long-group-names): new variable
+       (gnus-registry-add-group): use it
+       (gnus-registry-trim-articles-without-groups): new variable
+       (gnus-registry-delete-group): use it
+       (gnus-registry-unload-hook): uninstall all the hooks
+
+       * spam.el (spam-install-hooks-function, spam-unload-hook): new
+       functions so users that load spam.el for customization don't get
+       all the hooks installed
+       (spam-install-hooks): new variable, set to t by default if user
+       has one of the spam-use-* variables set
+
+       * spam-stat.el (spam-stat-install-hooks, spam-stat-unload-hook): new
+       functions so users that load spam-stat.el for customization don't get
+       all the hooks installed
+
 2003-05-30  Dave Love  <fx@gnu.org>
 
        * rfc2047.el (rfc2047-decode): Don't use
index 40b8a33..4180aa1 100644 (file)
@@ -54,6 +54,16 @@ The group names are matched, they don't have to be fully qualified."
   :group 'gnus-registry
   :type 'boolean)
 
+(defcustom gnus-registry-use-long-group-names nil
+  "Whether the registry should use long group names (BUGGY)."
+  :group 'gnus-registry
+  :type 'boolean)
+
+(defcustom gnus-registry-trim-articles-without-groups t
+  "Whether the registry should clean out message IDs without groups."
+  :group 'gnus-registry
+  :type 'boolean)
+
 (defcustom gnus-registry-cache-file "~/.gnus.registry.eld"
   "File where the Gnus registry will be stored."
   :group 'gnus-registry
@@ -364,8 +374,9 @@ Returns the first place where the trail finds a group name."
                      nil)
                 gnus-registry-hashtb))
       ;; now, clear the entry if there are no more groups
-      (unless (gnus-registry-group-count id)
-       (remhash id gnus-registry-hashtb))
+      (when gnus-registry-trim-articles-without-groups
+       (unless (gnus-registry-group-count id)
+         (remhash id gnus-registry-hashtb)))
       (gnus-registry-store-extra-entry id 'mtime (current-time)))))
 
 (defun gnus-registry-add-group (id group &rest extra)
@@ -374,8 +385,13 @@ Returns the first place where the trail finds a group name."
   (when group
     (when (and id
               (not (string-match "totally-fudged-out-message-id" id)))
-      (let ((group (gnus-group-short-name group)))
-       (gnus-registry-delete-group id group)   
+      (let ((full-group group)
+           (group (if gnus-registry-use-long-group-names 
+                      group 
+                    (gnus-group-short-name group))))
+       (gnus-registry-delete-group id group)
+       (unless gnus-registry-use-long-group-names 
+         (gnus-registry-delete-group id full-group))
        (let ((trail (gethash id gnus-registry-hashtb)))
          (puthash id (if trail
                          (cons group trail)
@@ -404,6 +420,19 @@ Returns the first place where the trail finds a group name."
 
   (add-hook 'gnus-summary-prepare-hook 'gnus-registry-register-message-ids))
 
+(defun gnus-registry-unload-hook ()
+  "Uninstall the registry hooks."
+  (interactive)
+  (remove-hook 'gnus-summary-article-move-hook 'gnus-register-action) 
+  (remove-hook 'gnus-summary-article-delete-hook 'gnus-register-action)
+  (remove-hook 'gnus-summary-article-expire-hook 'gnus-register-action)
+  (remove-hook 'nnmail-spool-hook 'gnus-register-spool-action)
+  
+  (remove-hook 'gnus-save-newsrc-hook 'gnus-registry-save)
+  (remove-hook 'gnus-read-newsrc-el-hook 'gnus-registry-read)
+
+  (remove-hook 'gnus-summary-prepare-hook 'gnus-registry-register-message-ids))
+
 (when gnus-registry-install
   (gnus-registry-install-hooks))
 
index 96df016..dcebb70 100644 (file)
@@ -238,12 +238,6 @@ This uses `gnus-article-buffer'."
     (set-buffer gnus-original-article-buffer)
     (spam-stat-store-current-buffer)))
 
-(when spam-stat-install-hooks
-  (add-hook 'nnmail-prepare-incoming-message-hook
-           'spam-stat-store-current-buffer)
-  (add-hook 'gnus-select-article-hook
-           'spam-stat-store-gnus-article-buffer))
-
 ;; Data -- not using defstruct in order to save space and time
 
 (defvar spam-stat (make-hash-table :test 'equal)
@@ -567,6 +561,25 @@ COUNT defaults to 5"
               (remhash key spam-stat)))
           spam-stat))
 
+(defun spam-stat-install-hooks-function ()
+  "Install the spam-stat function hooks"
+  (interactive)
+  (add-hook 'nnmail-prepare-incoming-message-hook
+           'spam-stat-store-current-buffer)
+  (add-hook 'gnus-select-article-hook
+           'spam-stat-store-gnus-article-buffer))
+
+(when spam-stat-install-hooks
+  (spam-stat-install-hooks-function))
+
+(defun spam-stat-unload-hook ()
+  "Uninstall the spam-stat function hooks"
+  (interactive)
+  (remove-hook 'nnmail-prepare-incoming-message-hook
+              'spam-stat-store-current-buffer)
+  (remove-hook 'gnus-select-article-hook
+              'spam-stat-store-gnus-article-buffer))
+
 (provide 'spam-stat)
 
 ;;; spam-stat.el ends here
index 477b052..f8fe28c 100644 (file)
@@ -179,6 +179,25 @@ considered spam."
   :type 'boolean
   :group 'spam)
 
+(defcustom spam-install-hooks (or
+                              spam-use-dig
+                              spam-use-blacklist
+                              spam-use-whitelist 
+                              spam-use-whitelist-exclusive 
+                              spam-use-blackholes 
+                              spam-use-hashcash 
+                              spam-use-regex-headers 
+                              spam-use-bogofilter-headers 
+                              spam-use-bogofilter 
+                              spam-use-BBDB 
+                              spam-use-BBDB-exclusive 
+                              spam-use-ifile 
+                              spam-use-stat)
+  "Whether the spam hooks should be installed, default to t if one of
+the spam-use-* variables is set."
+  :group 'gnus-registry
+  :type 'boolean)
+
 (defcustom spam-split-group "spam"
   "Group name where incoming spam should be put by spam-split."
   :type 'string
@@ -384,8 +403,6 @@ your main source of newsgroup names."
 (defun spam-summary-prepare ()
   (spam-mark-junk-as-spam-routine))
 
-(add-hook 'gnus-summary-prepare-hook 'spam-summary-prepare)
-
 ;; The spam processors are invoked for any group, spam or ham or neither
 (defun spam-summary-prepare-exit ()
   (unless gnus-group-is-exiting-without-update-p
@@ -453,8 +470,6 @@ your main source of newsgroup names."
       (spam-ham-move-routine
        (gnus-parameter-ham-process-destination gnus-newsgroup-name)))))
 
-(add-hook 'gnus-summary-prepare-exit-hook 'spam-summary-prepare-exit)
-
 (defun spam-mark-junk-as-spam-routine ()
   ;; check the global list of group names spam-junk-mailgroups and the
   ;; group parameters
@@ -642,8 +657,6 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details."
     (when (symbol-value check)
       (setq nnimap-split-download-body-default t))))
 
-(add-hook 'gnus-get-new-news-hook 'spam-setup-widening)
-
 \f
 ;;;; Regex headers
 
@@ -872,14 +885,11 @@ Uses `gnus-newsgroup-name' if category is nil (for ham registration)."
        (when spam-use-stat (spam-stat-load)))
       
       (defun spam-maybe-spam-stat-save ()
-       (when spam-use-stat (spam-stat-save)))
-
-      ;; 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))
+       (when spam-use-stat (spam-stat-save))))
 
   (file-error (progn
+               (defalias 'spam-maybe-spam-stat-load 'ignore)
+               (defalias 'spam-maybe-spam-stat-save 'ignore)
                (defalias 'spam-stat-register-ham-routine 'ignore)
                (defalias 'spam-stat-register-spam-routine 'ignore)
                (defalias 'spam-stat-buffer-is-spam 'ignore)
@@ -1060,6 +1070,34 @@ Uses `gnus-newsgroup-name' if category is nil (for ham registration)."
      (spam-bogofilter-register-with-bogofilter
       (spam-get-article-as-string article) nil))))
 
+\f
+;;;; Hooks
+
+(defun spam-install-hooks-function ()
+  "Install the spam.el hooks"
+  (interactive)
+  ;; Add hooks for loading and saving the spam stats
+  (when spam-use-stat
+    (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))
+
+(defun spam-unload-hook ()
+  "Uninstall the spam.el hooks"
+  (interactive)
+  (remove-hook 'gnus-save-newsrc-hook 'spam-maybe-spam-stat-save)
+  (remove-hook 'gnus-get-top-new-news-hook 'spam-maybe-spam-stat-load)
+  (remove-hook 'gnus-startup-hook 'spam-maybe-spam-stat-load)
+  (remove-hook 'gnus-summary-prepare-exit-hook 'spam-summary-prepare-exit)
+  (remove-hook 'gnus-summary-prepare-hook 'spam-summary-prepare)
+  (remove-hook 'gnus-get-new-news-hook 'spam-setup-widening))
+
+(when spam-install-hooks
+  (spam-install-hooks-function))
+
 (provide 'spam)
 
 ;;; spam.el ends here.