Gnus development mailing list
 help / color / mirror / Atom feed
* [PATCH] Don't handle spam when exiting a group without update
@ 2003-02-23 18:00 Michael Shields
  2003-02-24 16:02 ` Ted Zlatanov
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Shields @ 2003-02-23 18:00 UTC (permalink / raw)


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  <shields@msrl.com>

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




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

* Re: [PATCH] Don't handle spam when exiting a group without update
  2003-02-23 18:00 [PATCH] Don't handle spam when exiting a group without update Michael Shields
@ 2003-02-24 16:02 ` Ted Zlatanov
  0 siblings, 0 replies; 2+ messages in thread
From: Ted Zlatanov @ 2003-02-24 16:02 UTC (permalink / raw)


On Sun, 23 Feb 2003, shields@msrl.com wrote:
> 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.

Patch applied, thanks.

Ted



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

end of thread, other threads:[~2003-02-24 16:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-23 18:00 [PATCH] Don't handle spam when exiting a group without update Michael Shields
2003-02-24 16:02 ` 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).