annotate lisp/custom/cus-edit.el @ 28:1917ad0d78d7 r19-15b97

Import from CVS: tag r19-15b97
author cvs
date Mon, 13 Aug 2007 08:51:55 +0200
parents
children ec9a17fef872
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1 ;;; cus-edit.el --- Tools for customization Emacs.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
2 ;;
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
3 ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
4 ;;
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
6 ;; Keywords: help, faces
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
7 ;; Version: 1.50
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
8 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
9
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
10 ;;; Commentary:
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
11 ;;
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
12 ;; See `custom.el'.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
13
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
14 ;;; Code:
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
15
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
16 (require 'cus-face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
17 (require 'wid-edit)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
18 (require 'easymenu)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
19
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
20 (define-widget-keywords :custom-prefixes :custom-menu :custom-show
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
21 :custom-magic :custom-state :custom-level :custom-form
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
22 :custom-set :custom-save :custom-reset-current :custom-reset-saved
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
23 :custom-reset-factory)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
24
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
25 ;;; Customization Groups.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
26
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
27 (defgroup emacs nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
28 "Customization of the One True Editor."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
29 :link '(custom-manual "(emacs)Top"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
30
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
31 ;; Most of these groups are stolen from `finder.el',
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
32 (defgroup editing nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
33 "Basic text editing facilities."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
34 :group 'emacs)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
35
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
36 (defgroup abbrev nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
37 "Abbreviation handling, typing shortcuts, macros."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
38 :tag "Abbreviations"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
39 :group 'editing)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
40
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
41 (defgroup matching nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
42 "Various sorts of searching and matching."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
43 :group 'editing)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
44
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
45 (defgroup emulations nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
46 "Emulations of other editors."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
47 :group 'editing)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
48
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
49 (defgroup mouse nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
50 "Mouse support."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
51 :group 'editing)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
52
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
53 (defgroup outlines nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
54 "Support for hierarchical outlining."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
55 :group 'editing)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
56
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
57 (defgroup external nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
58 "Interfacing to external utilities."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
59 :group 'emacs)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
60
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
61 (defgroup bib nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
62 "Code related to the `bib' bibliography processor."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
63 :tag "Bibliography"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
64 :group 'external)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
65
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
66 (defgroup processes nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
67 "Process, subshell, compilation, and job control support."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
68 :group 'external
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
69 :group 'development)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
70
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
71 (defgroup programming nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
72 "Support for programming in other languages."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
73 :group 'emacs)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
74
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
75 (defgroup languages nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
76 "Specialized modes for editing programming languages."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
77 :group 'programming)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
78
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
79 (defgroup lisp nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
80 "Lisp support, including Emacs Lisp."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
81 :group 'languages
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
82 :group 'development)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
83
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
84 (defgroup c nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
85 "Support for the C language and related languages."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
86 :group 'languages)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
87
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
88 (defgroup tools nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
89 "Programming tools."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
90 :group 'programming)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
91
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
92 (defgroup oop nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
93 "Support for object-oriented programming."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
94 :group 'programming)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
95
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
96 (defgroup applications nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
97 "Applications written in Emacs."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
98 :group 'emacs)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
99
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
100 (defgroup calendar nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
101 "Calendar and time management support."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
102 :group 'applications)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
103
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
104 (defgroup mail nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
105 "Modes for electronic-mail handling."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
106 :group 'applications)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
107
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
108 (defgroup news nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
109 "Support for netnews reading and posting."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
110 :group 'applications)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
111
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
112 (defgroup games nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
113 "Games, jokes and amusements."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
114 :group 'applications)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
115
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
116 (defgroup development nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
117 "Support for further development of Emacs."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
118 :group 'emacs)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
119
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
120 (defgroup docs nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
121 "Support for Emacs documentation."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
122 :group 'development)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
123
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
124 (defgroup extensions nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
125 "Emacs Lisp language extensions."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
126 :group 'development)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
127
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
128 (defgroup internal nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
129 "Code for Emacs internals, build process, defaults."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
130 :group 'development)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
131
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
132 (defgroup maint nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
133 "Maintenance aids for the Emacs development group."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
134 :tag "Maintenance"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
135 :group 'development)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
136
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
137 (defgroup environment nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
138 "Fitting Emacs with its environment."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
139 :group 'emacs)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
140
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
141 (defgroup comm nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
142 "Communications, networking, remote access to files."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
143 :tag "Communication"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
144 :group 'environment)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
145
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
146 (defgroup hardware nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
147 "Support for interfacing with exotic hardware."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
148 :group 'environment)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
149
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
150 (defgroup terminals nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
151 "Support for terminal types."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
152 :group 'environment)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
153
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
154 (defgroup unix nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
155 "Front-ends/assistants for, or emulators of, UNIX features."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
156 :group 'environment)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
157
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
158 (defgroup vms nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
159 "Support code for vms."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
160 :group 'environment)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
161
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
162 (defgroup i18n nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
163 "Internationalization and alternate character-set support."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
164 :group 'environment
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
165 :group 'editing)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
166
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
167 (defgroup frames nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
168 "Support for Emacs frames and window systems."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
169 :group 'environment)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
170
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
171 (defgroup data nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
172 "Support editing files of data."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
173 :group 'emacs)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
174
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
175 (defgroup wp nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
176 "Word processing."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
177 :group 'emacs)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
178
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
179 (defgroup tex nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
180 "Code related to the TeX formatter."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
181 :group 'wp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
182
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
183 (defgroup faces nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
184 "Support for multiple fonts."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
185 :group 'emacs)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
186
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
187 (defgroup hypermedia nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
188 "Support for links between text or other media types."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
189 :group 'emacs)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
190
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
191 (defgroup help nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
192 "Support for on-line help systems."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
193 :group 'emacs)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
194
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
195 (defgroup local nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
196 "Code local to your site."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
197 :group 'emacs)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
198
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
199 (defgroup customize '((widgets custom-group))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
200 "Customization of the Customization support."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
201 :link '(custom-manual "(custom)Top")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
202 :link '(url-link :tag "Development Page"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
203 "http://www.dina.kvl.dk/~abraham/custom/")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
204 :prefix "custom-"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
205 :group 'help
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
206 :group 'faces)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
207
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
208 ;;; Utilities.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
209
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
210 (defun custom-quote (sexp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
211 "Quote SEXP iff it is not self quoting."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
212 (if (or (memq sexp '(t nil))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
213 (and (symbolp sexp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
214 (eq (aref (symbol-name sexp) 0) ?:))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
215 (and (listp sexp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
216 (memq (car sexp) '(lambda)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
217 (stringp sexp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
218 (numberp sexp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
219 (and (fboundp 'characterp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
220 (characterp sexp)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
221 sexp
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
222 (list 'quote sexp)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
223
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
224 (defun custom-split-regexp-maybe (regexp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
225 "If REGEXP is a string, split it to a list at `\\|'.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
226 You can get the original back with from the result with:
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
227 (mapconcat 'identity result \"\\|\")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
228
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
229 IF REGEXP is not a string, return it unchanged."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
230 (if (stringp regexp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
231 (let ((start 0)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
232 all)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
233 (while (string-match "\\\\|" regexp start)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
234 (setq all (cons (substring regexp start (match-beginning 0)) all)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
235 start (match-end 0)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
236 (nreverse (cons (substring regexp start) all)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
237 regexp))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
238
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
239 (defvar custom-prefix-list nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
240 "List of prefixes that should be ignored by `custom-unlispify'")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
241
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
242 (defcustom custom-unlispify-menu-entries t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
243 "Display menu entries as words instead of symbols if non nil."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
244 :group 'customize
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
245 :type 'boolean)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
246
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
247 (defun custom-unlispify-menu-entry (symbol &optional no-suffix)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
248 "Convert symbol into a menu entry."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
249 (cond ((not custom-unlispify-menu-entries)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
250 (symbol-name symbol))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
251 ((get symbol 'custom-tag)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
252 (if no-suffix
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
253 (get symbol 'custom-tag)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
254 (concat (get symbol 'custom-tag) "...")))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
255 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
256 (save-excursion
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
257 (set-buffer (get-buffer-create " *Custom-Work*"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
258 (erase-buffer)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
259 (princ symbol (current-buffer))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
260 (goto-char (point-min))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
261 (let ((prefixes custom-prefix-list)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
262 prefix)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
263 (while prefixes
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
264 (setq prefix (car prefixes))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
265 (if (search-forward prefix (+ (point) (length prefix)) t)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
266 (progn
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
267 (setq prefixes nil)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
268 (delete-region (point-min) (point)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
269 (setq prefixes (cdr prefixes)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
270 (subst-char-in-region (point-min) (point-max) ?- ?\ t)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
271 (capitalize-region (point-min) (point-max))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
272 (unless no-suffix
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
273 (goto-char (point-max))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
274 (insert "..."))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
275 (buffer-string)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
276
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
277 (defcustom custom-unlispify-tag-names t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
278 "Display tag names as words instead of symbols if non nil."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
279 :group 'customize
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
280 :type 'boolean)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
281
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
282 (defun custom-unlispify-tag-name (symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
283 "Convert symbol into a menu entry."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
284 (let ((custom-unlispify-menu-entries custom-unlispify-tag-names))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
285 (custom-unlispify-menu-entry symbol t)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
286
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
287 (defun custom-prefix-add (symbol prefixes)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
288 ;; Addd SYMBOL to list of ignored PREFIXES.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
289 (cons (or (get symbol 'custom-prefix)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
290 (concat (symbol-name symbol) "-"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
291 prefixes))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
292
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
293 ;;; The Custom Mode.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
294
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
295 (defvar custom-options nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
296 "Customization widgets in the current buffer.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
297
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
298 (defvar custom-mode-map nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
299 "Keymap for `custom-mode'.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
300
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
301 (unless custom-mode-map
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
302 (setq custom-mode-map (make-sparse-keymap))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
303 (set-keymap-parent custom-mode-map widget-keymap))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
304
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
305 (easy-menu-define custom-mode-menu
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
306 custom-mode-map
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
307 "Menu used in customization buffers."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
308 '("Custom"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
309 ["Set" custom-set t]
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
310 ["Save" custom-save t]
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
311 ["Reset to Current" custom-reset-current t]
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
312 ["Reset to Saved" custom-reset-saved t]
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
313 ["Reset to Factory Settings" custom-reset-factory t]
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
314 ["Info" (Info-goto-node "(custom)The Customization Buffer") t]))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
315
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
316 (defcustom custom-mode-hook nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
317 "Hook called when entering custom-mode."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
318 :type 'hook
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
319 :group 'customize)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
320
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
321 (defun custom-mode ()
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
322 "Major mode for editing customization buffers.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
323
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
324 The following commands are available:
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
325
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
326 \\[widget-forward] Move to next button or editable field.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
327 \\[widget-backward] Move to previous button or editable field.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
328 \\[widget-button-click] Activate button under the mouse pointer.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
329 \\[widget-button-press] Activate button under point.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
330 \\[custom-set] Set all modifications.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
331 \\[custom-save] Make all modifications default.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
332 \\[custom-reset-current] Reset all modified options.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
333 \\[custom-reset-saved] Reset all modified or set options.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
334 \\[custom-reset-factory] Reset all options.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
335
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
336 Entry to this mode calls the value of `custom-mode-hook'
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
337 if that value is non-nil."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
338 (kill-all-local-variables)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
339 (setq major-mode 'custom-mode
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
340 mode-name "Custom")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
341 (use-local-map custom-mode-map)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
342 (easy-menu-add custom-mode-menu)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
343 (make-local-variable 'custom-options)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
344 (run-hooks 'custom-mode-hook))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
345
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
346 ;;; Custom Mode Commands.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
347
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
348 (defun custom-set ()
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
349 "Set changes in all modified options."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
350 (interactive)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
351 (let ((children custom-options))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
352 (mapcar (lambda (child)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
353 (when (eq (widget-get child :custom-state) 'modified)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
354 (widget-apply child :custom-set)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
355 children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
356
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
357 (defun custom-save ()
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
358 "Set all modified group members and save them."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
359 (interactive)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
360 (let ((children custom-options))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
361 (mapcar (lambda (child)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
362 (when (memq (widget-get child :custom-state) '(modified set))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
363 (widget-apply child :custom-save)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
364 children))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
365 (custom-save-all))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
366
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
367 (defvar custom-reset-menu
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
368 '(("Current" . custom-reset-current)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
369 ("Saved" . custom-reset-saved)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
370 ("Factory Settings" . custom-reset-factory))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
371 "Alist of actions for the `Reset' button.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
372 The key is a string containing the name of the action, the value is a
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
373 lisp function taking the widget as an element which will be called
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
374 when the action is chosen.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
375
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
376 (defun custom-reset (event)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
377 "Select item from reset menu."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
378 (let* ((completion-ignore-case t)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
379 (answer (widget-choose "Reset to"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
380 custom-reset-menu
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
381 event)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
382 (if answer
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
383 (funcall answer))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
384
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
385 (defun custom-reset-current ()
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
386 "Reset all modified group members to their current value."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
387 (interactive)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
388 (let ((children custom-options))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
389 (mapcar (lambda (child)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
390 (when (eq (widget-get child :custom-state) 'modified)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
391 (widget-apply child :custom-reset-current)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
392 children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
393
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
394 (defun custom-reset-saved ()
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
395 "Reset all modified or set group members to their saved value."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
396 (interactive)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
397 (let ((children custom-options))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
398 (mapcar (lambda (child)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
399 (when (eq (widget-get child :custom-state) 'modified)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
400 (widget-apply child :custom-reset-current)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
401 children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
402
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
403 (defun custom-reset-factory ()
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
404 "Reset all modified, set, or saved group members to their factory settings."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
405 (interactive)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
406 (let ((children custom-options))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
407 (mapcar (lambda (child)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
408 (when (eq (widget-get child :custom-state) 'modified)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
409 (widget-apply child :custom-reset-current)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
410 children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
411
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
412 ;;; The Customize Commands
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
413
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
414 ;;;###autoload
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
415 (defun customize (symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
416 "Customize SYMBOL, which must be a customization group."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
417 (interactive (list (completing-read "Customize group: (default emacs) "
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
418 obarray
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
419 (lambda (symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
420 (get symbol 'custom-group))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
421 t)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
422
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
423 (when (stringp symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
424 (if (string-equal "" symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
425 (setq symbol 'emacs)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
426 (setq symbol (intern symbol))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
427 (custom-buffer-create (list (list symbol 'custom-group))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
428
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
429 ;;;###autoload
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
430 (defun customize-variable (symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
431 "Customize SYMBOL, which must be a variable."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
432 (interactive
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
433 ;; Code stolen from `help.el'.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
434 (let ((v (variable-at-point))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
435 (enable-recursive-minibuffers t)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
436 val)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
437 (setq val (completing-read
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
438 (if v
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
439 (format "Customize variable (default %s): " v)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
440 "Customize variable: ")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
441 obarray 'boundp t))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
442 (list (if (equal val "")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
443 v (intern val)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
444 (custom-buffer-create (list (list symbol 'custom-variable))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
445
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
446 ;;;###autoload
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
447 (defun customize-face (&optional symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
448 "Customize SYMBOL, which should be a face name or nil.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
449 If SYMBOL is nil, customize all faces."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
450 (interactive (list (completing-read "Customize face: (default all) "
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
451 obarray 'custom-facep)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
452 (if (or (null symbol) (and (stringp symbol) (zerop (length symbol))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
453 (let ((found nil))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
454 (message "Looking for faces...")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
455 (mapcar (lambda (symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
456 (setq found (cons (list symbol 'custom-face) found)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
457 (face-list))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
458 (message "Creating customization buffer...")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
459 (custom-buffer-create found))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
460 (if (stringp symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
461 (setq symbol (intern symbol)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
462 (unless (symbolp symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
463 (error "Should be a symbol %S" symbol))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
464 (custom-buffer-create (list (list symbol 'custom-face)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
465
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
466 ;;;###autoload
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
467 (defun customize-customized ()
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
468 "Customize all already customized user options."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
469 (interactive)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
470 (let ((found nil))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
471 (mapatoms (lambda (symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
472 (and (get symbol 'saved-face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
473 (custom-facep symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
474 (setq found (cons (list symbol 'custom-face) found)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
475 (and (get symbol 'saved-value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
476 (boundp symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
477 (setq found
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
478 (cons (list symbol 'custom-variable) found)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
479 (if found
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
480 (custom-buffer-create found)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
481 (error "No customized user options"))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
482
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
483 ;;;###autoload
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
484 (defun customize-apropos (regexp &optional all)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
485 "Customize all user options matching REGEXP.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
486 If ALL (e.g., started with a prefix key), include options which are not
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
487 user-settable."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
488 (interactive "sCustomize regexp: \nP")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
489 (let ((found nil))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
490 (mapatoms (lambda (symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
491 (when (string-match regexp (symbol-name symbol))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
492 (when (get symbol 'custom-group)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
493 (setq found (cons (list symbol 'custom-group) found)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
494 (when (custom-facep symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
495 (setq found (cons (list symbol 'custom-face) found)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
496 (when (and (boundp symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
497 (or (get symbol 'saved-value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
498 (get symbol 'factory-value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
499 (if all
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
500 (get symbol 'variable-documentation)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
501 (user-variable-p symbol))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
502 (setq found
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
503 (cons (list symbol 'custom-variable) found))))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
504 (if found
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
505 (custom-buffer-create found)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
506 (error "No matches"))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
507
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
508 ;;;###autoload
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
509 (defun custom-buffer-create (options)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
510 "Create a buffer containing OPTIONS.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
511 OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
512 SYMBOL is a customization option, and WIDGET is a widget for editing
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
513 that option."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
514 (kill-buffer (get-buffer-create "*Customization*"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
515 (switch-to-buffer (get-buffer-create "*Customization*"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
516 (custom-mode)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
517 (widget-insert "This is a customization buffer.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
518 Push RET or click mouse-2 on the word ")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
519 (widget-create 'info-link
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
520 :tag "help"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
521 :help-echo "Push me for help."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
522 "(custom)The Customization Buffer")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
523 (widget-insert " for more information.\n\n")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
524 (setq custom-options
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
525 (mapcar (lambda (entry)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
526 (prog1
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
527 (if (> (length options) 1)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
528 (widget-create (nth 1 entry)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
529 :tag (custom-unlispify-tag-name
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
530 (nth 0 entry))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
531 :value (nth 0 entry))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
532 ;; If there is only one entry, don't hide it!
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
533 (widget-create (nth 1 entry)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
534 :custom-state 'unknown
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
535 :tag (custom-unlispify-tag-name
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
536 (nth 0 entry))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
537 :value (nth 0 entry)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
538 (unless (eq (preceding-char) ?\n)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
539 (widget-insert "\n"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
540 (widget-insert "\n")))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
541 options))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
542 (mapcar 'custom-magic-reset custom-options)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
543 (widget-create 'push-button
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
544 :tag "Set"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
545 :help-echo "Push me to set all modifications."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
546 :action (lambda (widget &optional event)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
547 (custom-set)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
548 (widget-insert " ")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
549 (widget-create 'push-button
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
550 :tag "Save"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
551 :help-echo "Push me to make the modifications default."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
552 :action (lambda (widget &optional event)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
553 (custom-save)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
554 (widget-insert " ")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
555 (widget-create 'push-button
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
556 :tag "Reset"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
557 :help-echo "Push me to undo all modifications."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
558 :action (lambda (widget &optional event)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
559 (custom-reset event)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
560 (widget-insert " ")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
561 (widget-create 'push-button
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
562 :tag "Done"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
563 :help-echo "Push me to bury the buffer."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
564 :action (lambda (widget &optional event)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
565 (bury-buffer)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
566 ;; Steal button release event.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
567 (if (and (fboundp 'button-press-event-p)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
568 (fboundp 'next-command-event))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
569 ;; XEmacs
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
570 (and event
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
571 (button-press-event-p event)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
572 (next-command-event))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
573 ;; Emacs
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
574 (when (memq 'down (event-modifiers event))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
575 (read-event)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
576 (widget-insert "\n")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
577 (widget-setup))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
578
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
579 ;;; Modification of Basic Widgets.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
580 ;;
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
581 ;; We add extra properties to the basic widgets needed here. This is
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
582 ;; fine, as long as we are careful to stay within out own namespace.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
583 ;;
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
584 ;; We want simple widgets to be displayed by default, but complex
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
585 ;; widgets to be hidden.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
586
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
587 (widget-put (get 'item 'widget-type) :custom-show t)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
588 (widget-put (get 'editable-field 'widget-type)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
589 :custom-show (lambda (widget value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
590 (let ((pp (pp-to-string value)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
591 (cond ((string-match "\n" pp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
592 nil)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
593 ((> (length pp) 40)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
594 nil)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
595 (t t)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
596 (widget-put (get 'menu-choice 'widget-type) :custom-show t)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
597
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
598 ;;; The `custom-manual' Widget.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
599
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
600 (define-widget 'custom-manual 'info-link
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
601 "Link to the manual entry for this customization option."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
602 :help-echo "Push me to read the manual."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
603 :tag "Manual")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
604
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
605 ;;; The `custom-magic' Widget.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
606
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
607 (defface custom-invalid-face '((((class color))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
608 (:foreground "yellow" :background "red"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
609 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
610 (:bold t :italic t :underline t)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
611 "Face used when the customize item is invalid.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
612
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
613 (defface custom-rogue-face '((((class color))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
614 (:foreground "pink" :background "black"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
615 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
616 (:underline t)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
617 "Face used when the customize item is not defined for customization.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
618
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
619 (defface custom-modified-face '((((class color))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
620 (:foreground "white" :background "blue"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
621 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
622 (:italic t :bold)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
623 "Face used when the customize item has been modified.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
624
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
625 (defface custom-set-face '((((class color))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
626 (:foreground "blue" :background "white"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
627 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
628 (:italic t)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
629 "Face used when the customize item has been set.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
630
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
631 (defface custom-changed-face '((((class color))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
632 (:foreground "white" :background "blue"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
633 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
634 (:italic t)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
635 "Face used when the customize item has been changed.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
636
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
637 (defface custom-saved-face '((t (:underline t)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
638 "Face used when the customize item has been saved.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
639
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
640 (defcustom custom-magic-alist '((nil "#" underline "\
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
641 uninitialized, you should not see this.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
642 (unknown "?" italic "\
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
643 unknown, you should not see this.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
644 (hidden "-" default "\
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
645 hidden, press the state button to show.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
646 (invalid "x" custom-invalid-face "\
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
647 the value displayed for this item is invalid and cannot be set.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
648 (modified "*" custom-modified-face "\
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
649 you have edited the item, and can now set it.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
650 (set "+" custom-set-face "\
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
651 you have set this item, but not saved it.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
652 (changed ":" custom-changed-face "\
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
653 this item has been changed outside customize.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
654 (saved "!" custom-saved-face "\
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
655 this item has been saved.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
656 (rogue "@" custom-rogue-face "\
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
657 this item is not prepared for customization.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
658 (factory " " nil "\
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
659 this item is unchanged from its factory setting."))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
660 "Alist of customize option states.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
661 Each entry is of the form (STATE MAGIC FACE DESCRIPTION), where
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
662
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
663 STATE is one of the following symbols:
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
664
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
665 `nil'
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
666 For internal use, should never occur.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
667 `unknown'
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
668 For internal use, should never occur.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
669 `hidden'
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
670 This item is not being displayed.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
671 `invalid'
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
672 This item is modified, but has an invalid form.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
673 `modified'
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
674 This item is modified, and has a valid form.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
675 `set'
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
676 This item has been set but not saved.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
677 `changed'
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
678 The current value of this item has been changed temporarily.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
679 `saved'
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
680 This item is marked for saving.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
681 `rogue'
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
682 This item has no customization information.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
683 `factory'
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
684 This item is unchanged from the factory default.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
685
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
686 MAGIC is a string used to present that state.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
687
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
688 FACE is a face used to present the state.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
689
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
690 DESCRIPTION is a string describing the state.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
691
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
692 The list should be sorted most significant first."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
693 :type '(list (checklist :inline t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
694 (group (const nil)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
695 (string :tag "Magic")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
696 face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
697 (string :tag "Description"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
698 (group (const unknown)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
699 (string :tag "Magic")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
700 face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
701 (string :tag "Description"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
702 (group (const hidden)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
703 (string :tag "Magic")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
704 face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
705 (string :tag "Description"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
706 (group (const invalid)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
707 (string :tag "Magic")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
708 face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
709 (string :tag "Description"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
710 (group (const modified)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
711 (string :tag "Magic")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
712 face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
713 (string :tag "Description"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
714 (group (const set)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
715 (string :tag "Magic")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
716 face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
717 (string :tag "Description"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
718 (group (const changed)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
719 (string :tag "Magic")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
720 face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
721 (string :tag "Description"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
722 (group (const saved)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
723 (string :tag "Magic")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
724 face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
725 (string :tag "Description"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
726 (group (const rogue)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
727 (string :tag "Magic")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
728 face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
729 (string :tag "Description"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
730 (group (const factory)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
731 (string :tag "Magic")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
732 face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
733 (string :tag "Description")))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
734 (editable-list :inline t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
735 (group symbol
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
736 (string :tag "Magic")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
737 face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
738 (string :tag "Description"))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
739 :group 'customize)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
740
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
741 (defcustom custom-magic-show 'long
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
742 "Show long description of the state of each customization option."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
743 :type '(choice (const :tag "no" nil)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
744 (const short)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
745 (const long))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
746 :group 'customize)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
747
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
748 (defcustom custom-magic-show-button t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
749 "Show a magic button indicating the state of each customization option."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
750 :type 'boolean
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
751 :group 'customize)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
752
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
753 (define-widget 'custom-magic 'default
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
754 "Show and manipulate state for a customization option."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
755 :format "%v"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
756 :action 'widget-choice-item-action
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
757 :value-get 'ignore
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
758 :value-create 'custom-magic-value-create
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
759 :value-delete 'widget-children-value-delete)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
760
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
761 (defun custom-magic-value-create (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
762 ;; Create compact status report for WIDGET.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
763 (let* ((parent (widget-get widget :parent))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
764 (state (widget-get parent :custom-state))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
765 (entry (assq state custom-magic-alist))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
766 (magic (nth 1 entry))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
767 (face (nth 2 entry))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
768 (text (nth 3 entry))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
769 (lisp (eq (widget-get parent :custom-form) 'lisp))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
770 children)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
771 (when custom-magic-show
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
772 (push (widget-create-child-and-convert widget 'choice-item
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
773 :help-echo "\
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
774 Push me to change the state of this item."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
775 :format "%[%t%]"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
776 :tag "State")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
777 children)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
778 (insert ": ")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
779 (if (eq custom-magic-show 'long)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
780 (insert text)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
781 (insert (symbol-name state)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
782 (when lisp
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
783 (insert " (lisp)"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
784 (insert "\n"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
785 (when custom-magic-show-button
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
786 (when custom-magic-show
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
787 (let ((indent (widget-get parent :indent)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
788 (when indent
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
789 (insert-char ? indent))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
790 (push (widget-create-child-and-convert widget 'choice-item
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
791 :button-face face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
792 :help-echo "\
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
793 Push me to change the state."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
794 :format "%[%t%]"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
795 :tag (if lisp
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
796 (concat "(" magic ")")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
797 (concat "[" magic "]")))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
798 children)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
799 (insert " "))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
800 (widget-put widget :children children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
801
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
802 (defun custom-magic-reset (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
803 "Redraw the :custom-magic property of WIDGET."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
804 (let ((magic (widget-get widget :custom-magic)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
805 (widget-value-set magic (widget-value magic))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
806
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
807 ;;; The `custom-level' Widget.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
808
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
809 (define-widget 'custom-level 'item
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
810 "The custom level buttons."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
811 :format "%[%t%]"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
812 :help-echo "Push me to expand or collapse this item."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
813 :action 'custom-level-action)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
814
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
815 (defun custom-level-action (widget &optional event)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
816 "Toggle visibility for parent to WIDGET."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
817 (let* ((parent (widget-get widget :parent))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
818 (state (widget-get parent :custom-state)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
819 (cond ((memq state '(invalid modified))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
820 (error "There are unset changes"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
821 ((eq state 'hidden)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
822 (widget-put parent :custom-state 'unknown))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
823 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
824 (widget-put parent :custom-state 'hidden)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
825 (custom-redraw parent)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
826
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
827 ;;; The `custom' Widget.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
828
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
829 (define-widget 'custom 'default
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
830 "Customize a user option."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
831 :convert-widget 'custom-convert-widget
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
832 :format "%l%[%t%]: %v%m%h%a"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
833 :format-handler 'custom-format-handler
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
834 :notify 'custom-notify
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
835 :custom-level 1
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
836 :custom-state 'hidden
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
837 :documentation-property 'widget-subclass-responsibility
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
838 :value-create 'widget-subclass-responsibility
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
839 :value-delete 'widget-children-value-delete
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
840 :value-get 'widget-item-value-get
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
841 :validate 'widget-editable-list-validate
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
842 :match (lambda (widget value) (symbolp value)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
843
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
844 (defun custom-convert-widget (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
845 ;; Initialize :value and :tag from :args in WIDGET.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
846 (let ((args (widget-get widget :args)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
847 (when args
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
848 (widget-put widget :value (widget-apply widget
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
849 :value-to-internal (car args)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
850 (widget-put widget :tag (custom-unlispify-tag-name (car args)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
851 (widget-put widget :args nil)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
852 widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
853
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
854 (defun custom-format-handler (widget escape)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
855 ;; We recognize extra escape sequences.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
856 (let* ((buttons (widget-get widget :buttons))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
857 (state (widget-get widget :custom-state))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
858 (level (widget-get widget :custom-level)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
859 (cond ((eq escape ?l)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
860 (when level
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
861 (push (widget-create-child-and-convert
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
862 widget 'custom-level (make-string level ?*))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
863 buttons)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
864 (widget-insert " ")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
865 (widget-put widget :buttons buttons)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
866 ((eq escape ?L)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
867 (when (eq state 'hidden)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
868 (widget-insert " ...")))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
869 ((eq escape ?m)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
870 (and (eq (preceding-char) ?\n)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
871 (widget-get widget :indent)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
872 (insert-char ? (widget-get widget :indent)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
873 (let ((magic (widget-create-child-and-convert
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
874 widget 'custom-magic nil)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
875 (widget-put widget :custom-magic magic)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
876 (push magic buttons)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
877 (widget-put widget :buttons buttons)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
878 ((eq escape ?a)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
879 (let* ((symbol (widget-get widget :value))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
880 (links (get symbol 'custom-links))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
881 (many (> (length links) 2)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
882 (when links
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
883 (and (eq (preceding-char) ?\n)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
884 (widget-get widget :indent)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
885 (insert-char ? (widget-get widget :indent)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
886 (insert "See also ")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
887 (while links
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
888 (push (widget-create-child-and-convert widget (car links))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
889 buttons)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
890 (setq links (cdr links))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
891 (cond ((null links)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
892 (insert ".\n"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
893 ((null (cdr links))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
894 (if many
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
895 (insert ", and ")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
896 (insert " and ")))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
897 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
898 (insert ", "))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
899 (widget-put widget :buttons buttons))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
900 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
901 (widget-default-format-handler widget escape)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
902
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
903 (defun custom-notify (widget &rest args)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
904 "Keep track of changes."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
905 (widget-put widget :custom-state 'modified)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
906 (let ((buffer-undo-list t))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
907 (custom-magic-reset widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
908 (apply 'widget-default-notify widget args))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
909
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
910 (defun custom-redraw (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
911 "Redraw WIDGET with current settings."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
912 (let ((pos (point))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
913 (from (marker-position (widget-get widget :from)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
914 (to (marker-position (widget-get widget :to))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
915 (save-excursion
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
916 (widget-value-set widget (widget-value widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
917 (custom-redraw-magic widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
918 (when (and (>= pos from) (<= pos to))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
919 (goto-char pos))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
920
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
921 (defun custom-redraw-magic (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
922 "Redraw WIDGET state with current settings."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
923 (while widget
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
924 (let ((magic (widget-get widget :custom-magic)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
925 (unless magic
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
926 (debug))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
927 (widget-value-set magic (widget-value magic))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
928 (when (setq widget (widget-get widget :group))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
929 (custom-group-state-update widget))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
930 (widget-setup))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
931
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
932 (defun custom-show (widget value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
933 "Non-nil if WIDGET should be shown with VALUE by default."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
934 (let ((show (widget-get widget :custom-show)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
935 (cond ((null show)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
936 nil)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
937 ((eq t show)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
938 t)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
939 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
940 (funcall show widget value)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
941
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
942 (defun custom-load-symbol (symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
943 "Load all dependencies for SYMBOL."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
944 (let ((loads (get symbol 'custom-loads))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
945 load)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
946 (while loads
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
947 (setq load (car loads)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
948 loads (cdr loads))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
949 (cond ((symbolp load)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
950 (condition-case nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
951 (require load)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
952 (error nil)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
953 ((assoc load load-history))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
954 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
955 (condition-case nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
956 (load-library load)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
957 (error nil)))))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
958
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
959 (defun custom-load-widget (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
960 "Load all dependencies for WIDGET."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
961 (custom-load-symbol (widget-value widget)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
962
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
963 ;;; The `custom-variable' Widget.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
964
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
965 (defface custom-variable-sample-face '((t (:underline t)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
966 "Face used for unpushable variable tags."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
967 :group 'customize)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
968
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
969 (defface custom-variable-button-face '((t (:underline t :bold t)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
970 "Face used for pushable variable tags."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
971 :group 'customize)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
972
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
973 (define-widget 'custom-variable 'custom
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
974 "Customize variable."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
975 :format "%l%v%m%h%a"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
976 :help-echo "Push me to set or reset this variable."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
977 :documentation-property 'variable-documentation
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
978 :custom-state nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
979 :custom-menu 'custom-variable-menu-create
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
980 :custom-form 'edit
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
981 :value-create 'custom-variable-value-create
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
982 :action 'custom-variable-action
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
983 :custom-set 'custom-variable-set
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
984 :custom-save 'custom-variable-save
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
985 :custom-reset-current 'custom-redraw
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
986 :custom-reset-saved 'custom-variable-reset-saved
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
987 :custom-reset-factory 'custom-variable-reset-factory)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
988
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
989 (defun custom-variable-value-create (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
990 "Here is where you edit the variables value."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
991 (custom-load-widget widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
992 (let* ((buttons (widget-get widget :buttons))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
993 (children (widget-get widget :children))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
994 (form (widget-get widget :custom-form))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
995 (state (widget-get widget :custom-state))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
996 (symbol (widget-get widget :value))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
997 (options (get symbol 'custom-options))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
998 (child-type (or (get symbol 'custom-type) 'sexp))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
999 (tag (widget-get widget :tag))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1000 (type (let ((tmp (if (listp child-type)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1001 (copy-list child-type)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1002 (list child-type))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1003 (when options
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1004 (widget-put tmp :options options))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1005 tmp))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1006 (conv (widget-convert type))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1007 (value (if (default-boundp symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1008 (default-value symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1009 (widget-get conv :value))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1010 ;; If the widget is new, the child determine whether it is hidden.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1011 (cond (state)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1012 ((custom-show type value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1013 (setq state 'unknown))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1014 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1015 (setq state 'hidden)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1016 ;; If we don't know the state, see if we need to edit it in lisp form.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1017 (when (eq state 'unknown)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1018 (unless (widget-apply conv :match value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1019 ;; (widget-apply (widget-convert type) :match value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1020 (setq form 'lisp)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1021 ;; Now we can create the child widget.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1022 (cond ((eq state 'hidden)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1023 ;; Indicate hidden value.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1024 (push (widget-create-child-and-convert
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1025 widget 'item
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1026 :format "%{%t%}: ..."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1027 :sample-face 'custom-variable-sample-face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1028 :tag tag
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1029 :parent widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1030 children))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1031 ((eq form 'lisp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1032 ;; In lisp mode edit the saved value when possible.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1033 (let* ((value (cond ((get symbol 'saved-value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1034 (car (get symbol 'saved-value)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1035 ((get symbol 'factory-value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1036 (car (get symbol 'factory-value)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1037 ((default-boundp symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1038 (custom-quote (default-value symbol)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1039 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1040 (custom-quote (widget-get conv :value))))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1041 (push (widget-create-child-and-convert
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1042 widget 'sexp
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1043 :button-face 'custom-variable-button-face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1044 :tag (symbol-name symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1045 :parent widget
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1046 :value value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1047 children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1048 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1049 ;; Edit mode.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1050 (push (widget-create-child-and-convert
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1051 widget type
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1052 :tag tag
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1053 :button-face 'custom-variable-button-face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1054 :sample-face 'custom-variable-sample-face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1055 :value value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1056 children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1057 ;; Now update the state.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1058 (unless (eq (preceding-char) ?\n)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1059 (widget-insert "\n"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1060 (if (eq state 'hidden)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1061 (widget-put widget :custom-state state)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1062 (custom-variable-state-set widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1063 (widget-put widget :custom-form form)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1064 (widget-put widget :buttons buttons)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1065 (widget-put widget :children children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1066
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1067 (defun custom-variable-state-set (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1068 "Set the state of WIDGET."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1069 (let* ((symbol (widget-value widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1070 (value (if (default-boundp symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1071 (default-value symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1072 (widget-get widget :value)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1073 tmp
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1074 (state (cond ((setq tmp (get symbol 'customized-value))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1075 (if (condition-case nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1076 (equal value (eval (car tmp)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1077 (error nil))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1078 'set
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1079 'changed))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1080 ((setq tmp (get symbol 'saved-value))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1081 (if (condition-case nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1082 (equal value (eval (car tmp)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1083 (error nil))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1084 'saved
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1085 'changed))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1086 ((setq tmp (get symbol 'factory-value))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1087 (if (condition-case nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1088 (equal value (eval (car tmp)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1089 (error nil))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1090 'factory
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1091 'changed))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1092 (t 'rogue))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1093 (widget-put widget :custom-state state)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1094
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1095 (defvar custom-variable-menu
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1096 '(("Edit" . custom-variable-edit)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1097 ("Edit Lisp" . custom-variable-edit-lisp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1098 ("Set" . custom-variable-set)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1099 ("Save" . custom-variable-save)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1100 ("Reset to Current" . custom-redraw)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1101 ("Reset to Saved" . custom-variable-reset-saved)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1102 ("Reset to Factory Settings" . custom-variable-reset-factory))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1103 "Alist of actions for the `custom-variable' widget.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1104 The key is a string containing the name of the action, the value is a
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1105 lisp function taking the widget as an element which will be called
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1106 when the action is chosen.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1107
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1108 (defun custom-variable-action (widget &optional event)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1109 "Show the menu for `custom-variable' WIDGET.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1110 Optional EVENT is the location for the menu."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1111 (if (eq (widget-get widget :custom-state) 'hidden)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1112 (progn
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1113 (widget-put widget :custom-state 'unknown)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1114 (custom-redraw widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1115 (let* ((completion-ignore-case t)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1116 (answer (widget-choose (custom-unlispify-tag-name
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1117 (widget-get widget :value))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1118 custom-variable-menu
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1119 event)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1120 (if answer
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1121 (funcall answer widget)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1122
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1123 (defun custom-variable-edit (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1124 "Edit value of WIDGET."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1125 (widget-put widget :custom-state 'unknown)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1126 (widget-put widget :custom-form 'edit)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1127 (custom-redraw widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1128
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1129 (defun custom-variable-edit-lisp (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1130 "Edit the lisp representation of the value of WIDGET."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1131 (widget-put widget :custom-state 'unknown)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1132 (widget-put widget :custom-form 'lisp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1133 (custom-redraw widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1134
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1135 (defun custom-variable-set (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1136 "Set the current value for the variable being edited by WIDGET."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1137 (let ((form (widget-get widget :custom-form))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1138 (state (widget-get widget :custom-state))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1139 (child (car (widget-get widget :children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1140 (symbol (widget-value widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1141 val)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1142 (cond ((eq state 'hidden)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1143 (error "Cannot set hidden variable."))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1144 ((setq val (widget-apply child :validate))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1145 (goto-char (widget-get val :from))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1146 (error "%s" (widget-get val :error)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1147 ((eq form 'lisp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1148 (set symbol (eval (setq val (widget-value child))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1149 (put symbol 'customized-value (list val)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1150 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1151 (set symbol (setq val (widget-value child)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1152 (put symbol 'customized-value (list (custom-quote val)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1153 (custom-variable-state-set widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1154 (custom-redraw-magic widget)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1155
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1156 (defun custom-variable-save (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1157 "Set the default value for the variable being edited by WIDGET."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1158 (let ((form (widget-get widget :custom-form))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1159 (state (widget-get widget :custom-state))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1160 (child (car (widget-get widget :children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1161 (symbol (widget-value widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1162 val)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1163 (cond ((eq state 'hidden)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1164 (error "Cannot set hidden variable."))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1165 ((setq val (widget-apply child :validate))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1166 (goto-char (widget-get val :from))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1167 (error "%s" (widget-get val :error)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1168 ((eq form 'lisp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1169 (put symbol 'saved-value (list (widget-value child)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1170 (set symbol (eval (widget-value child))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1171 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1172 (put symbol
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1173 'saved-value (list (custom-quote (widget-value
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1174 child))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1175 (set symbol (widget-value child))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1176 (put symbol 'customized-value nil)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1177 (custom-save-all)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1178 (custom-variable-state-set widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1179 (custom-redraw-magic widget)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1180
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1181 (defun custom-variable-reset-saved (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1182 "Restore the saved value for the variable being edited by WIDGET."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1183 (let ((symbol (widget-value widget)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1184 (if (get symbol 'saved-value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1185 (condition-case nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1186 (set symbol (eval (car (get symbol 'saved-value))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1187 (error nil))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1188 (error "No saved value for %s" symbol))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1189 (put symbol 'customized-value nil)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1190 (widget-put widget :custom-state 'unknown)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1191 (custom-redraw widget)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1192
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1193 (defun custom-variable-reset-factory (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1194 "Restore the factory setting for the variable being edited by WIDGET."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1195 (let ((symbol (widget-value widget)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1196 (if (get symbol 'factory-value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1197 (set symbol (eval (car (get symbol 'factory-value))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1198 (error "No factory default for %S" symbol))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1199 (put symbol 'customized-value nil)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1200 (when (get symbol 'saved-value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1201 (put symbol 'saved-value nil)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1202 (custom-save-all))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1203 (widget-put widget :custom-state 'unknown)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1204 (custom-redraw widget)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1205
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1206 ;;; The `custom-face-edit' Widget.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1207
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1208 (defvar custom-face-edit-args
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1209 (mapcar (lambda (att)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1210 (list 'group
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1211 :inline t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1212 (list 'const :format "" :value (nth 0 att))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1213 (nth 1 att)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1214 custom-face-attributes))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1215
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1216 (define-widget 'custom-face-edit 'checklist
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1217 "Edit face attributes."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1218 :format "%t: %v"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1219 :tag "Attributes"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1220 :extra-offset 12
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1221 :args (mapcar (lambda (att)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1222 (list 'group
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1223 :inline t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1224 (list 'const :format "" :value (nth 0 att))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1225 (nth 1 att)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1226 custom-face-attributes))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1227
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1228 ;;; The `custom-display' Widget.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1229
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1230 (define-widget 'custom-display 'menu-choice
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1231 "Select a display type."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1232 :tag "Display"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1233 :value t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1234 :args '((const :tag "all" t)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1235 (checklist :offset 0
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1236 :extra-offset 9
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1237 :args ((group (const :format "Type: " type)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1238 (checklist :inline t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1239 :offset 0
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1240 (const :format "X "
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1241 x)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1242 (const :format "PM "
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1243 pm)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1244 (const :format "Win32 "
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1245 win32)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1246 (const :format "DOS "
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1247 pc)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1248 (const :format "TTY%n"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1249 tty)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1250 (group (const :format "Class: " class)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1251 (checklist :inline t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1252 :offset 0
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1253 (const :format "Color "
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1254 color)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1255 (const :format
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1256 "Grayscale "
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1257 grayscale)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1258 (const :format "Monochrome%n"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1259 mono)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1260 (group (const :format "Background: " background)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1261 (checklist :inline t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1262 :offset 0
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1263 (const :format "Light "
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1264 light)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1265 (const :format "Dark\n"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1266 dark)))))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1267
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1268 ;;; The `custom-face' Widget.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1269
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1270 (defface custom-face-tag-face '((t (:underline t)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1271 "Face used for face tags."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1272 :group 'customize)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1273
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1274 (define-widget 'custom-face 'custom
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1275 "Customize face."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1276 :format "%l%{%t%}: %s%m%h%a%v"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1277 :format-handler 'custom-face-format-handler
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1278 :sample-face 'custom-face-tag-face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1279 :help-echo "Push me to set or reset this face."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1280 :documentation-property '(lambda (face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1281 (face-documentation face))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1282 :value-create 'custom-face-value-create
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1283 :action 'custom-face-action
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1284 :custom-set 'custom-face-set
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1285 :custom-save 'custom-face-save
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1286 :custom-reset-current 'custom-redraw
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1287 :custom-reset-saved 'custom-face-reset-saved
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1288 :custom-reset-factory 'custom-face-reset-factory
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1289 :custom-menu 'custom-face-menu-create)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1290
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1291 (defun custom-face-format-handler (widget escape)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1292 ;; We recognize extra escape sequences.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1293 (let (child
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1294 (symbol (widget-get widget :value)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1295 (cond ((eq escape ?s)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1296 (and (string-match "XEmacs" emacs-version)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1297 ;; XEmacs cannot display initialized faces.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1298 (not (custom-facep symbol))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1299 (copy-face 'custom-face-empty symbol))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1300 (setq child (widget-create-child-and-convert
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1301 widget 'item
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1302 :format "(%{%t%})\n"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1303 :sample-face symbol
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1304 :tag "sample")))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1305 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1306 (custom-format-handler widget escape)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1307 (when child
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1308 (widget-put widget
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1309 :buttons (cons child (widget-get widget :buttons))))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1310
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1311 (defun custom-face-value-create (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1312 ;; Create a list of the display specifications.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1313 (unless (eq (preceding-char) ?\n)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1314 (insert "\n"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1315 (when (not (eq (widget-get widget :custom-state) 'hidden))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1316 (custom-load-widget widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1317 (let* ((symbol (widget-value widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1318 (edit (widget-create-child-and-convert
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1319 widget 'editable-list
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1320 :entry-format "%i %d %v"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1321 :value (or (get symbol 'saved-face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1322 (get symbol 'factory-face))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1323 '(group :format "%v"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1324 custom-display custom-face-edit))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1325 (custom-face-state-set widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1326 (widget-put widget :children (list edit)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1327
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1328 (defvar custom-face-menu
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1329 '(("Set" . custom-face-set)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1330 ("Save" . custom-face-save)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1331 ("Reset to Saved" . custom-face-reset-saved)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1332 ("Reset to Factory Setting" . custom-face-reset-factory))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1333 "Alist of actions for the `custom-face' widget.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1334 The key is a string containing the name of the action, the value is a
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1335 lisp function taking the widget as an element which will be called
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1336 when the action is chosen.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1337
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1338 (defun custom-face-state-set (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1339 "Set the state of WIDGET."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1340 (let ((symbol (widget-value widget)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1341 (widget-put widget :custom-state (cond ((get symbol 'customized-face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1342 'set)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1343 ((get symbol 'saved-face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1344 'saved)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1345 ((get symbol 'factory-face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1346 'factory)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1347 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1348 'rogue)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1349
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1350 (defun custom-face-action (widget &optional event)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1351 "Show the menu for `custom-face' WIDGET.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1352 Optional EVENT is the location for the menu."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1353 (if (eq (widget-get widget :custom-state) 'hidden)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1354 (progn
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1355 (widget-put widget :custom-state 'unknown)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1356 (custom-redraw widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1357 (let* ((completion-ignore-case t)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1358 (symbol (widget-get widget :value))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1359 (answer (widget-choose (custom-unlispify-tag-name symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1360 custom-face-menu event)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1361 (if answer
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1362 (funcall answer widget)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1363
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1364 (defun custom-face-set (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1365 "Make the face attributes in WIDGET take effect."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1366 (let* ((symbol (widget-value widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1367 (child (car (widget-get widget :children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1368 (value (widget-value child)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1369 (put symbol 'customized-face value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1370 (when (fboundp 'copy-face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1371 (copy-face 'custom-face-empty symbol))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1372 (custom-face-display-set symbol value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1373 (custom-face-state-set widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1374 (custom-redraw-magic widget)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1375
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1376 (defun custom-face-save (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1377 "Make the face attributes in WIDGET default."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1378 (let* ((symbol (widget-value widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1379 (child (car (widget-get widget :children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1380 (value (widget-value child)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1381 (when (fboundp 'copy-face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1382 (copy-face 'custom-face-empty symbol))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1383 (custom-face-display-set symbol value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1384 (put symbol 'saved-face value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1385 (put symbol 'customized-face nil)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1386 (custom-face-state-set widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1387 (custom-redraw-magic widget)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1388
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1389 (defun custom-face-reset-saved (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1390 "Restore WIDGET to the face's default attributes."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1391 (let* ((symbol (widget-value widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1392 (child (car (widget-get widget :children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1393 (value (get symbol 'saved-face)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1394 (unless value
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1395 (error "No saved value for this face"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1396 (put symbol 'customized-face nil)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1397 (when (fboundp 'copy-face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1398 (copy-face 'custom-face-empty symbol))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1399 (custom-face-display-set symbol value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1400 (widget-value-set child value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1401 (custom-face-state-set widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1402 (custom-redraw-magic widget)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1403
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1404 (defun custom-face-reset-factory (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1405 "Restore WIDGET to the face's factory settings."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1406 (let* ((symbol (widget-value widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1407 (child (car (widget-get widget :children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1408 (value (get symbol 'factory-face)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1409 (unless value
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1410 (error "No factory default for this face"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1411 (put symbol 'customized-face nil)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1412 (when (get symbol 'saved-face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1413 (put symbol 'saved-face nil)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1414 (custom-save-all))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1415 (when (fboundp 'copy-face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1416 (copy-face 'custom-face-empty symbol))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1417 (custom-face-display-set symbol value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1418 (widget-value-set child value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1419 (custom-face-state-set widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1420 (custom-redraw-magic widget)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1421
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1422 ;;; The `face' Widget.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1423
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1424 (define-widget 'face 'default
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1425 "Select and customize a face."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1426 :convert-widget 'widget-item-convert-widget
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1427 :format "%[%t%]: %v"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1428 :tag "Face"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1429 :value 'default
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1430 :value-create 'widget-face-value-create
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1431 :value-delete 'widget-face-value-delete
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1432 :value-get 'widget-item-value-get
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1433 :validate 'widget-editable-list-validate
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1434 :action 'widget-face-action
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1435 :match '(lambda (widget value) (symbolp value)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1436
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1437 (defun widget-face-value-create (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1438 ;; Create a `custom-face' child.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1439 (let* ((symbol (widget-value widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1440 (child (widget-create-child-and-convert
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1441 widget 'custom-face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1442 :format "%t %s%m%h%v"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1443 :custom-level nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1444 :value symbol)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1445 (custom-magic-reset child)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1446 (setq custom-options (cons child custom-options))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1447 (widget-put widget :children (list child))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1448
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1449 (defun widget-face-value-delete (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1450 ;; Remove the child from the options.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1451 (let ((child (car (widget-get widget :children))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1452 (setq custom-options (delq child custom-options))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1453 (widget-children-value-delete widget)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1454
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1455 (defvar face-history nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1456 "History of entered face names.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1457
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1458 (defun widget-face-action (widget &optional event)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1459 "Prompt for a face."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1460 (let ((answer (completing-read "Face: "
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1461 (mapcar (lambda (face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1462 (list (symbol-name face)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1463 (face-list))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1464 nil nil nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1465 'face-history)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1466 (unless (zerop (length answer))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1467 (widget-value-set widget (intern answer))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1468 (widget-apply widget :notify widget event)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1469 (widget-setup))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1470
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1471 ;;; The `hook' Widget.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1472
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1473 (define-widget 'hook 'list
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1474 "A emacs lisp hook"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1475 :convert-widget 'custom-hook-convert-widget
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1476 :tag "Hook")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1477
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1478 (defun custom-hook-convert-widget (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1479 ;; Handle `:custom-options'.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1480 (let* ((options (widget-get widget :options))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1481 (other `(editable-list :inline t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1482 :entry-format "%i %d%v"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1483 (function :format " %v")))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1484 (args (if options
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1485 (list `(checklist :inline t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1486 ,@(mapcar (lambda (entry)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1487 `(function-item ,entry))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1488 options))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1489 other)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1490 (list other))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1491 (widget-put widget :args args)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1492 widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1493
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1494 ;;; The `custom-group' Widget.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1495
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1496 (defcustom custom-group-tag-faces '(custom-group-tag-face-1)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1497 ;; In XEmacs, this ought to play games with font size.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1498 "Face used for group tags.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1499 The first member is used for level 1 groups, the second for level 2,
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1500 and so forth. The remaining group tags are shown with
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1501 `custom-group-tag-face'."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1502 :type '(repeat face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1503 :group 'customize)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1504
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1505 (defface custom-group-tag-face-1 '((((class color)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1506 (background dark))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1507 (:foreground "pink" :underline t))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1508 (((class color)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1509 (background light))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1510 (:foreground "red" :underline t))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1511 (t (:underline t)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1512 "Face used for group tags.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1513
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1514 (defface custom-group-tag-face '((((class color)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1515 (background dark))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1516 (:foreground "light blue" :underline t))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1517 (((class color)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1518 (background light))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1519 (:foreground "blue" :underline t))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1520 (t (:underline t)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1521 "Face used for low level group tags."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1522 :group 'customize)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1523
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1524 (define-widget 'custom-group 'custom
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1525 "Customize group."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1526 :format "%l%{%t%}:%L\n%m%h%a%v"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1527 :sample-face-get 'custom-group-sample-face-get
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1528 :documentation-property 'group-documentation
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1529 :help-echo "Push me to set or reset all members of this group."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1530 :value-create 'custom-group-value-create
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1531 :action 'custom-group-action
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1532 :custom-set 'custom-group-set
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1533 :custom-save 'custom-group-save
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1534 :custom-reset-current 'custom-group-reset-current
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1535 :custom-reset-saved 'custom-group-reset-saved
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1536 :custom-reset-factory 'custom-group-reset-factory
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1537 :custom-menu 'custom-group-menu-create)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1538
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1539 (defun custom-group-sample-face-get (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1540 ;; Use :sample-face.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1541 (or (nth (1- (widget-get widget :custom-level)) custom-group-tag-faces)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1542 'custom-group-tag-face))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1543
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1544 (defun custom-group-value-create (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1545 (let ((state (widget-get widget :custom-state)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1546 (unless (eq state 'hidden)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1547 (custom-load-widget widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1548 (let* ((level (widget-get widget :custom-level))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1549 (symbol (widget-value widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1550 (members (get symbol 'custom-group))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1551 (prefixes (widget-get widget :custom-prefixes))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1552 (custom-prefix-list (custom-prefix-add symbol prefixes))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1553 (children (mapcar (lambda (entry)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1554 (widget-insert "\n")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1555 (prog1
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1556 (widget-create-child-and-convert
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1557 widget (nth 1 entry)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1558 :group widget
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1559 :tag (custom-unlispify-tag-name
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1560 (nth 0 entry))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1561 :custom-prefixes custom-prefix-list
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1562 :custom-level (1+ level)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1563 :value (nth 0 entry))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1564 (unless (eq (preceding-char) ?\n)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1565 (widget-insert "\n"))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1566 members)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1567 (mapcar 'custom-magic-reset children)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1568 (widget-put widget :children children)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1569 (custom-group-state-update widget)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1570
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1571 (defvar custom-group-menu
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1572 '(("Set" . custom-group-set)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1573 ("Save" . custom-group-save)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1574 ("Reset to Current" . custom-group-reset-current)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1575 ("Reset to Saved" . custom-group-reset-saved)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1576 ("Reset to Factory" . custom-group-reset-factory))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1577 "Alist of actions for the `custom-group' widget.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1578 The key is a string containing the name of the action, the value is a
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1579 lisp function taking the widget as an element which will be called
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1580 when the action is chosen.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1581
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1582 (defun custom-group-action (widget &optional event)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1583 "Show the menu for `custom-group' WIDGET.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1584 Optional EVENT is the location for the menu."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1585 (if (eq (widget-get widget :custom-state) 'hidden)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1586 (progn
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1587 (widget-put widget :custom-state 'unknown)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1588 (custom-redraw widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1589 (let* ((completion-ignore-case t)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1590 (answer (widget-choose (custom-unlispify-tag-name
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1591 (widget-get widget :value))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1592 custom-group-menu
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1593 event)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1594 (if answer
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1595 (funcall answer widget)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1596
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1597 (defun custom-group-set (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1598 "Set changes in all modified group members."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1599 (let ((children (widget-get widget :children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1600 (mapcar (lambda (child)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1601 (when (eq (widget-get child :custom-state) 'modified)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1602 (widget-apply child :custom-set)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1603 children )))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1604
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1605 (defun custom-group-save (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1606 "Save all modified group members."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1607 (let ((children (widget-get widget :children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1608 (mapcar (lambda (child)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1609 (when (memq (widget-get child :custom-state) '(modified set))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1610 (widget-apply child :custom-save)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1611 children )))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1612
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1613 (defun custom-group-reset-current (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1614 "Reset all modified group members."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1615 (let ((children (widget-get widget :children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1616 (mapcar (lambda (child)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1617 (when (eq (widget-get child :custom-state) 'modified)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1618 (widget-apply child :custom-reset-current)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1619 children )))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1620
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1621 (defun custom-group-reset-saved (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1622 "Reset all modified or set group members."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1623 (let ((children (widget-get widget :children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1624 (mapcar (lambda (child)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1625 (when (memq (widget-get child :custom-state) '(modified set))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1626 (widget-apply child :custom-reset-saved)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1627 children )))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1628
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1629 (defun custom-group-reset-factory (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1630 "Reset all modified, set, or saved group members."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1631 (let ((children (widget-get widget :children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1632 (mapcar (lambda (child)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1633 (when (memq (widget-get child :custom-state)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1634 '(modified set saved))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1635 (widget-apply child :custom-reset-factory)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1636 children )))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1637
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1638 (defun custom-group-state-update (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1639 "Update magic."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1640 (unless (eq (widget-get widget :custom-state) 'hidden)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1641 (let* ((children (widget-get widget :children))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1642 (states (mapcar (lambda (child)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1643 (widget-get child :custom-state))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1644 children))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1645 (magics custom-magic-alist)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1646 (found 'factory))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1647 (while magics
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1648 (let ((magic (car (car magics))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1649 (if (and (not (eq magic 'hidden))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1650 (memq magic states))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1651 (setq found magic
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1652 magics nil)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1653 (setq magics (cdr magics)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1654 (widget-put widget :custom-state found)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1655 (custom-magic-reset widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1656
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1657 ;;; The `custom-save-all' Function.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1658
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1659 (defcustom custom-file "~/.emacs"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1660 "File used for storing customization information.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1661 If you change this from the default \"~/.emacs\" you need to
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1662 explicitly load that file for the settings to take effect."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1663 :type 'file
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1664 :group 'customize)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1665
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1666 (defun custom-save-delete (symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1667 "Delete the call to SYMBOL form `custom-file'.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1668 Leave point at the location of the call, or after the last expression."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1669 (set-buffer (find-file-noselect custom-file))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1670 (goto-char (point-min))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1671 (catch 'found
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1672 (while t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1673 (let ((sexp (condition-case nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1674 (read (current-buffer))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1675 (end-of-file (throw 'found nil)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1676 (when (and (listp sexp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1677 (eq (car sexp) symbol))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1678 (delete-region (save-excursion
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1679 (backward-sexp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1680 (point))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1681 (point))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1682 (throw 'found nil))))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1683
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1684 (defun custom-save-variables ()
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1685 "Save all customized variables in `custom-file'."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1686 (save-excursion
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1687 (custom-save-delete 'custom-set-variables)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1688 (let ((standard-output (current-buffer)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1689 (unless (bolp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1690 (princ "\n"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1691 (princ "(custom-set-variables")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1692 (mapatoms (lambda (symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1693 (let ((value (get symbol 'saved-value)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1694 (when value
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1695 (princ "\n '(")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1696 (princ symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1697 (princ " ")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1698 (prin1 (car value))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1699 (if (or (get symbol 'factory-value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1700 (and (not (boundp symbol))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1701 (not (get symbol 'force-value))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1702 (princ ")")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1703 (princ " t)"))))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1704 (princ ")")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1705 (unless (eolp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1706 (princ "\n")))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1707
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1708 (defun custom-save-faces ()
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1709 "Save all customized faces in `custom-file'."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1710 (save-excursion
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1711 (custom-save-delete 'custom-set-faces)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1712 (let ((standard-output (current-buffer)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1713 (unless (bolp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1714 (princ "\n"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1715 (princ "(custom-set-faces")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1716 (mapatoms (lambda (symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1717 (let ((value (get symbol 'saved-face)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1718 (when value
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1719 (princ "\n '(")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1720 (princ symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1721 (princ " ")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1722 (prin1 value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1723 (if (or (get symbol 'factory-face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1724 (and (not (custom-facep symbol))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1725 (not (get symbol 'force-face))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1726 (princ ")")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1727 (princ " t)"))))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1728 (princ ")")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1729 (unless (eolp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1730 (princ "\n")))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1731
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1732 (defun custom-save-all ()
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1733 "Save all customizations in `custom-file'."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1734 (custom-save-variables)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1735 (custom-save-faces)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1736 (save-excursion
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1737 (set-buffer (find-file-noselect custom-file))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1738 (save-buffer)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1739
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1740 ;;; The Customize Menu.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1741
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1742 (defcustom custom-menu-nesting 2
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1743 "Maximum nesting in custom menus."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1744 :type 'integer
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1745 :group 'customize)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1746
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1747 (defun custom-face-menu-create (widget symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1748 "Ignoring WIDGET, create a menu entry for customization face SYMBOL."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1749 (vector (custom-unlispify-menu-entry symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1750 `(custom-buffer-create '((,symbol custom-face)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1751 t))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1752
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1753 (defun custom-variable-menu-create (widget symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1754 "Ignoring WIDGET, create a menu entry for customization variable SYMBOL."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1755 (let ((type (get symbol 'custom-type)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1756 (unless (listp type)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1757 (setq type (list type)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1758 (if (and type (widget-get type :custom-menu))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1759 (widget-apply type :custom-menu symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1760 (vector (custom-unlispify-menu-entry symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1761 `(custom-buffer-create '((,symbol custom-variable)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1762 t))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1763
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1764 (widget-put (get 'boolean 'widget-type)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1765 :custom-menu (lambda (widget symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1766 (vector (custom-unlispify-menu-entry symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1767 `(custom-buffer-create
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1768 '((,symbol custom-variable)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1769 ':style 'toggle
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1770 ':selected symbol)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1771
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1772 (defun custom-group-menu-create (widget symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1773 "Ignoring WIDGET, create a menu entry for customization group SYMBOL."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1774 (custom-menu-create symbol))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1775
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1776 (defun custom-menu-create (symbol &optional name)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1777 "Create menu for customization group SYMBOL.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1778 If optional NAME is given, use that as the name of the menu.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1779 Otherwise make up a name from SYMBOL.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1780 The menu is in a format applicable to `easy-menu-define'."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1781 (unless name
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1782 (setq name (custom-unlispify-menu-entry symbol)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1783 (let ((item (vector name
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1784 `(custom-buffer-create '((,symbol custom-group)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1785 t)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1786 (if (and (> custom-menu-nesting 0)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1787 (< (length (get symbol 'custom-group)) widget-menu-max-size))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1788 (let ((custom-menu-nesting (1- custom-menu-nesting))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1789 (custom-prefix-list (custom-prefix-add symbol
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1790 custom-prefix-list)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1791 (custom-load-symbol symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1792 `(,(custom-unlispify-menu-entry symbol t)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1793 ,item
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1794 "--"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1795 ,@(mapcar (lambda (entry)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1796 (widget-apply (if (listp (nth 1 entry))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1797 (nth 1 entry)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1798 (list (nth 1 entry)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1799 :custom-menu (nth 0 entry)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1800 (get symbol 'custom-group))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1801 item)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1802
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1803 ;;;###autoload
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1804 (defun custom-menu-update ()
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1805 "Update customize menu."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1806 (interactive)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1807 (add-hook 'custom-define-hook 'custom-menu-reset)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1808 (let ((menu `(,(car custom-help-menu)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1809 ,(widget-apply '(custom-group) :custom-menu 'emacs)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1810 ,@(cdr (cdr custom-help-menu)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1811 (if (fboundp 'add-submenu)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1812 (add-submenu '("Help") menu)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1813 (define-key global-map [menu-bar help-menu customize-menu]
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1814 (cons (car menu) (easy-menu-create-keymaps (car menu) (cdr menu)))))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1815
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1816 ;;; Dependencies.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1817
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1818 ;;;###autoload
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1819 (defun custom-make-dependencies ()
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1820 "Batch function to extract custom dependencies from .el files.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1821 Usage: emacs -batch *.el -f custom-make-dependencies > deps.el"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1822 (let ((buffers (buffer-list)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1823 (while buffers
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1824 (set-buffer (car buffers))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1825 (setq buffers (cdr buffers))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1826 (let ((file (buffer-file-name)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1827 (when (and file (string-match "\\`\\(.*\\)\\.el\\'" file))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1828 (goto-char (point-min))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1829 (condition-case nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1830 (let ((name (file-name-nondirectory (match-string 1 file))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1831 (while t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1832 (let ((expr (read (current-buffer))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1833 (when (and (listp expr)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1834 (memq (car expr) '(defcustom defface defgroup)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1835 (eval expr)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1836 (put (nth 1 expr) 'custom-where name)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1837 (error nil))))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1838 (mapatoms (lambda (symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1839 (let ((members (get symbol 'custom-group))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1840 item where found)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1841 (when members
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1842 (princ "(put '")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1843 (princ symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1844 (princ " 'custom-loads '(")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1845 (while members
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1846 (setq item (car (car members))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1847 members (cdr members)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1848 where (get item 'custom-where))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1849 (unless (or (null where)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1850 (member where found))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1851 (when found
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1852 (princ " "))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1853 (prin1 where)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1854 (push where found)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1855 (princ "))\n"))))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1856
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1857 ;;; The End.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1858
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1859 (provide 'cus-edit)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1860
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1861 ;; cus-edit.el ends here