-;;; gnus-dup.el --- suppression of duplicate articles in Gnus
+;;; gnus-dup.el --- suppression of duplicate articles in Gnus -*- lexical-binding: t -*-
;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
(defvar gnus-dup-list nil
"List of seen message IDs, as strings.")
+
(defvar gnus-dup-hashtb nil
"Hash table of seen message IDs, for fast lookup.")
-(defvar gnus-dup-list-dirty nil)
+(defvar gnus-dup-list-dirty nil
+ "Non-nil if `gnus-dup-list' needs to be saved.")
;;;
;;; Starting and stopping
(if gnus-save-duplicate-list
(gnus-dup-read)
(setq gnus-dup-list nil))
- (setq gnus-dup-hashtb (gnus-make-hashtable gnus-duplicate-list-length))
+ (setq gnus-dup-hashtb (gnus-make-hashtable))
;; Enter all Message-IDs into the hash table.
(dolist (g gnus-dup-list)
(puthash g t gnus-dup-hashtb)))
(not (gethash msgid gnus-dup-hashtb)))
(push msgid gnus-dup-list)
(puthash msgid t gnus-dup-hashtb))))
- ;; Chop off excess Message-IDs from the list.
- (let ((end (nthcdr gnus-duplicate-list-length gnus-dup-list)))
+ ;; Remove excess Message-IDs from the list and hash table.
+ (let* ((dups (cons nil gnus-dup-list))
+ (end (nthcdr gnus-duplicate-list-length dups)))
(when end
(mapc (lambda (id) (remhash id gnus-dup-hashtb)) (cdr end))
- (setcdr end nil))))
+ (setcdr end nil))
+ (setq gnus-dup-list (cdr dups))))
(defun gnus-dup-suppress-articles ()
"Mark duplicate articles as read."
number)
(dolist (header gnus-newsgroup-headers)
(when (and (gethash (mail-header-id header) gnus-dup-hashtb)
- (gnus-summary-article-unread-p (mail-header-number header)))
- (setq gnus-newsgroup-unreads
- (delq (setq number (mail-header-number header))
- gnus-newsgroup-unreads))
+ (setq number (mail-header-number header))
+ (gnus-summary-article-unread-p number))
+ (setq gnus-newsgroup-unreads (delq number gnus-newsgroup-unreads))
(if (not auto)
(push (cons number gnus-duplicate-mark) gnus-newsgroup-reads)
(push number gnus-newsgroup-expirable)