Gnus development mailing list
 help / color / mirror / Atom feed
* Beginning to use async.el to help Gnus' interactivity
@ 2012-07-08  5:31 John Wiegley
  2012-07-09  5:22 ` Carson Chittom
  2012-07-18 14:03 ` Ted Zlatanov
  0 siblings, 2 replies; 7+ messages in thread
From: John Wiegley @ 2012-07-08  5:31 UTC (permalink / raw)
  To: ding

Here is a function I'm now using to help out spam.el.  Reporting SPAM to the
Internet takes about 5 seconds per messages, so this *really* helps after
leaving a busy spam group:

(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"))))))))

John




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

end of thread, other threads:[~2012-07-19 13:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-08  5:31 Beginning to use async.el to help Gnus' interactivity John Wiegley
2012-07-09  5:22 ` Carson Chittom
2012-07-18 14:03 ` Ted Zlatanov
2012-07-18 18:58   ` John Wiegley
2012-07-18 19:23     ` Ted Zlatanov
2012-07-18 21:27       ` Steinar Bang
2012-07-19 13:36         ` Ted Zlatanov

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).