(gnus-read-ephemeral-bug-group)
[gnus] / lisp / gnus-dup.el
index 5a2802d..73b183f 100644 (file)
@@ -1,14 +1,16 @@
 ;;; gnus-dup.el --- suppression of duplicate articles in Gnus
-;; Copyright (C) 1996 Free Software Foundation, Inc.
 
-;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
+;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+;;   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+
+;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;; Keywords: news
 
 ;; This file is part of GNU Emacs.
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -18,8 +20,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
 
 ;;; Code:
 
-(require 'gnus-load)
-(require 'gnus-art)
+(eval-when-compile (require 'cl))
+
 (require 'gnus)
+(require 'gnus-art)
+
+(defgroup gnus-duplicate nil
+  "Suppression of duplicate articles."
+  :group 'gnus)
 
-(defvar gnus-save-duplicate-list nil
+(defcustom gnus-save-duplicate-list nil
   "*If non-nil, save the duplicate list when shutting down Gnus.
 If nil, duplicate suppression will only work on duplicates
-seen in the same session.")
+seen in the same session."
+  :group 'gnus-duplicate
+  :type 'boolean)
 
-(defvar gnus-duplicate-list-length 10000
-  "*The number of Message-IDs to keep in the duplicate suppression list.")
+(defcustom gnus-duplicate-list-length 10000
+  "*The number of Message-IDs to keep in the duplicate suppression list."
+  :group 'gnus-duplicate
+  :type 'integer)
 
-(defvar gnus-duplicate-file (nnheader-concat gnus-directory "suppression")
-  "*The name of the file to store the duplicate suppression list.")
+(defcustom gnus-duplicate-file (nnheader-concat gnus-directory "suppression")
+  "*The name of the file to store the duplicate suppression list."
+  :group 'gnus-duplicate
+  :type 'file)
 
 ;;; Internal variables
 
@@ -72,10 +85,8 @@ seen in the same session.")
     (setq gnus-dup-list nil))
   (setq gnus-dup-hashtb (gnus-make-hashtable gnus-duplicate-list-length))
   ;; Enter all Message-IDs into the hash table.
-  (let ((list gnus-dup-list)
-       (obarray gnus-dup-hashtb))
-    (while list 
-      (intern (pop list)))))
+  (let ((obarray gnus-dup-hashtb))
+    (mapc 'intern gnus-dup-list)))
 
 (defun gnus-dup-read ()
   "Read the duplicate suppression list."
@@ -87,7 +98,7 @@ seen in the same session.")
   "Save the duplicate suppression list."
   (when (and gnus-save-duplicate-list
             gnus-dup-list-dirty)
-    (nnheader-temp-write gnus-duplicate-file
+    (with-temp-file gnus-duplicate-file
       (gnus-prin1 `(setq gnus-dup-list ',gnus-dup-list))))
   (setq gnus-dup-list-dirty nil))
 
@@ -100,21 +111,23 @@ seen in the same session.")
   (unless gnus-dup-list
     (gnus-dup-open))
   (setq gnus-dup-list-dirty t)         ; mark list for saving
-  (let ((data gnus-newsgroup-data)
-       datum)
+  (let (msgid)
     ;; Enter the Message-IDs of all read articles into the list
     ;; and hash table.
-    (while (setq datum (pop data))
+    (dolist (datum gnus-newsgroup-data)
       (when (and (not (gnus-data-pseudo-p datum))
-                (gnus-data-read-p datum)
-                (not (intern-soft (mail-header-id (gnus-data-header datum))
-                                  gnus-dup-hashtb)))
-       (intern (car (push (mail-header-id (gnus-data-header datum))
-                          gnus-dup-list))
-               gnus-dup-hashtb))))
+                (> (gnus-data-number datum) 0)
+                (not (memq (gnus-data-number