diff options
| author | Eric Abrahamsen | 2020-12-03 15:58:57 -0800 |
|---|---|---|
| committer | Eric Abrahamsen | 2020-12-12 09:03:13 -0800 |
| commit | 8a220d7c8f30fda7239c1dbf7522e0170ef53527 (patch) | |
| tree | d0d2d98eb350199610ecf5799f12c3c60c0a5a14 | |
| parent | b1f2eada47adda8349e6f1ef55dfd7a3ed60e6aa (diff) | |
| download | emacs-8a220d7c8f30fda7239c1dbf7522e0170ef53527.tar.gz emacs-8a220d7c8f30fda7239c1dbf7522e0170ef53527.zip | |
New option gnus-registry-register-all
* lisp/gnus/gnus-registry.el (gnus-registry-register-all): If nil,
the registry won't automatically create new entries for all seen
messages. Defaults to t to preserve previous behavior.
(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.
| -rw-r--r-- | doc/misc/gnus.texi | 24 | ||||
| -rw-r--r-- | etc/NEWS | 7 | ||||
| -rw-r--r-- | lisp/gnus/gnus-registry.el | 72 |
3 files changed, 71 insertions, 32 deletions
diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi index cfd3ceda3ff..3743b497da8 100644 --- a/doc/misc/gnus.texi +++ b/doc/misc/gnus.texi | |||
| @@ -26287,6 +26287,16 @@ registry will keep. If the registry has reached or exceeded this | |||
| 26287 | size, it will reject insertion of new entries. | 26287 | size, it will reject insertion of new entries. |
| 26288 | @end defvar | 26288 | @end defvar |
| 26289 | 26289 | ||
| 26290 | @defvar gnus-registry-register-all | ||
| 26291 | If this option is non-nil, the registry will register all messages, as | ||
| 26292 | you see them. This is important to making split-to-parent and | ||
| 26293 | Message-ID references work correctly, as the registry needs to know | ||
| 26294 | where all messages are, but it can slow down group opening and the | ||
| 26295 | saving of Gnus. If this option is nil, entries must be created | ||
| 26296 | manually, for instance by storing a custom flag or keyword for the | ||
| 26297 | message. | ||
| 26298 | @end defvar | ||
| 26299 | |||
| 26290 | @defvar gnus-registry-prune-factor | 26300 | @defvar gnus-registry-prune-factor |
| 26291 | This option (a float between 0 and 1) controls how much the registry | 26301 | This option (a float between 0 and 1) controls how much the registry |
| 26292 | is cut back during pruning. In order to prevent constant pruning, the | 26302 | is cut back during pruning. In order to prevent constant pruning, the |
| @@ -26376,8 +26386,14 @@ have to put a rule like this: | |||
| 26376 | "mail") | 26386 | "mail") |
| 26377 | @end lisp | 26387 | @end lisp |
| 26378 | 26388 | ||
| 26379 | in your fancy split setup. In addition, you may want to customize the | 26389 | in your fancy split setup. |
| 26380 | following variables. | 26390 | |
| 26391 | If @code{gnus-registry-register-all} is non-nil (the default), the | ||
| 26392 | registry will perform splitting for all messages. If it is nil, | ||
| 26393 | splitting will only happen for children of messages you've explicitly | ||
| 26394 | registered. | ||
| 26395 | |||
| 26396 | In addition, you may want to customize the following variables. | ||
| 26381 | 26397 | ||
| 26382 | @defvar gnus-registry-track-extra | 26398 | @defvar gnus-registry-track-extra |
| 26383 | This is a list of symbols, so it's best to change it from the | 26399 | This is a list of symbols, so it's best to change it from the |
| @@ -26450,7 +26466,9 @@ Store @code{value} under @code{key} for message @code{id}. | |||
| 26450 | @end defun | 26466 | @end defun |
| 26451 | 26467 | ||
| 26452 | @defun gnus-registry-get-id-key (id key) | 26468 | @defun gnus-registry-get-id-key (id key) |
| 26453 | Get the data under @code{key} for message @code{id}. | 26469 | Get the data under @code{key} for message @code{id}. If the option |
| 26470 | @code{gnus-registry-register-all} is non-nil, this function will also | ||
| 26471 | create an entry for @code{id} if one doesn't exist. | ||
| 26454 | @end defun | 26472 | @end defun |
| 26455 | 26473 | ||
| 26456 | @defvar gnus-registry-extra-entries-precious | 26474 | @defvar gnus-registry-extra-entries-precious |
| @@ -518,6 +518,13 @@ tags to be considered as well. | |||
| 518 | ** Gnus | 518 | ** Gnus |
| 519 | 519 | ||
| 520 | +++ | 520 | +++ |
| 521 | *** New user option 'gnus-registry-register-all'. | ||
| 522 | |||
| 523 | If non-nil (the default), create registry entries for all messages. | ||
| 524 | If nil, don't automatically create entries, they must be created | ||
| 525 | manually. | ||
| 526 | |||
| 527 | +++ | ||
| 521 | *** New user options to customise the summary line specs %[ and %]. | 528 | *** New user options to customise the summary line specs %[ and %]. |
| 522 | Four new options introduced in customisation group | 529 | Four new options introduced in customisation group |
| 523 | 'gnus-summary-format'. These are 'gnus-sum-opening-bracket', | 530 | 'gnus-summary-format'. These are 'gnus-sum-opening-bracket', |
diff --git a/lisp/gnus/gnus-registry.el b/lisp/gnus/gnus-registry.el index 65bcd0e8a36..31aee0364cf 100644 --- a/lisp/gnus/gnus-registry.el +++ b/lisp/gnus/gnus-registry.el | |||
| @@ -54,6 +54,9 @@ | |||
| 54 | 54 | ||
| 55 | ;; (: gnus-registry-split-fancy-with-parent) | 55 | ;; (: gnus-registry-split-fancy-with-parent) |
| 56 | 56 | ||
| 57 | ;; This won't work as expected unless `gnus-registry-register-all' | ||
| 58 | ;; is set to t. | ||
| 59 | |||
| 57 | ;; You should also consider using the nnregistry backend to look up | 60 | ;; You should also consider using the nnregistry backend to look up |
| 58 | ;; articles. See the Gnus manual for more information. | 61 | ;; articles. See the Gnus manual for more information. |
| 59 | 62 | ||
| @@ -160,6 +163,11 @@ nnmairix groups are specifically excluded because they are ephemeral." | |||
| 160 | (const :tag "Always Install" t) | 163 | (const :tag "Always Install" t) |
| 161 | (const :tag "Ask Me" ask))) | 164 | (const :tag "Ask Me" ask))) |
| 162 | 165 | ||
| 166 | (defcustom gnus-registry-register-all nil | ||
| 167 | "If non-nil, register all articles in the registry." | ||
| 168 | :type 'boolean | ||
| 169 | :version "28.1") | ||
| 170 | |||
| 163 | (defvar gnus-registry-enabled nil) | 171 | (defvar gnus-registry-enabled nil) |
| 164 | 172 | ||
| 165 | (defvar gnus-summary-misc-menu) ;; Avoid byte compiler warning. | 173 | (defvar gnus-summary-misc-menu) ;; Avoid byte compiler warning. |
| @@ -478,8 +486,8 @@ This is not required after changing `gnus-registry-cache-file'." | |||
| 478 | (let ((db gnus-registry-db) | 486 | (let ((db gnus-registry-db) |
| 479 | ;; if the group is ignored, set the destination to nil (same as delete) | 487 | ;; if the group is ignored, set the destination to nil (same as delete) |
| 480 | (to (if (gnus-registry-ignore-group-p to) nil to)) | 488 | (to (if (gnus-registry-ignore-group-p to) nil to)) |
| 481 | ;; safe if not found | 489 | ;; Only retrieve an existing entry, don't create a new one. |
| 482 | (entry (gnus-registry-get-or-make-entry id)) | 490 | (entry (gnus-registry-get-or-make-entry id t)) |
| 483 | (subject (gnus-string-remove-all-properties | 491 | (subject (gnus-string-remove-all-properties |
| 484 | (gnus-registry-simplify-subject subject))) | 492 | (gnus-registry-simplify-subject subject))) |
| 485 | (sender (gnus-string-remove-all-properties sender))) | 493 | (sender (gnus-string-remove-all-properties sender))) |
| @@ -488,29 +496,30 @@ This is not required after changing `gnus-registry-cache-file'." | |||
| 488 | ;; several times but it's better to bunch the transactions | 496 | ;; several times but it's better to bunch the transactions |
| 489 | ;; together | 497 | ;; together |
| 490 | 498 | ||
| 491 | (registry-delete db (list id) nil) | 499 | (when entry |
| 492 | (when from | 500 | (registry-delete db (list id) nil) |
| 493 | (setq entry (cons (delete from (assoc 'group entry)) | 501 | (when from |
| 494 | (assq-delete-all 'group entry)))) | 502 | (setq entry (cons (delete from (assoc 'group entry)) |
| 495 | ;; Only keep the entry if the message is going to a new group, or | 503 | (assq-delete-all 'group entry)))) |
| 496 | ;; it's still in some previous group. | 504 | ;; Only keep the entry if the message is going to a new group, or |
| 497 | (when (or to (alist-get 'group entry)) | 505 | ;; it's still in some previous group. |
| 498 | (dolist (kv `((group ,to) | 506 | (when (or to (alist-get 'group entry)) |
| 499 | (sender ,sender) | 507 | (dolist (kv `((group ,to) |
| 500 | (recipient ,@recipients) | 508 | (sender ,sender) |
| 501 | (subject ,subject))) | 509 | (recipient ,@recipients) |
| 502 | (when (cadr kv) | 510 | (subject ,subject))) |
| 503 | (let ((new (or (assq (car kv) entry) | 511 | (when (cadr kv) |
| 504 | (list (car kv))))) | 512 | (let ((new (or (assq (car kv) entry) |
| 505 | (dolist (toadd (cdr kv)) | 513 | (list (car kv))))) |
| 506 | (unless (member toadd new) | 514 | (dolist (toadd (cdr kv)) |
| 507 | (setq new (append new (list toadd))))) | 515 | (unless (member toadd new) |
| 508 | (setq entry (cons new | 516 | (setq new (append new (list toadd))))) |
| 509 | (assq-delete-all (car kv) entry)))))) | 517 | (setq entry (cons new |
| 510 | (gnus-message 10 "Gnus registry: new entry for %s is %S" | 518 | (assq-delete-all (car kv) entry)))))) |
| 511 | id | 519 | (gnus-message 10 "Gnus registry: new entry for %s is %S" |
| 512 | entry) | 520 | id |
| 513 | (gnus-registry-insert db id entry)))) | 521 | entry) |
| 522 | (gnus-registry-insert db id entry))))) | ||
| 514 | 523 | ||
| 515 | ;; Function for nn{mail|imap}-split-fancy: look up all references in | 524 | ;; Function for nn{mail|imap}-split-fancy: look up all references in |
| 516 | ;; the cache and if a match is found, return that group. | 525 | ;; the cache and if a match is found, return that group. |
| @@ -846,7 +855,8 @@ Overrides existing keywords with FORCE set non-nil." | |||
| 846 | 855 | ||
| 847 | (defun gnus-registry-register-message-ids () | 856 | (defun gnus-registry-register-message-ids () |
| 848 | "Register the Message-ID of every article in the group." | 857 | "Register the Message-ID of every article in the group." |
| 849 | (unless (gnus-parameter-registry-ignore gnus-newsgroup-name) | 858 | (unless (or (gnus-parameter-registry-ignore gnus-newsgroup-name) |
| 859 | (null gnus-registry-register-all)) | ||
| 850 | (dolist (article gnus-newsgroup-articles) | 860 | (dolist (article gnus-newsgroup-articles) |
| 851 | (let* ((id (gnus-registry-fetch-message-id-fast article)) | 861 | (let* ((id (gnus-registry-fetch-message-id-fast article)) |
| 852 | (groups (gnus-registry-get-id-key id 'group))) | 862 | (groups (gnus-registry-get-id-key id 'group))) |
| @@ -1082,12 +1092,15 @@ only the last one's marks are returned." | |||
| 1082 | "Get the number of groups of a message, based on the message ID." | 1092 | "Get the number of groups of a message, based on the message ID." |
| 1083 | (length (gnus-registry-get-id-key id 'group))) | 1093 | (length (gnus-registry-get-id-key id 'group))) |
| 1084 | 1094 | ||
| 1085 | (defun gnus-registry-get-or-make-entry (id) | 1095 | (defun gnus-registry-get-or-make-entry (id &optional no-create) |
| 1096 | "Return registry entry for ID. | ||
| 1097 | If entry is not found, create a new one, unless NO-create is | ||
| 1098 | non-nil." | ||
| 1086 | (let* ((db gnus-registry-db) | 1099 | (let* ((db gnus-registry-db) |
| 1087 | ;; safe if not found | 1100 | ;; safe if not found |
| 1088 | (entries (registry-lookup db (list id)))) | 1101 | (entries (registry-lookup db (list id)))) |
| 1089 | 1102 | ||
| 1090 | (when (null entries) | 1103 | (unless (or entries no-create) |
| 1091 | (gnus-registry-insert db id (list (list 'creation-time (current-time)) | 1104 | (gnus-registry-insert db id (list (list 'creation-time (current-time)) |
| 1092 | '(group) '(sender) '(subject))) | 1105 | '(group) '(sender) '(subject))) |
| 1093 | (setq entries (registry-lookup db (list id)))) | 1106 | (setq entries (registry-lookup db (list id)))) |
| @@ -1098,7 +1111,8 @@ only the last one's marks are returned." | |||
| 1098 | (registry-delete gnus-registry-db idlist nil)) | 1111 | (registry-delete gnus-registry-db idlist nil)) |
| 1099 | 1112 | ||
| 1100 | (defun gnus-registry-get-id-key (id key) | 1113 | (defun gnus-registry-get-id-key (id key) |
| 1101 | (cdr-safe (assq key (gnus-registry-get-or-make-entry id)))) | 1114 | (cdr-safe (assq key (gnus-registry-get-or-make-entry |
| 1115 | id (null gnus-registry-register-all))))) | ||
| 1102 | 1116 | ||
| 1103 | (defun gnus-registry-set-id-key (id key vals) | 1117 | (defun gnus-registry-set-id-key (id key vals) |
| 1104 | (let* ((db gnus-registry-db) | 1118 | (let* ((db gnus-registry-db) |