annotate lisp/custom/cus-edit.el @ 114:8619ce7e4c50 r20-1b9

Import from CVS: tag r20-1b9
author cvs
date Mon, 13 Aug 2007 09:21:54 +0200
parents c53a95d3c46d
children 8d2a9b52c682 9f59509498e1
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
36
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
7 ;; Version: 1.65
28
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))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
303 (set-keymap-parent custom-mode-map widget-keymap)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
304 (define-key custom-mode-map "q" 'bury-buffer))
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
305
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
306 (easy-menu-define custom-mode-menu
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
307 custom-mode-map
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
308 "Menu used in customization buffers."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
309 '("Custom"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
310 ["Set" custom-set t]
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
311 ["Save" custom-save t]
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
312 ["Reset to Current" custom-reset-current t]
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
313 ["Reset to Saved" custom-reset-saved t]
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
314 ["Reset to Factory Settings" custom-reset-factory t]
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
315 ["Info" (Info-goto-node "(custom)The Customization Buffer") t]))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
316
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
317 (defcustom custom-mode-hook nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
318 "Hook called when entering custom-mode."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
319 :type 'hook
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
320 :group 'customize)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
321
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
322 (defun custom-mode ()
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
323 "Major mode for editing customization buffers.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
324
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
325 The following commands are available:
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
326
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
327 \\[widget-forward] Move to next button or editable field.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
328 \\[widget-backward] Move to previous button or editable field.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
329 \\[widget-button-click] Activate button under the mouse pointer.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
330 \\[widget-button-press] Activate button under point.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
331 \\[custom-set] Set all modifications.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
332 \\[custom-save] Make all modifications default.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
333 \\[custom-reset-current] Reset all modified options.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
334 \\[custom-reset-saved] Reset all modified or set options.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
335 \\[custom-reset-factory] Reset all options.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
336
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
337 Entry to this mode calls the value of `custom-mode-hook'
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
338 if that value is non-nil."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
339 (kill-all-local-variables)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
340 (setq major-mode 'custom-mode
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
341 mode-name "Custom")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
342 (use-local-map custom-mode-map)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
343 (easy-menu-add custom-mode-menu)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
344 (make-local-variable 'custom-options)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
345 (run-hooks 'custom-mode-hook))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
346
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
347 ;;; Custom Mode Commands.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
348
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
349 (defun custom-set ()
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
350 "Set changes in all modified options."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
351 (interactive)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
352 (let ((children custom-options))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
353 (mapcar (lambda (child)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
354 (when (eq (widget-get child :custom-state) 'modified)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
355 (widget-apply child :custom-set)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
356 children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
357
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
358 (defun custom-save ()
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
359 "Set all modified group members and save them."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
360 (interactive)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
361 (let ((children custom-options))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
362 (mapcar (lambda (child)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
363 (when (memq (widget-get child :custom-state) '(modified set))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
364 (widget-apply child :custom-save)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
365 children))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
366 (custom-save-all))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
367
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
368 (defvar custom-reset-menu
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
369 '(("Current" . custom-reset-current)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
370 ("Saved" . custom-reset-saved)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
371 ("Factory Settings" . custom-reset-factory))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
372 "Alist of actions for the `Reset' button.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
373 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
374 lisp function taking the widget as an element which will be called
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
375 when the action is chosen.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
376
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
377 (defun custom-reset (event)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
378 "Select item from reset menu."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
379 (let* ((completion-ignore-case t)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
380 (answer (widget-choose "Reset to"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
381 custom-reset-menu
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
382 event)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
383 (if answer
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
384 (funcall answer))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
385
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
386 (defun custom-reset-current ()
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
387 "Reset all modified group members to their current value."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
388 (interactive)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
389 (let ((children custom-options))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
390 (mapcar (lambda (child)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
391 (when (eq (widget-get child :custom-state) 'modified)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
392 (widget-apply child :custom-reset-current)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
393 children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
394
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
395 (defun custom-reset-saved ()
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
396 "Reset all modified or set group members to their saved value."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
397 (interactive)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
398 (let ((children custom-options))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
399 (mapcar (lambda (child)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
400 (when (eq (widget-get child :custom-state) 'modified)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
401 (widget-apply child :custom-reset-current)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
402 children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
403
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
404 (defun custom-reset-factory ()
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
405 "Reset all modified, set, or saved group members to their factory settings."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
406 (interactive)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
407 (let ((children custom-options))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
408 (mapcar (lambda (child)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
409 (when (eq (widget-get child :custom-state) 'modified)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
410 (widget-apply child :custom-reset-current)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
411 children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
412
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
413 ;;; The Customize Commands
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
414
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
415 ;;;###autoload
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
416 (defun customize (symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
417 "Customize SYMBOL, which must be a customization group."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
418 (interactive (list (completing-read "Customize group: (default emacs) "
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
419 obarray
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
420 (lambda (symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
421 (get symbol 'custom-group))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
422 t)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
423
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
424 (when (stringp symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
425 (if (string-equal "" symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
426 (setq symbol 'emacs)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
427 (setq symbol (intern symbol))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
428 (custom-buffer-create (list (list symbol 'custom-group))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
429
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
430 ;;;###autoload
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
431 (defun customize-variable (symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
432 "Customize SYMBOL, which must be a variable."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
433 (interactive
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
434 ;; Code stolen from `help.el'.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
435 (let ((v (variable-at-point))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
436 (enable-recursive-minibuffers t)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
437 val)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
438 (setq val (completing-read
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
439 (if v
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
440 (format "Customize variable (default %s): " v)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
441 "Customize variable: ")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
442 obarray 'boundp t))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
443 (list (if (equal val "")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
444 v (intern val)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
445 (custom-buffer-create (list (list symbol 'custom-variable))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
446
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
447 ;;;###autoload
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
448 (defun customize-face (&optional symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
449 "Customize SYMBOL, which should be a face name or nil.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
450 If SYMBOL is nil, customize all faces."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
451 (interactive (list (completing-read "Customize face: (default all) "
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
452 obarray 'custom-facep)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
453 (if (or (null symbol) (and (stringp symbol) (zerop (length symbol))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
454 (let ((found nil))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
455 (message "Looking for faces...")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
456 (mapcar (lambda (symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
457 (setq found (cons (list symbol 'custom-face) found)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
458 (face-list))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
459 (message "Creating customization buffer...")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
460 (custom-buffer-create found))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
461 (if (stringp symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
462 (setq symbol (intern symbol)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
463 (unless (symbolp symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
464 (error "Should be a symbol %S" symbol))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
465 (custom-buffer-create (list (list symbol 'custom-face)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
466
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
467 ;;;###autoload
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
468 (defun customize-customized ()
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
469 "Customize all already customized user options."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
470 (interactive)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
471 (let ((found nil))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
472 (mapatoms (lambda (symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
473 (and (get symbol 'saved-face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
474 (custom-facep symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
475 (setq found (cons (list symbol 'custom-face) found)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
476 (and (get symbol 'saved-value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
477 (boundp symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
478 (setq found
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
479 (cons (list symbol 'custom-variable) found)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
480 (if found
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
481 (custom-buffer-create found)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
482 (error "No customized user options"))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
483
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
484 ;;;###autoload
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
485 (defun customize-apropos (regexp &optional all)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
486 "Customize all user options matching REGEXP.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
487 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
488 user-settable."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
489 (interactive "sCustomize regexp: \nP")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
490 (let ((found nil))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
491 (mapatoms (lambda (symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
492 (when (string-match regexp (symbol-name symbol))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
493 (when (get symbol 'custom-group)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
494 (setq found (cons (list symbol 'custom-group) found)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
495 (when (custom-facep symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
496 (setq found (cons (list symbol 'custom-face) found)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
497 (when (and (boundp symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
498 (or (get symbol 'saved-value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
499 (get symbol 'factory-value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
500 (if all
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
501 (get symbol 'variable-documentation)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
502 (user-variable-p symbol))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
503 (setq found
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
504 (cons (list symbol 'custom-variable) found))))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
505 (if found
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
506 (custom-buffer-create found)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
507 (error "No matches"))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
508
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
509 ;;;###autoload
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
510 (defun custom-buffer-create (options)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
511 "Create a buffer containing OPTIONS.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
512 OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
513 SYMBOL is a customization option, and WIDGET is a widget for editing
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
514 that option."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
515 (kill-buffer (get-buffer-create "*Customization*"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
516 (switch-to-buffer (get-buffer-create "*Customization*"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
517 (custom-mode)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
518 (widget-insert "This is a customization buffer.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
519 Push RET or click mouse-2 on the word ")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
520 (widget-create 'info-link
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
521 :tag "help"
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
522 :help-echo "Read the online help."
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
523 "(custom)The Customization Buffer")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
524 (widget-insert " for more information.\n\n")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
525 (setq custom-options
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
526 (mapcar (lambda (entry)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
527 (prog1
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
528 (if (> (length options) 1)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
529 (widget-create (nth 1 entry)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
530 :tag (custom-unlispify-tag-name
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
531 (nth 0 entry))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
532 :value (nth 0 entry))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
533 ;; If there is only one entry, don't hide it!
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
534 (widget-create (nth 1 entry)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
535 :custom-state 'unknown
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
536 :tag (custom-unlispify-tag-name
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
537 (nth 0 entry))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
538 :value (nth 0 entry)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
539 (unless (eq (preceding-char) ?\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 (widget-insert "\n")))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
542 options))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
543 (mapcar 'custom-magic-reset custom-options)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
544 (widget-create 'push-button
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
545 :tag "Set"
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
546 :help-echo "Set all modifications for this session."
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
547 :action (lambda (widget &optional event)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
548 (custom-set)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
549 (widget-insert " ")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
550 (widget-create 'push-button
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
551 :tag "Save"
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
552 :help-echo "\
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
553 Make the modifications default for future sessions."
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
554 :action (lambda (widget &optional event)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
555 (custom-save)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
556 (widget-insert " ")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
557 (widget-create 'push-button
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
558 :tag "Reset"
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
559 :help-echo "Undo all modifications."
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
560 :action (lambda (widget &optional event)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
561 (custom-reset event)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
562 (widget-insert " ")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
563 (widget-create 'push-button
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
564 :tag "Done"
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
565 :help-echo "Bury the buffer."
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
566 :action (lambda (widget &optional event)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
567 (bury-buffer)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
568 ;; Steal button release event.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
569 (if (and (fboundp 'button-press-event-p)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
570 (fboundp 'next-command-event))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
571 ;; XEmacs
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
572 (and event
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
573 (button-press-event-p event)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
574 (next-command-event))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
575 ;; Emacs
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
576 (when (memq 'down (event-modifiers event))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
577 (read-event)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
578 (widget-insert "\n")
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
579 (widget-setup)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
580 (goto-char (point-min)))
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
581
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
582 ;;; Modification of Basic Widgets.
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 add extra properties to the basic widgets needed here. This is
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
585 ;; fine, as long as we are careful to stay within out own namespace.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
586 ;;
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
587 ;; We want simple widgets to be displayed by default, but complex
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
588 ;; widgets to be hidden.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
589
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
590 (widget-put (get 'item 'widget-type) :custom-show t)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
591 (widget-put (get 'editable-field 'widget-type)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
592 :custom-show (lambda (widget value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
593 (let ((pp (pp-to-string value)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
594 (cond ((string-match "\n" pp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
595 nil)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
596 ((> (length pp) 40)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
597 nil)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
598 (t t)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
599 (widget-put (get 'menu-choice 'widget-type) :custom-show t)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
600
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
601 ;;; The `custom-manual' Widget.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
602
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
603 (define-widget 'custom-manual 'info-link
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
604 "Link to the manual entry for this customization option."
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
605 :help-echo "Read the manual entry for this option."
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
606 :tag "Manual")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
607
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
608 ;;; The `custom-magic' Widget.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
609
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
610 (defface custom-invalid-face '((((class color))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
611 (:foreground "yellow" :background "red"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
612 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
613 (:bold t :italic t :underline t)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
614 "Face used when the customize item is invalid.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
615
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
616 (defface custom-rogue-face '((((class color))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
617 (:foreground "pink" :background "black"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
618 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
619 (:underline t)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
620 "Face used when the customize item is not defined for customization.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
621
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
622 (defface custom-modified-face '((((class color))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
623 (:foreground "white" :background "blue"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
624 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
625 (:italic t :bold)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
626 "Face used when the customize item has been modified.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
627
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
628 (defface custom-set-face '((((class color))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
629 (:foreground "blue" :background "white"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
630 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
631 (:italic t)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
632 "Face used when the customize item has been set.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
633
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
634 (defface custom-changed-face '((((class color))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
635 (:foreground "white" :background "blue"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
636 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
637 (:italic t)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
638 "Face used when the customize item has been changed.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
639
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
640 (defface custom-saved-face '((t (:underline t)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
641 "Face used when the customize item has been saved.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
642
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
643 (defcustom custom-magic-alist '((nil "#" underline "\
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
644 uninitialized, you should not see this.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
645 (unknown "?" italic "\
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
646 unknown, you should not see this.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
647 (hidden "-" default "\
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
648 hidden, press the state button to show.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
649 (invalid "x" custom-invalid-face "\
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
650 the value displayed for this item is invalid and cannot be set.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
651 (modified "*" custom-modified-face "\
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
652 you have edited the item, and can now set it.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
653 (set "+" custom-set-face "\
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
654 you have set this item, but not saved it.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
655 (changed ":" custom-changed-face "\
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
656 this item has been changed outside customize.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
657 (saved "!" custom-saved-face "\
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
658 this item has been saved.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
659 (rogue "@" custom-rogue-face "\
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
660 this item is not prepared for customization.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
661 (factory " " nil "\
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
662 this item is unchanged from its factory setting."))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
663 "Alist of customize option states.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
664 Each entry is of the form (STATE MAGIC FACE DESCRIPTION), where
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
665
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
666 STATE is one of the following symbols:
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
667
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
668 `nil'
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
669 For internal use, should never occur.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
670 `unknown'
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
671 For internal use, should never occur.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
672 `hidden'
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
673 This item is not being displayed.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
674 `invalid'
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
675 This item is modified, but has an invalid form.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
676 `modified'
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
677 This item is modified, and has a valid form.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
678 `set'
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
679 This item has been set but not saved.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
680 `changed'
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
681 The current value of this item has been changed temporarily.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
682 `saved'
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
683 This item is marked for saving.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
684 `rogue'
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
685 This item has no customization information.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
686 `factory'
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
687 This item is unchanged from the factory default.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
688
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
689 MAGIC is a string used to present that state.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
690
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
691 FACE is a face used to present the state.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
692
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
693 DESCRIPTION is a string describing the state.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
694
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
695 The list should be sorted most significant first."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
696 :type '(list (checklist :inline t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
697 (group (const nil)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
698 (string :tag "Magic")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
699 face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
700 (string :tag "Description"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
701 (group (const unknown)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
702 (string :tag "Magic")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
703 face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
704 (string :tag "Description"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
705 (group (const hidden)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
706 (string :tag "Magic")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
707 face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
708 (string :tag "Description"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
709 (group (const invalid)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
710 (string :tag "Magic")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
711 face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
712 (string :tag "Description"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
713 (group (const modified)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
714 (string :tag "Magic")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
715 face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
716 (string :tag "Description"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
717 (group (const set)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
718 (string :tag "Magic")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
719 face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
720 (string :tag "Description"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
721 (group (const changed)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
722 (string :tag "Magic")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
723 face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
724 (string :tag "Description"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
725 (group (const saved)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
726 (string :tag "Magic")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
727 face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
728 (string :tag "Description"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
729 (group (const rogue)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
730 (string :tag "Magic")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
731 face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
732 (string :tag "Description"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
733 (group (const factory)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
734 (string :tag "Magic")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
735 face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
736 (string :tag "Description")))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
737 (editable-list :inline t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
738 (group symbol
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
739 (string :tag "Magic")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
740 face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
741 (string :tag "Description"))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
742 :group 'customize)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
743
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
744 (defcustom custom-magic-show 'long
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
745 "Show long description of the state of each customization option."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
746 :type '(choice (const :tag "no" nil)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
747 (const short)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
748 (const long))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
749 :group 'customize)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
750
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
751 (defcustom custom-magic-show-button t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
752 "Show a magic button indicating the state of each customization option."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
753 :type 'boolean
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
754 :group 'customize)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
755
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
756 (define-widget 'custom-magic 'default
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
757 "Show and manipulate state for a customization option."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
758 :format "%v"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
759 :action 'widget-choice-item-action
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
760 :value-get 'ignore
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
761 :value-create 'custom-magic-value-create
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
762 :value-delete 'widget-children-value-delete)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
763
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
764 (defun custom-magic-value-create (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
765 ;; Create compact status report for WIDGET.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
766 (let* ((parent (widget-get widget :parent))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
767 (state (widget-get parent :custom-state))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
768 (entry (assq state custom-magic-alist))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
769 (magic (nth 1 entry))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
770 (face (nth 2 entry))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
771 (text (nth 3 entry))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
772 (lisp (eq (widget-get parent :custom-form) 'lisp))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
773 children)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
774 (when custom-magic-show
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
775 (push (widget-create-child-and-convert widget 'choice-item
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
776 :help-echo "\
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
777 Change the state of this item."
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
778 :format "%[%t%]"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
779 :tag "State")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
780 children)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
781 (insert ": ")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
782 (if (eq custom-magic-show 'long)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
783 (insert text)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
784 (insert (symbol-name state)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
785 (when lisp
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
786 (insert " (lisp)"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
787 (insert "\n"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
788 (when custom-magic-show-button
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
789 (when custom-magic-show
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
790 (let ((indent (widget-get parent :indent)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
791 (when indent
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
792 (insert-char ? indent))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
793 (push (widget-create-child-and-convert widget 'choice-item
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
794 :button-face face
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
795 :help-echo "Change the state."
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
796 :format "%[%t%]"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
797 :tag (if lisp
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
798 (concat "(" magic ")")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
799 (concat "[" magic "]")))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
800 children)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
801 (insert " "))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
802 (widget-put widget :children children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
803
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
804 (defun custom-magic-reset (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
805 "Redraw the :custom-magic property of WIDGET."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
806 (let ((magic (widget-get widget :custom-magic)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
807 (widget-value-set magic (widget-value magic))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
808
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
809 ;;; The `custom-level' Widget.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
810
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
811 (define-widget 'custom-level 'item
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
812 "The custom level buttons."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
813 :format "%[%t%]"
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
814 :help-echo "Expand or collapse this item."
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
815 :action 'custom-level-action)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
816
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
817 (defun custom-level-action (widget &optional event)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
818 "Toggle visibility for parent to WIDGET."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
819 (let* ((parent (widget-get widget :parent))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
820 (state (widget-get parent :custom-state)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
821 (cond ((memq state '(invalid modified))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
822 (error "There are unset changes"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
823 ((eq state 'hidden)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
824 (widget-put parent :custom-state 'unknown))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
825 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
826 (widget-put parent :custom-state 'hidden)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
827 (custom-redraw parent)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
828
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
829 ;;; The `custom' Widget.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
830
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
831 (define-widget 'custom 'default
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
832 "Customize a user option."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
833 :convert-widget 'custom-convert-widget
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
834 :format "%l%[%t%]: %v%m%h%a"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
835 :format-handler 'custom-format-handler
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
836 :notify 'custom-notify
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
837 :custom-level 1
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
838 :custom-state 'hidden
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
839 :documentation-property 'widget-subclass-responsibility
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
840 :value-create 'widget-subclass-responsibility
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
841 :value-delete 'widget-children-value-delete
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
842 :value-get 'widget-item-value-get
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
843 :validate 'widget-editable-list-validate
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
844 :match (lambda (widget value) (symbolp value)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
845
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
846 (defun custom-convert-widget (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
847 ;; Initialize :value and :tag from :args in WIDGET.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
848 (let ((args (widget-get widget :args)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
849 (when args
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
850 (widget-put widget :value (widget-apply widget
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
851 :value-to-internal (car args)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
852 (widget-put widget :tag (custom-unlispify-tag-name (car args)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
853 (widget-put widget :args nil)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
854 widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
855
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
856 (defun custom-format-handler (widget escape)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
857 ;; We recognize extra escape sequences.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
858 (let* ((buttons (widget-get widget :buttons))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
859 (state (widget-get widget :custom-state))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
860 (level (widget-get widget :custom-level)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
861 (cond ((eq escape ?l)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
862 (when level
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
863 (push (widget-create-child-and-convert
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
864 widget 'custom-level (make-string level ?*))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
865 buttons)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
866 (widget-insert " ")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
867 (widget-put widget :buttons buttons)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
868 ((eq escape ?L)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
869 (when (eq state 'hidden)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
870 (widget-insert " ...")))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
871 ((eq escape ?m)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
872 (and (eq (preceding-char) ?\n)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
873 (widget-get widget :indent)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
874 (insert-char ? (widget-get widget :indent)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
875 (let ((magic (widget-create-child-and-convert
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
876 widget 'custom-magic nil)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
877 (widget-put widget :custom-magic magic)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
878 (push magic buttons)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
879 (widget-put widget :buttons buttons)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
880 ((eq escape ?a)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
881 (let* ((symbol (widget-get widget :value))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
882 (links (get symbol 'custom-links))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
883 (many (> (length links) 2)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
884 (when links
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
885 (and (eq (preceding-char) ?\n)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
886 (widget-get widget :indent)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
887 (insert-char ? (widget-get widget :indent)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
888 (insert "See also ")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
889 (while links
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
890 (push (widget-create-child-and-convert widget (car links))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
891 buttons)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
892 (setq links (cdr links))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
893 (cond ((null links)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
894 (insert ".\n"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
895 ((null (cdr links))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
896 (if many
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
897 (insert ", and ")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
898 (insert " and ")))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
899 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
900 (insert ", "))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
901 (widget-put widget :buttons buttons))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
902 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
903 (widget-default-format-handler widget escape)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
904
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
905 (defun custom-notify (widget &rest args)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
906 "Keep track of changes."
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
907 (unless (memq (widget-get widget :custom-state) '(nil unknown hidden))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
908 (widget-put widget :custom-state 'modified))
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
909 (let ((buffer-undo-list t))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
910 (custom-magic-reset widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
911 (apply 'widget-default-notify widget args))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
912
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
913 (defun custom-redraw (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
914 "Redraw WIDGET with current settings."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
915 (let ((pos (point))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
916 (from (marker-position (widget-get widget :from)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
917 (to (marker-position (widget-get widget :to))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
918 (save-excursion
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
919 (widget-value-set widget (widget-value widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
920 (custom-redraw-magic widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
921 (when (and (>= pos from) (<= pos to))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
922 (goto-char pos))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
923
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
924 (defun custom-redraw-magic (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
925 "Redraw WIDGET state with current settings."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
926 (while widget
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
927 (let ((magic (widget-get widget :custom-magic)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
928 (unless magic
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
929 (debug))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
930 (widget-value-set magic (widget-value magic))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
931 (when (setq widget (widget-get widget :group))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
932 (custom-group-state-update widget))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
933 (widget-setup))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
934
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
935 (defun custom-show (widget value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
936 "Non-nil if WIDGET should be shown with VALUE by default."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
937 (let ((show (widget-get widget :custom-show)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
938 (cond ((null show)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
939 nil)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
940 ((eq t show)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
941 t)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
942 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
943 (funcall show widget value)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
944
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
945 (defun custom-load-symbol (symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
946 "Load all dependencies for SYMBOL."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
947 (let ((loads (get symbol 'custom-loads))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
948 load)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
949 (while loads
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
950 (setq load (car loads)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
951 loads (cdr loads))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
952 (cond ((symbolp load)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
953 (condition-case nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
954 (require load)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
955 (error nil)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
956 ((assoc load load-history))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
957 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
958 (condition-case nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
959 (load-library load)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
960 (error nil)))))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
961
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
962 (defun custom-load-widget (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
963 "Load all dependencies for WIDGET."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
964 (custom-load-symbol (widget-value widget)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
965
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
966 ;;; The `custom-variable' Widget.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
967
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
968 (defface custom-variable-sample-face '((t (:underline t)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
969 "Face used for unpushable variable tags."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
970 :group 'customize)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
971
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
972 (defface custom-variable-button-face '((t (:underline t :bold t)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
973 "Face used for pushable variable tags."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
974 :group 'customize)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
975
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
976 (define-widget 'custom-variable 'custom
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
977 "Customize variable."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
978 :format "%l%v%m%h%a"
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
979 :help-echo "Set or reset this variable."
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
980 :documentation-property 'variable-documentation
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
981 :custom-state nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
982 :custom-menu 'custom-variable-menu-create
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
983 :custom-form 'edit
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
984 :value-create 'custom-variable-value-create
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
985 :action 'custom-variable-action
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
986 :custom-set 'custom-variable-set
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
987 :custom-save 'custom-variable-save
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
988 :custom-reset-current 'custom-redraw
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
989 :custom-reset-saved 'custom-variable-reset-saved
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
990 :custom-reset-factory 'custom-variable-reset-factory)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
991
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
992 (defun custom-variable-value-create (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
993 "Here is where you edit the variables value."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
994 (custom-load-widget widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
995 (let* ((buttons (widget-get widget :buttons))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
996 (children (widget-get widget :children))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
997 (form (widget-get widget :custom-form))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
998 (state (widget-get widget :custom-state))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
999 (symbol (widget-get widget :value))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1000 (options (get symbol 'custom-options))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1001 (child-type (or (get symbol 'custom-type) 'sexp))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1002 (tag (widget-get widget :tag))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1003 (type (let ((tmp (if (listp child-type)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1004 (copy-list child-type)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1005 (list child-type))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1006 (when options
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1007 (widget-put tmp :options options))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1008 tmp))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1009 (conv (widget-convert type))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1010 (value (if (default-boundp symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1011 (default-value symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1012 (widget-get conv :value))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1013 ;; If the widget is new, the child determine whether it is hidden.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1014 (cond (state)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1015 ((custom-show type value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1016 (setq state 'unknown))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1017 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1018 (setq state 'hidden)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1019 ;; 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
1020 (when (eq state 'unknown)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1021 (unless (widget-apply conv :match value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1022 ;; (widget-apply (widget-convert type) :match value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1023 (setq form 'lisp)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1024 ;; Now we can create the child widget.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1025 (cond ((eq state 'hidden)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1026 ;; Indicate hidden value.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1027 (push (widget-create-child-and-convert
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1028 widget 'item
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1029 :format "%{%t%}: ..."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1030 :sample-face 'custom-variable-sample-face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1031 :tag tag
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1032 :parent widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1033 children))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1034 ((eq form 'lisp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1035 ;; In lisp mode edit the saved value when possible.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1036 (let* ((value (cond ((get symbol 'saved-value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1037 (car (get symbol 'saved-value)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1038 ((get symbol 'factory-value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1039 (car (get symbol 'factory-value)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1040 ((default-boundp symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1041 (custom-quote (default-value symbol)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1042 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1043 (custom-quote (widget-get conv :value))))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1044 (push (widget-create-child-and-convert
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1045 widget 'sexp
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1046 :button-face 'custom-variable-button-face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1047 :tag (symbol-name symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1048 :parent widget
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1049 :value value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1050 children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1051 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1052 ;; Edit mode.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1053 (push (widget-create-child-and-convert
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1054 widget type
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1055 :tag tag
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1056 :button-face 'custom-variable-button-face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1057 :sample-face 'custom-variable-sample-face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1058 :value value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1059 children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1060 ;; Now update the state.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1061 (unless (eq (preceding-char) ?\n)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1062 (widget-insert "\n"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1063 (if (eq state 'hidden)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1064 (widget-put widget :custom-state state)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1065 (custom-variable-state-set widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1066 (widget-put widget :custom-form form)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1067 (widget-put widget :buttons buttons)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1068 (widget-put widget :children children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1069
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1070 (defun custom-variable-state-set (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1071 "Set the state of WIDGET."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1072 (let* ((symbol (widget-value widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1073 (value (if (default-boundp symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1074 (default-value symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1075 (widget-get widget :value)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1076 tmp
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1077 (state (cond ((setq tmp (get symbol 'customized-value))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1078 (if (condition-case nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1079 (equal value (eval (car tmp)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1080 (error nil))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1081 'set
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1082 'changed))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1083 ((setq tmp (get symbol 'saved-value))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1084 (if (condition-case nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1085 (equal value (eval (car tmp)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1086 (error nil))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1087 'saved
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1088 'changed))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1089 ((setq tmp (get symbol 'factory-value))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1090 (if (condition-case nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1091 (equal value (eval (car tmp)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1092 (error nil))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1093 'factory
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1094 'changed))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1095 (t 'rogue))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1096 (widget-put widget :custom-state state)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1097
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1098 (defvar custom-variable-menu
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1099 '(("Edit" . custom-variable-edit)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1100 ("Edit Lisp" . custom-variable-edit-lisp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1101 ("Set" . custom-variable-set)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1102 ("Save" . custom-variable-save)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1103 ("Reset to Current" . custom-redraw)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1104 ("Reset to Saved" . custom-variable-reset-saved)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1105 ("Reset to Factory Settings" . custom-variable-reset-factory))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1106 "Alist of actions for the `custom-variable' widget.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1107 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
1108 lisp function taking the widget as an element which will be called
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1109 when the action is chosen.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1110
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1111 (defun custom-variable-action (widget &optional event)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1112 "Show the menu for `custom-variable' WIDGET.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1113 Optional EVENT is the location for the menu."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1114 (if (eq (widget-get widget :custom-state) 'hidden)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1115 (progn
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1116 (widget-put widget :custom-state 'unknown)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1117 (custom-redraw widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1118 (let* ((completion-ignore-case t)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1119 (answer (widget-choose (custom-unlispify-tag-name
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1120 (widget-get widget :value))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1121 custom-variable-menu
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1122 event)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1123 (if answer
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1124 (funcall answer widget)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1125
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1126 (defun custom-variable-edit (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1127 "Edit value of WIDGET."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1128 (widget-put widget :custom-state 'unknown)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1129 (widget-put widget :custom-form 'edit)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1130 (custom-redraw widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1131
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1132 (defun custom-variable-edit-lisp (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1133 "Edit the lisp representation of the value of WIDGET."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1134 (widget-put widget :custom-state 'unknown)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1135 (widget-put widget :custom-form 'lisp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1136 (custom-redraw widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1137
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1138 (defun custom-variable-set (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1139 "Set the current value for the variable being edited by WIDGET."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1140 (let ((form (widget-get widget :custom-form))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1141 (state (widget-get widget :custom-state))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1142 (child (car (widget-get widget :children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1143 (symbol (widget-value widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1144 val)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1145 (cond ((eq state 'hidden)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1146 (error "Cannot set hidden variable."))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1147 ((setq val (widget-apply child :validate))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1148 (goto-char (widget-get val :from))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1149 (error "%s" (widget-get val :error)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1150 ((eq form 'lisp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1151 (set symbol (eval (setq val (widget-value child))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1152 (put symbol 'customized-value (list val)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1153 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1154 (set symbol (setq val (widget-value child)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1155 (put symbol 'customized-value (list (custom-quote val)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1156 (custom-variable-state-set widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1157 (custom-redraw-magic widget)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1158
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1159 (defun custom-variable-save (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1160 "Set the default value for the variable being edited by WIDGET."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1161 (let ((form (widget-get widget :custom-form))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1162 (state (widget-get widget :custom-state))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1163 (child (car (widget-get widget :children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1164 (symbol (widget-value widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1165 val)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1166 (cond ((eq state 'hidden)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1167 (error "Cannot set hidden variable."))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1168 ((setq val (widget-apply child :validate))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1169 (goto-char (widget-get val :from))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1170 (error "%s" (widget-get val :error)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1171 ((eq form 'lisp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1172 (put symbol 'saved-value (list (widget-value child)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1173 (set symbol (eval (widget-value child))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1174 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1175 (put symbol
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1176 'saved-value (list (custom-quote (widget-value
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1177 child))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1178 (set symbol (widget-value child))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1179 (put symbol 'customized-value nil)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1180 (custom-save-all)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1181 (custom-variable-state-set widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1182 (custom-redraw-magic widget)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1183
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1184 (defun custom-variable-reset-saved (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1185 "Restore the saved value for the variable being edited by WIDGET."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1186 (let ((symbol (widget-value widget)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1187 (if (get symbol 'saved-value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1188 (condition-case nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1189 (set symbol (eval (car (get symbol 'saved-value))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1190 (error nil))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1191 (error "No saved value for %s" symbol))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1192 (put symbol 'customized-value nil)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1193 (widget-put widget :custom-state 'unknown)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1194 (custom-redraw widget)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1195
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1196 (defun custom-variable-reset-factory (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1197 "Restore the factory setting for the variable being edited by WIDGET."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1198 (let ((symbol (widget-value widget)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1199 (if (get symbol 'factory-value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1200 (set symbol (eval (car (get symbol 'factory-value))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1201 (error "No factory default for %S" symbol))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1202 (put symbol 'customized-value nil)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1203 (when (get symbol 'saved-value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1204 (put symbol 'saved-value nil)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1205 (custom-save-all))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1206 (widget-put widget :custom-state 'unknown)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1207 (custom-redraw widget)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1208
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1209 ;;; The `custom-face-edit' Widget.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1210
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1211 (define-widget 'custom-face-edit 'checklist
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1212 "Edit face attributes."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1213 :format "%t: %v"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1214 :tag "Attributes"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1215 :extra-offset 12
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1216 :button-args '(:help-echo "Control whether this attribute have any effect.")
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1217 :args (mapcar (lambda (att)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1218 (list 'group
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1219 :inline t
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1220 :sibling-args (widget-get (nth 1 att) :sibling-args)
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1221 (list 'const :format "" :value (nth 0 att))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1222 (nth 1 att)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1223 custom-face-attributes))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1224
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1225 ;;; The `custom-display' Widget.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1226
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1227 (define-widget 'custom-display 'menu-choice
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1228 "Select a display type."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1229 :tag "Display"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1230 :value t
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1231 :help-echo "Specify frames where the face attributes should be used."
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1232 :args '((const :tag "all" t)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1233 (checklist
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1234 :offset 0
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1235 :extra-offset 9
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1236 :args ((group :sibling-args (:help-echo "\
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1237 Only match the specified window systems.")
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1238 (const :format "Type: "
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1239 type)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1240 (checklist :inline t
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1241 :offset 0
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1242 (const :format "X "
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1243 :sibling-args (:help-echo "\
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1244 The X11 Window System.")
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1245 x)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1246 (const :format "PM "
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1247 :sibling-args (:help-echo "\
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1248 OS/2 Presentation Manager.")
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1249 pm)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1250 (const :format "Win32 "
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1251 :sibling-args (:help-echo "\
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1252 Windows NT/95/97.")
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1253 win32)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1254 (const :format "DOS "
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1255 :sibling-args (:help-echo "\
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1256 Plain MS-DOS.")
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1257 pc)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1258 (const :format "TTY%n"
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1259 :sibling-args (:help-echo "\
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1260 Plain text terminals.")
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1261 tty)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1262 (group :sibling-args (:help-echo "\
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1263 Only match the frames with the specified color support.")
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1264 (const :format "Class: "
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1265 class)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1266 (checklist :inline t
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1267 :offset 0
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1268 (const :format "Color "
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1269 :sibling-args (:help-echo "\
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1270 Match color frames.")
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1271 color)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1272 (const :format "Grayscale "
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1273 :sibling-args (:help-echo "\
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1274 Match grayscale frames.")
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1275 grayscale)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1276 (const :format "Monochrome%n"
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1277 :sibling-args (:help-echo "\
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1278 Match frames with no color support.")
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1279 mono)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1280 (group :sibling-args (:help-echo "\
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1281 Only match frames with the specified intensity.")
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1282 (const :format "\
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1283 Background brightness: "
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1284 background)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1285 (checklist :inline t
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1286 :offset 0
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1287 (const :format "Light "
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1288 :sibling-args (:help-echo "\
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1289 Match frames with light backgrounds.")
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1290 light)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1291 (const :format "Dark\n"
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1292 :sibling-args (:help-echo "\
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1293 Match frames with dark backgrounds.")
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1294 dark)))))))
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1295
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1296 ;;; The `custom-face' Widget.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1297
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1298 (defface custom-face-tag-face '((t (:underline t)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1299 "Face used for face tags."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1300 :group 'customize)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1301
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1302 (define-widget 'custom-face 'custom
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1303 "Customize face."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1304 :format "%l%{%t%}: %s%m%h%a%v"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1305 :format-handler 'custom-face-format-handler
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1306 :sample-face 'custom-face-tag-face
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1307 :help-echo "Set or reset this face."
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1308 :documentation-property '(lambda (face)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1309 (face-doc-string face))
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1310 :value-create 'custom-face-value-create
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1311 :action 'custom-face-action
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1312 :custom-set 'custom-face-set
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1313 :custom-save 'custom-face-save
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1314 :custom-reset-current 'custom-redraw
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1315 :custom-reset-saved 'custom-face-reset-saved
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1316 :custom-reset-factory 'custom-face-reset-factory
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1317 :custom-menu 'custom-face-menu-create)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1318
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1319 (defun custom-face-format-handler (widget escape)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1320 ;; We recognize extra escape sequences.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1321 (let (child
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1322 (symbol (widget-get widget :value)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1323 (cond ((eq escape ?s)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1324 (and (string-match "XEmacs" emacs-version)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1325 ;; XEmacs cannot display initialized faces.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1326 (not (custom-facep symbol))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1327 (copy-face 'custom-face-empty symbol))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1328 (setq child (widget-create-child-and-convert
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1329 widget 'item
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1330 :format "(%{%t%})\n"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1331 :sample-face symbol
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1332 :tag "sample")))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1333 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1334 (custom-format-handler widget escape)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1335 (when child
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1336 (widget-put widget
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1337 :buttons (cons child (widget-get widget :buttons))))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1338
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1339 (defun custom-face-value-create (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1340 ;; Create a list of the display specifications.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1341 (unless (eq (preceding-char) ?\n)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1342 (insert "\n"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1343 (when (not (eq (widget-get widget :custom-state) 'hidden))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1344 (custom-load-widget widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1345 (let* ((symbol (widget-value widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1346 (edit (widget-create-child-and-convert
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1347 widget 'editable-list
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1348 :entry-format "%i %d %v"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1349 :value (or (get symbol 'saved-face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1350 (get symbol 'factory-face))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1351 :insert-button-args '(:help-echo "\
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1352 Insert new display specification here.")
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1353 :append-button-args '(:help-echo "\
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1354 Append new display specification here.")
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1355 :delete-button-args '(:help-echo "\
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1356 Delete this display specification.")
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1357 '(group :format "%v"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1358 custom-display custom-face-edit))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1359 (custom-face-state-set widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1360 (widget-put widget :children (list edit)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1361
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1362 (defvar custom-face-menu
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1363 '(("Set" . custom-face-set)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1364 ("Save" . custom-face-save)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1365 ("Reset to Saved" . custom-face-reset-saved)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1366 ("Reset to Factory Setting" . custom-face-reset-factory))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1367 "Alist of actions for the `custom-face' widget.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1368 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
1369 lisp function taking the widget as an element which will be called
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1370 when the action is chosen.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1371
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1372 (defun custom-face-state-set (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1373 "Set the state of WIDGET."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1374 (let ((symbol (widget-value widget)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1375 (widget-put widget :custom-state (cond ((get symbol 'customized-face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1376 'set)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1377 ((get symbol 'saved-face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1378 'saved)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1379 ((get symbol 'factory-face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1380 'factory)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1381 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1382 'rogue)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1383
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1384 (defun custom-face-action (widget &optional event)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1385 "Show the menu for `custom-face' WIDGET.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1386 Optional EVENT is the location for the menu."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1387 (if (eq (widget-get widget :custom-state) 'hidden)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1388 (progn
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1389 (widget-put widget :custom-state 'unknown)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1390 (custom-redraw widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1391 (let* ((completion-ignore-case t)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1392 (symbol (widget-get widget :value))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1393 (answer (widget-choose (custom-unlispify-tag-name symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1394 custom-face-menu event)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1395 (if answer
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1396 (funcall answer widget)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1397
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1398 (defun custom-face-set (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1399 "Make the face attributes in WIDGET take effect."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1400 (let* ((symbol (widget-value widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1401 (child (car (widget-get widget :children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1402 (value (widget-value child)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1403 (put symbol 'customized-face value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1404 (when (fboundp 'copy-face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1405 (copy-face 'custom-face-empty symbol))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1406 (custom-face-display-set symbol value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1407 (custom-face-state-set widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1408 (custom-redraw-magic widget)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1409
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1410 (defun custom-face-save (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1411 "Make the face attributes in WIDGET default."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1412 (let* ((symbol (widget-value widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1413 (child (car (widget-get widget :children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1414 (value (widget-value child)))
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 (put symbol 'saved-face value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1419 (put symbol 'customized-face nil)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1420 (custom-face-state-set widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1421 (custom-redraw-magic widget)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1422
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1423 (defun custom-face-reset-saved (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1424 "Restore WIDGET to the face's default attributes."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1425 (let* ((symbol (widget-value widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1426 (child (car (widget-get widget :children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1427 (value (get symbol 'saved-face)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1428 (unless value
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1429 (error "No saved value for this face"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1430 (put symbol 'customized-face nil)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1431 (when (fboundp 'copy-face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1432 (copy-face 'custom-face-empty symbol))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1433 (custom-face-display-set symbol value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1434 (widget-value-set child value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1435 (custom-face-state-set widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1436 (custom-redraw-magic widget)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1437
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1438 (defun custom-face-reset-factory (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1439 "Restore WIDGET to the face's factory settings."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1440 (let* ((symbol (widget-value widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1441 (child (car (widget-get widget :children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1442 (value (get symbol 'factory-face)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1443 (unless value
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1444 (error "No factory default for this face"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1445 (put symbol 'customized-face nil)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1446 (when (get symbol 'saved-face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1447 (put symbol 'saved-face nil)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1448 (custom-save-all))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1449 (when (fboundp 'copy-face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1450 (copy-face 'custom-face-empty symbol))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1451 (custom-face-display-set symbol value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1452 (widget-value-set child value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1453 (custom-face-state-set widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1454 (custom-redraw-magic widget)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1455
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1456 ;;; The `face' Widget.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1457
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1458 (define-widget 'face 'default
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1459 "Select and customize a face."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1460 :convert-widget 'widget-item-convert-widget
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1461 :format "%[%t%]: %v"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1462 :tag "Face"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1463 :value 'default
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1464 :value-create 'widget-face-value-create
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1465 :value-delete 'widget-face-value-delete
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1466 :value-get 'widget-item-value-get
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1467 :validate 'widget-editable-list-validate
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1468 :action 'widget-face-action
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1469 :match '(lambda (widget value) (symbolp value)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1470
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1471 (defun widget-face-value-create (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1472 ;; Create a `custom-face' child.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1473 (let* ((symbol (widget-value widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1474 (child (widget-create-child-and-convert
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1475 widget 'custom-face
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1476 :format "%t %s%m%h%v"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1477 :custom-level nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1478 :value symbol)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1479 (custom-magic-reset child)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1480 (setq custom-options (cons child custom-options))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1481 (widget-put widget :children (list child))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1482
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1483 (defun widget-face-value-delete (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1484 ;; Remove the child from the options.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1485 (let ((child (car (widget-get widget :children))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1486 (setq custom-options (delq child custom-options))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1487 (widget-children-value-delete widget)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1488
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1489 (defvar face-history nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1490 "History of entered face names.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1491
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1492 (defun widget-face-action (widget &optional event)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1493 "Prompt for a face."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1494 (let ((answer (completing-read "Face: "
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1495 (mapcar (lambda (face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1496 (list (symbol-name face)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1497 (face-list))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1498 nil nil nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1499 'face-history)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1500 (unless (zerop (length answer))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1501 (widget-value-set widget (intern answer))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1502 (widget-apply widget :notify widget event)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1503 (widget-setup))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1504
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1505 ;;; The `hook' Widget.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1506
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1507 (define-widget 'hook 'list
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1508 "A emacs lisp hook"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1509 :convert-widget 'custom-hook-convert-widget
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1510 :tag "Hook")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1511
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1512 (defun custom-hook-convert-widget (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1513 ;; Handle `:custom-options'.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1514 (let* ((options (widget-get widget :options))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1515 (other `(editable-list :inline t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1516 :entry-format "%i %d%v"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1517 (function :format " %v")))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1518 (args (if options
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1519 (list `(checklist :inline t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1520 ,@(mapcar (lambda (entry)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1521 `(function-item ,entry))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1522 options))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1523 other)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1524 (list other))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1525 (widget-put widget :args args)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1526 widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1527
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1528 ;;; The `custom-group' Widget.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1529
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1530 (defcustom custom-group-tag-faces '(custom-group-tag-face-1)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1531 ;; In XEmacs, this ought to play games with font size.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1532 "Face used for group tags.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1533 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
1534 and so forth. The remaining group tags are shown with
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1535 `custom-group-tag-face'."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1536 :type '(repeat face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1537 :group 'customize)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1538
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1539 (defface custom-group-tag-face-1 '((((class color)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1540 (background dark))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1541 (:foreground "pink" :underline t))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1542 (((class color)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1543 (background light))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1544 (:foreground "red" :underline t))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1545 (t (:underline t)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1546 "Face used for group tags.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1547
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1548 (defface custom-group-tag-face '((((class color)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1549 (background dark))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1550 (:foreground "light blue" :underline t))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1551 (((class color)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1552 (background light))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1553 (:foreground "blue" :underline t))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1554 (t (:underline t)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1555 "Face used for low level group tags."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1556 :group 'customize)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1557
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1558 (define-widget 'custom-group 'custom
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1559 "Customize group."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1560 :format "%l%{%t%}:%L\n%m%h%a%v"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1561 :sample-face-get 'custom-group-sample-face-get
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1562 :documentation-property 'group-documentation
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1563 :help-echo "Set or reset all members of this group."
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1564 :value-create 'custom-group-value-create
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1565 :action 'custom-group-action
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1566 :custom-set 'custom-group-set
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1567 :custom-save 'custom-group-save
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1568 :custom-reset-current 'custom-group-reset-current
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1569 :custom-reset-saved 'custom-group-reset-saved
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1570 :custom-reset-factory 'custom-group-reset-factory
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1571 :custom-menu 'custom-group-menu-create)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1572
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1573 (defun custom-group-sample-face-get (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1574 ;; Use :sample-face.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1575 (or (nth (1- (widget-get widget :custom-level)) custom-group-tag-faces)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1576 'custom-group-tag-face))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1577
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1578 (defun custom-group-value-create (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1579 (let ((state (widget-get widget :custom-state)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1580 (unless (eq state 'hidden)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1581 (custom-load-widget widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1582 (let* ((level (widget-get widget :custom-level))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1583 (symbol (widget-value widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1584 (members (get symbol 'custom-group))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1585 (prefixes (widget-get widget :custom-prefixes))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1586 (custom-prefix-list (custom-prefix-add symbol prefixes))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1587 (children (mapcar (lambda (entry)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1588 (widget-insert "\n")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1589 (prog1
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1590 (widget-create-child-and-convert
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1591 widget (nth 1 entry)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1592 :group widget
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1593 :tag (custom-unlispify-tag-name
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1594 (nth 0 entry))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1595 :custom-prefixes custom-prefix-list
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1596 :custom-level (1+ level)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1597 :value (nth 0 entry))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1598 (unless (eq (preceding-char) ?\n)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1599 (widget-insert "\n"))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1600 members)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1601 (mapcar 'custom-magic-reset children)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1602 (widget-put widget :children children)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1603 (custom-group-state-update widget)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1604
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1605 (defvar custom-group-menu
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1606 '(("Set" . custom-group-set)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1607 ("Save" . custom-group-save)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1608 ("Reset to Current" . custom-group-reset-current)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1609 ("Reset to Saved" . custom-group-reset-saved)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1610 ("Reset to Factory" . custom-group-reset-factory))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1611 "Alist of actions for the `custom-group' widget.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1612 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
1613 lisp function taking the widget as an element which will be called
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1614 when the action is chosen.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1615
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1616 (defun custom-group-action (widget &optional event)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1617 "Show the menu for `custom-group' WIDGET.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1618 Optional EVENT is the location for the menu."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1619 (if (eq (widget-get widget :custom-state) 'hidden)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1620 (progn
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1621 (widget-put widget :custom-state 'unknown)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1622 (custom-redraw widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1623 (let* ((completion-ignore-case t)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1624 (answer (widget-choose (custom-unlispify-tag-name
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1625 (widget-get widget :value))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1626 custom-group-menu
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1627 event)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1628 (if answer
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1629 (funcall answer widget)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1630
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1631 (defun custom-group-set (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1632 "Set changes in all modified group members."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1633 (let ((children (widget-get widget :children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1634 (mapcar (lambda (child)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1635 (when (eq (widget-get child :custom-state) 'modified)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1636 (widget-apply child :custom-set)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1637 children )))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1638
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1639 (defun custom-group-save (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1640 "Save all modified group members."
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 (mapcar (lambda (child)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1643 (when (memq (widget-get child :custom-state) '(modified set))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1644 (widget-apply child :custom-save)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1645 children )))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1646
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1647 (defun custom-group-reset-current (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1648 "Reset all modified group members."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1649 (let ((children (widget-get widget :children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1650 (mapcar (lambda (child)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1651 (when (eq (widget-get child :custom-state) 'modified)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1652 (widget-apply child :custom-reset-current)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1653 children )))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1654
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1655 (defun custom-group-reset-saved (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1656 "Reset all modified or set group members."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1657 (let ((children (widget-get widget :children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1658 (mapcar (lambda (child)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1659 (when (memq (widget-get child :custom-state) '(modified set))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1660 (widget-apply child :custom-reset-saved)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1661 children )))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1662
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1663 (defun custom-group-reset-factory (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1664 "Reset all modified, set, or saved group members."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1665 (let ((children (widget-get widget :children)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1666 (mapcar (lambda (child)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1667 (when (memq (widget-get child :custom-state)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1668 '(modified set saved))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1669 (widget-apply child :custom-reset-factory)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1670 children )))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1671
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1672 (defun custom-group-state-update (widget)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1673 "Update magic."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1674 (unless (eq (widget-get widget :custom-state) 'hidden)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1675 (let* ((children (widget-get widget :children))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1676 (states (mapcar (lambda (child)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1677 (widget-get child :custom-state))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1678 children))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1679 (magics custom-magic-alist)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1680 (found 'factory))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1681 (while magics
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1682 (let ((magic (car (car magics))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1683 (if (and (not (eq magic 'hidden))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1684 (memq magic states))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1685 (setq found magic
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1686 magics nil)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1687 (setq magics (cdr magics)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1688 (widget-put widget :custom-state found)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1689 (custom-magic-reset widget))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1690
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1691 ;;; The `custom-save-all' Function.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1692
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1693 (defcustom custom-file "~/.emacs"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1694 "File used for storing customization information.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1695 If you change this from the default \"~/.emacs\" you need to
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1696 explicitly load that file for the settings to take effect."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1697 :type 'file
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1698 :group 'customize)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1699
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1700 (defun custom-save-delete (symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1701 "Delete the call to SYMBOL form `custom-file'.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1702 Leave point at the location of the call, or after the last expression."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1703 (set-buffer (find-file-noselect custom-file))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1704 (goto-char (point-min))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1705 (catch 'found
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1706 (while t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1707 (let ((sexp (condition-case nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1708 (read (current-buffer))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1709 (end-of-file (throw 'found nil)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1710 (when (and (listp sexp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1711 (eq (car sexp) symbol))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1712 (delete-region (save-excursion
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1713 (backward-sexp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1714 (point))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1715 (point))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1716 (throw 'found nil))))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1717
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1718 (defun custom-save-variables ()
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1719 "Save all customized variables in `custom-file'."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1720 (save-excursion
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1721 (custom-save-delete 'custom-set-variables)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1722 (let ((standard-output (current-buffer)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1723 (unless (bolp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1724 (princ "\n"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1725 (princ "(custom-set-variables")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1726 (mapatoms (lambda (symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1727 (let ((value (get symbol 'saved-value)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1728 (when value
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1729 (princ "\n '(")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1730 (princ symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1731 (princ " ")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1732 (prin1 (car value))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1733 (if (or (get symbol 'factory-value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1734 (and (not (boundp symbol))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1735 (not (get symbol 'force-value))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1736 (princ ")")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1737 (princ " t)"))))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1738 (princ ")")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1739 (unless (eolp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1740 (princ "\n")))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1741
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1742 (defun custom-save-faces ()
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1743 "Save all customized faces in `custom-file'."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1744 (save-excursion
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1745 (custom-save-delete 'custom-set-faces)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1746 (let ((standard-output (current-buffer)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1747 (unless (bolp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1748 (princ "\n"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1749 (princ "(custom-set-faces")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1750 (mapatoms (lambda (symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1751 (let ((value (get symbol 'saved-face)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1752 (when value
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1753 (princ "\n '(")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1754 (princ symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1755 (princ " ")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1756 (prin1 value)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1757 (if (or (get symbol 'factory-face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1758 (and (not (custom-facep symbol))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1759 (not (get symbol 'force-face))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1760 (princ ")")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1761 (princ " t)"))))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1762 (princ ")")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1763 (unless (eolp)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1764 (princ "\n")))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1765
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1766 (defun custom-save-all ()
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1767 "Save all customizations in `custom-file'."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1768 (custom-save-variables)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1769 (custom-save-faces)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1770 (save-excursion
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1771 (set-buffer (find-file-noselect custom-file))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1772 (save-buffer)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1773
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1774 ;;; The Customize Menu.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1775
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1776 (defcustom custom-menu-nesting 2
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1777 "Maximum nesting in custom menus."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1778 :type 'integer
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1779 :group 'customize)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1780
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1781 (defun custom-face-menu-create (widget symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1782 "Ignoring WIDGET, create a menu entry for customization face SYMBOL."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1783 (vector (custom-unlispify-menu-entry symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1784 `(custom-buffer-create '((,symbol custom-face)))
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
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1787 (defun custom-variable-menu-create (widget symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1788 "Ignoring WIDGET, create a menu entry for customization variable SYMBOL."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1789 (let ((type (get symbol 'custom-type)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1790 (unless (listp type)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1791 (setq type (list type)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1792 (if (and type (widget-get type :custom-menu))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1793 (widget-apply type :custom-menu symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1794 (vector (custom-unlispify-menu-entry symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1795 `(custom-buffer-create '((,symbol custom-variable)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1796 t))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1797
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1798 (widget-put (get 'boolean 'widget-type)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1799 :custom-menu (lambda (widget symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1800 (vector (custom-unlispify-menu-entry symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1801 `(custom-buffer-create
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1802 '((,symbol custom-variable)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1803 ':style 'toggle
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1804 ':selected symbol)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1805
34
d620409f5eb8 Import from CVS: tag r19-15b100
cvs
parents: 32
diff changeset
1806 (if (string-match "XEmacs" emacs-version)
d620409f5eb8 Import from CVS: tag r19-15b100
cvs
parents: 32
diff changeset
1807 ;; XEmacs can create menus dynamically.
d620409f5eb8 Import from CVS: tag r19-15b100
cvs
parents: 32
diff changeset
1808 (defun custom-group-menu-create (widget symbol)
d620409f5eb8 Import from CVS: tag r19-15b100
cvs
parents: 32
diff changeset
1809 "Ignoring WIDGET, create a menu entry for customization group SYMBOL."
d620409f5eb8 Import from CVS: tag r19-15b100
cvs
parents: 32
diff changeset
1810 `( ,(custom-unlispify-menu-entry symbol t)
36
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
1811 :filter (lambda (&rest junk)
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
1812 (cdr (custom-menu-create ',symbol)))))
34
d620409f5eb8 Import from CVS: tag r19-15b100
cvs
parents: 32
diff changeset
1813 ;; But emacs can't.
d620409f5eb8 Import from CVS: tag r19-15b100
cvs
parents: 32
diff changeset
1814 (defun custom-group-menu-create (widget symbol)
d620409f5eb8 Import from CVS: tag r19-15b100
cvs
parents: 32
diff changeset
1815 "Ignoring WIDGET, create a menu entry for customization group SYMBOL."
d620409f5eb8 Import from CVS: tag r19-15b100
cvs
parents: 32
diff changeset
1816 ;; Limit the nesting.
d620409f5eb8 Import from CVS: tag r19-15b100
cvs
parents: 32
diff changeset
1817 (let ((custom-menu-nesting (1- custom-menu-nesting)))
d620409f5eb8 Import from CVS: tag r19-15b100
cvs
parents: 32
diff changeset
1818 (custom-menu-create symbol))))
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1819
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1820 (defun custom-menu-create (symbol &optional name)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1821 "Create menu for customization group SYMBOL.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1822 If optional NAME is given, use that as the name of the menu.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1823 Otherwise make up a name from SYMBOL.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1824 The menu is in a format applicable to `easy-menu-define'."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1825 (unless name
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1826 (setq name (custom-unlispify-menu-entry symbol)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1827 (let ((item (vector name
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1828 `(custom-buffer-create '((,symbol custom-group)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1829 t)))
34
d620409f5eb8 Import from CVS: tag r19-15b100
cvs
parents: 32
diff changeset
1830 (if (and (>= custom-menu-nesting 0)
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1831 (< (length (get symbol 'custom-group)) widget-menu-max-size))
34
d620409f5eb8 Import from CVS: tag r19-15b100
cvs
parents: 32
diff changeset
1832 (let ((custom-prefix-list (custom-prefix-add symbol
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1833 custom-prefix-list)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1834 (custom-load-symbol symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1835 `(,(custom-unlispify-menu-entry symbol t)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1836 ,item
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1837 "--"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1838 ,@(mapcar (lambda (entry)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1839 (widget-apply (if (listp (nth 1 entry))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1840 (nth 1 entry)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1841 (list (nth 1 entry)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1842 :custom-menu (nth 0 entry)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1843 (get symbol 'custom-group))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1844 item)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1845
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1846 ;;;###autoload
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
1847 (defun custom-menu-update (event)
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1848 "Update customize menu."
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
1849 (interactive "e")
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1850 (add-hook 'custom-define-hook 'custom-menu-reset)
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
1851 (let* ((emacs (widget-apply '(custom-group) :custom-menu 'emacs))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
1852 (menu `(,(car custom-help-menu)
34
d620409f5eb8 Import from CVS: tag r19-15b100
cvs
parents: 32
diff changeset
1853 ,emacs
d620409f5eb8 Import from CVS: tag r19-15b100
cvs
parents: 32
diff changeset
1854 ,@(cdr (cdr custom-help-menu)))))
d620409f5eb8 Import from CVS: tag r19-15b100
cvs
parents: 32
diff changeset
1855 (let ((map (easy-menu-create-keymaps (car menu) (cdr menu))))
d620409f5eb8 Import from CVS: tag r19-15b100
cvs
parents: 32
diff changeset
1856 (define-key global-map [menu-bar help-menu customize-menu]
d620409f5eb8 Import from CVS: tag r19-15b100
cvs
parents: 32
diff changeset
1857 (cons (car menu) map)))))
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1858
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1859 ;;; Dependencies.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1860
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1861 ;;;###autoload
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1862 (defun custom-make-dependencies ()
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1863 "Batch function to extract custom dependencies from .el files.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1864 Usage: emacs -batch *.el -f custom-make-dependencies > deps.el"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1865 (let ((buffers (buffer-list)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1866 (while buffers
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1867 (set-buffer (car buffers))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1868 (setq buffers (cdr buffers))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1869 (let ((file (buffer-file-name)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1870 (when (and file (string-match "\\`\\(.*\\)\\.el\\'" file))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1871 (goto-char (point-min))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1872 (condition-case nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1873 (let ((name (file-name-nondirectory (match-string 1 file))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1874 (while t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1875 (let ((expr (read (current-buffer))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1876 (when (and (listp expr)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1877 (memq (car expr) '(defcustom defface defgroup)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1878 (eval expr)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1879 (put (nth 1 expr) 'custom-where name)))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1880 (error nil))))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1881 (mapatoms (lambda (symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1882 (let ((members (get symbol 'custom-group))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1883 item where found)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1884 (when members
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1885 (princ "(put '")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1886 (princ symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1887 (princ " 'custom-loads '(")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1888 (while members
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1889 (setq item (car (car members))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1890 members (cdr members)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1891 where (get item 'custom-where))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1892 (unless (or (null where)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1893 (member where found))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1894 (when found
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1895 (princ " "))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1896 (prin1 where)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1897 (push where found)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1898 (princ "))\n"))))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1899
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1900 ;;; The End.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1901
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1902 (provide 'cus-edit)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1903
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1904 ;; cus-edit.el ends here