From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.bugs Subject: bug#45033: 28.0.50; New option gnus-registery-register-all-p Date: Thu, 03 Dec 2020 16:10:24 -0800 Message-ID: <87tut24ej3.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13583"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) To: 45033@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Dec 04 01:11:12 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kkygp-0003PA-Lg for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 04 Dec 2020 01:11:11 +0100 Original-Received: from localhost ([::1]:51312 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kkygo-0002TU-4h for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 03 Dec 2020 19:11:10 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35126) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kkygg-0002TM-5b for bug-gnu-emacs@gnu.org; Thu, 03 Dec 2020 19:11:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58910) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kkygf-0002WN-UC for bug-gnu-emacs@gnu.org; Thu, 03 Dec 2020 19:11:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kkygf-0002o2-OF for bug-gnu-emacs@gnu.org; Thu, 03 Dec 2020 19:11:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eric Abrahamsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 04 Dec 2020 00:11:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 45033 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.160704063410730 (code B ref -1); Fri, 04 Dec 2020 00:11:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 4 Dec 2020 00:10:34 +0000 Original-Received: from localhost ([127.0.0.1]:42214 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kkygD-0002mz-NA for submit@debbugs.gnu.org; Thu, 03 Dec 2020 19:10:34 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:45456) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kkygB-0002mr-1l for submit@debbugs.gnu.org; Thu, 03 Dec 2020 19:10:31 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35026) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kkygA-0002SJ-RD for bug-gnu-emacs@gnu.org; Thu, 03 Dec 2020 19:10:30 -0500 Original-Received: from ericabrahamsen.net ([52.70.2.18]:52404 helo=mail.ericabrahamsen.net) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kkyg7-0002GN-O7 for bug-gnu-emacs@gnu.org; Thu, 03 Dec 2020 19:10:30 -0500 Original-Received: from localhost (97-113-36-145.tukw.qwest.net [97.113.36.145]) (Authenticated sender: eric@ericabrahamsen.net) by mail.ericabrahamsen.net (Postfix) with ESMTPSA id 44E9DFA094 for ; Fri, 4 Dec 2020 00:10:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericabrahamsen.net; s=mail; t=1607040626; bh=6UfM9scVetRAbsQH85BvZXhNblUeqv3lOtKMEs4hkj4=; h=From:To:Subject:Date:From; b=XOOayvM/Hg0X8yzKBXteoGKeeSd8ZCZmdQNKPvAir7zTIUBL0FlMyrhbE/Uu7xOgQ EMGaGKCr1qEobxIAFZ4YsiNlKG1+wBQ5A34So4Y80P4Ux46LcVImsChMqULiEdUJVj PTlqMOuyt8uSXPROCTYBYS1+hd2rILEOROHtbb+E= Received-SPF: pass client-ip=52.70.2.18; envelope-from=eric@ericabrahamsen.net; helo=mail.ericabrahamsen.net X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:194931 Archived-At: --=-=-= Content-Type: text/plain The Gnus registry keeps track of all received messages in a series of databases, and allows the user to split follow-up messages into the same group as the parent, as well as associate It currently creates database entries for all messages, which slows down summary buffer creation, as well as Gnus' saving process. This patch introduces a new customization option, `gnus-registry-register-all-p', which, when nil, won't create database entries automatically. The registry will only contain entries that the user (or other packages) has created manually. If the user isn't using automatic splitting, this can provide a significant speedup for general Gnus usage. Discussions on gnus.general lead me to believe that universal splitting isn't used all that often, and that most users are very surprised to find that they have a 50MB registry file on disk. Therefore I've defaulted this option to nil, which is a change from previous behavior. It would be perfectly easy to default to t if this seems inappropriate. Eric --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-New-option-gnus-registry-register-all-p-default-to-n.patch >From a3083ea18bee87c805e4ef1b7883171e0bbb66ce Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen Date: Thu, 3 Dec 2020 15:58:57 -0800 Subject: [PATCH] New option gnus-registry-register-all-p, default to nil * lisp/gnus/gnus-registry.el (gnus-registry-register-all-p): If nil, the registry won't automatically create new entries for all seen messages. (gnus-registry-handle-action): Don't automatically create entries; if one doesn't exist, don't handle anything. (gnus-registry-register-message-ids): Only register if this option is t. (gnus-registry-get-or-make-entry): Add optional no-create argument. (gnus-registry-get-id-key): This "get" operation should only create an entry if this option is t. * doc/misc/gnus.texi: Documentation and news. --- doc/misc/gnus.texi | 24 +++++++++++-- etc/NEWS | 8 +++++ lisp/gnus/gnus-registry.el | 72 +++++++++++++++++++++++--------------- 3 files changed, 72 insertions(+), 32 deletions(-) diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi index 4aa07ce388..f1696bf58d 100644 --- a/doc/misc/gnus.texi +++ b/doc/misc/gnus.texi @@ -26260,6 +26260,16 @@ Gnus Registry Setup size, it will reject insertion of new entries. @end defvar +@defvar gnus-registry-register-all-p +If this option is non-nil, the registry will register all messages, as +you see them. This is important to making split-to-parent and +Message-ID references work correctly, as the registry needs to know +where all messages are. But it can slow down group opening, and the +saving of Gnus, so it is nil by default. This means entries must be +created manually, for instance by storing a custom flag or keyword for +the message. +@end defvar + @defvar gnus-registry-prune-factor This option (a float between 0 and 1) controls how much the registry is cut back during pruning. In order to prevent constant pruning, the @@ -26349,8 +26359,14 @@ Fancy splitting to parent "mail") @end lisp -in your fancy split setup. In addition, you may want to customize the -following variables. +in your fancy split setup. + +If @code{gnus-registry-register-all-p} is non-nil, the registry will +perform splitting for all messages. If it is nil (the default), +splitting will only happen for children of messages you've explicitly +registered. + +In addition, you may want to customize the following variables. @defvar gnus-registry-track-extra This is a list of symbols, so it's best to change it from the @@ -26423,7 +26439,9 @@ Store arbitrary data @end defun @defun gnus-registry-get-id-key (id key) -Get the data under @code{key} for message @code{id}. +Get the data under @code{key} for message @code{id}. If the option +@code{gnus-registry-register-all-p} is non-nil, this function will also +create an entry for @code{id} if one doesn't exist. @end defun @defvar gnus-registry-extra-entries-precious diff --git a/etc/NEWS b/etc/NEWS index c9da296278..0782515401 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -488,6 +488,14 @@ tags to be considered as well. ** Gnus ++++ +*** New user option 'gnus-registry-register-all-p'. + +If non-nil, create registry entries for all messages. If nil (the +default), don't automatically create entries, they must be created +manually. This is a change from the previous default behavior, which +always created entries. + +++ *** New user option 'gnus-paging-select-next'. This controls what happens when using commands like 'SPC' and 'DEL' to diff --git a/lisp/gnus/gnus-registry.el b/lisp/gnus/gnus-registry.el index 65bcd0e8a3..b4b158bd02 100644 --- a/lisp/gnus/gnus-registry.el +++ b/lisp/gnus/gnus-registry.el @@ -54,6 +54,9 @@ ;; (: gnus-registry-split-fancy-with-parent) +;; This won't work as expected unless `gnus-registry-register-all-p' +;; is set to t. + ;; You should also consider using the nnregistry backend to look up ;; articles. See the Gnus manual for more information. @@ -160,6 +163,11 @@ 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 + :version "28.1") + (defvar gnus-registry-enabled nil) (defvar gnus-summary-misc-menu) ;; Avoid byte compiler warning. @@ -478,8 +486,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 +496,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 +855,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 +1092,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 +1111,8 @@ 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 (null gnus-registry-register-all-p))))) (defun gnus-registry-set-id-key (id key vals) (let* ((db gnus-registry-db) -- 2.29.2 --=-=-=--