annotate lisp/emacs-lisp/eieio-custom.el @ 105237:1a62d24e31a6

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