]> code.delx.au - gnu-emacs/blobdiff - lisp/gnus/registry.el
Merge branch 'emacs-25' of /home/acm/emacs/emacs.git/emacs-25 into emacs-25
[gnu-emacs] / lisp / gnus / registry.el
index e4ba0bc547f5dd8f7d46187945f6fedcdd65cf86..9e6babcc355c0a6914671095744c529a9f4a17bd 100644 (file)
@@ -1,6 +1,6 @@
 ;;; registry.el --- Track and remember data items by various fields
 
-;; Copyright (C) 2011-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2016 Free Software Foundation, Inc.
 
 ;; Author: Teodor Zlatanov <tzz@lifelogs.com>
 ;; Keywords: data
     :initform 0.1
     :type float
     :custom float
-    :documentation "Prune to \(:max-size * :prune-factor\) less
+    :documentation "Prune to (:max-size * :prune-factor) less
     than the :max-size limit.  Should be a float between 0 and 1.")
    (tracked :initarg :tracked
             :initform nil
@@ -222,9 +222,9 @@ When SET is not nil, set it for VAL (use t for an empty list)."
 
 (defmethod registry-search ((db registry-db) &rest spec)
   "Search for SPEC across the registry-db THIS.
-For example calling with :member '(a 1 2) will match entry '((a 3 1)).
-Calling with :all t (any non-nil value) will match all.
-Calling with :regex '\(a \"h.llo\") will match entry '((a \"hullo\" \"bye\").
+For example calling with `:member \\='(a 1 2)' will match entry \((a 3 1)).
+Calling with `:all t' (any non-nil value) will match all.
+Calling with `:regex \\='(a \"h.llo\")' will match entry \(a \"hullo\" \"bye\").
 The test order is to check :all first, then :member, then :regex."
   (when db
     (let ((all (plist-get spec :all))
@@ -320,7 +320,7 @@ Errors out if the key exists already."
           (when (and (< 0 expected)
                      (= 0 (mod count 1000)))
             (message "reindexing: %d of %d (%.2f%%)"
-                     count expected (/ (* 100 count) expected)))
+                     count expected (/ (* 100.0 count) expected)))
           (dolist (val (cdr-safe (assq tr v)))
             (let* ((value-keys (registry-lookup-secondary-value db tr val)))
               (push key value-keys)
@@ -331,7 +331,7 @@ Errors out if the key exists already."
   "Prunes the registry-db object DB.
 
 Attempts to prune the number of entries down to \(*
-:max-size :prune-factor\) less than the max-size limit, so
+:max-size :prune-factor) less than the max-size limit, so
 pruning doesn't need to happen on every save. Removes only
 entries without the :precious keys, so it may not be possible to
 reach the target limit.
@@ -341,11 +341,12 @@ from the front of the list are deleted first.
 
 Returns the number of deleted entries."
   (let ((size (registry-size db))
-       (target-size (- (oref db max-size)
-                       (* (oref db max-size)
-                          (oref db prune-factor))))
+       (target-size
+        (floor (- (oref db max-size)
+                  (* (oref db max-size)
+                     (oref db prune-factor)))))
        candidates)
-    (if (> size (oref db max-size))
+    (if (registry-full db)
        (progn
          (setq candidates
                (registry-collect-prune-candidates