diff options
| author | Basil L. Contovounesios | 2019-03-25 20:14:40 +0000 |
|---|---|---|
| committer | Basil L. Contovounesios | 2019-04-03 02:55:41 +0100 |
| commit | 2bd3e484041b2b7ea47c236b86f59610d971b609 (patch) | |
| tree | 33da485df75171902c7fee4852dbdf57d7846bc9 | |
| parent | e25e7d812f2f3f9a195b7b201b8bd99a5228b108 (diff) | |
| download | emacs-2bd3e484041b2b7ea47c236b86f59610d971b609.tar.gz emacs-2bd3e484041b2b7ea47c236b86f59610d971b609.zip | |
* lisp/gnus/gnus-dup.el: Use lexical-binding
(gnus-dup-list-dirty): Add docstring.
(gnus-dup-open): Allocate gnus-dup-hashtb more conservatively now
that it is no longer an obarray.
(gnus-dup-enter-articles): Fix off-by-one error.
(gnus-dup-suppress-articles): DRY.
For discussion, see thread starting at:
https://lists.gnu.org/archive/html/emacs-devel/2019-03/msg00974.html
| -rw-r--r-- | lisp/gnus/gnus-dup.el | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/lisp/gnus/gnus-dup.el b/lisp/gnus/gnus-dup.el index 8b876489e1c..49022124e97 100644 --- a/lisp/gnus/gnus-dup.el +++ b/lisp/gnus/gnus-dup.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; gnus-dup.el --- suppression of duplicate articles in Gnus | 1 | ;;; gnus-dup.el --- suppression of duplicate articles in Gnus -*- lexical-binding: t -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1996-2019 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1996-2019 Free Software Foundation, Inc. |
| 4 | 4 | ||
| @@ -57,10 +57,12 @@ seen in the same session." | |||
| 57 | 57 | ||
| 58 | (defvar gnus-dup-list nil | 58 | (defvar gnus-dup-list nil |
| 59 | "List of seen message IDs, as strings.") | 59 | "List of seen message IDs, as strings.") |
| 60 | |||
| 60 | (defvar gnus-dup-hashtb nil | 61 | (defvar gnus-dup-hashtb nil |
| 61 | "Hash table of seen message IDs, for fast lookup.") | 62 | "Hash table of seen message IDs, for fast lookup.") |
| 62 | 63 | ||
| 63 | (defvar gnus-dup-list-dirty nil) | 64 | (defvar gnus-dup-list-dirty nil |
| 65 | "Non-nil if `gnus-dup-list' needs to be saved.") | ||
| 64 | 66 | ||
| 65 | ;;; | 67 | ;;; |
| 66 | ;;; Starting and stopping | 68 | ;;; Starting and stopping |
| @@ -80,7 +82,7 @@ seen in the same session." | |||
| 80 | (if gnus-save-duplicate-list | 82 | (if gnus-save-duplicate-list |
| 81 | (gnus-dup-read) | 83 | (gnus-dup-read) |
| 82 | (setq gnus-dup-list nil)) | 84 | (setq gnus-dup-list nil)) |
| 83 | (setq gnus-dup-hashtb (gnus-make-hashtable gnus-duplicate-list-length)) | 85 | (setq gnus-dup-hashtb (gnus-make-hashtable)) |
| 84 | ;; Enter all Message-IDs into the hash table. | 86 | ;; Enter all Message-IDs into the hash table. |
| 85 | (dolist (g gnus-dup-list) | 87 | (dolist (g gnus-dup-list) |
| 86 | (puthash g t gnus-dup-hashtb))) | 88 | (puthash g t gnus-dup-hashtb))) |
| @@ -121,11 +123,13 @@ seen in the same session." | |||
| 121 | (not (gethash msgid gnus-dup-hashtb))) | 123 | (not (gethash msgid gnus-dup-hashtb))) |
| 122 | (push msgid gnus-dup-list) | 124 | (push msgid gnus-dup-list) |
| 123 | (puthash msgid t gnus-dup-hashtb)))) | 125 | (puthash msgid t gnus-dup-hashtb)))) |
| 124 | ;; Chop off excess Message-IDs from the list. | 126 | ;; Remove excess Message-IDs from the list and hash table. |
| 125 | (let ((end (nthcdr gnus-duplicate-list-length gnus-dup-list))) | 127 | (let* ((dups (cons nil gnus-dup-list)) |
| 128 | (end (nthcdr gnus-duplicate-list-length dups))) | ||
| 126 | (when end | 129 | (when end |
| 127 | (mapc (lambda (id) (remhash id gnus-dup-hashtb)) (cdr end)) | 130 | (mapc (lambda (id) (remhash id gnus-dup-hashtb)) (cdr end)) |
| 128 | (setcdr end nil)))) | 131 | (setcdr end nil)) |
| 132 | (setq gnus-dup-list (cdr dups)))) | ||
| 129 | 133 | ||
| 130 | (defun gnus-dup-suppress-articles () | 134 | (defun gnus-dup-suppress-articles () |
| 131 | "Mark duplicate articles as read." | 135 | "Mark duplicate articles as read." |
| @@ -137,10 +141,9 @@ seen in the same session." | |||
| 137 | number) | 141 | number) |
| 138 | (dolist (header gnus-newsgroup-headers) | 142 | (dolist (header gnus-newsgroup-headers) |
| 139 | (when (and (gethash (mail-header-id header) gnus-dup-hashtb) | 143 | (when (and (gethash (mail-header-id header) gnus-dup-hashtb) |
| 140 | (gnus-summary-article-unread-p (mail-header-number header))) | 144 | (setq number (mail-header-number header)) |
| 141 | (setq gnus-newsgroup-unreads | 145 | (gnus-summary-article-unread-p number)) |
| 142 | (delq (setq number (mail-header-number header)) | 146 | (setq gnus-newsgroup-unreads (delq number gnus-newsgroup-unreads)) |
| 143 | gnus-newsgroup-unreads)) | ||
| 144 | (if (not auto) | 147 | (if (not auto) |
| 145 | (push (cons number gnus-duplicate-mark) gnus-newsgroup-reads) | 148 | (push (cons number gnus-duplicate-mark) gnus-newsgroup-reads) |
| 146 | (push number gnus-newsgroup-expirable) | 149 | (push number gnus-newsgroup-expirable) |