Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
* How to use the new code in spam.el?
@ 2012-07-06 21:07 John Wiegley
  2012-07-08 16:50 ` Tassilo Horn
  0 siblings, 1 reply; 4+ messages in thread
From: John Wiegley @ 2012-07-06 21:07 UTC (permalink / raw)
  To: info-gnus-english

I have the following setup: Procmail runs SpamAssassin, and then splits mail
into INBOX or mail.spam based on the headers.

In Gnus, I want to be able to mark spam in INBOX with $, and ham in mail.spam
with M-u, and have each moved to the right place.

Plus, when I leave INBOX or mail.spam, I want all the aricles passed to
sa-learn, to be learned as spam or ham, accordingly.

I'm finding the new spam.el code to be rather impenetrable.  It goes through
several layers of abstraction, such that I can't figure how to get spam/ham
learning to occur.  I see the function
`spam-spamassassin-register-spam-routine', but how do I invoke it?  What
should my `spam-process' group parameter be set to?  I have
`spam-use-spamassassin-headers' set to t before I call (spam-initialize).

Thanks,
  John

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to use the new code in spam.el?
  2012-07-06 21:07 How to use the new code in spam.el? John Wiegley
@ 2012-07-08 16:50 ` Tassilo Horn
  2012-07-08 17:44   ` John Wiegley
  0 siblings, 1 reply; 4+ messages in thread
From: Tassilo Horn @ 2012-07-08 16:50 UTC (permalink / raw)
  To: info-gnus-english

"John Wiegley" <johnw@newartisans.com> writes:

Hi John,

> In Gnus, I want to be able to mark spam in INBOX with $, and ham in
> mail.spam with M-u, and have each moved to the right place.

I do exactly that.  Here're the relevant settings:

--8<---------------cut here---------------start------------->8---
(spam-initialize)
(setq gnus-spam-newsgroup-contents
      '(("\\(spam\\|Junk\\)" gnus-group-spam-classification-spam))
      ;; Move SPAM in normal groups to traning.spam.
      gnus-spam-process-destinations
      '(("nnimap\\+Fastmail:"
	 "nnimap+Fastmail:INBOX.training.spam")
	("nnimap\\+Uni:"
	 "nnimap+Uni:Junk"))
      ;; Move ham in spam groups to both inbox and training.ham.
      gnus-ham-process-destinations
      '(("nnimap\\+Fastmail:INBOX\\.Junk Mail"
	 "nnimap+Fastmail:INBOX"
	 "nnimap+Fastmail:INBOX.training.ham")
	("nnimap\\+Uni:Junk"
	 "nnimap+Uni:INBOX")))
--8<---------------cut here---------------end--------------->8---

Bye,
Tassilo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to use the new code in spam.el?
  2012-07-08 16:50 ` Tassilo Horn
@ 2012-07-08 17:44   ` John Wiegley
  2012-07-09  6:50     ` Tassilo Horn
  0 siblings, 1 reply; 4+ messages in thread
From: John Wiegley @ 2012-07-08 17:44 UTC (permalink / raw)
  To: info-gnus-english

>>>>> Tassilo Horn <tassilo@member.fsf.org> writes:

>> In Gnus, I want to be able to mark spam in INBOX with $, and ham in
>> mail.spam with M-u, and have each moved to the right place.

> I do exactly that.  Here're the relevant settings:

Your setting only move Spam around, they don't truly process it.  I want
ham/spam sent to sa-learn, and spam sent to spamassassin -r.

Here's what I had to do: In my gnus-parameters, I have this:

 ("INBOX"
  (total-expire . t)
  (expiry-wait . 14)
  (expiry-target . "mail.archive")
  (spam-process-destination . "mail.spam")
  (spam-contents gnus-group-spam-classification-ham)
  (spam-process
   ((spam spam-use-spamassassin)
    (ham spam-use-spamassassin))))

 ("mail\\.spam"
  (gnus-article-sort-functions gnus-article-sort-by-chars)
  (ham-process-destination . "INBOX")
  (spam-contents gnus-group-spam-classification-spam)
  (spam-process
   ((spam spam-use-spamassassin)
    (ham spam-use-spamassassin))))

And then I had to enrich the definition of
spam-spamassassin-register-with-sa-learn, since there is currently no way to
have Gnus report Spam to Razor.  Also note that this version is fully
asynchronous, since there's no reason for me to have to wait on spam
reporting:

(require 'spam)
(require 'async)

(defun spam-spamassassin-register-with-sa-learn (articles spam
                                                          &optional unregister)
  "Register articles with spamassassin's sa-learn as spam or non-spam."
  (if articles
      (let ((action (if unregister spam-sa-learn-unregister-switch
                      (if spam spam-sa-learn-spam-switch
                        spam-sa-learn-ham-switch)))
            (summary-buffer-name (buffer-name)))
        (with-temp-buffer
          ;; group the articles into mbox format
          (dolist (article articles)
            (let (article-string)
              (with-current-buffer summary-buffer-name
                (setq article-string (spam-get-article-as-string article)))
              (when (stringp article-string)
                ;; mbox separator
                (insert (concat "From nobody " (current-time-string) "\n"))
                (insert article-string)
                (insert "\n"))))
          ;; call sa-learn on all messages at the same time, and also report
          ;; them as SPAM to the Internet
          (async-start
           `(lambda ()
              (with-temp-buffer
                (insert ,(buffer-substring-no-properties
                          (point-min) (point-max)))
                (call-process-region (point-min) (point-max)
                                     ,spam-sa-learn-program
                                     nil nil nil "--mbox"
                                     ,@(if spam-sa-learn-rebuild
                                           (list action)
                                         (list "--no-rebuild" action)))
                (if ,spam
                    (call-process-region (point-min) (point-max)
                                         ,(executable-find "spamassassin-5.12")
                                         nil nil nil "--mbox" "-r"))))
           `(lambda (&optional ignore)
              (message  "Finished learning messsages as %s"
                        ,(if spam "spam" "ham"))))))))

Do note that I have a hard-coded executable name in that function.  Change
"spamassassin-5.12" to just "spamassassin", for your system.

John

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to use the new code in spam.el?
  2012-07-08 17:44   ` John Wiegley
@ 2012-07-09  6:50     ` Tassilo Horn
  0 siblings, 0 replies; 4+ messages in thread
From: Tassilo Horn @ 2012-07-09  6:50 UTC (permalink / raw)
  To: info-gnus-english

"John Wiegley" <johnw@newartisans.com> writes:

>>> In Gnus, I want to be able to mark spam in INBOX with $, and ham in
>>> mail.spam with M-u, and have each moved to the right place.
>
>> I do exactly that.  Here're the relevant settings:
>
> Your setting only move Spam around, they don't truly process it.

Oh, right.  I just put false positives/negatives into some special
groups, and then update the spam handling tools on the servers regularly
via their web interfaces.

Bye,
Tassilo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-07-09  6:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-06 21:07 How to use the new code in spam.el? John Wiegley
2012-07-08 16:50 ` Tassilo Horn
2012-07-08 17:44   ` John Wiegley
2012-07-09  6:50     ` Tassilo Horn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).