annotate lisp/eieio/eieio-opt.el @ 104404:7602fd69cd93

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