From f5a375ed2830c5de00702d97ef1dd50a21f7405e Mon Sep 17 00:00:00 2001 From: Teodor Zlatanov Date: Thu, 24 Jul 2003 19:52:02 +0000 Subject: [PATCH] (gnus-registry-cache-whitespace): make "adding whitespace" message level 5 instead of 4 (gnus-registry-clean-empty-function): new function to remove empty registry entries (gnus-registry-clean-empty): new variable to enable cleaning the registry when saving it by calling gnus-registry-clean-empty-function --- lisp/ChangeLog | 7 +++++++ lisp/gnus-registry.el | 25 +++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 773449992..67a1a865b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,12 @@ 2003-07-24 Teodor Zlatanov + * gnus-registry.el (gnus-registry-cache-whitespace): make "adding + whitespace" message level 5 instead of 4 + (gnus-registry-clean-empty-function): new function to remove empty + registry entries + (gnus-registry-clean-empty): new variable to enable cleaning the + registry when saving it by calling gnus-registry-clean-empty-function + * spam.el (spam-summary-prepare-exit): use spam-process-ham-in-spam-groups (spam-process-ham-in-spam-groups): new variable diff --git a/lisp/gnus-registry.el b/lisp/gnus-registry.el index b2a66c286..0766da786 100644 --- a/lisp/gnus-registry.el +++ b/lisp/gnus-registry.el @@ -54,6 +54,12 @@ The group names are matched, they don't have to be fully qualified." :group 'gnus-registry :type 'boolean) +(defcustom gnus-registry-clean-empty t + "Whether the empty registry entries should be deleted. +Registry entries are considered empty when they have no groups." + :group 'gnus-registry + :type 'boolean) + (defcustom gnus-registry-use-long-group-names nil "Whether the registry should use long group names (BUGGY)." :group 'gnus-registry @@ -155,7 +161,7 @@ The group names are matched, they don't have to be fully qualified." ;; Idea from Dan Christensen ;; Save the gnus-registry file with extra line breaks. (defun gnus-registry-cache-whitespace (filename) - (gnus-message 4 "Adding whitespace to %s" filename) + (gnus-message 5 "Adding whitespace to %s" filename) (save-excursion (goto-char (point-min)) (while (re-search-forward "^(\\|(\\\"" nil t) @@ -165,13 +171,28 @@ The group names are matched, they don't have to be fully qualified." (replace-match "" t t)))) (defun gnus-registry-save (&optional force) -;; TODO: delete entries with 0 groups (when (or gnus-registry-dirty force) + ;; remove empty entries + (when gnus-registry-clean-empty + (gnus-registry-clean-empty-function)) + ;; now trim the registry appropriately (setq gnus-registry-alist (gnus-registry-trim (hashtable-to-alist gnus-registry-hashtb))) + ;; really save (gnus-registry-cache-save) (setq gnus-registry-dirty nil))) +(defun gnus-registry-clean-empty-function () + "Remove all empty entries from the registry. Returns count thereof." + (let ((count 0)) + (maphash + (lambda (key value) + (unless (gnus-registry-fetch-group key) + (incf count) + (remhash key gnus-registry-hashtb))) + gnus-registry-hashtb) + count)) + (defun gnus-registry-read () (gnus-registry-cache-read) (setq gnus-registry-hashtb (alist-to-hashtable gnus-registry-alist)) -- 2.25.1