;;; Code:
(eval-when-compile (require 'cl))
+(eval-when-compile (require 'spam-report))
(require 'path-util)
(require 'gnus-sum)
:type 'boolean
:group 'spam)
+(defcustom spam-mark-new-messages-in-spam-group-as-spam t
+ "Whether new messages in a spam group should get the spam-mark."
+ :type 'boolean
+ :group 'spam)
+
(defcustom spam-process-ham-in-nonham-groups nil
"Whether ham should be processed in non-ham groups."
:type 'boolean
(defun spam-group-spam-contents-p (group)
"Is GROUP a spam group?"
- (if (stringp group)
+ (if (and (stringp group) (< 0 (length group)))
(or (member group spam-junk-mailgroups)
(memq 'gnus-group-spam-classification-spam
(gnus-parameter-spam-contents group)))
(gnus-group-spam-exit-processor-spamoracle spam spam-use-spamoracle)
(nil spam spam-use-crm114)
(gnus-group-spam-exit-processor-spamassassin spam spam-use-spamassassin)
+
+ (nil ham spam-use-resend)
(gnus-group-ham-exit-processor-ifile ham spam-use-ifile)
(gnus-group-ham-exit-processor-bogofilter ham spam-use-bogofilter)
(gnus-group-ham-exit-processor-bsfilter ham spam-use-bsfilter)
(gnus-summary-remove-process-mark article)
(spam-report-gmane article)))
-(defun spam-report-articles-resend (n)
+(defun spam-report-articles-resend (n &optional ham)
"Report the current message as spam by resending it.
Respects the process/prefix convention. Also see
-`spam-report-resend-to'."
+`spam-report-resend-to'. Operates as ham when HAM is set."
(interactive "P")
- (let ((spam-report-resend-to
- (gnus-parameter-spam-resend-to gnus-newsgroup-name))
- (articles (gnus-summary-work-articles n)))
- (spam-report-resend articles)
+ (let* ((gp
+ (if ham
+ (gnus-parameter-ham-resend-to gnus-newsgroup-name)
+ (gnus-parameter-spam-resend-to gnus-newsgroup-name)))
+ (spam-report-resend-to (or (car-safe gp)
+ spam-report-resend-to))
+ (articles (gnus-summary-work-articles n)))
+ (spam-report-resend articles ham)
(dolist (article articles)
(gnus-summary-remove-process-mark article))))
(num (spam-mark-spam-as-expired-and-move-routine group)))
(when (> num 0)
(gnus-message 6
- "%d spam messages are marked as expired and moved it to %s"
- num group))))
+ "%d spam messages are marked as expired%s."
+ num
+ (if group
+ (format " and moved it to %s" group)
+ "")))))
;; now we redo spam-mark-spam-as-expired-and-move-routine to only
;; expire spam, in case the above did not expire them
(let ((num (spam-mark-spam-as-expired-and-move-routine nil)))
(when (> num 0)
(gnus-message 6
- "%d spam messages are markd as expired without moving it"
+ "%d spam messages were marked as expired."
num)))
(when (or (spam-group-ham-contents-p gnus-newsgroup-name)
(spam-ham-copy-routine
(gnus-parameter-ham-process-destination gnus-newsgroup-name))))
(when (> num 0)
- (gnus-message 6 "%d ham messages are copied" num))))
+ (gnus-message 6 "%d ham messages were copied" num))))
;; now move all ham articles out of spam groups
(when (spam-group-spam-contents-p gnus-newsgroup-name)
(spam-ham-move-routine
(gnus-parameter-ham-process-destination gnus-newsgroup-name))))
(when (> num 0)
- (gnus-message 6 "%d ham messages are moved from spam group" num)))))
+ (gnus-message 6 "%d ham messages were moved from spam group" num)))))
(setq spam-old-ham-articles nil)
(setq spam-old-spam-articles nil))
(let ((articles (if spam-mark-only-unseen-as-spam
gnus-newsgroup-unseen
gnus-newsgroup-unreads)))
- (dolist (article articles)
- (gnus-summary-mark-article article gnus-spam-mark)))))
+ (if spam-mark-new-messages-in-spam-group-as-spam
+ (dolist (article articles)
+ (gnus-summary-mark-article article gnus-spam-mark))
+ (gnus-message 9 "Did not mark new messages as spam.")))))
(defun spam-mark-spam-as-expired-and-move-routine (&rest groups)
(if (and (car-safe groups) (listp (car-safe groups)))
(gnus-check-backend-function
'request-move-article gnus-newsgroup-name))
(respool-method (gnus-find-method-for-group gnus-newsgroup-name))
- article mark todo deletep respool)
+ article mark deletep respool)
(when (member 'respool groups)
(setq respool t) ; boolean for later
;; does Gmane support unregistration?
nil
nil)
- (spam-use-resend nil
+ (spam-use-resend spam-report-resend-register-ham-routine
spam-report-resend-register-routine
nil
nil)
gnus-newsgroup-articles
classification)))
;; process them
- (gnus-message 5 "%s %d %s articles as %s using backend %s"
- (if unregister "Unregistering" "Registering")
- (length articles)
- (if specific-articles "specific" "")
- (symbol-name classification)
- (symbol-name check))
- (funcall run-function articles)
- ;; now log all the registrations (or undo them, depending on unregister)
- (dolist (article articles)
- (funcall log-function
- (spam-fetch-field-message-id-fast article)
- 'process
- classification
- check
- gnus-newsgroup-name))))))
+ (when (> (length articles) 0)
+ (gnus-message 5 "%s %d %s articles as %s using backend %s"
+ (if unregister "Unregistering" "Registering")
+ (length articles)
+ (if specific-articles "specific" "")
+ (symbol-name classification)
+ (symbol-name check))
+ (funcall run-function articles)
+ ;; now log all the registrations (or undo them, depending on unregister)
+ (dolist (article articles)
+ (funcall log-function
+ (spam-fetch-field-message-id-fast article)
+ 'process
+ classification
+ check
+ gnus-newsgroup-name)))))))
;;; log a ham- or spam-processor invocation to the registry
(defun spam-log-processing-to-registry (id type classification check group)
(when articles
(apply 'spam-report-gmane articles)))
-(defun spam-report-resend-register-routine (articles)
- (let ((spam-report-resend-to (gnus-parameter-spam-resend-to gnus-newsgroup-name)))
- (spam-report-resend articles)))
+(defun spam-report-resend-register-ham-routine (articles)
+ (spam-report-resend-register-routine articles t))
+
+(defun spam-report-resend-register-routine (articles &optional ham)
+ (let* ((resend-to-gp
+ (if ham
+ (gnus-parameter-ham-resend-to gnus-newsgroup-name)
+ (gnus-parameter-spam-resend-to gnus-newsgroup-name)))
+ (spam-report-resend-to (or (car-safe resend-to-gp)
+ spam-report-resend-to)))
+ (spam-report-resend articles ham)))
\f
;;;; Bogofilter