Fixes suggested by David Engster <deng@randomsample.de>.
authorTed Zlatanov <tzz@lifelogs.com>
Tue, 5 Apr 2011 15:54:02 +0000 (10:54 -0500)
committerTed Zlatanov <tzz@lifelogs.com>
Tue, 5 Apr 2011 15:54:02 +0000 (10:54 -0500)
* gnus-registry.el (gnus-registry-fixup-registry): New function to
fixup the parameters that can be customized by the user between
save/read cycles.
(gnus-registry-read): Use it.
(gnus-registry-make-db): Use it.
(gnus-registry-spool-action, gnus-registry-handle-action): Fix
messaging.
(gnus-registry--split-fancy-with-parent-internal): Fix loop.
(gnus-registry-post-process-groups): Use `cond' for better messaging.
(gnus-registry-usage-test): Add subject lookup test.

* registry.el (registry-db, initialize-instance): Set up constructor
instead of :initform arguments for the sake of older Emacsen.

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

index 45f7371..f790f53 100644 (file)
@@ -1,5 +1,8 @@
 2011-04-05  Teodor Zlatanov  <tzz@lifelogs.com>
 
+       * registry.el (registry-db, initialize-instance): Set up constructor
+       instead of :initform arguments for the sake of older Emacsen.
+
        * gnus-registry.el (gnus-registry-fixup-registry): New function to
        fixup the parameters that can be customized by the user between
        save/read cycles.
index 5ae7ed6..504e39a 100644 (file)
@@ -216,6 +216,22 @@ the Bit Bucket."
   :type '(radio (const :format "Unlimited " nil)
                 (integer :format "Maximum number: %v")))
 
+(defun gnus-registry-fixup-registry (db)
+  (when db
+    (oset db :precious
+          (append gnus-registry-extra-entries-precious
+                  '()))
+    (oset db :max-hard
+          (or gnus-registry-max-entries
+              most-positive-fixnum))
+    (oset db :max-soft
+          (or gnus-registry-max-pruned-entries
+              most-positive-fixnum))
+    (oset db :tracked
+          (append gnus-registry-track-extra
+                  '(mark group keyword))))
+  db)
+
 (defun gnus-registry-make-db (&optional file)
   (interactive "fGnus registry persistence file: \n")
   (gnus-registry-fixup-registry
@@ -257,22 +273,6 @@ This is not required after changing `gnus-registry-cache-file'."
         file)
        (gnus-registry-remake-db t)))))
 
-(defun gnus-registry-fixup-registry (db)
-  (when db
-    (oset db :precious
-          (append gnus-registry-extra-entries-precious
-                  '()))
-    (oset db :max-hard
-          (or gnus-registry-max-entries
-              most-positive-fixnum))
-    (oset db :max-soft
-          (or gnus-registry-max-pruned-entries
-              most-positive-fixnum))
-    (oset db :tracked
-          (append gnus-registry-track-extra
-                  '(mark group keyword))))
-  db)
-
 (defun gnus-registry-save (&optional file db)
   "Save the registry cache file."
   (interactive)
index 3da83d1..ef78fec 100644 (file)
             :custom float
             :documentation "The registry version.")
    (max-hard :initarg :max-hard
-             :initform 5000000
              :type integer
              :custom integer
              :documentation "Never accept more than this many elements.")
    (max-soft :initarg :max-soft
-             :initform 50000
              :type integer
              :custom integer
              :documentation "Prune as much as possible to get to this size.")
    (tracked :initarg :tracked
-            :initform nil
             :type t
             :documentation "The tracked (indexed) fields, a list of symbols.")
    (precious :initarg :precious
-             :initform nil
              :type t
              :documentation "The precious fields, a list of symbols.")
    (tracker :initarg :tracker
-            :initform (make-hash-table :size 100 :rehash-size 2.0)
-            :type t
+            :type hash-table
             :documentation "The field tracking hashtable.")
    (data :initarg :data
-         :initform (make-hash-table :size 10000 :rehash-size 2.0 :test 'equal)
-         :type t
+         :type hash-table
          :documentation "The data hashtable.")))
 
-;; (defmethod initialize-instance :after ((this registry-db) slots)
-;;   "Set value of data slot of THIS after initialization."
-;;   (with-slots (data tracker max-hard max-soft tracked precious version) this
-;;     (setq data (make-hash-table :size 10000 :rehash-size 2.0 :test 'equal)
-;;           tracker (make-hash-table :size 100 :rehash-size 2.0)
-;;           max-hard 5000000
-;;           max-soft 50000
-;;           tracked nil
-;;           precious nil
-;;           version 0.1)))
+(defmethod initialize-instance :after ((this registry-db) slots)
+  "Set value of data slot of THIS after initialization."
+  ;; 'data' will already be set if read from file, so don't overwrite it.
+  (with-slots (data tracker tracked precious max-soft max-hard) this
+    (unless (member :data slots)
+      (setq data (make-hash-table :size 10000 :rehash-size 2.0 :test 'equal)))
+    (unless (member :tracker slots)
+      (setq tracker (make-hash-table :size 100 :rehash-size 2.0)))
+    (unless (member :max-soft slots)
+      (setq max-soft 50000))
+    (unless (member :max-hard slots)
+      (setq max-hard 5000000))
+    (unless (member :tracked slots)
+      (setq tracked nil))
+    (unless (member :precious slots)
+      (setq precious nil))))
 
 (defmethod registry-lookup ((db registry-db) keys)
   "Search for KEYS in the registry-db THIS.