(require 'gnus-sum)
+(require 'gnus-uu) ; because of key prefix issues
+(require 'gnus) ; for the definitions of group content classification and spam processors
+
;; FIXME! We should not require `message' until we actually need
;; them. Best would be to declare needed functions as auto-loadable.
(require 'message)
:type '(repeat (string :tag "Server"))
:group 'spam)
-(defcustom spam-ham-marks (list gnus-del-mark gnus-read-mark gnus-killed-mark gnus-kill-file-mark gnus-low-score-mark)
+(defcustom spam-ham-marks (list 'gnus-del-mark 'gnus-read-mark 'gnus-killed-mark 'gnus-kill-file-mark 'gnus-low-score-mark)
"Marks considered as being ham (positively not spam).
Such articles will be processed as ham (non-spam) on group exit."
- :type '(repeat (character :tag "Mark"))
+ :type '(set
+ (variable-item gnus-del-mark)
+ (variable-item gnus-read-mark)
+ (variable-item gnus-killed-mark)
+ (variable-item gnus-kill-file-mark)
+ (variable-item gnus-low-score-mark))
:group 'spam)
-(defcustom spam-spam-marks (list gnus-spam-mark)
+(defcustom spam-spam-marks (list 'gnus-spam-mark)
"Marks considered as being spam (positively spam).
Such articles will be transmitted to `bogofilter -s' on group exit."
- :type '(repeat (character :tag "Mark"))
+ :type '(set
+ (variable-item gnus-spam-mark)
+ (variable-item gnus-killed-mark)
+ (variable-item gnus-kill-file-mark)
+ (variable-item gnus-low-score-mark))
:group 'spam)
(defcustom spam-face 'gnus-splash-face
(push '((eq mark gnus-spam-mark) . spam-face)
gnus-summary-highlight)
+;; convenience functions
+(defun spam-group-spam-contents-p (group)
+ (if (stringp group)
+ (or (member group spam-junk-mailgroups)
+ (memq 'gnus-group-spam-classification-spam (gnus-parameter-spam-contents group)))
+ nil))
+
+(defun spam-group-ham-contents-p (group)
+ (if (stringp group)
+ (memq 'gnus-group-spam-classification-ham (gnus-parameter-spam-contents group))
+ nil))
+
+
;;; Hooks dispatching. A bit raw for now.
(defun spam-summary-prepare ()
(spam-mark-junk-as-spam-routine))
(defun spam-summary-prepare-exit ()
- (spam-bogofilter-register-routine))
+ (spam-bogofilter-register-routine)
+ (when (spam-group-spam-contents-p gnus-newsgroup-name)
+ (
+ ;; TODO: the spam processors here
+ ;; TODO: the spam-processed articles will be moved here
+ ))
+ (when (spam-group-ham-contents-p gnus-newsgroup-name)
+ (
+ ;; TODO: the ham processors here
+ )))
(add-hook 'gnus-summary-prepare-hook 'spam-summary-prepare)
(add-hook 'gnus-summary-prepare-exit-hook 'spam-summary-prepare-exit)
(defun spam-mark-junk-as-spam-routine ()
- (when (member gnus-newsgroup-name spam-junk-mailgroups)
+ ;; check the global list of group names spam-junk-mailgroups and the group parameters
+ (when (spam-group-spam-contents-p gnus-newsgroup-name)
(let ((articles gnus-newsgroup-articles)
article)
(while articles
(defun spam-bogofilter-register-routine ()
(when (and spam-use-bogofilter spam-bogofilter-path)
(let ((articles gnus-newsgroup-articles)
- article mark ham-articles spam-articles)
+ article mark ham-articles spam-articles spam-mark-values ham-mark-values)
+
+ ;; marks are stored as symbolic values, so we have to dereference them for memq to work
+ ;; we wouldn't have to do this if gnus-summary-article-mark returned a symbol.
+ (dolist (mark spam-ham-marks)
+ (push (symbol-value mark) ham-mark-values))
+
+ (dolist (mark spam-spam-marks)
+ (push (symbol-value mark) spam-mark-values))
+
(while articles
(setq article (pop articles)
mark (gnus-summary-article-mark article))
- (cond ((memq mark spam-spam-marks) (push article spam-articles))
+ (cond ((memq mark spam-mark-values) (push article spam-articles))
((memq article gnus-newsgroup-saved))
- ((memq mark spam-ham-marks) (push article ham-articles))))
+ ((memq mark ham-mark-values) (push article ham-articles))))
(when ham-articles
(spam-bogofilter-articles "ham" "-n" ham-articles))
(when spam-articles