diff options
| -rw-r--r-- | lisp/gnus/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/gnus/gnus-registry.el | 14 | ||||
| -rw-r--r-- | lisp/gnus/registry.el | 28 |
3 files changed, 30 insertions, 21 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index af49782a035..5d699e0be27 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2015-03-07 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * registry.el (registry-lookup-breaks-before-lexbind, registry-lookup) | ||
| 4 | (registry-search, registry-delete, registry-size, registry-insert) | ||
| 5 | (registry-reindex, registry-collect-prune-candidates): | ||
| 6 | * gnus-registry.el (gnus-registry-fixup-registry) | ||
| 7 | (gnus-registry-remove-extra-data): Use slot names rather than initarg | ||
| 8 | names in `oref' and `oset'. | ||
| 9 | |||
| 1 | 2015-02-26 Katsumi Yamaoka <yamaoka@jpl.org> | 10 | 2015-02-26 Katsumi Yamaoka <yamaoka@jpl.org> |
| 2 | 11 | ||
| 3 | * gnus-art.el (gnus-mime-inline-part, gnus-mm-display-part): | 12 | * gnus-art.el (gnus-mime-inline-part, gnus-mm-display-part): |
diff --git a/lisp/gnus/gnus-registry.el b/lisp/gnus/gnus-registry.el index 2017ea2f826..ac903a250ec 100644 --- a/lisp/gnus/gnus-registry.el +++ b/lisp/gnus/gnus-registry.el | |||
| @@ -276,20 +276,20 @@ This can slow pruning down. Set to nil to perform no sorting." | |||
| 276 | 276 | ||
| 277 | (defun gnus-registry-fixup-registry (db) | 277 | (defun gnus-registry-fixup-registry (db) |
| 278 | (when db | 278 | (when db |
| 279 | (let ((old (oref db :tracked))) | 279 | (let ((old (oref db tracked))) |
| 280 | (oset db :precious | 280 | (oset db precious |
| 281 | (append gnus-registry-extra-entries-precious | 281 | (append gnus-registry-extra-entries-precious |
| 282 | '())) | 282 | '())) |
| 283 | (oset db :max-size | 283 | (oset db max-size |
| 284 | (or gnus-registry-max-entries | 284 | (or gnus-registry-max-entries |
| 285 | most-positive-fixnum)) | 285 | most-positive-fixnum)) |
| 286 | (oset db :prune-factor | 286 | (oset db prune-factor |
| 287 | (or gnus-registry-prune-factor | 287 | (or gnus-registry-prune-factor |
| 288 | 0.1)) | 288 | 0.1)) |
| 289 | (oset db :tracked | 289 | (oset db tracked |
| 290 | (append gnus-registry-track-extra | 290 | (append gnus-registry-track-extra |
| 291 | '(mark group keyword))) | 291 | '(mark group keyword))) |
| 292 | (when (not (equal old (oref db :tracked))) | 292 | (when (not (equal old (oref db tracked))) |
| 293 | (gnus-message 9 "Reindexing the Gnus registry (tracked change)") | 293 | (gnus-message 9 "Reindexing the Gnus registry (tracked change)") |
| 294 | (registry-reindex db)))) | 294 | (registry-reindex db)))) |
| 295 | db) | 295 | db) |
| @@ -1242,7 +1242,7 @@ from your existing entries." | |||
| 1242 | (when extra | 1242 | (when extra |
| 1243 | (let ((db gnus-registry-db)) | 1243 | (let ((db gnus-registry-db)) |
| 1244 | (registry-reindex db) | 1244 | (registry-reindex db) |
| 1245 | (loop for k being the hash-keys of (oref db :data) | 1245 | (loop for k being the hash-keys of (oref db data) |
| 1246 | using (hash-value v) | 1246 | using (hash-value v) |
| 1247 | do (let ((newv (delq nil (mapcar #'(lambda (entry) | 1247 | do (let ((newv (delq nil (mapcar #'(lambda (entry) |
| 1248 | (unless (member (car entry) extra) | 1248 | (unless (member (car entry) extra) |
diff --git a/lisp/gnus/registry.el b/lisp/gnus/registry.el index 55b83a8e889..881eb9f5a65 100644 --- a/lisp/gnus/registry.el +++ b/lisp/gnus/registry.el | |||
| @@ -155,7 +155,7 @@ | |||
| 155 | (defmethod registry-lookup ((db registry-db) keys) | 155 | (defmethod registry-lookup ((db registry-db) keys) |
| 156 | "Search for KEYS in the registry-db THIS. | 156 | "Search for KEYS in the registry-db THIS. |
| 157 | Returns an alist of the key followed by the entry in a list, not a cons cell." | 157 | Returns an alist of the key followed by the entry in a list, not a cons cell." |
| 158 | (let ((data (oref db :data))) | 158 | (let ((data (oref db data))) |
| 159 | (delq nil | 159 | (delq nil |
| 160 | (mapcar | 160 | (mapcar |
| 161 | (lambda (k) | 161 | (lambda (k) |
| @@ -166,7 +166,7 @@ Returns an alist of the key followed by the entry in a list, not a cons cell." | |||
| 166 | (defmethod registry-lookup-breaks-before-lexbind ((db registry-db) keys) | 166 | (defmethod registry-lookup-breaks-before-lexbind ((db registry-db) keys) |
| 167 | "Search for KEYS in the registry-db THIS. | 167 | "Search for KEYS in the registry-db THIS. |
| 168 | Returns an alist of the key followed by the entry in a list, not a cons cell." | 168 | Returns an alist of the key followed by the entry in a list, not a cons cell." |
| 169 | (let ((data (oref db :data))) | 169 | (let ((data (oref db data))) |
| 170 | (delq nil | 170 | (delq nil |
| 171 | (loop for key in keys | 171 | (loop for key in keys |
| 172 | when (gethash key data) | 172 | when (gethash key data) |
| @@ -227,7 +227,7 @@ The test order is to check :all first, then :member, then :regex." | |||
| 227 | (let ((all (plist-get spec :all)) | 227 | (let ((all (plist-get spec :all)) |
| 228 | (member (plist-get spec :member)) | 228 | (member (plist-get spec :member)) |
| 229 | (regex (plist-get spec :regex))) | 229 | (regex (plist-get spec :regex))) |
| 230 | (loop for k being the hash-keys of (oref db :data) | 230 | (loop for k being the hash-keys of (oref db data) |
| 231 | using (hash-values v) | 231 | using (hash-values v) |
| 232 | when (or | 232 | when (or |
| 233 | ;; :all non-nil returns all | 233 | ;; :all non-nil returns all |
| @@ -243,10 +243,10 @@ The test order is to check :all first, then :member, then :regex." | |||
| 243 | If KEYS is nil, use SPEC to do a search. | 243 | If KEYS is nil, use SPEC to do a search. |
| 244 | Updates the secondary ('tracked') indices as well. | 244 | Updates the secondary ('tracked') indices as well. |
| 245 | With assert non-nil, errors out if the key does not exist already." | 245 | With assert non-nil, errors out if the key does not exist already." |
| 246 | (let* ((data (oref db :data)) | 246 | (let* ((data (oref db data)) |
| 247 | (keys (or keys | 247 | (keys (or keys |
| 248 | (apply 'registry-search db spec))) | 248 | (apply 'registry-search db spec))) |
| 249 | (tracked (oref db :tracked))) | 249 | (tracked (oref db tracked))) |
| 250 | 250 | ||
| 251 | (dolist (key keys) | 251 | (dolist (key keys) |
| 252 | (let ((entry (gethash key data))) | 252 | (let ((entry (gethash key data))) |
| @@ -273,8 +273,8 @@ With assert non-nil, errors out if the key does not exist already." | |||
| 273 | 273 | ||
| 274 | (defmethod registry-size ((db registry-db)) | 274 | (defmethod registry-size ((db registry-db)) |
| 275 | "Returns the size of the registry-db object THIS. | 275 | "Returns the size of the registry-db object THIS. |
| 276 | This is the key count of the :data slot." | 276 | This is the key count of the `data' slot." |
| 277 | (hash-table-count (oref db :data))) | 277 | (hash-table-count (oref db data))) |
| 278 | 278 | ||
| 279 | (defmethod registry-full ((db registry-db)) | 279 | (defmethod registry-full ((db registry-db)) |
| 280 | "Checks if registry-db THIS is full." | 280 | "Checks if registry-db THIS is full." |
| @@ -286,7 +286,7 @@ This is the key count of the :data slot." | |||
| 286 | Updates the secondary ('tracked') indices as well. | 286 | Updates the secondary ('tracked') indices as well. |
| 287 | Errors out if the key exists already." | 287 | Errors out if the key exists already." |
| 288 | 288 | ||
| 289 | (assert (not (gethash key (oref db :data))) nil | 289 | (assert (not (gethash key (oref db data))) nil |
| 290 | "Key already exists in database") | 290 | "Key already exists in database") |
| 291 | 291 | ||
| 292 | (assert (not (registry-full db)) | 292 | (assert (not (registry-full db)) |
| @@ -294,10 +294,10 @@ Errors out if the key exists already." | |||
| 294 | "registry max-size limit reached") | 294 | "registry max-size limit reached") |
| 295 | 295 | ||
| 296 | ;; store the entry | 296 | ;; store the entry |
| 297 | (puthash key entry (oref db :data)) | 297 | (puthash key entry (oref db data)) |
| 298 | 298 | ||
| 299 | ;; store the secondary indices | 299 | ;; store the secondary indices |
| 300 | (dolist (tr (oref db :tracked)) | 300 | (dolist (tr (oref db tracked)) |
| 301 | ;; for every value in the entry under that key... | 301 | ;; for every value in the entry under that key... |
| 302 | (dolist (val (cdr-safe (assq tr entry))) | 302 | (dolist (val (cdr-safe (assq tr entry))) |
| 303 | (let* ((value-keys (registry-lookup-secondary-value db tr val))) | 303 | (let* ((value-keys (registry-lookup-secondary-value db tr val))) |
| @@ -308,8 +308,8 @@ Errors out if the key exists already." | |||
| 308 | (defmethod registry-reindex ((db registry-db)) | 308 | (defmethod registry-reindex ((db registry-db)) |
| 309 | "Rebuild the secondary indices of registry-db THIS." | 309 | "Rebuild the secondary indices of registry-db THIS." |
| 310 | (let ((count 0) | 310 | (let ((count 0) |
| 311 | (expected (* (length (oref db :tracked)) (registry-size db)))) | 311 | (expected (* (length (oref db tracked)) (registry-size db)))) |
| 312 | (dolist (tr (oref db :tracked)) | 312 | (dolist (tr (oref db tracked)) |
| 313 | (let (values) | 313 | (let (values) |
| 314 | (maphash | 314 | (maphash |
| 315 | (lambda (key v) | 315 | (lambda (key v) |
| @@ -322,7 +322,7 @@ Errors out if the key exists already." | |||
| 322 | (let* ((value-keys (registry-lookup-secondary-value db tr val))) | 322 | (let* ((value-keys (registry-lookup-secondary-value db tr val))) |
| 323 | (push key value-keys) | 323 | (push key value-keys) |
| 324 | (registry-lookup-secondary-value db tr val value-keys)))) | 324 | (registry-lookup-secondary-value db tr val value-keys)))) |
| 325 | (oref db :data)))))) | 325 | (oref db data)))))) |
| 326 | 326 | ||
| 327 | (defmethod registry-prune ((db registry-db) &optional sortfunc) | 327 | (defmethod registry-prune ((db registry-db) &optional sortfunc) |
| 328 | "Prunes the registry-db object DB. | 328 | "Prunes the registry-db object DB. |
| @@ -359,7 +359,7 @@ entries first and return candidates from beginning of list." | |||
| 359 | (let* ((precious (oref db :precious)) | 359 | (let* ((precious (oref db :precious)) |
| 360 | (precious-p (lambda (entry-key) | 360 | (precious-p (lambda (entry-key) |
| 361 | (cdr (memq (car entry-key) precious)))) | 361 | (cdr (memq (car entry-key) precious)))) |
| 362 | (data (oref db :data)) | 362 | (data (oref db data)) |
| 363 | (candidates (cl-loop for k being the hash-keys of data | 363 | (candidates (cl-loop for k being the hash-keys of data |
| 364 | using (hash-values v) | 364 | using (hash-values v) |
| 365 | when (notany precious-p v) | 365 | when (notany precious-p v) |