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