diff options
| author | Stefan Monnier | 2015-02-04 13:49:49 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2015-02-04 13:49:49 -0500 |
| commit | 73b17f7c2b723a0ad4ea04cf1a5a8be5bbdf6121 (patch) | |
| tree | fc2ee663521960bf1c102bb98a72f31903e5110b /lisp/cedet/srecode/fields.el | |
| parent | 102a21d68976ab9dc85304e0bc47b7562d3cf93f (diff) | |
| download | emacs-73b17f7c2b723a0ad4ea04cf1a5a8be5bbdf6121.tar.gz emacs-73b17f7c2b723a0ad4ea04cf1a5a8be5bbdf6121.zip | |
* lisp/cedet: Use cl-generic instead of EIEIO's defgeneric/defmethod
* lisp/cedet/**/*.el: Mechanically replace all calls to defmethod/defgeneric
by calls to cl-defmethod/cl-defgeneric.
* lisp/cedet/srecode/table.el:
* lisp/cedet/srecode/fields.el:
* lisp/cedet/srecode/dictionary.el:
* lisp/cedet/srecode/compile.el:
* lisp/cedet/semantic/debug.el:
* lisp/cedet/semantic/db-ref.el:
* lisp/cedet/ede/base.el:
* lisp/cedet/ede/auto.el:
* lisp/cedet/ede.el: Require `cl-generic'.
Diffstat (limited to 'lisp/cedet/srecode/fields.el')
| -rw-r--r-- | lisp/cedet/srecode/fields.el | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/lisp/cedet/srecode/fields.el b/lisp/cedet/srecode/fields.el index f473a0d8261..dd38b65d7bf 100644 --- a/lisp/cedet/srecode/fields.el +++ b/lisp/cedet/srecode/fields.el | |||
| @@ -39,6 +39,7 @@ | |||
| 39 | 39 | ||
| 40 | ;; Keep this library independent of SRecode proper. | 40 | ;; Keep this library independent of SRecode proper. |
| 41 | (require 'eieio) | 41 | (require 'eieio) |
| 42 | (require 'cl-generic) | ||
| 42 | 43 | ||
| 43 | ;;; Code: | 44 | ;;; Code: |
| 44 | (defvar srecode-field-archive nil | 45 | (defvar srecode-field-archive nil |
| @@ -74,7 +75,7 @@ The overlay will crossreference this object.") | |||
| 74 | "An object that gets automatically bound to an overlay. | 75 | "An object that gets automatically bound to an overlay. |
| 75 | Has virtual :start and :end initializers.") | 76 | Has virtual :start and :end initializers.") |
| 76 | 77 | ||
| 77 | (defmethod initialize-instance ((olaid srecode-overlaid) &optional args) | 78 | (cl-defmethod initialize-instance ((olaid srecode-overlaid) &optional args) |
| 78 | "Initialize OLAID, being sure it archived." | 79 | "Initialize OLAID, being sure it archived." |
| 79 | ;; Extract :start and :end from the olaid list. | 80 | ;; Extract :start and :end from the olaid list. |
| 80 | (let ((newargs nil) | 81 | (let ((newargs nil) |
| @@ -107,11 +108,11 @@ Has virtual :start and :end initializers.") | |||
| 107 | (overlay-put olay 'srecode-init-only t) | 108 | (overlay-put olay 'srecode-init-only t) |
| 108 | 109 | ||
| 109 | (oset olaid overlay olay) | 110 | (oset olaid overlay olay) |
| 110 | (call-next-method olaid (nreverse newargs)) | 111 | (cl-call-next-method olaid (nreverse newargs)) |
| 111 | 112 | ||
| 112 | )) | 113 | )) |
| 113 | 114 | ||
| 114 | (defmethod srecode-overlaid-activate ((olaid srecode-overlaid)) | 115 | (cl-defmethod srecode-overlaid-activate ((olaid srecode-overlaid)) |
| 115 | "Activate the overlaid area." | 116 | "Activate the overlaid area." |
| 116 | (let* ((ola (oref olaid overlay)) | 117 | (let* ((ola (oref olaid overlay)) |
| 117 | (start (overlay-start ola)) | 118 | (start (overlay-start ola)) |
| @@ -128,23 +129,23 @@ Has virtual :start and :end initializers.") | |||
| 128 | 129 | ||
| 129 | )) | 130 | )) |
| 130 | 131 | ||
| 131 | (defmethod srecode-delete ((olaid srecode-overlaid)) | 132 | (cl-defmethod srecode-delete ((olaid srecode-overlaid)) |
| 132 | "Delete the overlay from OLAID." | 133 | "Delete the overlay from OLAID." |
| 133 | (delete-overlay (oref olaid overlay)) | 134 | (delete-overlay (oref olaid overlay)) |
| 134 | (slot-makeunbound olaid 'overlay) | 135 | (slot-makeunbound olaid 'overlay) |
| 135 | ) | 136 | ) |
| 136 | 137 | ||
| 137 | (defmethod srecode-empty-region-p ((olaid srecode-overlaid)) | 138 | (cl-defmethod srecode-empty-region-p ((olaid srecode-overlaid)) |
| 138 | "Return non-nil if the region covered by OLAID is of length 0." | 139 | "Return non-nil if the region covered by OLAID is of length 0." |
| 139 | (= 0 (srecode-region-size olaid))) | 140 | (= 0 (srecode-region-size olaid))) |
| 140 | 141 | ||
| 141 | (defmethod srecode-region-size ((olaid srecode-overlaid)) | 142 | (cl-defmethod srecode-region-size ((olaid srecode-overlaid)) |
| 142 | "Return the length of region covered by OLAID." | 143 | "Return the length of region covered by OLAID." |
| 143 | (let ((start (overlay-start (oref olaid overlay))) | 144 | (let ((start (overlay-start (oref olaid overlay))) |
| 144 | (end (overlay-end (oref olaid overlay)))) | 145 | (end (overlay-end (oref olaid overlay)))) |
| 145 | (- end start))) | 146 | (- end start))) |
| 146 | 147 | ||
| 147 | (defmethod srecode-point-in-region-p ((olaid srecode-overlaid)) | 148 | (cl-defmethod srecode-point-in-region-p ((olaid srecode-overlaid)) |
| 148 | "Return non-nil if point is in the region of OLAID." | 149 | "Return non-nil if point is in the region of OLAID." |
| 149 | (let ((start (overlay-start (oref olaid overlay))) | 150 | (let ((start (overlay-start (oref olaid overlay))) |
| 150 | (end (overlay-end (oref olaid overlay)))) | 151 | (end (overlay-end (oref olaid overlay)))) |
| @@ -161,7 +162,7 @@ Has virtual :start and :end initializers.") | |||
| 161 | (setq ol (cdr ol))) | 162 | (setq ol (cdr ol))) |
| 162 | (car (nreverse ret)))) | 163 | (car (nreverse ret)))) |
| 163 | 164 | ||
| 164 | (defmethod srecode-overlaid-text ((olaid srecode-overlaid) &optional set-to) | 165 | (cl-defmethod srecode-overlaid-text ((olaid srecode-overlaid) &optional set-to) |
| 165 | "Return the text under OLAID. | 166 | "Return the text under OLAID. |
| 166 | If SET-TO is a string, then replace the text of OLAID wit SET-TO." | 167 | If SET-TO is a string, then replace the text of OLAID wit SET-TO." |
| 167 | (let* ((ol (oref olaid overlay)) | 168 | (let* ((ol (oref olaid overlay)) |
| @@ -191,7 +192,7 @@ If SET-TO is a string, then replace the text of OLAID wit SET-TO." | |||
| 191 | ) | 192 | ) |
| 192 | "Manage a buffer region in which fields exist.") | 193 | "Manage a buffer region in which fields exist.") |
| 193 | 194 | ||
| 194 | (defmethod initialize-instance ((ir srecode-template-inserted-region) | 195 | (cl-defmethod initialize-instance ((ir srecode-template-inserted-region) |
| 195 | &rest args) | 196 | &rest args) |
| 196 | "Initialize IR, capturing the active fields, and creating the overlay." | 197 | "Initialize IR, capturing the active fields, and creating the overlay." |
| 197 | ;; Fill in the fields | 198 | ;; Fill in the fields |
| @@ -199,10 +200,10 @@ If SET-TO is a string, then replace the text of OLAID wit SET-TO." | |||
| 199 | (setq srecode-field-archive nil) | 200 | (setq srecode-field-archive nil) |
| 200 | 201 | ||
| 201 | ;; Initialize myself first. | 202 | ;; Initialize myself first. |
| 202 | (call-next-method) | 203 | (cl-call-next-method) |
| 203 | ) | 204 | ) |
| 204 | 205 | ||
| 205 | (defmethod srecode-overlaid-activate ((ir srecode-template-inserted-region)) | 206 | (cl-defmethod srecode-overlaid-activate ((ir srecode-template-inserted-region)) |
| 206 | "Activate the template area for IR." | 207 | "Activate the template area for IR." |
| 207 | ;; Activate all our fields | 208 | ;; Activate all our fields |
| 208 | 209 | ||
| @@ -210,7 +211,7 @@ If SET-TO is a string, then replace the text of OLAID wit SET-TO." | |||
| 210 | (srecode-overlaid-activate F)) | 211 | (srecode-overlaid-activate F)) |
| 211 | 212 | ||
| 212 | ;; Activate our overlay. | 213 | ;; Activate our overlay. |
| 213 | (call-next-method) | 214 | (cl-call-next-method) |
| 214 | 215 | ||
| 215 | ;; Position the cursor at the first field | 216 | ;; Position the cursor at the first field |
| 216 | (let ((first (car (oref ir fields)))) | 217 | (let ((first (car (oref ir fields)))) |
| @@ -223,14 +224,14 @@ If SET-TO is a string, then replace the text of OLAID wit SET-TO." | |||
| 223 | (add-hook 'post-command-hook 'srecode-field-post-command t t) | 224 | (add-hook 'post-command-hook 'srecode-field-post-command t t) |
| 224 | ) | 225 | ) |
| 225 | 226 | ||
| 226 | (defmethod srecode-delete ((ir srecode-template-inserted-region)) | 227 | (cl-defmethod srecode-delete ((ir srecode-template-inserted-region)) |
| 227 | "Call into our base, but also clear out the fields." | 228 | "Call into our base, but also clear out the fields." |
| 228 | ;; Clear us out of the baseclass. | 229 | ;; Clear us out of the baseclass. |
| 229 | (oset ir active-region nil) | 230 | (oset ir active-region nil) |
| 230 | ;; Clear our fields. | 231 | ;; Clear our fields. |
| 231 | (mapc 'srecode-delete (oref ir fields)) | 232 | (mapc 'srecode-delete (oref ir fields)) |
| 232 | ;; Call to our base | 233 | ;; Call to our base |
| 233 | (call-next-method) | 234 | (cl-call-next-method) |
| 234 | ;; Clear our hook. | 235 | ;; Clear our hook. |
| 235 | (remove-hook 'post-command-hook 'srecode-field-post-command t) | 236 | (remove-hook 'post-command-hook 'srecode-field-post-command t) |
| 236 | ) | 237 | ) |
| @@ -285,15 +286,15 @@ Try to use this to provide useful completion when available.") | |||
| 285 | km) | 286 | km) |
| 286 | "Keymap applied to field overlays.") | 287 | "Keymap applied to field overlays.") |
| 287 | 288 | ||
| 288 | (defmethod initialize-instance ((field srecode-field) &optional args) | 289 | (cl-defmethod initialize-instance ((field srecode-field) &optional args) |
| 289 | "Initialize FIELD, being sure it archived." | 290 | "Initialize FIELD, being sure it archived." |
| 290 | (add-to-list 'srecode-field-archive field t) | 291 | (add-to-list 'srecode-field-archive field t) |
| 291 | (call-next-method) | 292 | (cl-call-next-method) |
| 292 | ) | 293 | ) |
| 293 | 294 | ||
| 294 | (defmethod srecode-overlaid-activate ((field srecode-field)) | 295 | (cl-defmethod srecode-overlaid-activate ((field srecode-field)) |
| 295 | "Activate the FIELD area." | 296 | "Activate the FIELD area." |
| 296 | (call-next-method) | 297 | (cl-call-next-method) |
| 297 | 298 | ||
| 298 | (let* ((ol (oref field overlay)) | 299 | (let* ((ol (oref field overlay)) |
| 299 | (end nil) | 300 | (end nil) |
| @@ -314,13 +315,13 @@ Try to use this to provide useful completion when available.") | |||
| 314 | ) | 315 | ) |
| 315 | ) | 316 | ) |
| 316 | 317 | ||
| 317 | (defmethod srecode-delete ((olaid srecode-field)) | 318 | (cl-defmethod srecode-delete ((olaid srecode-field)) |
| 318 | "Delete our secondary overlay." | 319 | "Delete our secondary overlay." |
| 319 | ;; Remove our spare overlay | 320 | ;; Remove our spare overlay |
| 320 | (delete-overlay (oref olaid tail)) | 321 | (delete-overlay (oref olaid tail)) |
| 321 | (slot-makeunbound olaid 'tail) | 322 | (slot-makeunbound olaid 'tail) |
| 322 | ;; Do our baseclass work. | 323 | ;; Do our baseclass work. |
| 323 | (call-next-method) | 324 | (cl-call-next-method) |
| 324 | ) | 325 | ) |
| 325 | 326 | ||
| 326 | (defvar srecode-field-replication-max-size 100 | 327 | (defvar srecode-field-replication-max-size 100 |
| @@ -379,7 +380,7 @@ PRE-LEN is used in the after mode for the length of the changed text." | |||
| 379 | (srecode-field-mod-hook ol after start end pre-len)) | 380 | (srecode-field-mod-hook ol after start end pre-len)) |
| 380 | )) | 381 | )) |
| 381 | 382 | ||
| 382 | (defmethod srecode-field-goto ((field srecode-field)) | 383 | (cl-defmethod srecode-field-goto ((field srecode-field)) |
| 383 | "Goto the FIELD." | 384 | "Goto the FIELD." |
| 384 | (goto-char (overlay-start (oref field overlay)))) | 385 | (goto-char (overlay-start (oref field overlay)))) |
| 385 | 386 | ||