From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.devel Subject: Proposed changes to gnus-dup.el Date: Mon, 25 Mar 2019 03:55:54 +0000 Message-ID: <8736nbip4l.fsf@tcd.ie> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="138743"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Eric Abrahamsen , Lars Ingebrigtsen To: Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Mar 25 05:07:04 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h8Gt3-000Zts-3l for ged-emacs-devel@m.gmane.org; Mon, 25 Mar 2019 05:07:01 +0100 Original-Received: from localhost ([127.0.0.1]:35911 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h8Gt1-0004u7-Gw for ged-emacs-devel@m.gmane.org; Mon, 25 Mar 2019 00:06:59 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:41058) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h8Gr0-0003oN-Vq for emacs-devel@gnu.org; Mon, 25 Mar 2019 00:04:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h8GiM-0006Lq-8G for emacs-devel@gnu.org; Sun, 24 Mar 2019 23:55:59 -0400 Original-Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]:34304) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h8GiL-0006Kh-SI for emacs-devel@gnu.org; Sun, 24 Mar 2019 23:55:58 -0400 Original-Received: by mail-ed1-x533.google.com with SMTP id x14so3601495eds.1 for ; Sun, 24 Mar 2019 20:55:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:user-agent:mime-version; bh=vyM9MW//YgjftaJVC+5M/Sx/psKkntp2KxJYcQXhzQ0=; b=E8lQHIF7u+Vws9H4Nzd2I8d1tqtYOJhbA+13XoG26uA2RocfZehFrOYIRc/u0WMdpJ NymD3HN0++lDlfLfSsBzg5BZN2B6d+mg2MdTAbUG9nc42/Amqy20qgWE8ldAAtYZDJjw NHzNjiDqm2MGu/q9mZrSFVaU+d15LO63U+r/3fUIU+wekl20pNAIUZ4JnvbQgyKhxXxG RVqSZxFN561rKPqAXcltiG1E/ghOR9wgc0C1186Hr96Gsx5ZbrRvkplJULEO/z3DyMxY 6OMVQNbI/f4N004AuiOKQjtzIslwbqogTeP5NvdnIN8+8d090VhLefSPpn/L8teQ0OzU hzAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:user-agent :mime-version; bh=vyM9MW//YgjftaJVC+5M/Sx/psKkntp2KxJYcQXhzQ0=; b=CWE79jgDpBM6COkPbWsAqztOdPCxxKMgEuFaeXK4Zfhu8TlKq0/o0JOHrzjY47iNuu bCDdZjfk2oZuViQ9P1aI6y9nnSLgkRAZWh67n5T3IDJ7gUA9WqLDoZDuCUMBleC/xHtp GjPbGyEWTsWV6X7jbQTpGFxmAIY5fqFLmm8t9A0ziXbGeWA96xFhrntVxVTFcf68U/8T Z2QyyImsCa83zy5RXQWbvpQyGPz6c2kALJPnppTfLOaArpTRuvkMA6vk2v7wpD7WogUE bSwFyl/dcQsxa0iZz9RySkdrm06RkvmNNnIvtlze5dbREP/WutyVZB0lxp4S9QfgUTEw ULTg== X-Gm-Message-State: APjAAAVLuAnDOXj4WlYqXOqQ9rcYa4AbGtQbTm6x3igPn7XhmDu2XKLc 97Uhj2xwL4DTzVfVpVQUZQfl6g7Ab7bR4A== X-Google-Smtp-Source: APXvYqyuYqvyyWkP+8BTNauw++DBIPpyFt6E/CNxbUbDBp/2tvO6Gf3JiLlcTFR0DELhLa1C/65+KA== X-Received: by 2002:a50:b0c6:: with SMTP id j64mr14790127edd.204.1553486156160; Sun, 24 Mar 2019 20:55:56 -0700 (PDT) Original-Received: from localhost ([2a02:8084:20e2:c380:f786:805d:f4ab:1006]) by smtp.gmail.com with ESMTPSA id b10sm4372762edt.76.2019.03.24.20.55.55 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 24 Mar 2019 20:55:55 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::533 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:234697 Archived-At: --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-lisp-gnus-gnus-dup.el-Use-lexical-binding.patch >From b360958263800408081fc5b7a92fb219c46a43a5 Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" 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 --=-=-= Content-Type: text/plain 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 --=-=-=--