emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 5b66483: Prevent gnus-registry-handle-action from creating spurio


From: Eric Abrahamsen
Subject: master 5b66483: Prevent gnus-registry-handle-action from creating spurious entries
Date: Wed, 20 May 2020 15:00:38 -0400 (EDT)

branch: master
commit 5b66483eadebbd3b1c37a46d2d987637b2872a8e
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>

    Prevent gnus-registry-handle-action from creating spurious entries
    
    Thanks to Bob Newell for finding this.
    
    * lisp/gnus/gnus-registry.el (gnus-registry-handle-action): If a
    message entry ends up with no groups in its 'group key, that means the
    entry should be deleted.
---
 lisp/gnus/gnus-registry.el | 36 +++++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/lisp/gnus/gnus-registry.el b/lisp/gnus/gnus-registry.el
index 480ed80..f306889 100644
--- a/lisp/gnus/gnus-registry.el
+++ b/lisp/gnus/gnus-registry.el
@@ -485,23 +485,25 @@ This is not required after changing 
`gnus-registry-cache-file'."
     (when from
       (setq entry (cons (delete from (assoc 'group entry))
                         (assq-delete-all '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)))
+    ;; 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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]