From: "Basil L. Contovounesios" <contovob@tcd.ie>
To: <emacs-devel@gnu.org>
Cc: Eric Abrahamsen <eric@ericabrahamsen.net>,
Lars Ingebrigtsen <larsi@gnus.org>
Subject: Proposed changes to gnus-dup.el
Date: Mon, 25 Mar 2019 03:55:54 +0000 [thread overview]
Message-ID: <8736nbip4l.fsf@tcd.ie> (raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: 0001-lisp-gnus-gnus-dup.el-Use-lexical-binding.patch --]
[-- Type: text/x-diff, Size: 3911 bytes --]
From b360958263800408081fc5b7a92fb219c46a43a5 Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob@tcd.ie>
Date: Mon, 25 Mar 2019 02:22:58 +0000
Subject: [PATCH] * 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 and De Morgan.
(gnus-dup-suppress-articles): DRY.
---
lisp/gnus/gnus-dup.el | 37 ++++++++++++++++++++-----------------
1 file changed, 20 insertions(+), 17 deletions(-)
diff --git a/lisp/gnus/gnus-dup.el b/lisp/gnus/gnus-dup.el
index 8b876489e1..e2de5d0c8e 100644
--- a/lisp/gnus/gnus-dup.el
+++ b/lisp/gnus/gnus-dup.el
@@ -1,4 +1,4 @@
-;;; 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.
@@ -57,10 +57,12 @@ gnus-duplicate-file
(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
@@ -80,7 +82,7 @@ gnus-dup-open
(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)))
@@ -112,20 +114,22 @@ gnus-dup-enter-articles
;; Enter the Message-IDs of all read articles into the list
;; and hash table.
(dolist (datum gnus-newsgroup-data)
- (when (and (not (gnus-data-pseudo-p datum))
- (> (gnus-data-number datum) 0)
- (not (memq (gnus-data-number datum) gnus-newsgroup-unreads))
- (not (= (gnus-data-mark datum) gnus-canceled-mark))
- (setq msgid (mail-header-id (gnus-data-header datum)))
- (not (nnheader-fake-message-id-p msgid))
- (not (gethash msgid gnus-dup-hashtb)))
+ (unless (or (gnus-data-pseudo-p datum)
+ (<= (gnus-data-number datum) 0)
+ (memq (gnus-data-number datum) gnus-newsgroup-unreads)
+ (= (gnus-data-mark datum) gnus-canceled-mark)
+ (not (setq msgid (mail-header-id (gnus-data-header datum))))
+ (nnheader-fake-message-id-p msgid)
+ (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."
@@ -137,10 +141,9 @@ gnus-dup-suppress-articles
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)
--
2.20.1
[-- Attachment #2: Type: text/plain, Size: 182 bytes --]
While looking into bug#34973, bug#34974, and bug#34987, I accumulated
the attached changes to lisp/gnus/gnus-dup.el which I would like to push
to master. WDYT?
Thanks,
--
Basil
next reply other threads:[~2019-03-25 3:55 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-25 3:55 Basil L. Contovounesios [this message]
2019-03-25 15:59 ` Proposed changes to gnus-dup.el Andy Moreton
2019-03-25 16:50 ` Stefan Monnier
2019-03-25 17:33 ` Basil L. Contovounesios
2019-03-27 17:57 ` Andy Moreton
2019-03-27 18:42 ` Stefan Monnier
2019-03-31 21:47 ` Basil L. Contovounesios
2019-03-25 17:33 ` Basil L. Contovounesios
2019-03-25 17:55 ` Tadeus Prastowo
2019-03-25 18:13 ` Eric Abrahamsen
2019-03-25 18:14 ` Basil L. Contovounesios
2019-03-25 17:42 ` Lars Ingebrigtsen
2019-03-25 18:13 ` Basil L. Contovounesios
2019-03-25 18:15 ` Eric Abrahamsen
2019-03-25 18:27 ` Basil L. Contovounesios
2019-04-01 23:43 ` Basil L. Contovounesios
2019-04-03 1:49 ` Eric Abrahamsen
2019-04-03 1:59 ` Basil L. Contovounesios
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8736nbip4l.fsf@tcd.ie \
--to=contovob@tcd.ie \
--cc=emacs-devel@gnu.org \
--cc=eric@ericabrahamsen.net \
--cc=larsi@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).