From 69a512a196a2e3f5f771e419e7c2524210c9b391 Mon Sep 17 00:00:00 2001 From: Teodor Zlatanov Date: Wed, 28 May 2003 21:29:06 +0000 Subject: [PATCH] (gnus-registry-dirty): flag for modified registry (gnus-registry-save, gnus-registry-read) (gnus-registry-store-extra, gnus-registry-clear): use it (note that gnus-registry-store-extra is invoked for all modifications to set the mtime, so gnus-registry-dirty only needs to be set there) --- lisp/ChangeLog | 8 ++++++++ lisp/gnus-registry.el | 20 ++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 2055cac31..68aa85d8f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,11 @@ +2003-05-28 Teodor Zlatanov + + * gnus-registry.el (gnus-registry-dirty): flag for modified registry + (gnus-registry-save, gnus-registry-read) + (gnus-registry-store-extra, gnus-registry-clear): use it (note + that gnus-registry-store-extra is invoked for all modifications to + set the mtime, so gnus-registry-dirty only needs to be set there) + 2003-05-23 Simon Josefsson * mml1991.el (mml1991-pgg-sign): Use mml-sender instead of diff --git a/lisp/gnus-registry.el b/lisp/gnus-registry.el index e97b1e4ab..b43e48853 100644 --- a/lisp/gnus-registry.el +++ b/lisp/gnus-registry.el @@ -33,6 +33,9 @@ (require 'gnus-sum) (require 'nnmail) +(defvar gnus-registry-dirty t + "Boolean set to t when the registry is modified") + (defgroup gnus-registry nil "The Gnus registry." :group 'gnus) @@ -77,7 +80,6 @@ The group names are matched, they don't have to be fully qualified." (interactive) (let ((file gnus-registry-cache-file)) (save-excursion - ;; Save .newsrc.eld. (set-buffer (gnus-get-buffer-create " *Gnus-registry-cache*")) (make-local-variable 'version-control) (setq version-control gnus-backup-startup-file) @@ -148,12 +150,16 @@ The group names are matched, they don't have to be fully qualified." (replace-match "" t t)))) (defun gnus-registry-save () - (setq gnus-registry-alist (hashtable-to-alist gnus-registry-hashtb)) - (gnus-registry-cache-save)) +;; TODO: delete entries with 0 groups + (when gnus-registry-dirty + (setq gnus-registry-alist (hashtable-to-alist gnus-registry-hashtb)) + (gnus-registry-cache-save) + (setq gnus-registry-dirty nil))) (defun gnus-registry-read () (gnus-registry-cache-read) - (setq gnus-registry-hashtb (alist-to-hashtable gnus-registry-alist))) + (setq gnus-registry-hashtb (alist-to-hashtable gnus-registry-alist)) + (setq gnus-registry-dirty nil)) (defun alist-to-hashtable (alist) "Build a hashtable from the values in ALIST." @@ -294,7 +300,8 @@ The message must have at least one group name." (let ((trail (gethash id gnus-registry-hashtb)) (old-extra (gnus-registry-fetch-extra id))) (puthash id (cons extra (delete old-extra trail)) - gnus-registry-hashtb)))) + gnus-registry-hashtb) + (setq gnus-registry-dirty t)))) (defun gnus-registry-store-extra-entry (id key value) "Put a specific entry in the extras field of the registry entry for id." @@ -355,7 +362,8 @@ Returns the first place where the trail finds a group name." "Clear the Gnus registry." (interactive) (setq gnus-registry-alist nil) - (setq gnus-registry-hashtb (alist-to-hashtable gnus-registry-alist))) + (setq gnus-registry-hashtb (alist-to-hashtable gnus-registry-alist)) + (setq gnus-registry-dirty t)) (defun gnus-registry-install-hooks () "Install the registry hooks." -- 2.34.1