* gnus-start.el (gnus-read-newsrc-el-hook): new hook called by gnus-read-newsrc-el...
authorTeodor Zlatanov <tzz@lifelogs.com>
Fri, 28 Mar 2003 09:41:18 +0000 (09:41 +0000)
committerTeodor Zlatanov <tzz@lifelogs.com>
Fri, 28 Mar 2003 09:41:18 +0000 (09:41 +0000)
(gnus-read-newsrc-el-file): call the gnus-read-newsrc-el-hook

* gnus-registry.el (gnus-registry-translate-to-alist)
(gnus-registry-translate-from-alist, alist-to-hashtable)
(hashtable-to-alist): new functions
(gnus-register-spool-action): add a spool item to the registry

* gnus.el (gnus-variable-list): added gnus-registry-alist to the
list of saved variables
(gnus-registry-alist): new variable

lisp/ChangeLog
lisp/gnus-registry.el
lisp/gnus-start.el
lisp/gnus.el

index 7cc5fb1..1fc305e 100644 (file)
@@ -1,3 +1,17 @@
+2003-03-28  Teodor Zlatanov  <tzz@lifelogs.com>
+
+       * gnus-start.el (gnus-read-newsrc-el-hook): new hook called by gnus-read-newsrc-el-file
+       (gnus-read-newsrc-el-file): call the gnus-read-newsrc-el-hook
+
+       * gnus-registry.el (gnus-registry-translate-to-alist) 
+       (gnus-registry-translate-from-alist, alist-to-hashtable) 
+       (hashtable-to-alist): new functions
+       (gnus-register-spool-action): add a spool item to the registry
+
+       * gnus.el (gnus-variable-list): added gnus-registry-alist to the
+       list of saved variables
+       (gnus-registry-alist): new variable
+
 2003-03-27  Simon Josefsson  <jas@extundo.com>
 
        * gnus-art.el (article-decode-group-name): Be correct instead of
index 6c11631..5bed64a 100644 (file)
     ;; alias puthash is missing from Emacs 20 cl-extra.el
     (defalias 'puthash 'cl-puthash)))
 
+(defun gnus-registry-translate-to-alist
+  (setq gnus-registry-alist (hashtable-to-alist gnus-registry-hashtb)))
+
+(defun gnus-registry-translate-from-alist
+  (setq gnus-registry-hashtb (alist-to-hashtable gnus-registry-alist)))
+
+(defun alist-to-hashtable (alist)
+  "Build a hashtable from the values in ALIST."
+  (let ((ht (make-hash-table                       
+            :size 4096
+            :test 'equal)))
+    (mapc
+     (lambda (kv-pair)
+       (puthash (car kv-pair) (cdr kv-pair) ht))
+     alist)
+     ht))
+
+(defun hashtable-to-alist (hash)
+  "Build an alist from the values in HASH."
+  (let ((list nil))
+    (maphash
+     (lambda (key value)
+       (setq list (cons (cons key value) list)))
+     hash)))
+
 (defun gnus-register-action (action data-header from &optional to method)
   (let* ((id (mail-header-id data-header))
        (hash-entry (gethash id gnus-registry-hashtb)))
           (gnus-group-prefixed-name 
            group 
            gnus-internal-registry-spool-current-method 
-           t)))
+           t))
+  (puthash id (cons (list 'spool nil group nil) 
+                   (gethash id gnus-registry-hashtb)) gnus-registry-hashtb))
 
 (add-hook 'gnus-summary-article-move-hook 'gnus-register-action) ; also does copy, respool, and crosspost
 (add-hook 'gnus-summary-article-delete-hook 'gnus-register-action)
 (add-hook 'gnus-summary-article-expire-hook 'gnus-register-action)
 (add-hook 'nnmail-spool-hook 'gnus-register-spool-action)
 
+(add-hook 'gnus-save-newsrc-hook 'gnus-registry-translate-to-alist)
+(add-hook 'gnus-read-newsrc-el-hook 'gnus-registry-translate-from-alist)
+
 ;; TODO: a lot of things
-;; TODO: we have to load and save the registry through gnus-save-newsrc-file
 
 (provide 'gnus-registry)
 
index b212ec4..fd0bb8f 100644 (file)
@@ -404,6 +404,11 @@ This hook is called as the first thing when Gnus is started."
   :group 'gnus-group-new
   :type 'hook)
 
+(defcustom gnus-read-newsrc-el-hook nil
+  "A hook called after reading the newsrc.eld? file."
+  :group 'gnus-newsrc
+  :type 'hook)
+
 (defcustom gnus-save-newsrc-hook nil
   "A hook called before saving any of the newsrc files."
   :group 'gnus-newsrc
@@ -2231,7 +2236,8 @@ If FORCE is non-nil, the .newsrc file is read."
       (gnus-message 5 "Reading %s..." file)
       ;; The .el file is newer than the .eld file, so we read that one
       ;; as well.
-      (gnus-read-old-newsrc-el-file file))))
+      (gnus-read-old-newsrc-el-file file)))
+  (gnus-run-hooks 'gnus-read-newsrc-el-hook))
 
 ;; Parse the old-style quick startup file
 (defun gnus-read-old-newsrc-el-file (file)
index cd52c60..732545a 100644 (file)
@@ -2286,6 +2286,7 @@ such as a mark that says whether an article is stored in the cache
   '(gnus-newsrc-options gnus-newsrc-options-n
                        gnus-newsrc-last-checked-date
                        gnus-newsrc-alist gnus-server-alist
+                       gnus-registry-alist
                        gnus-killed-list gnus-zombie-list
                        gnus-topic-topology gnus-topic-alist
                        gnus-agent-covered-methods gnus-format-specs)
@@ -2295,6 +2296,10 @@ such as a mark that says whether an article is stored in the cache
   "Assoc list of read articles.
 gnus-newsrc-hashtb should be kept so that both hold the same information.")
 
+(defvar gnus-registry-alist nil
+  "Assoc list of registry data.
+gnus-registry.el will populate this if it's loaded.")
+
 (defvar gnus-newsrc-hashtb nil
   "Hashtable of gnus-newsrc-alist.")