From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/50318 Path: main.gmane.org!not-for-mail From: Michael Shields Newsgroups: gmane.emacs.gnus.general Subject: [PATCH] Don't handle spam when exiting a group without update Date: Sun, 23 Feb 2003 18:00:40 +0000 Organization: Mad Science Research Labs Sender: owner-ding@hpc.uh.edu Message-ID: <878yw67u7r.fsf@mulligatwani.msrl.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1046023287 23700 80.91.224.249 (23 Feb 2003 18:01:27 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 23 Feb 2003 18:01:27 +0000 (UTC) Return-path: Original-Received: from malifon.math.uh.edu ([129.7.128.13]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18n0RH-0006A2-00 for ; Sun, 23 Feb 2003 19:01:23 +0100 Original-Received: from sina.hpc.uh.edu ([129.7.128.10] ident=lists) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 18n0Qx-00038E-00; Sun, 23 Feb 2003 12:01:03 -0600 Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Sun, 23 Feb 2003 12:02:02 -0600 (CST) Original-Received: from sclp3.sclp.com (sclp3.sclp.com [66.230.238.2]) by sina.hpc.uh.edu (8.9.3/8.9.3) with SMTP id MAA02781 for ; Sun, 23 Feb 2003 12:01:47 -0600 (CST) Original-Received: (qmail 49785 invoked by alias); 23 Feb 2003 18:00:44 -0000 Original-Received: (qmail 49780 invoked from network); 23 Feb 2003 18:00:43 -0000 Original-Received: from challah.msrl.com (198.137.194.222) by 66.230.238.6 with SMTP; 23 Feb 2003 18:00:43 -0000 Original-Received: (qmail 3942 invoked from network); 23 Feb 2003 18:00:41 -0000 Original-Received: from localhost (HELO mulligatwani.msrl.com) (127.0.0.1) by localhost with SMTP; 23 Feb 2003 18:00:41 -0000 Original-To: ding@gnus.org Original-Lines: 205 User-Agent: Gnus/5.090016 (Oort Gnus v0.16) XEmacs/21.4 (Military Intelligence) Precedence: list X-Majordomo: 1.94.jlt7 Xref: main.gmane.org gmane.emacs.gnus.general:50318 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:50318 Currently spam processing is done even when a group is exited with `Q'. This patch fixes that and gives a variable that hooks can check, instead of just running all hooks except gnus-summary-expire-articles. The spam.el patch is one new line of code, plus indentation change. lisp/ChangeLog addition: 2003-02-23 Michael Shields * gnus-group.el (gnus-group-is-exiting-without-update-p): New. * gnus-sum.el (gnus-summary-exit-no-update): Use it. * gnus-sum.el (gnus-summary-expire-articles): Use it. * spam.el (spam-summary-prepare-exit): Use it. gnus source patch: Diff command: cvs -q diff -u Files affected: lisp/spam.el lisp/gnus-sum.el lisp/gnus-group.el Index: lisp/gnus-group.el =================================================================== RCS file: /usr/local/cvsroot/gnus/lisp/gnus-group.el,v retrieving revision 6.101 diff -u -r6.101 gnus-group.el --- lisp/gnus-group.el 14 Feb 2003 20:28:13 -0000 6.101 +++ lisp/gnus-group.el 23 Feb 2003 18:12:20 -0000 @@ -445,6 +445,7 @@ ;;; Internal variables (defvar gnus-group-is-exiting-p nil) +(defvar gnus-group-is-exiting-without-update-p nil) (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat "Function for sorting the group buffer.") Index: lisp/gnus-sum.el =================================================================== RCS file: /usr/local/cvsroot/gnus/lisp/gnus-sum.el,v retrieving revision 6.314 diff -u -r6.314 gnus-sum.el --- lisp/gnus-sum.el 23 Feb 2003 00:09:28 -0000 6.314 +++ lisp/gnus-sum.el 23 Feb 2003 18:12:30 -0000 @@ -6467,14 +6467,13 @@ (interactive) (let* ((group gnus-newsgroup-name) (gnus-group-is-exiting-p t) + (gnus-group-is-exiting-without-update-p t) (quit-config (gnus-group-quit-config group))) (when (or no-questions gnus-expert-user (gnus-y-or-n-p "Discard changes to this group and exit? ")) (gnus-async-halt-prefetch) - (mapcar 'funcall - (delq 'gnus-summary-expire-articles - (copy-sequence gnus-summary-prepare-exit-hook))) + (run-hooks 'gnus-summary-prepare-exit-hook) (when (gnus-buffer-live-p gnus-article-buffer) (save-excursion (set-buffer gnus-article-buffer) @@ -9062,8 +9061,9 @@ (defun gnus-summary-expire-articles (&optional now) "Expire all articles that are marked as expirable in the current group." (interactive) - (when (gnus-check-backend-function - 'request-expire-articles gnus-newsgroup-name) + (when (and (not gnus-group-is-exiting-without-update-p) + (gnus-check-backend-function + 'request-expire-articles gnus-newsgroup-name)) ;; This backend supports expiry. (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name)) (expirable (if total Index: lisp/spam.el =================================================================== RCS file: /usr/local/cvsroot/gnus/lisp/spam.el,v retrieving revision 6.71 diff -u -r6.71 spam.el --- lisp/spam.el 20 Feb 2003 00:39:05 -0000 6.71 +++ lisp/spam.el 23 Feb 2003 18:12:31 -0000 @@ -343,62 +359,69 @@ (add-hook 'gnus-summary-prepare-hook 'spam-summary-prepare) +;; The spam processors are invoked for any group, spam or ham or neither (defun spam-summary-prepare-exit () - ;; The spam processors are invoked for any group, spam or ham or neither - (gnus-message 6 "Exiting summary buffer and applying spam rules") - (when (and spam-bogofilter-path - (spam-group-spam-processor-bogofilter-p gnus-newsgroup-name)) - (gnus-message 5 "Registering spam with bogofilter") - (spam-bogofilter-register-spam-routine)) + (unless gnus-group-is-exiting-without-update-p - (when (and spam-ifile-path - (spam-group-spam-processor-ifile-p gnus-newsgroup-name)) - (gnus-message 5 "Registering spam with ifile") - (spam-ifile-register-spam-routine)) + (gnus-message 6 "Exiting summary buffer and applying spam rules") + (when (and spam-bogofilter-path + (spam-group-spam-processor-bogofilter-p gnus-newsgroup-name)) + (gnus-message 5 "Registering spam with bogofilter") + (spam-bogofilter-register-spam-routine)) - (when (spam-group-spam-processor-stat-p gnus-newsgroup-name) - (gnus-message 5 "Registering spam with spam-stat") - (spam-stat-register-spam-routine)) - - (when (spam-group-spam-processor-blacklist-p gnus-newsgroup-name) - (gnus-message 5 "Registering spam with the blacklist") - (spam-blacklist-register-routine)) - - (if spam-move-spam-nonspam-groups-only - (when (not (spam-group-spam-contents-p gnus-newsgroup-name)) - (spam-mark-spam-as-expired-and-move-routine - (gnus-parameter-spam-process-destination gnus-newsgroup-name))) - (gnus-message 5 "Marking spam as expired and moving it to %s" gnus-newsgroup-name) - (spam-mark-spam-as-expired-and-move-routine - (gnus-parameter-spam-process-destination gnus-newsgroup-name))) - - ;; now we redo spam-mark-spam-as-expired-and-move-routine to only - ;; expire spam, in case the above did not expire them - (gnus-message 5 "Marking spam as expired without moving it") - (spam-mark-spam-as-expired-and-move-routine nil) - - (when (spam-group-ham-contents-p gnus-newsgroup-name) - (when (spam-group-ham-processor-whitelist-p gnus-newsgroup-name) - (gnus-message 5 "Registering ham with the whitelist") - (spam-whitelist-register-routine)) - (when (spam-group-ham-processor-ifile-p gnus-newsgroup-name) - (gnus-message 5 "Registering ham with ifile") - (spam-ifile-register-ham-routine)) - (when (spam-group-ham-processor-bogofilter-p gnus-newsgroup-name) - (gnus-message 5 "Registering ham with Bogofilter") - (spam-bogofilter-register-ham-routine)) - (when (spam-group-ham-processor-stat-p gnus-newsgroup-name) - (gnus-message 5 "Registering ham with spam-stat") - (spam-stat-register-ham-routine)) - (when (spam-group-ham-processor-BBDB-p gnus-newsgroup-name) - (gnus-message 5 "Registering ham with the BBDB") - (spam-BBDB-register-routine))) - - ;; now move all ham articles out of spam groups - (when (spam-group-spam-contents-p gnus-newsgroup-name) - (gnus-message 5 "Moving ham messages from spam group") - (spam-ham-move-routine - (gnus-parameter-ham-process-destination gnus-newsgroup-name)))) + (when (and spam-ifile-path + (spam-group-spam-processor-ifile-p gnus-newsgroup-name)) + (gnus-message 5 "Registering spam with ifile") + (spam-ifile-register-spam-routine)) + + (when (spam-group-spam-processor-stat-p gnus-newsgroup-name) + (gnus-message 5 "Registering spam with spam-stat") + (spam-stat-register-spam-routine)) + + (when (spam-group-spam-processor-blacklist-p gnus-newsgroup-name) + (gnus-message 5 "Registering spam with the blacklist") + (spam-blacklist-register-routine)) + + (if spam-move-spam-nonspam-groups-only + (when (not (spam-group-spam-contents-p gnus-newsgroup-name)) + (spam-mark-spam-as-expired-and-move-routine + (gnus-parameter-spam-process-destination gnus-newsgroup-name))) + (gnus-message 5 "Marking spam as expired and moving it to %s" gnus-newsgroup-name) + (spam-mark-spam-as-expired-and-move-routine + (gnus-parameter-spam-process-destination gnus-newsgroup-name))) + + ;; now we redo spam-mark-spam-as-expired-and-move-routine to only + ;; expire spam, in case the above did not expire them + (gnus-message 5 "Marking spam as expired without moving it") + (spam-mark-spam-as-expired-and-move-routine nil) + + (when (spam-group-ham-contents-p gnus-newsgroup-name) + (when (spam-group-ham-processor-whitelist-p gnus-newsgroup-name) + (gnus-message 5 "Registering ham with the whitelist") + (spam-whitelist-register-routine)) + (when (spam-group-ham-processor-ifile-p gnus-newsgroup-name) + (gnus-message 5 "Registering ham with ifile") + (spam-ifile-register-ham-routine)) + (when (spam-group-ham-processor-bogofilter-p gnus-newsgroup-name) + (gnus-message 5 "Registering ham with Bogofilter") + (spam-bogofilter-register-ham-routine)) + (when (spam-group-ham-processor-stat-p gnus-newsgroup-name) + (gnus-message 5 "Registering ham with spam-stat") + (spam-stat-register-ham-routine)) + (when (spam-group-ham-processor-BBDB-p gnus-newsgroup-name) + (gnus-message 5 "Registering ham with the BBDB") + (spam-BBDB-register-routine))) + + (when (spam-group-ham-processor-copy-p gnus-newsgroup-name) + (gnus-message 5 "Copying ham") + (spam-ham-move-routine + (gnus-parameter-ham-process-destination gnus-newsgroup-name) t)) + + ;; now move all ham articles out of spam groups + (when (spam-group-spam-contents-p gnus-newsgroup-name) + (gnus-message 5 "Moving ham messages from spam group") + (spam-ham-move-routine + (gnus-parameter-ham-process-destination gnus-newsgroup-name))))) (add-hook 'gnus-summary-prepare-exit-hook 'spam-summary-prepare-exit) -- Shields.