From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/82006 Path: news.gmane.org!not-for-mail From: "John Wiegley" Newsgroups: gmane.emacs.gnus.general Subject: Beginning to use async.el to help Gnus' interactivity Date: Sun, 08 Jul 2012 00:31:31 -0500 Organization: New Artisans LLC Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1341730429 2127 80.91.229.3 (8 Jul 2012 06:53:49 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 8 Jul 2012 06:53:49 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M30276@lists.math.uh.edu Sun Jul 08 08:53:49 2012 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SnlNM-0000xI-BA for ding-account@gmane.org; Sun, 08 Jul 2012 08:53:48 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1SnlLw-0003bK-7D; Sun, 08 Jul 2012 01:52:20 -0500 Original-Received: from mx2.math.uh.edu ([129.7.128.33]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1SnkhB-0003R3-Kw for ding@lists.math.uh.edu; Sun, 08 Jul 2012 01:10:13 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1Snkh9-0000CD-Iu for ding@lists.math.uh.edu; Sun, 08 Jul 2012 01:10:12 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]) by quimby.gnus.org with esmtp (Exim 4.72) (envelope-from ) id 1Snkh7-0001FU-7F for ding@gnus.org; Sun, 08 Jul 2012 08:10:09 +0200 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Snkh2-0003rt-6i for ding@gnus.org; Sun, 08 Jul 2012 08:10:04 +0200 Original-Received: from c-98-215-105-167.hsd1.il.comcast.net ([98.215.105.167]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 08 Jul 2012 08:10:04 +0200 Original-Received: from johnw by c-98-215-105-167.hsd1.il.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 08 Jul 2012 08:10:04 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 48 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: c-98-215-105-167.hsd1.il.comcast.net User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.1 (darwin) Cancel-Lock: sha1:OlOycjqtqo8jPNbfoKDSkY543rc= X-Spam-Score: -1.9 (-) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:82006 Archived-At: 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