comparison lisp/eieio/eieio-opt.el @ 104401:2efe3dc24373

Add files for the EIEIO library.
author Chong Yidong <cyd@stupidchicken.com>
date Sat, 22 Aug 2009 04:12:52 +0000
parents
children
comparison
equal deleted inserted replaced
104400:ed5d844496e7 104401:2efe3dc24373
1 ;;; eieio-opt.el -- eieio optional functions (debug, printing, speedbar)
2
3 ;;; Copyright (C) 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2005,
4 ;;; 2008, 2009 Free Software Foundation, Inc.
5
6 ;; Author: Eric M. Ludlam <zappo@gnu.org>
7 ;; Version: 0.2
8 ;; Keywords: OO, lisp
9
10 ;; This file is part of GNU Emacs.
11
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
16
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
21
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24
25 ;;; Commentary:
26 ;;
27 ;; This contains support functions to eieio. These functions contain
28 ;; some small class browser and class printing functions.
29 ;;
30
31 (require 'eieio)
32
33 ;;; Code:
34 (defun eieio-browse (&optional root-class)
35 "Create an object browser window to show all objects.
36 If optional ROOT-CLASS, then start with that, otherwise start with
37 variable `eieio-default-superclass'."
38 (interactive (if current-prefix-arg
39 (list (read (completing-read "Class: "
40 (eieio-build-class-alist)
41 nil t)))
42 nil))
43 (if (not root-class) (setq root-class 'eieio-default-superclass))
44 (if (not (class-p root-class)) (signal 'wrong-type-argument (list 'class-p root-class)))
45 (display-buffer (get-buffer-create "*EIEIO OBJECT BROWSE*") t)
46 (save-excursion
47 (set-buffer (get-buffer "*EIEIO OBJECT BROWSE*"))
48 (erase-buffer)
49 (goto-char 0)
50 (eieio-browse-tree root-class "" "")
51 ))
52
53 (defun eieio-browse-tree (this-root prefix ch-prefix)
54 "Recursively, draws the children of the given class on the screen.
55 Argument THIS-ROOT is the local root of the tree.
56 Argument PREFIX is the character prefix to use.
57 Argument CH-PREFIX is another character prefix to display."
58 (if (not (class-p (eval this-root))) (signal 'wrong-type-argument (list 'class-p this-root)))
59 (let ((myname (symbol-name this-root))
60 (chl (aref (class-v this-root) class-children))
61 (fprefix (concat ch-prefix " +--"))
62 (mprefix (concat ch-prefix " | "))
63 (lprefix (concat ch-prefix " ")))
64 (insert prefix myname "\n")
65 (while (cdr chl)
66 (eieio-browse-tree (car chl) fprefix mprefix)
67 (setq chl (cdr chl)))
68 (if chl
69 (eieio-browse-tree (car chl) fprefix lprefix))
70 ))
71
72 ;;; CLASS COMPLETION / DOCUMENTATION
73 ;;;###autoload
74 (defalias 'describe-class 'eieio-describe-class)
75 ;;;###autoload
76 (defun eieio-describe-class (class &optional headerfcn)
77 "Describe a CLASS defined by a string or symbol.
78 If CLASS is actually an object, then also display current values of that obect.
79 Optional HEADERFCN should be called to insert a few bits of info first."
80 (interactive (list (eieio-read-class "Class: ")))
81 (with-output-to-temp-buffer (help-buffer) ;"*Help*"
82 (help-setup-xref (list #'eieio-describe-class class headerfcn)
83 (interactive-p))
84
85 (when headerfcn (funcall headerfcn))
86
87 (if (class-option class :abstract)
88 (princ "Abstract "))
89 (princ "Class ")
90 (prin1 class)
91 (terpri)
92 ;; Inheritence tree information
93 (let ((pl (class-parents class)))
94 (when pl
95 (princ " Inherits from ")
96 (while pl
97 (princ "`") (prin1 (car pl)) (princ "'")
98 (setq pl (cdr pl))
99 (if pl (princ ", ")))
100 (terpri)))
101 (let ((ch (class-children class)))
102 (when ch
103 (princ " Children ")
104 (while ch
105 (princ "`") (prin1 (car ch)) (princ "'")
106 (setq ch (cdr ch))
107 (if ch (princ ", ")))
108 (terpri)))
109 (terpri)
110 ;; System documentation
111 (let ((doc (documentation-property class 'variable-documentation)))
112 (when doc
113 (princ "Documentation:")
114 (terpri)
115 (princ doc)
116 (terpri)
117 (terpri)))
118 ;; Describe all the slots in this class
119 (eieio-describe-class-slots class)
120 ;; Describe all the methods specific to this class.
121 (let ((methods (eieio-all-generic-functions class))
122 (doc nil))
123 (if (not methods) nil
124 (princ "Specialized Methods:")
125 (terpri)
126 (terpri)
127 (while methods
128 (setq doc (eieio-method-documentation (car methods) class))
129 (princ "`")
130 (prin1 (car methods))
131 (princ "'")
132 (if (not doc)
133 (princ " Undocumented")
134 (if (car doc)
135 (progn
136 (princ " :STATIC ")
137 (prin1 (car (car doc)))
138 (terpri)
139 (princ (cdr (car doc)))))
140 (setq doc (cdr doc))
141 (if (car doc)
142 (progn
143 (princ " :BEFORE ")
144 (prin1 (car (car doc)))
145 (terpri)
146 (princ (cdr (car doc)))))
147 (setq doc (cdr doc))
148 (if (car doc)
149 (progn
150 (princ " :PRIMARY ")
151 (prin1 (car (car doc)))
152 (terpri)
153 (princ (cdr (car doc)))))
154 (setq doc (cdr doc))
155 (if (car doc)
156 (progn
157 (princ " :AFTER ")
158 (prin1 (car (car doc)))
159 (terpri)
160 (princ (cdr (car doc)))))
161 (terpri)
162 (terpri))
163 (setq methods (cdr methods))))))
164 (save-excursion
165 (set-buffer (help-buffer))
166 (buffer-string)))
167
168 (defun eieio-describe-class-slots (class)
169 "Describe the slots in CLASS.
170 Outputs to the standard output."
171 (let* ((cv (class-v class))
172 (docs (aref cv class-public-doc))
173 (names (aref cv class-public-a))
174 (deflt (aref cv class-public-d))
175 (types (aref cv class-public-type))
176 (publp (aref cv class-public-printer))
177 (i 0)
178 (prot (aref cv class-protection))
179 )
180 (princ "Instance Allocated Slots:")
181 (terpri)
182 (terpri)
183 (while names
184 (if (car prot) (princ "Private "))
185 (princ "Slot: ")
186 (prin1 (car names))
187 (when (not (eq (aref types i) t))
188 (princ " type = ")
189 (prin1 (aref types i)))
190 (unless (eq (car deflt) eieio-unbound)
191 (princ " default = ")
192 (prin1 (car deflt)))
193 (when (car publp)
194 (princ " printer = ")
195 (prin1 (car publp)))
196 (when (car docs)
197 (terpri)
198 (princ " ")
199 (princ (car docs))
200 (terpri))
201 (terpri)
202 (setq names (cdr names)
203 docs (cdr docs)
204 deflt (cdr deflt)
205 publp (cdr publp)
206 prot (cdr prot)
207 i (1+ i)))
208 (setq docs (aref cv class-class-allocation-doc)
209 names (aref cv class-class-allocation-a)
210 types (aref cv class-class-allocation-type)
211 i 0
212 prot (aref cv class-class-allocation-protection))
213 (when names
214 (terpri)
215 (princ "Class Allocated Slots:"))
216 (terpri)
217 (terpri)
218 (while names
219 (when (car prot)
220 (princ "Private "))
221 (princ "Slot: ")
222 (prin1 (car names))
223 (unless (eq (aref types i) t)
224 (princ " type = ")
225 (prin1 (aref types i)))
226 (condition-case nil
227 (let ((value (eieio-oref class (car names))))
228 (princ " value = ")
229 (prin1 value))
230 (error nil))
231 (when (car docs)
232 (terpri)
233 (princ " ")
234 (princ (car docs))
235 (terpri))
236 (terpri)
237 (setq names (cdr names)
238 docs (cdr docs)
239 prot (cdr prot)
240 i (1+ i)))))
241
242 (defun eieio-describe-constructor (fcn)
243 "Describe the constructor function FCN.
244 Uses `eieio-describe-class' to describe the class being constructed."
245 (interactive
246 ;; Use eieio-read-class since all constructors have the same name as
247 ;; the class they create.
248 (list (eieio-read-class "Class: ")))
249 (eieio-describe-class
250 fcn (lambda ()
251 ;; Describe the constructor part.
252 (princ "Object Constructor Function: ")
253 (prin1 fcn)
254 (terpri)
255 (princ "Creates an object of class ")
256 (prin1 fcn)
257 (princ ".")
258 (terpri)
259 (terpri)
260 ))
261 )
262
263 (defun eieio-build-class-alist (&optional class instantiable-only buildlist)
264 "Return an alist of all currently active classes for completion purposes.
265 Optional argument CLASS is the class to start with.
266 If INSTANTIABLE-ONLY is non nil, only allow names of classes which
267 are not abstract, otherwise allow all classes.
268 Optional argument BUILDLIST is more list to attach and is used internally."
269 (let* ((cc (or class eieio-default-superclass))
270 (sublst (aref (class-v cc) class-children)))
271 (if (or (not instantiable-only) (not (class-abstract-p cc)))
272 (setq buildlist (cons (cons (symbol-name cc) 1) buildlist)))
273 (while sublst
274 (setq buildlist (eieio-build-class-alist
275 (car sublst) instantiable-only buildlist))
276 (setq sublst (cdr sublst)))
277 buildlist))
278
279 (defvar eieio-read-class nil
280 "History of the function `eieio-read-class' prompt.")
281
282 (defun eieio-read-class (prompt &optional histvar instantiable-only)
283 "Return a class chosen by the user using PROMPT.
284 Optional argument HISTVAR is a variable to use as history.
285 If INSTANTIABLE-ONLY is non nil, only allow names of classes which
286 are not abstract."
287 (intern (completing-read prompt (eieio-build-class-alist nil instantiable-only)
288 nil t nil
289 (or histvar 'eieio-read-class))))
290
291 (defun eieio-read-subclass (prompt class &optional histvar instantiable-only)
292 "Return a class chosen by the user using PROMPT.
293 CLASS is the base class, and completion occurs across all subclasses.
294 Optional argument HISTVAR is a variable to use as history.
295 If INSTANTIABLE-ONLY is non nil, only allow names of classes which
296 are not abstract."
297 (intern (completing-read prompt
298 (eieio-build-class-alist class instantiable-only)
299 nil t nil
300 (or histvar 'eieio-read-class))))
301
302 ;;; METHOD COMPLETION / DOC
303 ;;
304 ;;;###autoload
305 (defalias 'describe-method 'eieio-describe-generic)
306 ;;;###autoload
307 (defalias 'describe-generic 'eieio-describe-generic)
308 ;;;###autoload
309 (defalias 'eieio-describe-method 'eieio-describe-generic)
310 ;;;###autoload
311 (defun eieio-describe-generic (generic)
312 "Describe the generic function GENERIC.
313 Also extracts information about all methods specific to this generic."
314 (interactive (list (eieio-read-generic "Generic Method: ")))
315 (if (not (generic-p generic))
316 (signal 'wrong-type-argument '(generic-p generic)))
317 (with-output-to-temp-buffer (help-buffer) ; "*Help*"
318 (help-setup-xref (list #'eieio-describe-generic generic) (interactive-p))
319
320 (prin1 generic)
321 (princ " is a generic function")
322 (when (generic-primary-only-p generic)
323 (princ " with only ")
324 (when (generic-primary-only-one-p generic)
325 (princ "one "))
326 (princ "primary method")
327 (when (not (generic-primary-only-one-p generic))
328 (princ "s"))
329 )
330 (princ ".")
331 (terpri)
332 (terpri)
333 (let ((d (documentation generic)))
334 (if (not d)
335 (princ "The generic is not documented.\n")
336 (princ "Documentation:")
337 (terpri)
338 (princ d)
339 (terpri)
340 (terpri)))
341 (princ "Implementations:")
342 (terpri)
343 (terpri)
344 (let ((i 3)
345 (prefix [ ":STATIC" ":BEFORE" ":PRIMARY" ":AFTER" ] ))
346 ;; Loop over fanciful generics
347 (while (< i 6)
348 (let ((gm (aref (get generic 'eieio-method-tree) i)))
349 (when gm
350 (princ "Generic ")
351 (princ (aref prefix (- i 3)))
352 (terpri)
353 (princ (or (nth 2 gm) "Undocumented"))
354 (terpri)
355 (terpri)))
356 (setq i (1+ i)))
357 (setq i 0)
358 ;; Loop over defined class-specific methods
359 (while (< i 3)
360 (let ((gm (reverse (aref (get generic 'eieio-method-tree) i))))
361 (while gm
362 (princ "`")
363 (prin1 (car (car gm)))
364 (princ "'")
365 ;; prefix type
366 (princ " ")
367 (princ (aref prefix i))
368 (princ " ")
369 ;; argument list
370 (let* ((func (cdr (car gm)))
371 (arglst (eieio-lambda-arglist func)))
372 (prin1 arglst))
373 (terpri)
374 ;; 3 because of cdr
375 (princ (or (documentation (cdr (car gm)))
376 "Undocumented"))
377 (setq gm (cdr gm))
378 (terpri)
379 (terpri)))
380 (setq i (1+ i)))))
381 (save-excursion
382 (set-buffer (help-buffer))
383 (buffer-string)))
384
385 (defun eieio-lambda-arglist (func)
386 "Return the argument list of FUNC, a function body."
387 (if (symbolp func) (setq func (symbol-function func)))
388 (if (byte-code-function-p func)
389 (eieio-compiled-function-arglist func)
390 (car (cdr func))))
391
392 (defun eieio-all-generic-functions (&optional class)
393 "Return a list of all generic functions.
394 Optional CLASS argument returns only those functions that contain methods for CLASS."
395 (let ((l nil) tree (cn (if class (symbol-name class) nil)))
396 (mapatoms
397 (lambda (symbol)
398 (setq tree (get symbol 'eieio-method-obarray))
399 (if tree
400 (progn
401 ;; A symbol might be interned for that class in one of
402 ;; these three slots in the method-obarray.
403 (if (or (not class)
404 (fboundp (intern-soft cn (aref tree 0)))
405 (fboundp (intern-soft cn (aref tree 1)))
406 (fboundp (intern-soft cn (aref tree 2))))
407 (setq l (cons symbol l)))))))
408 l))
409
410 (defun eieio-method-documentation (generic class)
411 "Return a list of the specific documentation of GENERIC for CLASS.
412 If there is not an explicit method for CLASS in GENERIC, or if that
413 function has no documentation, then return nil."
414 (let ((tree (get generic 'eieio-method-obarray))
415 (cn (symbol-name class))
416 before primary after)
417 (if (not tree)
418 nil
419 ;; A symbol might be interned for that class in one of
420 ;; these three slots in the method-obarray.
421 (setq before (intern-soft cn (aref tree 0))
422 primary (intern-soft cn (aref tree 1))
423 after (intern-soft cn (aref tree 2)))
424 (if (not (or (fboundp before)
425 (fboundp primary)
426 (fboundp after)))
427 nil
428 (list (if (fboundp before)
429 (cons (eieio-lambda-arglist before)
430 (documentation before))
431 nil)
432 (if (fboundp primary)
433 (cons (eieio-lambda-arglist primary)
434 (documentation primary))
435 nil)
436 (if (fboundp after)
437 (cons (eieio-lambda-arglist after)
438 (documentation after))
439 nil))))))
440
441 (defvar eieio-read-generic nil
442 "History of the `eieio-read-generic' prompt.")
443
444 (defun eieio-read-generic-p (fn)
445 "Function used in function `eieio-read-generic'.
446 This is because `generic-p' is a macro.
447 Argument FN is the function to test."
448 (generic-p fn))
449
450 (defun eieio-read-generic (prompt &optional historyvar)
451 "Read a generic function from the minibuffer with PROMPT.
452 Optional argument HISTORYVAR is the variable to use as history."
453 (intern (completing-read prompt obarray 'eieio-read-generic-p
454 t nil (or historyvar 'eieio-read-generic))))
455
456 ;;; METHOD STATS
457 ;;
458 ;; Dump out statistics about all the active methods in a session.
459 (defun eieio-display-method-list ()
460 "Display a list of all the methods and what features are used."
461 (interactive)
462 (let* ((meth1 (eieio-all-generic-functions))
463 (meth (sort meth1 (lambda (a b)
464 (string< (symbol-name a)
465 (symbol-name b)))))
466 (buff (get-buffer-create "*EIEIO Method List*"))
467 (methidx 0)
468 (standard-output buff)
469 (slots '(method-static
470 method-before
471 method-primary
472 method-after
473 method-generic-before
474 method-generic-primary
475 method-generic-after))
476 (slotn '("static"
477 "before"
478 "primary"
479 "after"
480 "G bef"
481 "G prim"
482 "G aft"))
483 (idxarray (make-vector (length slots) 0))
484 (primaryonly 0)
485 (oneprimary 0)
486 )
487 (switch-to-buffer-other-window buff)
488 (erase-buffer)
489 (dolist (S slotn)
490 (princ S)
491 (princ "\t")
492 )
493 (princ "Method Name")
494 (terpri)
495 (princ "--------------------------------------------------------------------")
496 (terpri)
497 (dolist (M meth)
498 (let ((mtree (get M 'eieio-method-tree))
499 (P nil) (numP)
500 (!P nil))
501 (dolist (S slots)
502 (let ((num (length (aref mtree (symbol-value S)))))
503 (aset idxarray (symbol-value S)
504 (+ num (aref idxarray (symbol-value S))))
505 (prin1 num)
506 (princ "\t")
507 (when (< 0 num)
508 (if (eq S 'method-primary)
509 (setq P t numP num)
510 (setq !P t)))
511 ))
512 ;; Is this a primary-only impl method?
513 (when (and P (not !P))
514 (setq primaryonly (1+ primaryonly))
515 (when (= numP 1)
516 (setq oneprimary (1+ oneprimary))
517 (princ "*"))
518 (princ "* ")
519 )
520 (prin1 M)
521 (terpri)
522 (setq methidx (1+ methidx))
523 )
524 )
525 (princ "--------------------------------------------------------------------")
526 (terpri)
527 (dolist (S slots)
528 (prin1 (aref idxarray (symbol-value S)))
529 (princ "\t")
530 )
531 (prin1 methidx)
532 (princ " Total symbols")
533 (terpri)
534 (dolist (S slotn)
535 (princ S)
536 (princ "\t")
537 )
538 (terpri)
539 (terpri)
540 (princ "Methods Primary Only: ")
541 (prin1 primaryonly)
542 (princ "\t")
543 (princ (format "%d" (* (/ (float primaryonly) (float methidx)) 100)))
544 (princ "% of total methods")
545 (terpri)
546 (princ "Only One Primary Impl: ")
547 (prin1 oneprimary)
548 (princ "\t")
549 (princ (format "%d" (* (/ (float oneprimary) (float primaryonly)) 100)))
550 (princ "% of total primary methods")
551 (terpri)
552 ))
553
554 ;;; HELP AUGMENTATION
555 ;;
556 (defun eieio-help-mode-augmentation-maybee (&rest unused)
557 "For buffers thrown into help mode, augment for eieio.
558 Arguments UNUSED are not used."
559 ;; Scan created buttons so far if we are in help mode.
560 (when (eq major-mode 'help-mode)
561 (save-excursion
562 (goto-char (point-min))
563 (let ((pos t) (inhibit-read-only t))
564 (while pos
565 (if (get-text-property (point) 'help-xref) ; move off reference
566 (goto-char
567 (or (next-single-property-change (point) 'help-xref)
568 (point))))
569 (setq pos (next-single-property-change (point) 'help-xref))
570 (when pos
571 (goto-char pos)
572 (let* ((help-data (get-text-property (point) 'help-xref))
573 ;(method (car help-data))
574 (args (cdr help-data)))
575 (when (symbolp (car args))
576 (cond ((class-p (car args))
577 (setcar help-data 'eieio-describe-class))
578 ((generic-p (car args))
579 (setcar help-data 'eieio-describe-generic))
580 (t nil))
581 ))))
582 ;; start back at the beginning, and highlight some sections
583 (goto-char (point-min))
584 (while (re-search-forward "^\\(Documentation\\|Implementations\\):$" nil t)
585 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
586 (goto-char (point-min))
587 (if (re-search-forward "^Specialized Methods:$" nil t)
588 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
589 (goto-char (point-min))
590 (while (re-search-forward "^\\(Instance\\|Class\\) Allocated Slots:$" nil t)
591 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
592 (goto-char (point-min))
593 (while (re-search-forward ":\\(STATIC\\|BEFORE\\|AFTER\\|PRIMARY\\)" nil t)
594 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
595 (goto-char (point-min))
596 (while (re-search-forward "^\\(Private \\)?Slot:" nil t)
597 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
598 ))))
599
600 ;;; SPEEDBAR SUPPORT
601 ;;
602 (eval-when-compile
603 (condition-case nil
604 (require 'speedbar)
605 (error (message "Error loading speedbar... ignored."))))
606
607 (defvar eieio-class-speedbar-key-map nil
608 "Keymap used when working with a project in speedbar.")
609
610 (defun eieio-class-speedbar-make-map ()
611 "Make a keymap for eieio under speedbar."
612 (setq eieio-class-speedbar-key-map (speedbar-make-specialized-keymap))
613
614 ;; General viewing stuff
615 (define-key eieio-class-speedbar-key-map "\C-m" 'speedbar-edit-line)
616 (define-key eieio-class-speedbar-key-map "+" 'speedbar-expand-line)
617 (define-key eieio-class-speedbar-key-map "-" 'speedbar-contract-line)
618 )
619
620 (if eieio-class-speedbar-key-map
621 nil
622 (if (not (featurep 'speedbar))
623 (add-hook 'speedbar-load-hook (lambda ()
624 (eieio-class-speedbar-make-map)
625 (speedbar-add-expansion-list
626 '("EIEIO"
627 eieio-class-speedbar-menu
628 eieio-class-speedbar-key-map
629 eieio-class-speedbar))))
630 (eieio-class-speedbar-make-map)
631 (speedbar-add-expansion-list '("EIEIO"
632 eieio-class-speedbar-menu
633 eieio-class-speedbar-key-map
634 eieio-class-speedbar))))
635
636 (defvar eieio-class-speedbar-menu
637 ()
638 "Menu part in easymenu format used in speedbar while in `eieio' mode.")
639
640 (defun eieio-class-speedbar (dir-or-object depth)
641 "Create buttons in speedbar that represents the current project.
642 DIR-OR-OBJECT is the object to expand, or nil, and DEPTH is the current
643 expansion depth."
644 (when (eq (point-min) (point-max))
645 ;; This function is only called once, to start the whole deal.
646 ;; Ceate, and expand the default object.
647 (eieio-class-button eieio-default-superclass 0)
648 (forward-line -1)
649 (speedbar-expand-line)))
650
651 (defun eieio-class-button (class depth)
652 "Draw a speedbar button at the current point for CLASS at DEPTH."
653 (if (not (class-p class))
654 (signal 'wrong-type-argument (list 'class-p class)))
655 (let ((subclasses (aref (class-v class) class-children)))
656 (if subclasses
657 (speedbar-make-tag-line 'angle ?+
658 'eieio-sb-expand
659 class
660 (symbol-name class)
661 'eieio-describe-class-sb
662 class
663 'speedbar-directory-face
664 depth)
665 (speedbar-make-tag-line 'angle ? nil nil
666 (symbol-name class)
667 'eieio-describe-class-sb
668 class
669 'speedbar-directory-face
670 depth))))
671
672 (defun eieio-sb-expand (text class indent)
673 "For button TEXT, expand CLASS at the current location.
674 Argument INDENT is the depth of indentation."
675 (cond ((string-match "+" text) ;we have to expand this file
676 (speedbar-change-expand-button-char ?-)
677 (speedbar-with-writable
678 (save-excursion
679 (end-of-line) (forward-char 1)
680 (let ((subclasses (aref (class-v class) class-children)))
681 (while subclasses
682 (eieio-class-button (car subclasses) (1+ indent))
683 (setq subclasses (cdr subclasses)))))))
684 ((string-match "-" text) ;we have to contract this node
685 (speedbar-change-expand-button-char ?+)
686 (speedbar-delete-subblock indent))
687 (t (error "Ooops... not sure what to do")))
688 (speedbar-center-buffer-smartly))
689
690 (defun eieio-describe-class-sb (text token indent)
691 "Describe the class TEXT in TOKEN.
692 INDENT is the current indentation level."
693 (speedbar-with-attached-buffer
694 (eieio-describe-class token))
695 (speedbar-maybee-jump-to-attached-frame))
696
697 (provide 'eieio-opt)
698
699 ;;; eieio-opt.el ends here