+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
;; 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)
: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
(let ((list gnus-product-variable-file-list))
(while list
(apply 'gnus-product-read-variable-file-1 (car list))
- (setq list (cdr list))))))
+ (setq list (cdr list)))))
+ (gnus-run-hooks 'gnus-read-newsrc-el-hook))
;;(defun gnus-re-read-newsrc-el-file (file)
;; "Attempt to re-read .newsrc.eld file. Returns nil if successful.
'(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)
"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.")