+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
: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
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)
(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)
(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))
(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)
(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
: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
(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
(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
(when (symbol-value check)
(setq nnimap-split-download-body-default t))))
-(add-hook 'gnus-get-new-news-hook 'spam-setup-widening)
-
\f
;;;; Regex headers
(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)
(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.