* gnus-util.el (gnus-alist-to-hashtable, gnus-hashtable-to-alist):
authorRomain Francoise <romain@orebokech.com>
Thu, 13 Apr 2006 19:02:40 +0000 (19:02 +0000)
committerRomain Francoise <romain@orebokech.com>
Thu, 13 Apr 2006 19:02:40 +0000 (19:02 +0000)
Moved here (and renamed) from gnus-registry.el.

* gnus-registry.el: Require gnus-util.
Use `gnus-alist-to-hashtable' and `gnus-hashtable-to-alist'.

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

index 9ba718e..f6e8286 100644 (file)
@@ -1,3 +1,11 @@
+2006-04-13  Romain Francoise  <romain@orebokech.com>
+
+       * gnus-util.el (gnus-alist-to-hashtable, gnus-hashtable-to-alist):
+       Moved here (and renamed) from gnus-registry.el.
+
+       * gnus-registry.el: Require gnus-util.
+       Use `gnus-alist-to-hashtable' and `gnus-hashtable-to-alist'.
+
 2006-04-13  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
        * gnus-group.el (gnus-group-catchup-current): Change
index 192f644..150008c 100644 (file)
@@ -60,6 +60,7 @@
 (require 'gnus)
 (require 'gnus-int)
 (require 'gnus-sum)
+(require 'gnus-util)
 (require 'nnmail)
 
 (defvar gnus-registry-dirty t
@@ -242,7 +243,8 @@ way."
        (gnus-registry-clean-empty-function))
       ;; now trim the registry appropriately
       (setq gnus-registry-alist (gnus-registry-trim
-                                (hashtable-to-alist gnus-registry-hashtb)))
+                                (gnus-hashtable-to-alist
+                                 gnus-registry-hashtb)))
       ;; really save
       (gnus-registry-cache-save)
       (setq gnus-registry-entry-caching caching)
@@ -287,7 +289,7 @@ way."
 
 (defun gnus-registry-read ()
   (gnus-registry-cache-read)
-  (setq gnus-registry-hashtb (alist-to-hashtable gnus-registry-alist))
+  (setq gnus-registry-hashtb (gnus-alist-to-hashtable gnus-registry-alist))
   (setq gnus-registry-dirty nil))
 
 (defun gnus-registry-trim (alist)
@@ -316,26 +318,6 @@ Also, drop all gnus-registry-ignored-groups matches."
                      (or (cdr (gethash (car a) timehash)) '(0 0 0))
                      (or (cdr (gethash (car b) timehash)) '(0 0 0))))))))))
 
-(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)
-    list))
-
 (defun gnus-registry-action (action data-header from &optional to method)
   (let* ((id (mail-header-id data-header))
         (subject (gnus-registry-simplify-subject
@@ -714,7 +696,7 @@ 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 (gnus-alist-to-hashtable gnus-registry-alist))
   (setq gnus-registry-dirty t))
 
 ;;;###autoload
index a94f727..265d143 100644 (file)
@@ -723,6 +723,28 @@ If there's no subdirectory, delete DIRECTORY as well."
       (unless dir
        (delete-directory directory)))))
 
+;; The following two functions are used in gnus-registry.
+;; They were contributed by Andreas Fuchs <asf@void.at>.
+(defun gnus-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 gnus-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)
+    list))
+
 (defun gnus-strip-whitespace (string)
   "Return STRING stripped of all whitespace."
   (while (string-match "[\r\n\t ]+" string)