aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2016-02-12 16:45:30 +1100
committerLars Ingebrigtsen2016-02-12 16:45:30 +1100
commitba9c534b955c3f0ef6dac7b2ecc1a125507b481c (patch)
treecd8803a50884422aa3ab614689bc99eeec95e7c5
parentb78a7596f684dd6cde814dacd220471bc8ea18a0 (diff)
downloademacs-ba9c534b955c3f0ef6dac7b2ecc1a125507b481c.tar.gz
emacs-ba9c534b955c3f0ef6dac7b2ecc1a125507b481c.zip
Use cl-defmethod in registry.el
* lisp/gnus/registry.el: Use cl-defmethod instead of the obsolete defmethod.
-rw-r--r--lisp/gnus/registry.el33
1 files changed, 17 insertions, 16 deletions
diff --git a/lisp/gnus/registry.el b/lisp/gnus/registry.el
index 9e6babcc355..9182920b87f 100644
--- a/lisp/gnus/registry.el
+++ b/lisp/gnus/registry.el
@@ -129,7 +129,7 @@
129 :type hash-table 129 :type hash-table
130 :documentation "The data hashtable."))) 130 :documentation "The data hashtable.")))
131 131
132(defmethod initialize-instance :BEFORE ((this registry-db) slots) 132(cl-defmethod initialize-instance :BEFORE ((this registry-db) slots)
133 "Check whether a registry object needs to be upgraded." 133 "Check whether a registry object needs to be upgraded."
134 ;; Hardcoded upgrade routines. Version 0.1 to 0.2 requires the 134 ;; Hardcoded upgrade routines. Version 0.1 to 0.2 requires the
135 ;; :max-soft slot to disappear, and the :max-hard slot to be renamed 135 ;; :max-soft slot to disappear, and the :max-hard slot to be renamed
@@ -146,7 +146,7 @@
146 (cl-remf slots :max-hard) 146 (cl-remf slots :max-hard)
147 (cl-remf slots :max-soft)))) 147 (cl-remf slots :max-soft))))
148 148
149(defmethod initialize-instance :AFTER ((this registry-db) slots) 149(cl-defmethod initialize-instance :AFTER ((this registry-db) slots)
150 "Set value of data slot of THIS after initialization." 150 "Set value of data slot of THIS after initialization."
151 (with-slots (data tracker) this 151 (with-slots (data tracker) this
152 (unless (member :data slots) 152 (unless (member :data slots)
@@ -155,7 +155,7 @@
155 (unless (member :tracker slots) 155 (unless (member :tracker slots)
156 (setq tracker (make-hash-table :size 100 :rehash-size 2.0))))) 156 (setq tracker (make-hash-table :size 100 :rehash-size 2.0)))))
157 157
158(defmethod registry-lookup ((db registry-db) keys) 158(cl-defmethod registry-lookup ((db registry-db) keys)
159 "Search for KEYS in the registry-db THIS. 159 "Search for KEYS in the registry-db THIS.
160Returns an alist of the key followed by the entry in a list, not a cons cell." 160Returns an alist of the key followed by the entry in a list, not a cons cell."
161 (let ((data (oref db data))) 161 (let ((data (oref db data)))
@@ -166,7 +166,7 @@ Returns an alist of the key followed by the entry in a list, not a cons cell."
166 (list k (gethash k data)))) 166 (list k (gethash k data))))
167 keys)))) 167 keys))))
168 168
169(defmethod registry-lookup-breaks-before-lexbind ((db registry-db) keys) 169(cl-defmethod registry-lookup-breaks-before-lexbind ((db registry-db) keys)
170 "Search for KEYS in the registry-db THIS. 170 "Search for KEYS in the registry-db THIS.
171Returns an alist of the key followed by the entry in a list, not a cons cell." 171Returns an alist of the key followed by the entry in a list, not a cons cell."
172 (let ((data (oref db data))) 172 (let ((data (oref db data)))
@@ -175,8 +175,8 @@ Returns an alist of the key followed by the entry in a list, not a cons cell."
175 when (gethash key data) 175 when (gethash key data)
176 collect (list key (gethash key data)))))) 176 collect (list key (gethash key data))))))
177 177
178(defmethod registry-lookup-secondary ((db registry-db) tracksym 178(cl-defmethod registry-lookup-secondary ((db registry-db) tracksym
179 &optional create) 179 &optional create)
180 "Search for TRACKSYM in the registry-db THIS. 180 "Search for TRACKSYM in the registry-db THIS.
181When CREATE is not nil, create the secondary index hashtable if needed." 181When CREATE is not nil, create the secondary index hashtable if needed."
182 (let ((h (gethash tracksym (oref db :tracker)))) 182 (let ((h (gethash tracksym (oref db :tracker))))
@@ -188,8 +188,8 @@ When CREATE is not nil, create the secondary index hashtable if needed."
188 (oref db tracker)) 188 (oref db tracker))
189 (gethash tracksym (oref db tracker)))))) 189 (gethash tracksym (oref db tracker))))))
190 190
191(defmethod registry-lookup-secondary-value ((db registry-db) tracksym val 191(cl-defmethod registry-lookup-secondary-value ((db registry-db) tracksym val
192 &optional set) 192 &optional set)
193 "Search for TRACKSYM with value VAL in the registry-db THIS. 193 "Search for TRACKSYM with value VAL in the registry-db THIS.
194When SET is not nil, set it for VAL (use t for an empty list)." 194When SET is not nil, set it for VAL (use t for an empty list)."
195 ;; either we're asked for creation or there should be an existing index 195 ;; either we're asked for creation or there should be an existing index
@@ -220,7 +220,7 @@ When SET is not nil, set it for VAL (use t for an empty list)."
220 (or found 220 (or found
221 (registry--match mode entry (cdr-safe check-list)))))) 221 (registry--match mode entry (cdr-safe check-list))))))
222 222
223(defmethod registry-search ((db registry-db) &rest spec) 223(cl-defmethod registry-search ((db registry-db) &rest spec)
224 "Search for SPEC across the registry-db THIS. 224 "Search for SPEC across the registry-db THIS.
225For example calling with `:member \\='(a 1 2)' will match entry \((a 3 1)). 225For example calling with `:member \\='(a 1 2)' will match entry \((a 3 1)).
226Calling with `:all t' (any non-nil value) will match all. 226Calling with `:all t' (any non-nil value) will match all.
@@ -241,7 +241,7 @@ The test order is to check :all first, then :member, then :regex."
241 (and regex (registry--match :regex v regex))) 241 (and regex (registry--match :regex v regex)))
242 collect k)))) 242 collect k))))
243 243
244(defmethod registry-delete ((db registry-db) keys assert &rest spec) 244(cl-defmethod registry-delete ((db registry-db) keys assert &rest spec)
245 "Delete KEYS from the registry-db THIS. 245 "Delete KEYS from the registry-db THIS.
246If KEYS is nil, use SPEC to do a search. 246If KEYS is nil, use SPEC to do a search.
247Updates the secondary ('tracked') indices as well. 247Updates the secondary ('tracked') indices as well.
@@ -274,17 +274,17 @@ With assert non-nil, errors out if the key does not exist already."
274 (remhash key data))) 274 (remhash key data)))
275 keys)) 275 keys))
276 276
277(defmethod registry-size ((db registry-db)) 277(cl-defmethod registry-size ((db registry-db))
278 "Returns the size of the registry-db object THIS. 278 "Returns the size of the registry-db object THIS.
279This is the key count of the `data' slot." 279This is the key count of the `data' slot."
280 (hash-table-count (oref db data))) 280 (hash-table-count (oref db data)))
281 281
282(defmethod registry-full ((db registry-db)) 282(cl-defmethod registry-full ((db registry-db))
283 "Checks if registry-db THIS is full." 283 "Checks if registry-db THIS is full."
284 (>= (registry-size db) 284 (>= (registry-size db)
285 (oref db max-size))) 285 (oref db max-size)))
286 286
287(defmethod registry-insert ((db registry-db) key entry) 287(cl-defmethod registry-insert ((db registry-db) key entry)
288 "Insert ENTRY under KEY into the registry-db THIS. 288 "Insert ENTRY under KEY into the registry-db THIS.
289Updates the secondary ('tracked') indices as well. 289Updates the secondary ('tracked') indices as well.
290Errors out if the key exists already." 290Errors out if the key exists already."
@@ -308,7 +308,7 @@ Errors out if the key exists already."
308 (registry-lookup-secondary-value db tr val value-keys)))) 308 (registry-lookup-secondary-value db tr val value-keys))))
309 entry) 309 entry)
310 310
311(defmethod registry-reindex ((db registry-db)) 311(cl-defmethod registry-reindex ((db registry-db))
312 "Rebuild the secondary indices of registry-db THIS." 312 "Rebuild the secondary indices of registry-db THIS."
313 (let ((count 0) 313 (let ((count 0)
314 (expected (* (length (oref db tracked)) (registry-size db)))) 314 (expected (* (length (oref db tracked)) (registry-size db))))
@@ -327,7 +327,7 @@ Errors out if the key exists already."
327 (registry-lookup-secondary-value db tr val value-keys)))) 327 (registry-lookup-secondary-value db tr val value-keys))))
328 (oref db data)))))) 328 (oref db data))))))
329 329
330(defmethod registry-prune ((db registry-db) &optional sortfunc) 330(cl-defmethod registry-prune ((db registry-db) &optional sortfunc)
331 "Prunes the registry-db object DB. 331 "Prunes the registry-db object DB.
332 332
333Attempts to prune the number of entries down to \(* 333Attempts to prune the number of entries down to \(*
@@ -354,7 +354,8 @@ Returns the number of deleted entries."
354 (length (registry-delete db candidates nil))) 354 (length (registry-delete db candidates nil)))
355 0))) 355 0)))
356 356
357(defmethod registry-collect-prune-candidates ((db registry-db) limit sortfunc) 357(cl-defmethod registry-collect-prune-candidates ((db registry-db)
358 limit sortfunc)
358 "Collects pruning candidates from the registry-db object DB. 359 "Collects pruning candidates from the registry-db object DB.
359 360
360Proposes only entries without the :precious keys, and attempts to 361Proposes only entries without the :precious keys, and attempts to