annotate lisp/eieio/eieio-custom.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-custom.el -- eieio object customization
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) 1999, 2000, 2001, 2005, 2007, 2008, 2009
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
4 ;;; 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 customization of eieio objects. Enabling
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
28 ;; your object to be customizable requires use of the slot attirbute
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
29 ;; `:custom'.
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 (require 'widget)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
33 (require 'wid-edit)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
34 (require 'custom)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
35
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
36 ;;; Compatibility
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
37 ;;
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
38 (eval-and-compile
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
39 (if (featurep 'xemacs)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
40 (defalias 'eieio-overlay-lists (lambda () (list (extent-list))))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
41 (defalias 'eieio-overlay-lists 'overlay-lists)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
42 )
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
43 )
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
44 ;;; Code:
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
45 (defclass eieio-widget-test-class nil
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
46 ((a-string :initarg :a-string
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
47 :initform "The moose is loose"
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
48 :custom string
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
49 :label "Amorphous String"
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
50 :group (default foo)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
51 :documentation "A string for testing custom.
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
52 This is the next line of documentation.")
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
53 (listostuff :initarg :listostuff
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
54 :initform ("1" "2" "3")
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
55 :type list
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
56 :custom (repeat (string :tag "Stuff"))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
57 :label "List of Strings"
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
58 :group foo
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
59 :documentation "A list of stuff.")
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
60 (uninitialized :initarg :uninitialized
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
61 :type string
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
62 :custom string
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
63 :documentation "This slot is not initialized.
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
64 Used to make sure that custom doesn't barf when it encounters one
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
65 of these.")
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
66 (a-number :initarg :a-number
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
67 :initform 2
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
68 :custom integer
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
69 :documentation "A number of thingies."))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
70 "A class for testing the widget on.")
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 (defcustom eieio-widget-test (eieio-widget-test-class "Foo")
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
73 "Test variable for editing an object."
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
74 :type 'object
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
75 :group 'eieio)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
76
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
77 (defface eieio-custom-slot-tag-face '((((class color)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
78 (background dark))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
79 (:foreground "light blue"))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
80 (((class color)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
81 (background light))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
82 (:foreground "blue"))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
83 (t (:italic t)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
84 "Face used for unpushable variable tags."
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
85 :group 'custom-faces)
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 (defvar eieio-wo nil
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
88 "Buffer local variable in object customize buffers for the current widget.")
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
89 (defvar eieio-co nil
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
90 "Buffer local variable in object customize buffers for the current obj.")
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
91 (defvar eieio-cog nil
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
92 "Buffer local variable in object customize buffers for the current group.")
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
93
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
94 (defvar eieio-custom-ignore-eieio-co nil
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
95 "When true, all customizable slots of the current object are updated.
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
96 Updates occur regardless of the current customization group.")
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
97
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
98 (define-widget 'object-slot 'group
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
99 "Abstractly modify a single slot in an object."
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
100 :tag "Slot"
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
101 :format "%t %v%h\n"
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
102 :convert-widget 'widget-types-convert-widget
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
103 :value-create 'eieio-slot-value-create
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
104 :value-get 'eieio-slot-value-get
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
105 :value-delete 'widget-children-value-delete
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
106 :validate 'widget-children-validate
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
107 :match 'eieio-object-match ;; same
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
108 )
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
109
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
110 (defun eieio-slot-value-create (widget)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
111 "Create the value of WIDGET."
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
112 (let ((chil nil)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
113 )
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
114 ; (setq chil (cons (widget-create-child-and-convert
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
115 ; widget 'visibility
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
116 ; :help-echo "Hide the value of this option."
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
117 ; :action 'eieio-custom-toggle-parent
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
118 ; t)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
119 ; chil))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
120 (setq chil (cons
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
121 (widget-create-child-and-convert
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
122 widget (widget-get widget :childtype)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
123 :tag ""
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
124 :value (widget-get widget :value))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
125 chil))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
126 (widget-put widget :children chil)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
127
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
128 (defun eieio-slot-value-get (widget)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
129 "Get the value of WIDGET."
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
130 (widget-value (car (widget-get widget :children))))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
131
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
132 (defun eieio-custom-toggle-hide (widget)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
133 "Toggle visibility of WIDGET."
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
134 (let ((vc (car (widget-get widget :children))))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
135 (cond ((eq (widget-get vc :eieio-custom-state) 'hidden)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
136 (widget-put vc :eieio-custom-state 'visible)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
137 (widget-put vc :value-face (widget-get vc :orig-face)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
138 (t
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
139 (widget-put vc :eieio-custom-state 'hidden)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
140 (widget-put vc :orig-face (widget-get vc :value-face))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
141 (widget-put vc :value-face 'invisible)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
142 ))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
143 (widget-value-set vc (widget-value vc))))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
144
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
145 (defun eieio-custom-toggle-parent (widget &rest ignore)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
146 "Toggle visibility of parent of WIDGET.
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
147 Optional argument IGNORE is an extraneous parameter."
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
148 (eieio-custom-toggle-hide (widget-get widget :parent)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
149
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
150 (define-widget 'object-edit 'group
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
151 "Abstractly modify a CLOS object."
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
152 :tag "Object"
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
153 :format "%v"
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
154 :convert-widget 'widget-types-convert-widget
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
155 :value-create 'eieio-object-value-create
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
156 :value-get 'eieio-object-value-get
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
157 :value-delete 'widget-children-value-delete
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
158 :validate 'widget-children-validate
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
159 :match 'eieio-object-match
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
160 :clone-object-children nil
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
161 )
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
162
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
163 (defun eieio-object-match (widget value)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
164 "Match info for WIDGET against VALUE."
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
165 ;; Write me
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
166 t)
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-filter-slot-type (widget slottype)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
169 "Filter WIDGETs SLOTTYPE."
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
170 (if (widget-get widget :clone-object-children)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
171 slottype
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
172 (cond ((eq slottype 'object)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
173 'object-edit)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
174 ((and (listp slottype)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
175 (eq (car slottype) 'object))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
176 (cons 'object-edit (cdr slottype)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
177 ((equal slottype '(repeat object))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
178 '(repeat object-edit))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
179 ((and (listp slottype)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
180 (equal (car slottype) 'repeat)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
181 (listp (car (cdr slottype)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
182 (equal (car (car (cdr slottype))) 'object))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
183 (list 'repeat
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
184 (cons 'object-edit
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
185 (cdr (car (cdr slottype))))))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
186 (t slottype))))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
187
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
188 (defun eieio-object-value-create (widget)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
189 "Create the value of WIDGET."
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
190 (if (not (widget-get widget :value))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
191 (widget-put widget
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
192 :value (cond ((widget-get widget :objecttype)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
193 (funcall (class-constructor
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
194 (widget-get widget :objecttype))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
195 "Custom-new"))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
196 ((widget-get widget :objectcreatefcn)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
197 (funcall (widget-get widget :objectcreatefcn)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
198 (t (error "No create method specified")))))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
199 (let* ((chil nil)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
200 (obj (widget-get widget :value))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
201 (master-group (widget-get widget :eieio-group))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
202 (cv (class-v (object-class-fast obj)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
203 (slots (aref cv class-public-a))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
204 (flabel (aref cv class-public-custom-label))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
205 (fgroup (aref cv class-public-custom-group))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
206 (fdoc (aref cv class-public-doc))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
207 (fcust (aref cv class-public-custom)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
208 ;; First line describes the object, but may not editable.
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
209 (if (widget-get widget :eieio-show-name)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
210 (setq chil (cons (widget-create-child-and-convert
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
211 widget 'string :tag "Object "
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
212 :sample-face 'bold
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
213 (object-name-string obj))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
214 chil)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
215 ;; Display information about the group being shown
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
216 (when master-group
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
217 (let ((groups (class-option (object-class-fast obj) :custom-groups)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
218 (widget-insert "Groups:")
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
219 (while groups
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
220 (widget-insert " ")
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
221 (if (eq (car groups) master-group)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
222 (widget-insert "*" (capitalize (symbol-name master-group)) "*")
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
223 (widget-create 'push-button
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
224 :thing (cons obj (car groups))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
225 :notify (lambda (widget &rest stuff)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
226 (eieio-customize-object
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
227 (car (widget-get widget :thing))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
228 (cdr (widget-get widget :thing))))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
229 (capitalize (symbol-name (car groups)))))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
230 (setq groups (cdr groups)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
231 (widget-insert "\n\n")))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
232 ;; Loop over all the slots, creating child widgets.
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
233 (while slots
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
234 ;; Output this slot if it has a customize flag associated with it.
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
235 (when (and (car fcust)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
236 (or (not master-group) (member master-group (car fgroup)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
237 (slot-boundp obj (car slots)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
238 ;; In this case, this slot has a custom type. Create it's
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
239 ;; children widgets.
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
240 (let ((type (eieio-filter-slot-type widget (car fcust)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
241 (stuff nil))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
242 ;; This next bit is an evil hack to get some EDE functions
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
243 ;; working the way I like.
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
244 (if (and (listp type)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
245 (setq stuff (member :slotofchoices type)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
246 (let ((choices (eieio-oref obj (car (cdr stuff))))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
247 (newtype nil))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
248 (while (not (eq (car type) :slotofchoices))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
249 (setq newtype (cons (car type) newtype)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
250 type (cdr type)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
251 (while choices
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
252 (setq newtype (cons (list 'const (car choices))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
253 newtype)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
254 choices (cdr choices)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
255 (setq type (nreverse newtype))))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
256 (setq chil (cons (widget-create-child-and-convert
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
257 widget 'object-slot
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
258 :childtype type
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
259 :sample-face 'eieio-custom-slot-tag-face
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
260 :tag
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
261 (concat
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
262 (make-string
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
263 (or (widget-get widget :indent) 0)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
264 ? )
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
265 (if (car flabel)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
266 (car flabel)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
267 (let ((s (symbol-name
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
268 (or
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
269 (class-slot-initarg
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
270 (object-class-fast obj)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
271 (car slots))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
272 (car slots)))))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
273 (capitalize
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
274 (if (string-match "^:" s)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
275 (substring s (match-end 0))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
276 s)))))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
277 :value (slot-value obj (car slots))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
278 :doc (if (car fdoc) (car fdoc)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
279 "Slot not Documented.")
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
280 :eieio-custom-visibility 'visible
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 chil))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
283 )
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
284 )
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
285 (setq slots (cdr slots)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
286 fdoc (cdr fdoc)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
287 fcust (cdr fcust)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
288 flabel (cdr flabel)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
289 fgroup (cdr fgroup)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
290 (widget-put widget :children (nreverse chil))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
291 ))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
292
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
293 (defun eieio-object-value-get (widget)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
294 "Get the value of WIDGET."
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
295 (let* ((obj (widget-get widget :value))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
296 (master-group eieio-cog)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
297 (cv (class-v (object-class-fast obj)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
298 (fgroup (aref cv class-public-custom-group))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
299 (wids (widget-get widget :children))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
300 (name (if (widget-get widget :eieio-show-name)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
301 (car (widget-apply (car wids) :value-inline))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
302 nil))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
303 (chil (if (widget-get widget :eieio-show-name)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
304 (nthcdr 1 wids) wids))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
305 (cv (class-v (object-class-fast obj)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
306 (slots (aref cv class-public-a))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
307 (fcust (aref cv class-public-custom)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
308 ;; If there are any prefix widgets, clear them.
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
309 ;; -- None yet
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
310 ;; Create a batch of initargs for each slot.
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
311 (while (and slots chil)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
312 (if (and (car fcust)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
313 (or eieio-custom-ignore-eieio-co
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
314 (not master-group) (member master-group (car fgroup)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
315 (slot-boundp obj (car slots)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
316 (progn
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
317 ;; Only customized slots have widgets
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
318 (let ((eieio-custom-ignore-eieio-co t))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
319 (eieio-oset obj (car slots)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
320 (car (widget-apply (car chil) :value-inline))))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
321 (setq chil (cdr chil))))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
322 (setq slots (cdr slots)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
323 fgroup (cdr fgroup)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
324 fcust (cdr fcust)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
325 ;; Set any name updates on it.
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
326 (if name (aset obj object-name name))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
327 ;; This is the same object we had before.
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
328 obj))
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 (defmethod eieio-done-customizing ((obj eieio-default-superclass))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
331 "When a applying change to a widget, call this method.
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
332 This method is called by the default widget-edit commands. User made
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
333 commands should also call this method when applying changes.
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
334 Argument OBJ is the object that has been customized."
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
335 nil)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
336
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
337 (defun customize-object (obj &optional group)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
338 "Customize OBJ in a custom buffer.
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
339 Optional argument GROUP is the sub-group of slots to display."
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
340 (eieio-customize-object obj group))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
341
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
342 (defmethod eieio-customize-object ((obj eieio-default-superclass)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
343 &optional group)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
344 "Customize OBJ in a specialized custom buffer.
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
345 To override call the `eieio-custom-widget-insert' to just insert the
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
346 object widget.
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
347 Optional argument GROUP specifies a subgroup of slots to edit as a symbol.
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
348 These groups are specified with the `:group' slot flag."
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
349 ;; Insert check for multiple edits here.
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
350 (let* ((g (or group 'default)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
351 (switch-to-buffer (get-buffer-create
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
352 (concat "*CUSTOMIZE "
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
353 (object-name obj) " "
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
354 (symbol-name g) "*")))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
355 (toggle-read-only -1)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
356 (kill-all-local-variables)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
357 (erase-buffer)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
358 (let ((all (eieio-overlay-lists)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
359 ;; Delete all the overlays.
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
360 (mapc 'delete-overlay (car all))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
361 (mapc 'delete-overlay (cdr all)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
362 ;; Add an apply reset option at the top of the buffer.
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
363 (eieio-custom-object-apply-reset obj)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
364 (widget-insert "\n\n")
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
365 (widget-insert "Edit object " (object-name obj) "\n\n")
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
366 ;; Create the widget editing the object.
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
367 (make-local-variable 'eieio-wo)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
368 (setq eieio-wo (eieio-custom-widget-insert obj :eieio-group g))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
369 ;;Now generate the apply buttons
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
370 (widget-insert "\n")
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
371 (eieio-custom-object-apply-reset obj)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
372 ;; Now initialize the buffer
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
373 (use-local-map widget-keymap)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
374 (widget-setup)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
375 ;;(widget-minor-mode)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
376 (goto-char (point-min))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
377 (widget-forward 3)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
378 (make-local-variable 'eieio-co)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
379 (setq eieio-co obj)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
380 (make-local-variable 'eieio-cog)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
381 (setq eieio-cog group)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
382
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
383 (defmethod eieio-custom-object-apply-reset ((obj eieio-default-superclass))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
384 "Insert an Apply and Reset button into the object editor.
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
385 Argument OBJ os the object being customized."
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
386 (widget-create 'push-button
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
387 :notify (lambda (&rest ignore)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
388 (widget-apply eieio-wo :value-get)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
389 (eieio-done-customizing eieio-co)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
390 (bury-buffer))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
391 "Accept")
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
392 (widget-insert " ")
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
393 (widget-create 'push-button
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
394 :notify (lambda (&rest ignore)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
395 ;; I think the act of getting it sets
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
396 ;; it's value through the get function.
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
397 (message "Applying Changes...")
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
398 (widget-apply eieio-wo :value-get)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
399 (eieio-done-customizing eieio-co)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
400 (message "Applying Changes...Done."))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
401 "Apply")
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
402 (widget-insert " ")
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
403 (widget-create 'push-button
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
404 :notify (lambda (&rest ignore)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
405 (message "Resetting.")
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
406 (eieio-customize-object eieio-co eieio-cog))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
407 "Reset")
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
408 (widget-insert " ")
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
409 (widget-create 'push-button
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
410 :notify (lambda (&rest ignore)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
411 (bury-buffer))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
412 "Cancel"))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
413
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
414 (defmethod eieio-custom-widget-insert ((obj eieio-default-superclass)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
415 &rest flags)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
416 "Insert the widget used for editing object OBJ in the current buffer.
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
417 Arguments FLAGS are widget compatible flags.
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
418 Must return the created widget."
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
419 (apply 'widget-create 'object-edit :value obj flags))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
420
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
421 (define-widget 'object 'object-edit
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
422 "Instance of a CLOS class."
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
423 :format "%{%t%}:\n%v"
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
424 :value-to-internal 'eieio-object-value-to-abstract
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
425 :value-to-external 'eieio-object-abstract-to-value
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
426 :clone-object-children t
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
427 )
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
428
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
429 (defun eieio-object-value-to-abstract (widget value)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
430 "For WIDGET, convert VALUE to an abstract /safe/ representation."
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
431 (if (eieio-object-p value) value
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
432 (if (null value) value
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
433 nil)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
434
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
435 (defun eieio-object-abstract-to-value (widget value)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
436 "For WIDGET, convert VALUE from an abstract /safe/ representation."
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
437 value)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
438
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
439
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
440 ;;; customization group functions
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
441 ;;
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
442 ;; These functions provide the ability to create dynamic menus to
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
443 ;; customize specific sections of an object. They do not hook directly
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
444 ;; into a filter, but can be used to create easymenu vectors.
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
445 (defmethod eieio-customize-object-group ((obj eieio-default-superclass))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
446 "Create a list of vectors for customizing sections of OBJ."
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
447 (mapcar (lambda (group)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
448 (vector (concat "Group " (symbol-name group))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
449 (list 'customize-object obj (list 'quote group))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
450 t))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
451 (class-option (object-class-fast obj) :custom-groups)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
452
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
453 (defvar eieio-read-custom-group-history nil
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
454 "History for the custom group reader.")
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 (defmethod eieio-read-customization-group ((obj eieio-default-superclass))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
457 "Do a completing read on the name of a customization group in OBJ.
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
458 Return the symbol for the group, or nil"
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
459 (let ((g (class-option (object-class-fast obj) :custom-groups)))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
460 (if (= (length g) 1)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
461 (car g)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
462 ;; Make the association list
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
463 (setq g (mapcar (lambda (g) (cons (symbol-name g) g)) g))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
464 (cdr (assoc
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
465 (completing-read (concat (oref obj name) " Custom Group: ")
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
466 g nil t nil 'eieio-read-custom-group-history)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
467 g)))))
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
468
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
469 (provide 'eieio-custom)
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
470
2efe3dc24373 Add files for the EIEIO library.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
471 ;;; eieio-custom.el ends here