Function: spam-split

spam-split is a byte-compiled function defined in spam.el.gz.

Signature

(spam-split &rest SPECIFIC-CHECKS)

Documentation

Split this message into the spam group if it is spam.

This function can be used as an entry in the variable nnmail-split-fancy(var)/nnmail-split-fancy(fun), for example like this: (: spam-split). It can take checks as parameters. A string as a parameter will set the spam-split-group to that string.

See the Info node (gnus)Fancy Mail Splitting for more details.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/spam.el.gz
;;}}}

;;{{{ Spam determination.

(defun spam-split (&rest specific-checks)
  "Split this message into the `spam' group if it is spam.
This function can be used as an entry in the variable `nnmail-split-fancy',
for example like this: (: spam-split).  It can take checks as
parameters.  A string as a parameter will set the
`spam-split-group' to that string.

See the Info node `(gnus)Fancy Mail Splitting' for more details."
  (setq spam-split-last-successful-check nil)
  (unless spam-split-disabled
    (let ((spam-split-group-choice spam-split-group))
      (dolist (check specific-checks)
        (when (stringp check)
          (setq spam-split-group-choice check)
          (setq specific-checks (delq check specific-checks))))

      (let ((spam-split-group spam-split-group-choice)
            (widening-needed-check (spam-widening-needed-p specific-checks)))
        (save-excursion
          (save-restriction
            (when widening-needed-check
              (widen)
              (gnus-message 8 "spam-split: widening the buffer (%s requires it)"
                            widening-needed-check))
            (let ((backends (spam-backend-list))
                  decision)
              (while (and backends (not decision))
                (let* ((backend (pop backends))
                       (check-function (spam-backend-check backend))
                       (spam-split-group (if spam-split-symbolic-return
                                             'spam
                                           spam-split-group)))
                  (when (or
                         ;; either, given specific checks, this is one of them
                         (memq backend specific-checks)
                         ;; or, given no specific checks, spam-use-CHECK is set
                         (and (null specific-checks) (symbol-value backend)))
                    (gnus-message 6 "spam-split: calling the %s function"
                                  check-function)
                    (setq decision (funcall check-function))
                    ;; if we got a decision at all, save the current check
                    (when decision
                      (setq spam-split-last-successful-check backend))

                    (when (eq decision 'spam)
                      (unless spam-split-symbolic-return
                        (gnus-error
                         5
                         (format "spam-split got %s but %s is nil"
                                 decision
                                 spam-split-symbolic-return)))))))
              (if (eq decision t)
                  (if spam-split-symbolic-return-positive 'ham nil)
                decision))))))))