Function: spam-find-spam

spam-find-spam is an interactive and byte-compiled function defined in spam.el.gz.

Signature

(spam-find-spam)

Documentation

Detect spam in the current newsgroup using spam-split.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/spam.el.gz
(defun spam-find-spam ()
  "Detect spam in the current newsgroup using `spam-split'."
  (interactive nil gnus-summary-mode)

  (let* ((group gnus-newsgroup-name)
         (autodetect (gnus-parameter-spam-autodetect group))
         (methods (gnus-parameter-spam-autodetect-methods group))
         (first-method (nth 0 methods))
         (articles (if spam-autodetect-recheck-messages
                       gnus-newsgroup-articles
                     gnus-newsgroup-unseen))
         article-cannot-be-faked)


    (cl-dolist (backend methods)
      (when (spam-backend-statistical-p backend)
        (setq article-cannot-be-faked t)
        (cl-return)))

    (when (memq 'default methods)
      (setq article-cannot-be-faked t))

    (when (and autodetect
               (not (equal first-method 'none)))
      (mapcar
       (lambda (article)
         (let ((id (spam-fetch-field-message-id-fast article))
               (subject (spam-fetch-field-subject-fast article))
               (sender (spam-fetch-field-from-fast article))
               registry-lookup)

           (unless id
             (gnus-message 6 "Article %d has no message ID!" article))

           (when (and id spam-log-to-registry)
             (setq registry-lookup (spam-log-registration-type id 'incoming))
             (when registry-lookup
               (gnus-message
                9
                "spam-find-spam: message %s was already registered incoming"
                id)))

           (let* ((spam-split-symbolic-return t)
                  (spam-split-symbolic-return-positive t)
                  (fake-headers (spam-generate-fake-headers article))
                  (split-return
                   (or registry-lookup
                       (with-temp-buffer
                         (if article-cannot-be-faked
                             (gnus-request-article-this-buffer
                              article
                              group)
                           ;; else, we fake the article
                           (when fake-headers (insert fake-headers)))
                         (if (or (null first-method)
                                 (equal first-method 'default))
                             (spam-split)
                           (apply #'spam-split methods))))))
             (if (equal split-return 'spam)
                 (gnus-summary-mark-article article gnus-spam-mark))

             (when (and id split-return spam-log-to-registry)
               (when (zerop (gnus-registry-group-count id))
                 (gnus-registry-handle-action id nil group subject sender))

               (unless registry-lookup
                 (spam-log-processing-to-registry
                  id
                  'incoming
                  split-return
                  spam-split-last-successful-check
                  group))))))
       articles))))