From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 18936 invoked from network); 30 Nov 2020 20:17:17 -0000 Received: from mx1.math.uh.edu (129.7.128.32) by inbox.vuxu.org with ESMTPUTF8; 30 Nov 2020 20:17:17 -0000 Received: from lists1.math.uh.edu ([129.7.128.208]) by mx1.math.uh.edu with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1kjpaN-00FYFy-CP; Mon, 30 Nov 2020 14:15:47 -0600 Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by lists1.math.uh.edu with smtp (Exim 4.94) (envelope-from ) id 1kjpaM-00EQ9V-8l; Mon, 30 Nov 2020 14:15:46 -0600 Received: from mx2.math.uh.edu ([129.7.128.33]) by lists1.math.uh.edu with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1kjpaH-00EQ7q-Ne for ding@lists.math.uh.edu; Mon, 30 Nov 2020 14:15:41 -0600 Received: from quimby.gnus.org ([95.216.78.240]) by mx2.math.uh.edu with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1kjpaE-004QsI-9Y for ding@lists.math.uh.edu; Mon, 30 Nov 2020 14:15:41 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Cc:Content-Type:Mime-Version:Message-ID:Date:Subject:From:To: Sender:Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=DHw0bIFgvCfIRSDW3g6dLv8C2bfyr5JuNbfzTNVWjk4=; b=o8ZLRzF+pKu9+KgQgp5OzJU1/Z 6sBupTJtS0h9cp97DBQ7c2DkZCVTYLvMixXq+3JCi+gclIy+DC1oi0Ig09zVJW5nea+DvHRX1F3Wl 3dP29y+/GyLXA2fLhsRAFOT7rhaciaSFRr18xg+PeEGy77FfRpkrlWrXCVLjaQSjZEkg=; Received: from static.214.254.202.116.clients.your-server.de ([116.202.254.214] helo=ciao.gmane.io) by quimby.gnus.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kjpa4-0004rF-Pn for ding@gnus.org; Mon, 30 Nov 2020 21:15:33 +0100 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1kjpa2-0008Dk-Rl for ding@gnus.org; Mon, 30 Nov 2020 21:15:26 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: ding@gnus.org From: Eric Abrahamsen Subject: Don't default to making registry entries for all articles Date: Mon, 30 Nov 2020 12:15:19 -0800 Message-ID: <87360qsiso.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Ted Zlatanov Cancel-Lock: sha1:pqq/zEszskZGliio0hee3KPrssA= List-ID: Precedence: bulk --=-=-= Content-Type: text/plain Hi all, I've been thinking about how to do this for a while, and think I've got an okay approach. The Gnus registry registers everything by default, which slows down summary buffer creation, and also saving Gnus. The only time you'd actually want everything registered is if you're splitting using `gnus-registry-split-fancy-with-parent', which I have to imagine is a minority of users. The attached patch lets you change this behavior so the registry only creates and saves entries that you have made manually, either by setting a mark on an article, or via some other library. It does this with a new defcustom, `gnus-registry-register-all-p', which I'd like to default to nil. If this is nil, `gnus-registry-register-message-ids' won't do anything. The patch also adds an optional NO-CREATE argument to `gnus-registry-get-or-make-entry', to tell it to only get, not make. Lastly it has `gnus-registry-get-id-key' set that flag to t, so getting an id key doesn't create a new entry (while setting an id key does). This last change makes everything else work correctly (spooling and handling actions) but is also a fairly fundamental change, so I'm hoping others will look at it closely. If this is okay, there's also quite a few manual/docs/comments/NEWS tweaks to make. Please help test! Eric --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=gnus-registry-no-register.diff diff --git a/lisp/gnus/gnus-registry.el b/lisp/gnus/gnus-registry.el index 65bcd0e8a3..d7f8002745 100644 --- a/lisp/gnus/gnus-registry.el +++ b/lisp/gnus/gnus-registry.el @@ -160,6 +160,10 @@ gnus-registry-install (const :tag "Always Install" t) (const :tag "Ask Me" ask))) +(defcustom gnus-registry-register-all-p nil + "If non-nil, register all articles in the registry." + :type 'boolean) + (defvar gnus-registry-enabled nil) (defvar gnus-summary-misc-menu) ;; Avoid byte compiler warning. @@ -478,8 +482,8 @@ gnus-registry-handle-action (let ((db gnus-registry-db) ;; if the group is ignored, set the destination to nil (same as delete) (to (if (gnus-registry-ignore-group-p to) nil to)) - ;; safe if not found - (entry (gnus-registry-get-or-make-entry id)) + ;; Only retrieve an existing entry, don't create a new one. + (entry (gnus-registry-get-or-make-entry id t)) (subject (gnus-string-remove-all-properties (gnus-registry-simplify-subject subject))) (sender (gnus-string-remove-all-properties sender))) @@ -488,29 +492,30 @@ gnus-registry-handle-action ;; several times but it's better to bunch the transactions ;; together - (registry-delete db (list id) nil) - (when from - (setq entry (cons (delete from (assoc 'group entry)) - (assq-delete-all 'group entry)))) - ;; Only keep the entry if the message is going to a new group, or - ;; it's still in some previous group. - (when (or to (alist-get 'group entry)) - (dolist (kv `((group ,to) - (sender ,sender) - (recipient ,@recipients) - (subject ,subject))) - (when (cadr kv) - (let ((new (or (assq (car kv) entry) - (list (car kv))))) - (dolist (toadd (cdr kv)) - (unless (member toadd new) - (setq new (append new (list toadd))))) - (setq entry (cons new - (assq-delete-all (car kv) entry)))))) - (gnus-message 10 "Gnus registry: new entry for %s is %S" - id - entry) - (gnus-registry-insert db id entry)))) + (when entry + (registry-delete db (list id) nil) + (when from + (setq entry (cons (delete from (assoc 'group entry)) + (assq-delete-all 'group entry)))) + ;; Only keep the entry if the message is going to a new group, or + ;; it's still in some previous group. + (when (or to (alist-get 'group entry)) + (dolist (kv `((group ,to) + (sender ,sender) + (recipient ,@recipients) + (subject ,subject))) + (when (cadr kv) + (let ((new (or (assq (car kv) entry) + (list (car kv))))) + (dolist (toadd (cdr kv)) + (unless (member toadd new) + (setq new (append new (list toadd))))) + (setq entry (cons new + (assq-delete-all (car kv) entry)))))) + (gnus-message 10 "Gnus registry: new entry for %s is %S" + id + entry) + (gnus-registry-insert db id entry))))) ;; Function for nn{mail|imap}-split-fancy: look up all references in ;; the cache and if a match is found, return that group. @@ -846,7 +851,8 @@ gnus-registry-find-keywords (defun gnus-registry-register-message-ids () "Register the Message-ID of every article in the group." - (unless (gnus-parameter-registry-ignore gnus-newsgroup-name) + (unless (or (gnus-parameter-registry-ignore gnus-newsgroup-name) + (null gnus-registry-register-all-p)) (dolist (article gnus-newsgroup-articles) (let* ((id (gnus-registry-fetch-message-id-fast article)) (groups (gnus-registry-get-id-key id 'group))) @@ -1082,12 +1088,15 @@ gnus-registry-group-count "Get the number of groups of a message, based on the message ID." (length (gnus-registry-get-id-key id 'group))) -(defun gnus-registry-get-or-make-entry (id) +(defun gnus-registry-get-or-make-entry (id &optional no-create) + "Return registry entry for ID. +If entry is not found, create a new one, unless NO-create is +non-nil." (let* ((db gnus-registry-db) ;; safe if not found (entries (registry-lookup db (list id)))) - (when (null entries) + (unless (or entries no-create) (gnus-registry-insert db id (list (list 'creation-time (current-time)) '(group) '(sender) '(subject))) (setq entries (registry-lookup db (list id)))) @@ -1098,7 +1107,7 @@ gnus-registry-delete-entries (registry-delete gnus-registry-db idlist nil)) (defun gnus-registry-get-id-key (id key) - (cdr-safe (assq key (gnus-registry-get-or-make-entry id)))) + (cdr-safe (assq key (gnus-registry-get-or-make-entry id t)))) (defun gnus-registry-set-id-key (id key vals) (let* ((db gnus-registry-db) --=-=-=--