(gnus-registry-trim): fix for when
[gnus] / lisp / gnus-registry.el
index 7395281..b2a66c2 100644 (file)
@@ -179,7 +179,9 @@ The group names are matched, they don't have to be fully qualified."
 
 (defun gnus-registry-trim (alist)
   "Trim alist to size, using gnus-registry-max-entries."
-  (unless (null gnus-registry-max-entries)
+  (if (null gnus-registry-max-entries)
+      alist                            ; just return the alist
+    ;; else, when given max-entries, trim the alist
     (let ((timehash (make-hash-table                       
                     :size 4096
                     :test 'equal)))
@@ -188,6 +190,7 @@ The group names are matched, they don't have to be fully qualified."
         (puthash key (gnus-registry-fetch-extra key 'mtime) timehash))
        gnus-registry-hashtb)
 
+      ;; we use the return value of this setq, which is the trimmed alist
       (setq alist
            (nthcdr
             (- (length alist) gnus-registry-max-entries)
@@ -354,7 +357,7 @@ Returns the first place where the trail finds a group name."
     (let ((trail (gethash id gnus-registry-hashtb)))
       (dolist (crumb trail)
        (when (stringp crumb)
-         (return crumb))))))
+         (return (gnus-group-short-name crumb)))))))
 
 (defun gnus-registry-group-count (id)
   "Get the number of groups of a message, based on the message ID."
@@ -420,6 +423,19 @@ Returns the first place where the trail finds a group name."
 
   (add-hook 'gnus-summary-prepare-hook 'gnus-registry-register-message-ids))
 
+(defun gnus-registry-unload-hook ()
+  "Uninstall the registry hooks."
+  (interactive)
+  (remove-hook 'gnus-summary-article-move-hook 'gnus-register-action) 
+  (remove-hook 'gnus-summary-article-delete-hook 'gnus-register-action)
+  (remove-hook 'gnus-summary-article-expire-hook 'gnus-register-action)
+  (remove-hook 'nnmail-spool-hook 'gnus-register-spool-action)
+  
+  (remove-hook 'gnus-save-newsrc-hook 'gnus-registry-save)
+  (remove-hook 'gnus-read-newsrc-el-hook 'gnus-registry-read)
+
+  (remove-hook 'gnus-summary-prepare-hook 'gnus-registry-register-message-ids))
+
 (when gnus-registry-install
   (gnus-registry-install-hooks))