summaryrefslogtreecommitdiff
path: root/lisp/gnus/gnus-registry.el
diff options
context:
space:
mode:
authorTeodor Zlatanov <tzz@lifelogs.com>2011-05-09 22:27:17 +0000
committerKatsumi Yamaoka <yamaoka@jpl.org>2011-05-09 22:27:17 +0000
commit81d7704c970a3d5b7275f450245ab86b23f4e37d (patch)
tree4ba3f9f78beeb38b72f65fbab253e46b8a5f9e5a /lisp/gnus/gnus-registry.el
parent9bedd73a50921360823210bcc791d1ba1861be70 (diff)
downloademacs-81d7704c970a3d5b7275f450245ab86b23f4e37d.tar.gz
registry.el (registry-full): Add convenience method. Fix logic.
(registry-insert): Use it. Fix logic here too. gnus-registry.el (gnus-registry-insert): Add wrapper that calls `registry-prune' if `registry-full' returns t. (gnus-registry-handle-action, gnus-registry-get-or-make-entry, gnus-registry-set-id-key, gnus-registry-usage-test): Use it.
Diffstat (limited to 'lisp/gnus/gnus-registry.el')
-rw-r--r--lisp/gnus/gnus-registry.el18
1 files changed, 13 insertions, 5 deletions
diff --git a/lisp/gnus/gnus-registry.el b/lisp/gnus/gnus-registry.el
index e6c96ab2b19..02e4ce7e2e6 100644
--- a/lisp/gnus/gnus-registry.el
+++ b/lisp/gnus/gnus-registry.el
@@ -383,7 +383,7 @@ This is not required after changing `gnus-registry-cache-file'."
(gnus-message 10 "Gnus registry: new entry for %s is %S"
id
entry)
- (registry-insert db id entry)))
+ (gnus-registry-insert db id entry)))
;; Function for nn{mail|imap}-split-fancy: look up all references in
;; the cache and if a match is found, return that group.
@@ -962,8 +962,8 @@ only the last one's marks are returned."
(entries (registry-lookup db (list id))))
(when (null entries)
- (registry-insert db id (list (list 'creation-time (current-time))
- '(group) '(sender) '(subject)))
+ (gnus-registry-insert db id (list (list 'creation-time (current-time))
+ '(group) '(sender) '(subject)))
(setq entries (registry-lookup db (list id))))
(nth 1 (assoc id entries))))
@@ -979,9 +979,17 @@ only the last one's marks are returned."
(entry (gnus-registry-get-or-make-entry id)))
(registry-delete db (list id) nil)
(setq entry (cons (cons key vals) (assq-delete-all key entry)))
- (registry-insert db id entry)
+ (gnus-registry-insert db id entry)
entry))
+(defun gnus-registry-insert (db id entry)
+ "Just like `registry-insert' but tries to prune on error."
+ (when (registry-full db)
+ (message "Trying to prune the registry because it's full")
+ (registry-prune db))
+ (registry-insert db id entry)
+ entry)
+
(defun gnus-registry-import-eld (file)
(interactive "fOld registry file to import? ")
;; example content:
@@ -1075,7 +1083,7 @@ only the last one's marks are returned."
(should (equal (gnus-registry-get-id-key "34" 'group) '("togroup")))
(should (equal (gnus-registry-get-id-key "34" 'subject) '("subject 4")))
(message "Trying to insert a duplicate key")
- (should-error (registry-insert db "55" '()))
+ (should-error (gnus-registry-insert db "55" '()))
(message "Looking up individual keys (gnus-registry-get-or-make-entry)")
(should (gnus-registry-get-or-make-entry "22"))
(message "Saving the Gnus registry to %s" tempfile)