annotate lisp/cus-edit.el @ 424:11054d720c21 r21-2-20

Import from CVS: tag r21-2-20
author cvs
date Mon, 13 Aug 2007 11:26:11 +0200
parents 95016f13131a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1 ;;; cus-edit.el --- Tools for customizating Emacs and Lisp packages.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2 ;;
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
3 ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc.
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
4 ;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
6 ;; Maintainer: Hrvoje Niksic <hniksic@srce.hr>
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
7 ;; Keywords: help, faces
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
8 ;; Version: 1.9960-x
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
9 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
10
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
11 ;; This file is part of XEmacs.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
12
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
13 ;; XEmacs is free software; you can redistribute it and/or modify
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
15 ;; the Free Software Foundation; either version 2, or (at your option)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
16 ;; any later version.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
17
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
18 ;; XEmacs is distributed in the hope that it will be useful,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
21 ;; GNU General Public License for more details.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
22
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
24 ;; along with XEmacs; see the file COPYING. If not, write to the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
26 ;; Boston, MA 02111-1307, USA.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
27
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
28 ;;; Commentary:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
29 ;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
30 ;; This file implements the code to create and edit customize buffers.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
31 ;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
32 ;; See `custom.el'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
33
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
34 ;; No commands should have names starting with `custom-' because
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
35 ;; that interferes with completion. Use `customize-' for commands
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
36 ;; that the user will run with M-x, and `Custom-' for interactive commands.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
37
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
38 ;; NOTE: In many places within this file we use `mapatoms', which is
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
39 ;; very slow in an average XEmacs because of the large number of
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
40 ;; symbols requiring a large number of funcalls -- XEmacs with Gnus
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
41 ;; can grow to some 17000 symbols without ever doing anything fancy.
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
42 ;; It would probably pay off to make a hash table of symbols known to
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
43 ;; Custom, similar to custom-group-hash-table.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
44
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
45 ;; This is not top priority, because none of the functions that do
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
46 ;; mapatoms are speed-critical (the one that was now uses
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
47 ;; custom-group-hash-table), but it would be nice to have.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
48
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
49
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
50 ;;; Code:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
51
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
52 (require 'cus-face)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
53 (require 'wid-edit)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
54 (require 'easymenu)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
55
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
56 (require 'cus-load)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
57 (require 'cus-start)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
58
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
59 ;; Huh? This looks dirty!
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
60 (put 'custom-define-hook 'custom-type 'hook)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
61 (put 'custom-define-hook 'standard-value '(nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
62 (custom-add-to-group 'customize 'custom-define-hook 'custom-variable)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
63
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
64 ;;; Customization Groups.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
65
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
66 (defgroup emacs nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
67 "Customization of the One True Editor."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
68 :link '(custom-manual "(XEmacs)Top"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
69
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
70 ;; Most of these groups are stolen from `finder.el',
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
71 (defgroup editing nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
72 "Basic text editing facilities."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
73 :group 'emacs)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
74
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
75 (defgroup matching nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
76 "Various sorts of searching and matching."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
77 :group 'editing)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
78
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
79 (defgroup emulations nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
80 "Emulations of other editors."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
81 :group 'editing)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
82
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
83 (defgroup outlines nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
84 "Support for hierarchical outlining."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
85 :group 'editing)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
86
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
87 (defgroup external nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
88 "Interfacing to external utilities."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
89 :group 'emacs)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
90
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
91 (defgroup bib nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
92 "Code related to the `bib' bibliography processor."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
93 :tag "Bibliography"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
94 :group 'external)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
95
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
96 (defgroup programming nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
97 "Support for programming in other languages."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
98 :group 'emacs)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
99
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
100 (defgroup languages nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
101 "Specialized modes for editing programming languages."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
102 :group 'programming)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
103
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
104 ;; #### This should be in cc-vars.el
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
105 (defgroup c nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
106 "Support for the C language and related languages."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
107 :group 'languages)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
108
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
109 (defgroup tools nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
110 "Programming tools."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
111 :group 'programming)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
112
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
113 (defgroup oop nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
114 "Support for object-oriented programming."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
115 :group 'programming)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
116
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
117 (defgroup applications nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
118 "Applications written in Emacs."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
119 :group 'emacs)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
120
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
121 ;; #### This should be in calendar.el
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
122 (defgroup calendar nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
123 "Calendar and time management support."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
124 :group 'applications)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
125
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
126 (defgroup mail nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
127 "Modes for electronic-mail handling."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
128 :group 'applications)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
129
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
130 (defgroup news nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
131 "Support for netnews reading and posting."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
132 :group 'applications)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
133
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
134 (defgroup games nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
135 "Games, jokes and amusements."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
136 :group 'applications)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
137
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
138 (defgroup development nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
139 "Support for further development of Emacs."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
140 :group 'emacs)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
141
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
142 (defgroup docs nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
143 "Support for Emacs documentation."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
144 :group 'development)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
145
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
146 (defgroup extensions nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
147 "Emacs Lisp language extensions."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
148 :group 'development)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
149
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
150 (defgroup internal nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
151 "Code for Emacs internals, build process, defaults."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
152 :group 'development)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
153
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
154 (defgroup maint nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
155 "Maintenance aids for the Emacs development group."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
156 :tag "Maintenance"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
157 :group 'development)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
158
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
159 (defgroup environment nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
160 "Fitting Emacs with its environment."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
161 :group 'emacs)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
162
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
163 (defgroup comm nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
164 "Communications, networking, remote access to files."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
165 :tag "Communication"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
166 :group 'environment)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
167
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
168 (defgroup hardware nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
169 "Support for interfacing with exotic hardware."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
170 :group 'environment)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
171
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
172 (defgroup terminals nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
173 "Support for terminal types."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
174 :group 'environment)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
175
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
176 (defgroup unix nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
177 "Front-ends/assistants for, or emulators of, UNIX features."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
178 :group 'environment)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
179
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
180 (defgroup i18n nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
181 "Internationalization and alternate character-set support."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
182 :group 'environment
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
183 :group 'editing)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
184
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
185 (defgroup data nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
186 "Support editing files of data."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
187 :group 'emacs)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
188
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
189 (defgroup wp nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
190 "Word processing."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
191 :group 'emacs)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
192
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
193 (defgroup tex nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
194 "Code related to the TeX formatter."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
195 :group 'wp)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
196
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
197 (defgroup hypermedia nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
198 "Support for links between text or other media types."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
199 :group 'emacs)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
200
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
201 (defgroup local nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
202 "Code local to your site."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
203 :group 'emacs)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
204
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
205 (defgroup customize '((widgets custom-group))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
206 "Customization of the Customization support."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
207 :link '(custom-manual "(custom)Top")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
208 :link '(url-link :tag "Development Page"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
209 "http://www.dina.kvl.dk/~abraham/custom/")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
210 :prefix "custom-"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
211 :group 'help)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
212
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
213 (defgroup custom-faces nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
214 "Faces used by customize."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
215 :group 'customize
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
216 :group 'faces)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
217
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
218 (defgroup custom-browse nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
219 "Control customize browser."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
220 :prefix "custom-"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
221 :group 'customize)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
222
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
223 (defgroup custom-buffer nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
224 "Control customize buffers."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
225 :prefix "custom-"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
226 :group 'customize)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
227
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
228 (defgroup custom-menu nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
229 "Control customize menus."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
230 :prefix "custom-"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
231 :group 'customize)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
232
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
233 (defgroup alloc nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
234 "Storage allocation and gc for GNU Emacs Lisp interpreter."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
235 :tag "Storage Allocation"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
236 :group 'internal)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
237
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
238 (defgroup undo nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
239 "Undoing changes in buffers."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
240 :group 'editing)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
241
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
242 (defgroup editing-basics nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
243 "Most basic editing facilities."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
244 :group 'editing)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
245
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
246 (defgroup display nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
247 "How characters are displayed in buffers."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
248 :group 'environment)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
249
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
250 (defgroup installation nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
251 "The Emacs installation."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
252 :group 'environment)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
253
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
254 (defgroup limits nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
255 "Internal Emacs limits."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
256 :group 'internal)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
257
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
258 (defgroup debug nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
259 "Debugging Emacs itself."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
260 :group 'development)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
261
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
262 (defgroup mule nil
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
263 "Mule XEmacs internationalization."
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
264 :group 'i18n)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
265
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
266
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
267 ;;; Utilities.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
268
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
269 (defun custom-quote (sexp)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
270 "Quote SEXP iff it is not self quoting."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
271 (if (or (memq sexp '(t nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
272 (keywordp sexp)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
273 (eq (car-safe sexp) 'lambda)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
274 (stringp sexp)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
275 (numberp sexp)
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
276 (characterp sexp)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
277 (vectorp sexp)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
278 (bit-vector-p sexp))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
279 sexp
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
280 (list 'quote sexp)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
281
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
282 (defun custom-split-regexp-maybe (regexp)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
283 "If REGEXP is a string, split it to a list at `\\|'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
284 You can get the original back with from the result with:
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
285 (mapconcat #'identity result \"\\|\")
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
286
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
287 IF REGEXP is not a string, return it unchanged."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
288 (if (stringp regexp)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
289 (split-string regexp "\\\\|")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
290 regexp))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
291
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
292 (defun custom-variable-prompt ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
293 ;; Code stolen from `help.el'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
294 "Prompt for a variable, defaulting to the variable at point.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
295 Return a list suitable for use in `interactive'."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
296 (let ((v (variable-at-point))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
297 (enable-recursive-minibuffers t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
298 val)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
299 (setq val (completing-read
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
300 (if (symbolp v)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
301 (format "Customize variable: (default %s) " v)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
302 "Customize variable: ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
303 obarray (lambda (symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
304 (and (boundp symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
305 (or (get symbol 'custom-type)
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
306 (user-variable-p symbol)))) t))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
307 (list (if (equal val "")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
308 (if (symbolp v) v nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
309 (intern val)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
310
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
311 ;; Here we take not only the actual groups, but the loads, too.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
312 (defun custom-group-prompt (prompt)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
313 "Read group from minibuffer."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
314 (let ((completion-ignore-case t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
315 (list (completing-read
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
316 prompt obarray
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
317 (lambda (symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
318 (or (get symbol 'custom-group)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
319 (get symbol 'custom-loads)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
320 t))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
321
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
322 (defun custom-menu-filter (menu widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
323 "Convert MENU to the form used by `widget-choose'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
324 MENU should be in the same format as `custom-variable-menu'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
325 WIDGET is the widget to apply the filter entries of MENU on."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
326 (let ((result nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
327 current name action filter)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
328 (while menu
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
329 (setq current (car menu)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
330 name (nth 0 current)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
331 action (nth 1 current)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
332 filter (nth 2 current)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
333 menu (cdr menu))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
334 (if (or (null filter) (funcall filter widget))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
335 (push (cons name action) result)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
336 (push name result)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
337 (nreverse result)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
338
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
339
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
340 ;;; Unlispify.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
341
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
342 (defvar custom-prefix-list nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
343 "List of prefixes that should be ignored by `custom-unlispify'")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
344
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
345 (defcustom custom-unlispify-menu-entries t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
346 "Display menu entries as words instead of symbols if non nil."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
347 :group 'custom-menu
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
348 :type 'boolean)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
349
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
350 (defcustom custom-unlispify-remove-prefixes t
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
351 "Non-nil means remove group prefixes from option names in buffers and menus.
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
352 This only has an effect when `custom-unlispify-tag-names' or
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
353 `custom-unlispify-menu-entries' is on."
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
354 :group 'custom-menu
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
355 :type 'boolean)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
356
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
357 (defun custom-unlispify-menu-entry (symbol &optional no-suffix)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
358 "Convert symbol into a menu entry."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
359 (cond ((not custom-unlispify-menu-entries)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
360 (symbol-name symbol))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
361 ((get symbol 'custom-tag)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
362 (if no-suffix
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
363 (get symbol 'custom-tag)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
364 (concat (get symbol 'custom-tag) "...")))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
365 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
366 (with-current-buffer (get-buffer-create " *Custom-Work*")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
367 (erase-buffer)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
368 (princ symbol (current-buffer))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
369 (goto-char (point-min))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
370 (when (and (eq (get symbol 'custom-type) 'boolean)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
371 (re-search-forward "-p\\'" nil t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
372 (replace-match "" t t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
373 (goto-char (point-min)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
374 (when custom-unlispify-remove-prefixes
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
375 (let ((prefixes custom-prefix-list)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
376 prefix)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
377 (while prefixes
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
378 (setq prefix (car prefixes))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
379 (if (search-forward prefix (+ (point) (length prefix)) t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
380 (progn
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
381 (setq prefixes nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
382 (delete-region (point-min) (point)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
383 (setq prefixes (cdr prefixes))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
384 (subst-char-in-region (point-min) (point-max) ?- ?\ t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
385 (capitalize-region (point-min) (point-max))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
386 (unless no-suffix
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
387 (goto-char (point-max))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
388 (insert "..."))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
389 (buffer-string)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
390
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
391 (defcustom custom-unlispify-tag-names t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
392 "Display tag names as words instead of symbols if non nil."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
393 :group 'custom-buffer
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
394 :type 'boolean)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
395
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
396 (defun custom-unlispify-tag-name (symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
397 "Convert symbol into a menu entry."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
398 (let ((custom-unlispify-menu-entries custom-unlispify-tag-names))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
399 (custom-unlispify-menu-entry symbol t)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
400
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
401 (defun custom-prefix-add (symbol prefixes)
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
402 ;; Addd SYMBOL to list of ignored PREFIXES.
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
403 (cons (or (get symbol 'custom-prefix)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
404 (concat (symbol-name symbol) "-"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
405 prefixes))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
406
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
407
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
408 ;;; Guess.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
409
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
410 (defcustom custom-guess-name-alist
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
411 '(("-p\\'" boolean)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
412 ("-hooks?\\'" hook)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
413 ("-face\\'" face)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
414 ("-file\\'" file)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
415 ("-function\\'" function)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
416 ("-functions\\'" (repeat function))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
417 ("-list\\'" (repeat sexp))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
418 ("-alist\\'" (repeat (cons sexp sexp))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
419 "Alist of (MATCH TYPE).
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
420
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
421 MATCH should be a regexp matching the name of a symbol, and TYPE should
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
422 be a widget suitable for editing the value of that symbol. The TYPE
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
423 of the first entry where MATCH matches the name of the symbol will be
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
424 used.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
425
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
426 This is used for guessing the type of variables not declared with
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
427 customize."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
428 :type '(repeat (group (regexp :tag "Match") (sexp :tag "Type")))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
429 :group 'customize)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
430
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
431 (defcustom custom-guess-doc-alist
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
432 '(("\\`\\*?Non-nil " boolean))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
433 "Alist of (MATCH TYPE).
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
434
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
435 MATCH should be a regexp matching a documentation string, and TYPE
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
436 should be a widget suitable for editing the value of a variable with
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
437 that documentation string. The TYPE of the first entry where MATCH
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
438 matches the name of the symbol will be used.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
439
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
440 This is used for guessing the type of variables not declared with
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
441 customize."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
442 :type '(repeat (group (regexp :tag "Match") (sexp :tag "Type")))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
443 :group 'customize)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
444
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
445 (defun custom-guess-type (symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
446 "Guess a widget suitable for editing the value of SYMBOL.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
447 This is done by matching SYMBOL with `custom-guess-name-alist' and
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
448 if that fails, the doc string with `custom-guess-doc-alist'."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
449 (let ((name (symbol-name symbol))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
450 (names custom-guess-name-alist)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
451 current found)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
452 (while names
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
453 (setq current (car names)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
454 names (cdr names))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
455 (when (string-match (nth 0 current) name)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
456 (setq found (nth 1 current)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
457 names nil)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
458 (unless found
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
459 (let ((doc (documentation-property symbol 'variable-documentation))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
460 (docs custom-guess-doc-alist))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
461 (when doc
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
462 (while docs
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
463 (setq current (car docs)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
464 docs (cdr docs))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
465 (when (string-match (nth 0 current) doc)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
466 (setq found (nth 1 current)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
467 docs nil))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
468 found))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
469
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
470
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
471 ;;; Sorting.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
472
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
473 (defcustom custom-browse-sort-alphabetically nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
474 "If non-nil, sort members of each customization group alphabetically."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
475 :type 'boolean
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
476 :group 'custom-browse)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
477
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
478 (defcustom custom-browse-order-groups nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
479 "If non-nil, order group members within each customization group.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
480 If `first', order groups before non-groups.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
481 If `last', order groups after non-groups."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
482 :type '(choice (const first)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
483 (const last)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
484 (const :tag "none" nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
485 :group 'custom-browse)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
486
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
487 (defcustom custom-browse-only-groups nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
488 "If non-nil, show group members only within each customization group."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
489 :type 'boolean
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
490 :group 'custom-browse)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
491
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
492 (defcustom custom-buffer-sort-alphabetically nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
493 "If non-nil, sort members of each customization group alphabetically."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
494 :type 'boolean
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
495 :group 'custom-buffer)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
496
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
497 (defcustom custom-buffer-order-groups 'last
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
498 "If non-nil, order group members within each customization group.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
499 If `first', order groups before non-groups.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
500 If `last', order groups after non-groups."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
501 :type '(choice (const first)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
502 (const last)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
503 (const :tag "none" nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
504 :group 'custom-buffer)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
505
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
506 (defcustom custom-menu-sort-alphabetically nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
507 "If non-nil, sort members of each customization group alphabetically."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
508 :type 'boolean
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
509 :group 'custom-menu)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
510
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
511 (defcustom custom-menu-order-groups 'first
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
512 "If non-nil, order group members within each customization group.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
513 If `first', order groups before non-groups.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
514 If `last', order groups after non-groups."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
515 :type '(choice (const first)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
516 (const last)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
517 (const :tag "none" nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
518 :group 'custom-menu)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
519
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
520 (defun custom-sort-items (items sort-alphabetically order-groups)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
521 "Return a sorted copy of ITEMS.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
522 ITEMS should be a `custom-group' property.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
523 If SORT-ALPHABETICALLY non-nil, sort alphabetically.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
524 If ORDER-GROUPS is `first' order groups before non-groups, if `last' order
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
525 groups after non-groups, if nil do not order groups at all."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
526 (sort (copy-sequence items)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
527 (lambda (a b)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
528 (let ((typea (nth 1 a)) (typeb (nth 1 b))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
529 (namea (symbol-name (nth 0 a))) (nameb (symbol-name (nth 0 b))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
530 (cond ((not order-groups)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
531 ;; Since we don't care about A and B order, maybe sort.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
532 (when sort-alphabetically
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
533 (string-lessp namea nameb)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
534 ((eq typea 'custom-group)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
535 ;; If B is also a group, maybe sort. Otherwise, order A and B.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
536 (if (eq typeb 'custom-group)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
537 (when sort-alphabetically
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
538 (string-lessp namea nameb))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
539 (eq order-groups 'first)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
540 ((eq typeb 'custom-group)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
541 ;; Since A cannot be a group, order A and B.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
542 (eq order-groups 'last))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
543 (sort-alphabetically
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
544 ;; Since A and B cannot be groups, sort.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
545 (string-lessp namea nameb)))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
546
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
547
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
548 ;;; Custom Mode Commands.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
549
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
550 (defvar custom-options nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
551 "Customization widgets in the current buffer.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
552
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
553 (defun Custom-set ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
554 "Set changes in all modified options."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
555 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
556 (let ((children custom-options))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
557 (mapc (lambda (child)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
558 (when (eq (widget-get child :custom-state) 'modified)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
559 (widget-apply child :custom-set)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
560 children)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
561
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
562 (defun Custom-save ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
563 "Set all modified group members and save them."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
564 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
565 (let ((children custom-options))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
566 (mapc (lambda (child)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
567 (when (memq (widget-get child :custom-state) '(modified set))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
568 (widget-apply child :custom-save)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
569 children))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
570 (custom-save-all))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
571
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
572 (defvar custom-reset-menu
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
573 '(("Current" . Custom-reset-current)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
574 ("Saved" . Custom-reset-saved)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
575 ("Standard Settings" . Custom-reset-standard))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
576 "Alist of actions for the `Reset' button.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
577 The key is a string containing the name of the action, the value is a
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
578 lisp function taking the widget as an element which will be called
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
579 when the action is chosen.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
580
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
581 (defun custom-reset (event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
582 "Select item from reset menu."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
583 (let* ((completion-ignore-case t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
584 (answer (widget-choose "Reset to"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
585 custom-reset-menu
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
586 event)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
587 (if answer
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
588 (funcall answer))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
589
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
590 (defun Custom-reset-current (&rest ignore)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
591 "Reset all modified group members to their current value."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
592 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
593 (let ((children custom-options))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
594 (mapc (lambda (child)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
595 (when (eq (widget-get child :custom-state) 'modified)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
596 (widget-apply child :custom-reset-current)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
597 children)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
598
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
599 (defun Custom-reset-saved (&rest ignore)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
600 "Reset all modified or set group members to their saved value."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
601 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
602 (let ((children custom-options))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
603 (mapc (lambda (child)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
604 (when (eq (widget-get child :custom-state) 'modified)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
605 (widget-apply child :custom-reset-saved)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
606 children)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
607
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
608 (defun Custom-reset-standard (&rest ignore)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
609 "Reset all modified, set, or saved group members to their standard settings."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
610 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
611 (let ((children custom-options))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
612 (mapc (lambda (child)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
613 (when (eq (widget-get child :custom-state) 'modified)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
614 (widget-apply child :custom-reset-standard)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
615 children)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
616
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
617
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
618 ;;; The Customize Commands
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
619
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
620 (defun custom-prompt-variable (prompt-var prompt-val &optional comment)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
621 "Prompt for a variable and a value and return them as a list.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
622 PROMPT-VAR is the prompt for the variable, and PROMPT-VAL is the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
623 prompt for the value. The %s escape in PROMPT-VAL is replaced with
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
624 the name of the variable.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
625
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
626 If the variable has a `variable-interactive' property, that is used as if
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
627 it were the arg to `interactive' (which see) to interactively read the value.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
628
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
629 If the variable has a `custom-type' property, it must be a widget and the
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
630 `:prompt-value' property of that widget will be used for reading the value.
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
631
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
632 If optional COMMENT argument is non nil, also prompt for a comment and return
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
633 it as the third element in the list."
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
634 (let* ((var (read-variable prompt-var))
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
635 (minibuffer-help-form '(describe-variable var))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
636 (val
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
637 (let ((prop (get var 'variable-interactive))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
638 (type (get var 'custom-type))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
639 (prompt (format prompt-val var)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
640 (unless (listp type)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
641 (setq type (list type)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
642 (cond (prop
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
643 ;; Use VAR's `variable-interactive' property
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
644 ;; as an interactive spec for prompting.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
645 (call-interactively (list 'lambda '(arg)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
646 (list 'interactive prop)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
647 'arg)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
648 (type
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
649 (widget-prompt-value type
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
650 prompt
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
651 (if (boundp var)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
652 (symbol-value var))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
653 (not (boundp var))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
654 (t
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
655 (eval-minibuffer prompt))))))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
656 (if comment
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
657 (list var val
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
658 (read-string "Comment: " (get var 'variable-comment)))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
659 (list var val))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
660 ))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
661
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
662 ;;;###autoload
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
663 (defun customize-set-value (var val &optional comment)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
664 "Set VARIABLE to VALUE. VALUE is a Lisp object.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
665
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
666 If VARIABLE has a `variable-interactive' property, that is used as if
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
667 it were the arg to `interactive' (which see) to interactively read the value.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
668
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
669 If VARIABLE has a `custom-type' property, it must be a widget and the
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
670 `:prompt-value' property of that widget will be used for reading the value.
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
671
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
672 If given a prefix (or a COMMENT argument), also prompt for a comment."
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
673 (interactive (custom-prompt-variable "Set variable: "
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
674 "Set %s to value: "
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
675 current-prefix-arg))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
676
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
677 (set var val)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
678 (cond ((string= comment "")
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
679 (put var 'variable-comment nil))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
680 (comment
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
681 (put var 'variable-comment comment))))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
682
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
683 ;;;###autoload
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
684 (defun customize-set-variable (var val &optional comment)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
685 "Set the default for VARIABLE to VALUE. VALUE is a Lisp object.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
686
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
687 If VARIABLE has a `custom-set' property, that is used for setting
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
688 VARIABLE, otherwise `set-default' is used.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
689
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
690 The `customized-value' property of the VARIABLE will be set to a list
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
691 with a quoted VALUE as its sole list member.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
692
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
693 If VARIABLE has a `variable-interactive' property, that is used as if
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
694 it were the arg to `interactive' (which see) to interactively read the value.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
695
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
696 If VARIABLE has a `custom-type' property, it must be a widget and the
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
697 `:prompt-value' property of that widget will be used for reading the value.
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
698
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
699 If given a prefix (or a COMMENT argument), also prompt for a comment."
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
700 (interactive (custom-prompt-variable "Set variable: "
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
701 "Set customized value for %s to: "
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
702 current-prefix-arg))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
703 (funcall (or (get var 'custom-set) 'set-default) var val)
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
704 (put var 'customized-value (list (custom-quote val)))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
705 (cond ((string= comment "")
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
706 (put var 'variable-comment nil)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
707 (put var 'customized-variable-comment nil))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
708 (comment
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
709 (put var 'variable-comment comment)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
710 (put var 'customized-variable-comment comment))))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
711
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
712
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
713 ;;;###autoload
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
714 (defun customize-save-variable (var val &optional comment)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
715 "Set the default for VARIABLE to VALUE, and save it for future sessions.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
716 If VARIABLE has a `custom-set' property, that is used for setting
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
717 VARIABLE, otherwise `set-default' is used.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
718
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
719 The `customized-value' property of the VARIABLE will be set to a list
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
720 with a quoted VALUE as its sole list member.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
721
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
722 If VARIABLE has a `variable-interactive' property, that is used as if
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
723 it were the arg to `interactive' (which see) to interactively read the value.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
724
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
725 If VARIABLE has a `custom-type' property, it must be a widget and the
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
726 `:prompt-value' property of that widget will be used for reading the value.
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
727
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
728 If given a prefix (or a COMMENT argument), also prompt for a comment."
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
729 (interactive (custom-prompt-variable "Set and ave variable: "
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
730 "Set and save value for %s as: "
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
731 current-prefix-arg))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
732 (funcall (or (get var 'custom-set) 'set-default) var val)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
733 (put var 'saved-value (list (custom-quote val)))
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
734 (custom-push-theme 'theme-value var 'user 'set (list (custom-quote val)))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
735 (cond ((string= comment "")
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
736 (put var 'variable-comment nil)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
737 (put var 'saved-variable-comment nil))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
738 (comment
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
739 (put var 'variable-comment comment)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
740 (put var 'saved-variable-comment comment)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
741 (custom-save-all))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
742
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
743 ;;;###autoload
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
744 (defun customize (group)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
745 "Select a customization buffer which you can use to set user options.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
746 User options are structured into \"groups\".
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
747 The default group is `Emacs'."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
748 (interactive (custom-group-prompt
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
749 "Customize group: (default emacs) "))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
750 (when (stringp group)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
751 (if (string-equal "" group)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
752 (setq group 'emacs)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
753 (setq group (intern group))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
754 (let ((name (format "*Customize Group: %s*"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
755 (custom-unlispify-tag-name group))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
756 (if (get-buffer name)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
757 (switch-to-buffer name)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
758 (custom-buffer-create (list (list group 'custom-group))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
759 name
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
760 (concat " for group "
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
761 (custom-unlispify-tag-name group))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
762
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
763 ;;;###autoload
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
764 (defalias 'customize-group 'customize)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
765
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
766 ;;;###autoload
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
767 (defun customize-other-window (symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
768 "Customize SYMBOL, which must be a customization group."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
769 (interactive (custom-group-prompt
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
770 "Customize group: (default emacs) "))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
771 (when (stringp symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
772 (if (string-equal "" symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
773 (setq symbol 'emacs)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
774 (setq symbol (intern symbol))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
775 (custom-buffer-create-other-window
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
776 (list (list symbol 'custom-group))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
777 (format "*Customize Group: %s*" (custom-unlispify-tag-name symbol))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
778
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
779 ;;;###autoload
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
780 (defalias 'customize-group-other-window 'customize-other-window)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
781
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
782 ;;;###autoload
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
783 (defalias 'customize-option 'customize-variable)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
784
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
785 ;;;###autoload
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
786 (defun customize-variable (symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
787 "Customize SYMBOL, which must be a user option variable."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
788 (interactive (custom-variable-prompt))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
789 (custom-buffer-create (list (list symbol 'custom-variable))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
790 (format "*Customize Variable: %s*"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
791 (custom-unlispify-tag-name symbol))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
792
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
793 ;;;###autoload
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
794 (defun customize-changed-options (since-version)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
795 "Customize all user option variables whose default values changed recently.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
796 This means, in other words, variables defined with a `:version' keyword."
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
797 (interactive "sCustomize options changed, since version (default all versions): ")
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
798 (if (equal since-version "")
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
799 (setq since-version nil))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
800 (let ((found nil))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
801 (mapatoms (lambda (symbol)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
802 (and (boundp symbol)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
803 (let ((version (get symbol 'custom-version)))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
804 (and version
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
805 (or (null since-version)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
806 (customize-version-lessp since-version version))))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
807 (push (list symbol 'custom-variable) found))))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
808 (unless found
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
809 (error "No user options have changed defaults %s"
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
810 (if since-version
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
811 (format "since XEmacs %s" since-version)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
812 "in recent Emacs versions")))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
813 (custom-buffer-create (custom-sort-items found t nil)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
814 "*Customize Changed Options*")))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
815
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
816 (defun customize-version-lessp (version1 version2)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
817 (let (major1 major2 minor1 minor2)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
818 (string-match "\\([0-9]+\\)[.]\\([0-9]+\\)" version1)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
819 (setq major1 (read (match-string 1 version1)))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
820 (setq minor1 (read (match-string 2 version1)))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
821 (string-match "\\([0-9]+\\)[.]\\([0-9]+\\)" version2)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
822 (setq major2 (read (match-string 1 version2)))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
823 (setq minor2 (read (match-string 2 version2)))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
824 (or (< major1 major2)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
825 (and (= major1 major2)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
826 (< minor1 minor2)))))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
827
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
828 ;;;###autoload
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
829 (defalias 'customize-variable-other-window 'customize-option-other-window)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
830
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
831 ;;;###autoload
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
832 (defun customize-option-other-window (symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
833 "Customize SYMBOL, which must be a user option variable.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
834 Show the buffer in another window, but don't select it."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
835 (interactive (custom-variable-prompt))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
836 (custom-buffer-create-other-window
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
837 (list (list symbol 'custom-variable))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
838 (format "*Customize Option: %s*" (custom-unlispify-tag-name symbol))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
839
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
840 ;;;###autoload
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
841 (defun customize-face (&optional symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
842 "Customize SYMBOL, which should be a face name or nil.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
843 If SYMBOL is nil, customize all faces."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
844 (interactive (list (completing-read "Customize face: (default all) "
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
845 obarray 'find-face)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
846 (if (or (null symbol) (and (stringp symbol) (zerop (length symbol))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
847 (custom-buffer-create (custom-sort-items
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
848 (mapcar (lambda (symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
849 (list symbol 'custom-face))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
850 (face-list))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
851 t nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
852 "*Customize Faces*")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
853 (when (stringp symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
854 (setq symbol (intern symbol)))
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
855 (check-argument-type 'symbolp symbol)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
856 (custom-buffer-create (list (list symbol 'custom-face))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
857 (format "*Customize Face: %s*"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
858 (custom-unlispify-tag-name symbol)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
859
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
860 ;;;###autoload
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
861 (defun customize-face-other-window (&optional symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
862 "Show customization buffer for FACE in other window."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
863 (interactive (list (completing-read "Customize face: "
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
864 obarray 'find-face)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
865 (if (or (null symbol) (and (stringp symbol) (zerop (length symbol))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
866 ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
867 (if (stringp symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
868 (setq symbol (intern symbol)))
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
869 (check-argument-type 'symbolp symbol)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
870 (custom-buffer-create-other-window
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
871 (list (list symbol 'custom-face))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
872 (format "*Customize Face: %s*" (custom-unlispify-tag-name symbol)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
873
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
874 ;;;###autoload
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
875 (defun customize-customized ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
876 "Customize all user options set since the last save in this session."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
877 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
878 (let ((found nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
879 (mapatoms (lambda (symbol)
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
880 (and (or (get symbol 'customized-face)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
881 (get symbol 'customized-face-comment))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
882 (find-face symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
883 (push (list symbol 'custom-face) found))
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
884 (and (or (get symbol 'customized-value)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
885 (get symbol 'customized-variable-comment))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
886 (boundp symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
887 (push (list symbol 'custom-variable) found))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
888 (if (not found)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
889 (error "No customized user options")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
890 (custom-buffer-create (custom-sort-items found t nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
891 "*Customize Customized*"))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
892
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
893 ;;;###autoload
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
894 (defun customize-saved ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
895 "Customize all already saved user options."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
896 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
897 (let ((found nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
898 (mapatoms (lambda (symbol)
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
899 (and (or (get symbol 'saved-face)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
900 (get symbol 'saved-face-comment))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
901 (find-face symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
902 (push (list symbol 'custom-face) found))
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
903 (and (or (get symbol 'saved-value)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
904 (get symbol 'saved-variable-comment))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
905 (boundp symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
906 (push (list symbol 'custom-variable) found))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
907 (if (not found )
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
908 (error "No saved user options")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
909 (custom-buffer-create (custom-sort-items found t nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
910 "*Customize Saved*"))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
911
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
912 ;;;###autoload
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
913 (defun customize-apropos (regexp &optional all)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
914 "Customize all user options matching REGEXP.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
915 If ALL is `options', include only options.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
916 If ALL is `faces', include only faces.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
917 If ALL is `groups', include only groups.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
918 If ALL is t (interactively, with prefix arg), include options which are not
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
919 user-settable, as well as faces and groups."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
920 (interactive "sCustomize regexp: \nP")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
921 (let ((found nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
922 (mapatoms (lambda (symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
923 (when (string-match regexp (symbol-name symbol))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
924 (when (and (not (memq all '(faces options)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
925 (get symbol 'custom-group))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
926 (push (list symbol 'custom-group) found))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
927 (when (and (not (memq all '(options groups)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
928 (find-face symbol))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
929 (push (list symbol 'custom-face) found))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
930 (when (and (not (memq all '(groups faces)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
931 (boundp symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
932 (or (get symbol 'saved-value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
933 (get symbol 'standard-value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
934 (if (memq all '(nil options))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
935 (user-variable-p symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
936 (get symbol 'variable-documentation))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
937 (push (list symbol 'custom-variable) found)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
938 (if (not found)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
939 (error "No matches")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
940 (custom-buffer-create (custom-sort-items found t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
941 custom-buffer-order-groups)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
942 "*Customize Apropos*"))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
943
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
944 ;;;###autoload
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
945 (defun customize-apropos-options (regexp &optional arg)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
946 "Customize all user options matching REGEXP.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
947 With prefix arg, include options which are not user-settable."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
948 (interactive "sCustomize regexp: \nP")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
949 (customize-apropos regexp (or arg 'options)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
950
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
951 ;;;###autoload
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
952 (defun customize-apropos-faces (regexp)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
953 "Customize all user faces matching REGEXP."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
954 (interactive "sCustomize regexp: \n")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
955 (customize-apropos regexp 'faces))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
956
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
957 ;;;###autoload
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
958 (defun customize-apropos-groups (regexp)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
959 "Customize all user groups matching REGEXP."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
960 (interactive "sCustomize regexp: \n")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
961 (customize-apropos regexp 'groups))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
962
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
963
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
964 ;;; Buffer.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
965
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
966 (defcustom custom-buffer-style 'links
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
967 "*Control the presentation style for customization buffers.
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
968 The value should be a symbol, one of:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
969
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
970 brackets: groups nest within each other with big horizontal brackets.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
971 links: groups have links to subgroups."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
972 :type '(radio (const :tag "brackets: Groups nest within each others" brackets)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
973 (const :tag "links: Group have links to subgroups" links))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
974 :group 'custom-buffer)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
975
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
976 (defcustom custom-buffer-done-function 'kill-buffer
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
977 "*Function to be used to remove the buffer when the user is done with it.
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
978 Choices include `kill-buffer' (the default) and `bury-buffer'.
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
979 The function will be called with one argument, the buffer to remove."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
980 :type '(radio (function-item kill-buffer)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
981 (function-item bury-buffer)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
982 (function :tag "Other" nil))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
983 :group 'custom-buffer)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
984
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
985 (defcustom custom-buffer-indent 3
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
986 "Number of spaces to indent nested groups."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
987 :type 'integer
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
988 :group 'custom-buffer)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
989
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
990 ;;;###autoload
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
991 (defun custom-buffer-create (options &optional name description)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
992 "Create a buffer containing OPTIONS.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
993 Optional NAME is the name of the buffer.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
994 OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
995 SYMBOL is a customization option, and WIDGET is a widget for editing
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
996 that option."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
997 (unless name (setq name "*Customization*"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
998 (kill-buffer (get-buffer-create name))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
999 (switch-to-buffer (get-buffer-create name))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1000 (custom-buffer-create-internal options description))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1001
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1002 ;;;###autoload
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1003 (defun custom-buffer-create-other-window (options &optional name description)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1004 "Create a buffer containing OPTIONS.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1005 Optional NAME is the name of the buffer.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1006 OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1007 SYMBOL is a customization option, and WIDGET is a widget for editing
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1008 that option."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1009 (unless name (setq name "*Customization*"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1010 (kill-buffer (get-buffer-create name))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1011 (let ((window (selected-window)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1012 (switch-to-buffer-other-window (get-buffer-create name))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1013 (custom-buffer-create-internal options description)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1014 (select-window window)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1015
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1016 (defcustom custom-reset-button-menu t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1017 "If non-nil, only show a single reset button in customize buffers.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1018 This button will have a menu with all three reset operations."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1019 :type 'boolean
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1020 :group 'custom-buffer)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1021
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1022 (defconst custom-skip-messages 5)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1023
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
1024 (defun Custom-buffer-done ()
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
1025 "Remove current buffer.
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
1026 This works by calling the function specified by
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
1027 `custom-buffer-done-function'."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
1028 (interactive)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
1029 (funcall custom-buffer-done-function (current-buffer)))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
1030
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1031 (defun custom-buffer-create-buttons ()
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1032 (message "Creating customization buttons...")
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1033 (widget-insert "\nOperate on everything in this buffer:\n ")
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1034 (widget-create 'push-button
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1035 :tag "Set"
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
1036 :tag-glyph '("set-up" "set-down")
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1037 :help-echo "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1038 Make your editing in this buffer take effect for this session"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1039 :action (lambda (widget &optional event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1040 (Custom-set)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1041 (widget-insert " ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1042 (widget-create 'push-button
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1043 :tag "Save"
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
1044 :tag-glyph '("save-up" "save-down")
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1045 :help-echo "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1046 Make your editing in this buffer take effect for future Emacs sessions"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1047 :action (lambda (widget &optional event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1048 (Custom-save)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1049 (if custom-reset-button-menu
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1050 (progn
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1051 (widget-insert " ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1052 (widget-create 'push-button
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1053 :tag "Reset"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1054 :tag-glyph '("reset-up" "reset-down")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1055 :help-echo "Show a menu with reset operations"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1056 :mouse-down-action (lambda (&rest junk) t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1057 :action (lambda (widget &optional event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1058 (custom-reset event))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1059 (widget-insert " ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1060 (widget-create 'push-button
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1061 :tag "Reset"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1062 :help-echo "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1063 Reset all edited text in this buffer to reflect current values"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1064 :action 'Custom-reset-current)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1065 (widget-insert " ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1066 (widget-create 'push-button
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1067 :tag "Reset to Saved"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1068 :help-echo "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1069 Reset all values in this buffer to their saved settings"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1070 :action 'Custom-reset-saved)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1071 (widget-insert " ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1072 (widget-create 'push-button
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1073 :tag "Reset to Standard"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1074 :help-echo "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1075 Reset all values in this buffer to their standard settings"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1076 :action 'Custom-reset-standard))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1077 (widget-insert " ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1078 (widget-create 'push-button
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1079 :tag "Done"
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
1080 :tag-glyph '("done-up" "done-down")
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
1081 :help-echo "Remove the buffer"
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1082 :action (lambda (widget &optional event)
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
1083 (Custom-buffer-done)))
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1084 (widget-insert "\n"))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1085
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1086 (defcustom custom-novice t
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1087 "If non-nil, show help message at top of customize buffers."
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1088 :type 'boolean
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1089 :group 'custom-buffer)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1090
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1091 (defcustom custom-display-global-buttons 'top
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1092 "If `nil' don't display the global buttons. If `top' display at the
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1093 beginning of custom buffers. If `bottom', display at the end."
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1094 :type '(choice (const top)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1095 (const bottom)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1096 (const :tag "don't" nil))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1097 :group 'custom-buffer)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1098
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1099 (defun custom-buffer-create-internal (options &optional description)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1100 (message "Creating customization buffer...")
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1101 (custom-mode)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1102 (widget-insert "This is a customization buffer")
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1103 (if description
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1104 (widget-insert description))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1105 (when custom-novice
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1106 (widget-insert ".\n\
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1107 Type RET or click button2 on an active field to invoke its action.
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1108 Invoke ")
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1109 (widget-create 'info-link
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1110 :tag "Help"
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1111 :help-echo "Read the online help"
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1112 "(XEmacs)Easy Customization")
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1113 (widget-insert " for more information."))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1114 (widget-insert "\n")
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1115 (if (equal custom-display-global-buttons 'top)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1116 (custom-buffer-create-buttons))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1117 (widget-insert "\n")
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1118 (message "Creating customization items...")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1119 (setq custom-options
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1120 (if (= (length options) 1)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1121 (mapcar (lambda (entry)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1122 (widget-create (nth 1 entry)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1123 :documentation-shown t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1124 :custom-state 'unknown
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1125 :tag (custom-unlispify-tag-name
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1126 (nth 0 entry))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1127 :value (nth 0 entry)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1128 options)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1129 (let ((count 0)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1130 (length (length options)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1131 (mapcar (lambda (entry)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1132 (prog2
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1133 (display-message
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1134 'progress
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1135 (format "Creating customization items %2d%%..."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1136 (/ (* 100.0 count) length)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1137 (widget-create (nth 1 entry)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1138 :tag (custom-unlispify-tag-name
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1139 (nth 0 entry))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1140 :value (nth 0 entry))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1141 (incf count)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1142 (unless (eq (preceding-char) ?\n)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1143 (widget-insert "\n"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1144 (widget-insert "\n")))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1145 options))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1146 (unless (eq (preceding-char) ?\n)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1147 (widget-insert "\n"))
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1148 (if (equal custom-display-global-buttons 'bottom)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1149 (custom-buffer-create-buttons))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1150 (display-message 'progress
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1151 (format
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1152 "Creating customization items %2d%%...done" 100))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1153 (unless (eq custom-buffer-style 'tree)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1154 (mapc 'custom-magic-reset custom-options))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1155 (message "Creating customization setup...")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1156 (widget-setup)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1157 (goto-char (point-min))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1158 (message "Creating customization buffer...done"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1159
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1160
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1161 ;;; The Tree Browser.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1162
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1163 ;;;###autoload
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1164 (defun customize-browse (&optional group)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1165 "Create a tree browser for the customize hierarchy."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1166 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1167 (unless group
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1168 (setq group 'emacs))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1169 (let ((name "*Customize Browser*"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1170 (kill-buffer (get-buffer-create name))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1171 (switch-to-buffer (get-buffer-create name)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1172 (custom-mode)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1173 (widget-insert "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1174 Square brackets show active fields; type RET or click button2
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1175 on an active field to invoke its action.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1176 Invoke [+] below to expand a group, and [-] to collapse an expanded group.\n")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1177 (if custom-browse-only-groups
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1178 (widget-insert "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1179 Invoke the [Group] button below to edit that item in another window.\n\n")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1180 (widget-insert "Invoke the ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1181 (widget-create 'item
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1182 :format "%t"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1183 :tag "[Group]"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1184 :tag-glyph "folder")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1185 (widget-insert ", ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1186 (widget-create 'item
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1187 :format "%t"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1188 :tag "[Face]"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1189 :tag-glyph "face")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1190 (widget-insert ", and ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1191 (widget-create 'item
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1192 :format "%t"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1193 :tag "[Option]"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1194 :tag-glyph "option")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1195 (widget-insert " buttons below to edit that
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1196 item in another window.\n\n"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1197 (let ((custom-buffer-style 'tree))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1198 (widget-create 'custom-group
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1199 :custom-last t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1200 :custom-state 'unknown
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1201 :tag (custom-unlispify-tag-name group)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1202 :value group))
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
1203 (widget-add-change)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1204 (goto-char (point-min)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1205
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1206 (define-widget 'custom-browse-visibility 'item
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1207 "Control visibility of of items in the customize tree browser."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1208 :format "%[[%t]%]"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1209 :action 'custom-browse-visibility-action)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1210
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1211 (defun custom-browse-visibility-action (widget &rest ignore)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1212 (let ((custom-buffer-style 'tree))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1213 (custom-toggle-parent widget)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1214
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1215 (define-widget 'custom-browse-group-tag 'push-button
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1216 "Show parent in other window when activated."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1217 :tag "Group"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1218 :tag-glyph "folder"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1219 :action 'custom-browse-group-tag-action)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1220
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1221 (defun custom-browse-group-tag-action (widget &rest ignore)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1222 (let ((parent (widget-get widget :parent)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1223 (customize-group-other-window (widget-value parent))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1224
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1225 (define-widget 'custom-browse-variable-tag 'push-button
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1226 "Show parent in other window when activated."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1227 :tag "Option"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1228 :tag-glyph "option"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1229 :action 'custom-browse-variable-tag-action)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1230
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1231 (defun custom-browse-variable-tag-action (widget &rest ignore)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1232 (let ((parent (widget-get widget :parent)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1233 (customize-variable-other-window (widget-value parent))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1234
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1235 (define-widget 'custom-browse-face-tag 'push-button
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1236 "Show parent in other window when activated."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1237 :tag "Face"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1238 :tag-glyph "face"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1239 :action 'custom-browse-face-tag-action)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1240
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1241 (defun custom-browse-face-tag-action (widget &rest ignore)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1242 (let ((parent (widget-get widget :parent)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1243 (customize-face-other-window (widget-value parent))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1244
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1245 (defconst custom-browse-alist '((" " "space")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1246 (" | " "vertical")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1247 ("-\\ " "top")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1248 (" |-" "middle")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1249 (" `-" "bottom")))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1250
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1251 (defun custom-browse-insert-prefix (prefix)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1252 "Insert PREFIX. On XEmacs convert it to line graphics."
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
1253 ;; ### Unfinished.
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1254 (if nil ; (string-match "XEmacs" emacs-version)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1255 (progn
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1256 (insert "*")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1257 (while (not (string-equal prefix ""))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1258 (let ((entry (substring prefix 0 3)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1259 (setq prefix (substring prefix 3))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1260 (let ((overlay (make-overlay (1- (point)) (point) nil t nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1261 (name (nth 1 (assoc entry custom-browse-alist))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1262 (overlay-put overlay 'end-glyph (widget-glyph-find name entry))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1263 (overlay-put overlay 'start-open t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1264 (overlay-put overlay 'end-open t)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1265 (insert prefix)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1266
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1267
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1268 ;;; Modification of Basic Widgets.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1269 ;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1270 ;; We add extra properties to the basic widgets needed here. This is
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1271 ;; fine, as long as we are careful to stay within out own namespace.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1272 ;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1273 ;; We want simple widgets to be displayed by default, but complex
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1274 ;; widgets to be hidden.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1275
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1276 (widget-put (get 'item 'widget-type) :custom-show t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1277 (widget-put (get 'editable-field 'widget-type)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1278 :custom-show (lambda (widget value)
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
1279 ;; This used to call pp-to-string
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
1280 (let ((pp (widget-prettyprint-to-string value)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1281 (cond ((string-match "\n" pp)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1282 nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1283 ((> (length pp) 40)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1284 nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1285 (t t)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1286 (widget-put (get 'menu-choice 'widget-type) :custom-show t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1287
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1288 ;;; The `custom-manual' Widget.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1289
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1290 (define-widget 'custom-manual 'info-link
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1291 "Link to the manual entry for this customization option."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1292 :tag "Manual")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1293
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1294 ;;; The `custom-magic' Widget.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1295
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1296 (defgroup custom-magic-faces nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1297 "Faces used by the magic button."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1298 :group 'custom-faces
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1299 :group 'custom-buffer)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1300
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1301 (defface custom-invalid-face '((((class color))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1302 (:foreground "yellow" :background "red"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1303 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1304 (:bold t :italic t :underline t)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1305 "Face used when the customize item is invalid."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1306 :group 'custom-magic-faces)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1307
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1308 (defface custom-rogue-face '((((class color))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1309 (:foreground "pink" :background "black"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1310 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1311 (:underline t)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1312 "Face used when the customize item is not defined for customization."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1313 :group 'custom-magic-faces)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1314
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1315 (defface custom-modified-face '((((class color))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1316 (:foreground "white" :background "blue"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1317 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1318 (:italic t :bold)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1319 "Face used when the customize item has been modified."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1320 :group 'custom-magic-faces)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1321
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1322 (defface custom-set-face '((((class color))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1323 (:foreground "blue" :background "white"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1324 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1325 (:italic t)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1326 "Face used when the customize item has been set."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1327 :group 'custom-magic-faces)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1328
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1329 (defface custom-changed-face '((((class color))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1330 (:foreground "white" :background "blue"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1331 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1332 (:italic t)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1333 "Face used when the customize item has been changed."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1334 :group 'custom-magic-faces)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1335
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1336 (defface custom-saved-face '((t (:underline t)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1337 "Face used when the customize item has been saved."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1338 :group 'custom-magic-faces)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1339
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1340 (defconst custom-magic-alist '((nil "#" underline "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1341 uninitialized, you should not see this.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1342 (unknown "?" italic "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1343 unknown, you should not see this.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1344 (hidden "-" default "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1345 hidden, invoke \"Show\" button in the previous line to show." "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1346 group now hidden, invoke the above \"Show\" button to show contents.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1347 (invalid "x" custom-invalid-face "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1348 the value displayed for this %c is invalid and cannot be set.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1349 (modified "*" custom-modified-face "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1350 you have edited the value as text, but you have not set the %c." "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1351 you have edited something in this group, but not set it.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1352 (set "+" custom-set-face "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1353 you have set this %c, but not saved it for future sessions." "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1354 something in this group has been set, but not saved.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1355 (changed ":" custom-changed-face "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1356 this %c has been changed outside the customize buffer." "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1357 something in this group has been changed outside customize.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1358 (saved "!" custom-saved-face "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1359 this %c has been set and saved." "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1360 something in this group has been set and saved.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1361 (rogue "@" custom-rogue-face "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1362 this %c has not been changed with customize." "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1363 something in this group is not prepared for customization.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1364 (standard " " nil "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1365 this %c is unchanged from its standard setting." "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1366 visible group members are all at standard settings."))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1367 "Alist of customize option states.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1368 Each entry is of the form (STATE MAGIC FACE ITEM-DESC [ GROUP-DESC ]), where
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1369
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1370 STATE is one of the following symbols:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1371
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1372 `nil'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1373 For internal use, should never occur.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1374 `unknown'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1375 For internal use, should never occur.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1376 `hidden'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1377 This item is not being displayed.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1378 `invalid'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1379 This item is modified, but has an invalid form.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1380 `modified'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1381 This item is modified, and has a valid form.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1382 `set'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1383 This item has been set but not saved.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1384 `changed'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1385 The current value of this item has been changed temporarily.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1386 `saved'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1387 This item is marked for saving.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1388 `rogue'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1389 This item has no customization information.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1390 `standard'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1391 This item is unchanged from the standard setting.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1392
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1393 MAGIC is a string used to present that state.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1394
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1395 FACE is a face used to present the state.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1396
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1397 ITEM-DESC is a string describing the state for options.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1398
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1399 GROUP-DESC is a string describing the state for groups. If this is
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1400 left out, ITEM-DESC will be used.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1401
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1402 The string %c in either description will be replaced with the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1403 category of the item. These are `group'. `option', and `face'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1404
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1405 The list should be sorted most significant first.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1406
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1407 (defcustom custom-magic-show 'long
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1408 "If non-nil, show textual description of the state.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1409 If `long', show a full-line description, not just one word."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1410 :type '(choice (const :tag "no" nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1411 (const short)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1412 (const long))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1413 :group 'custom-buffer)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1414
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1415 (defcustom custom-magic-show-hidden '(option face)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1416 "Control whether the State button is shown for hidden items.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1417 The value should be a list with the custom categories where the State
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1418 button should be visible. Possible categories are `group', `option',
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1419 and `face'."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1420 :type '(set (const group) (const option) (const face))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1421 :group 'custom-buffer)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1422
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1423 (defcustom custom-magic-show-button nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1424 "Show a \"magic\" button indicating the state of each customization option."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1425 :type 'boolean
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1426 :group 'custom-buffer)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1427
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1428 (define-widget 'custom-magic 'default
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1429 "Show and manipulate state for a customization option."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1430 :format "%v"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1431 :action 'widget-parent-action
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1432 :notify 'ignore
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1433 :value-get 'ignore
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1434 :value-create 'custom-magic-value-create
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1435 :value-delete 'widget-children-value-delete)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1436
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1437 (defun widget-magic-mouse-down-action (widget &optional event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1438 ;; Non-nil unless hidden.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1439 (not (eq (widget-get (widget-get (widget-get widget :parent) :parent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1440 :custom-state)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1441 'hidden)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1442
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1443 (defun custom-magic-value-create (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1444 ;; Create compact status report for WIDGET.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1445 (let* ((parent (widget-get widget :parent))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1446 (state (widget-get parent :custom-state))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1447 (hidden (eq state 'hidden))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1448 (entry (assq state custom-magic-alist))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1449 (magic (nth 1 entry))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1450 (face (nth 2 entry))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1451 (category (widget-get parent :custom-category))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1452 (text (or (and (eq category 'group)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1453 (nth 4 entry))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1454 (nth 3 entry)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1455 (form (widget-get parent :custom-form))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1456 children)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1457 (while (string-match "\\`\\(.*\\)%c\\(.*\\)\\'" text)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1458 (setq text (concat (match-string 1 text)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1459 (symbol-name category)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1460 (match-string 2 text))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1461 (when (and custom-magic-show
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1462 (or (not hidden)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1463 (memq category custom-magic-show-hidden)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1464 (insert " ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1465 (when (and (eq category 'group)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1466 (not (and (eq custom-buffer-style 'links)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1467 (> (widget-get parent :custom-level) 1))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1468 (insert-char ?\ (* custom-buffer-indent
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1469 (widget-get parent :custom-level))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1470 (push (widget-create-child-and-convert
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1471 widget 'choice-item
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1472 :help-echo "Change the state of this item"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1473 :format (if hidden "%t" "%[%t%]")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1474 :button-prefix 'widget-push-button-prefix
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1475 :button-suffix 'widget-push-button-suffix
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1476 :mouse-down-action 'widget-magic-mouse-down-action
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1477 :tag "State"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1478 ;;:tag-glyph (or hidden '("state-up" "state-down"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1479 )
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1480 children)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1481 (insert ": ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1482 (let ((start (point)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1483 (if (eq custom-magic-show 'long)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1484 (insert text)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1485 (insert (symbol-name state)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1486 (cond ((eq form 'lisp)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1487 (insert " (lisp)"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1488 ((eq form 'mismatch)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1489 (insert " (mismatch)")))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1490 (put-text-property start (point) 'face 'custom-state-face))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1491 (insert "\n"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1492 (when (and (eq category 'group)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1493 (not (and (eq custom-buffer-style 'links)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1494 (> (widget-get parent :custom-level) 1))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1495 (insert-char ?\ (* custom-buffer-indent
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1496 (widget-get parent :custom-level))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1497 (when custom-magic-show-button
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1498 (when custom-magic-show
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1499 (let ((indent (widget-get parent :indent)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1500 (when indent
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1501 (insert-char ?\ indent))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1502 (push (widget-create-child-and-convert
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1503 widget 'choice-item
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1504 :mouse-down-action 'widget-magic-mouse-down-action
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1505 :button-face face
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1506 :button-prefix ""
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1507 :button-suffix ""
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1508 :help-echo "Change the state"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1509 :format (if hidden "%t" "%[%t%]")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1510 :tag (if (memq form '(lisp mismatch))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1511 (concat "(" magic ")")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1512 (concat "[" magic "]")))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1513 children)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1514 (insert " "))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1515 (widget-put widget :children children)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1516
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1517 (defun custom-magic-reset (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1518 "Redraw the :custom-magic property of WIDGET."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1519 (let ((magic (widget-get widget :custom-magic)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1520 (widget-value-set magic (widget-value magic))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1521
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1522 ;;; The `custom' Widget.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1523
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1524 (defface custom-button-face '((t (:bold t)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1525 "Face used for buttons in customization buffers."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1526 :group 'custom-faces)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1527
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1528 (defface custom-documentation-face nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1529 "Face used for documentation strings in customization buffers."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1530 :group 'custom-faces)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1531
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1532 (defface custom-state-face '((((class color)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1533 (background dark))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1534 (:foreground "lime green"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1535 (((class color)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1536 (background light))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1537 (:foreground "dark green"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1538 (t nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1539 "Face used for State descriptions in the customize buffer."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1540 :group 'custom-faces)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1541
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1542 (define-widget 'custom 'default
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1543 "Customize a user option."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1544 :format "%v"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1545 :convert-widget 'custom-convert-widget
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1546 :notify 'custom-notify
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1547 :custom-prefix ""
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1548 :custom-level 1
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1549 :custom-state 'hidden
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1550 :documentation-property 'widget-subclass-responsibility
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1551 :value-create 'widget-subclass-responsibility
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1552 :value-delete 'widget-children-value-delete
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1553 :value-get 'widget-value-value-get
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1554 :validate 'widget-children-validate
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1555 :match (lambda (widget value) (symbolp value)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1556
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1557 (defun custom-convert-widget (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1558 ;; Initialize :value and :tag from :args in WIDGET.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1559 (let ((args (widget-get widget :args)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1560 (when args
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1561 (widget-put widget :value (widget-apply widget
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1562 :value-to-internal (car args)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1563 (widget-put widget :tag (custom-unlispify-tag-name (car args)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1564 (widget-put widget :args nil)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1565 widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1566
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1567 (defun custom-notify (widget &rest args)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1568 "Keep track of changes."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1569 (let ((state (widget-get widget :custom-state)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1570 (unless (eq state 'modified)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1571 (unless (memq state '(nil unknown hidden))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1572 (widget-put widget :custom-state 'modified))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1573 (custom-magic-reset widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1574 (apply 'widget-default-notify widget args))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1575
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1576 (defun custom-redraw (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1577 "Redraw WIDGET with current settings."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1578 (let ((line (count-lines (point-min) (point)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1579 (column (current-column))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1580 (pos (point))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1581 (from (marker-position (widget-get widget :from)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1582 (to (marker-position (widget-get widget :to))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1583 (save-excursion
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1584 (widget-value-set widget (widget-value widget))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1585 (custom-redraw-magic widget))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1586 (when (and (>= pos from) (<= pos to))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1587 (condition-case nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1588 (progn
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1589 (if (> column 0)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1590 (goto-line line)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1591 (goto-line (1+ line)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1592 (move-to-column column))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1593 (error nil)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1594
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1595 (defun custom-redraw-magic (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1596 "Redraw WIDGET state with current settings."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1597 (while widget
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1598 (let ((magic (widget-get widget :custom-magic)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1599 (cond (magic
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1600 (widget-value-set magic (widget-value magic))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1601 (when (setq widget (widget-get widget :group))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1602 (custom-group-state-update widget)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1603 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1604 (setq widget nil)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1605 (widget-setup))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1606
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1607 (defun custom-show (widget value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1608 "Non-nil if WIDGET should be shown with VALUE by default."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1609 (let ((show (widget-get widget :custom-show)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1610 (cond ((null show)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1611 nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1612 ((eq t show)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1613 t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1614 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1615 (funcall show widget value)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1616
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1617 (defvar custom-load-recursion nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1618 "Hack to avoid recursive dependencies.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1619
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1620 (defun custom-load-symbol (symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1621 "Load all dependencies for SYMBOL."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1622 (unless custom-load-recursion
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1623 (let ((custom-load-recursion t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1624 (loads (get symbol 'custom-loads))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1625 load)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1626 (while loads
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1627 (setq load (car loads)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1628 loads (cdr loads))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1629 (cond ((symbolp load)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1630 (condition-case nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1631 (require load)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1632 (error nil)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1633 ;; Don't reload a file already loaded.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1634 ((and (boundp 'preloaded-file-list)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1635 (member load preloaded-file-list)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1636 ((assoc load load-history))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1637 ((assoc (locate-library load) load-history))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1638 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1639 (condition-case nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1640 ;; Without this, we would load cus-edit recursively.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1641 ;; We are still loading it when we call this,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1642 ;; and it is not in load-history yet.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1643 (or (equal load "cus-edit")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1644 (load-library load))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1645 (error nil))))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1646
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1647 (defun custom-load-widget (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1648 "Load all dependencies for WIDGET."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1649 (custom-load-symbol (widget-value widget)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1650
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1651 (defun custom-unloaded-symbol-p (symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1652 "Return non-nil if the dependencies of SYMBOL has not yet been loaded."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1653 (let ((found nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1654 (loads (get symbol 'custom-loads))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1655 load)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1656 (while loads
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1657 (setq load (car loads)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1658 loads (cdr loads))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1659 (cond ((symbolp load)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1660 (unless (featurep load)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1661 (setq found t)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1662 ((assoc load load-history))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1663 ((assoc (locate-library load) load-history)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1664 ;; #### WTF???
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1665 (message nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1666 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1667 (setq found t))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1668 found))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1669
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1670 (defun custom-unloaded-widget-p (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1671 "Return non-nil if the dependencies of WIDGET has not yet been loaded."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1672 (custom-unloaded-symbol-p (widget-value widget)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1673
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1674 (defun custom-toggle-hide (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1675 "Toggle visibility of WIDGET."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1676 (custom-load-widget widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1677 (let ((state (widget-get widget :custom-state)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1678 (cond ((memq state '(invalid modified))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1679 (error "There are unset changes"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1680 ((eq state 'hidden)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1681 (widget-put widget :custom-state 'unknown))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1682 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1683 (widget-put widget :documentation-shown nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1684 (widget-put widget :custom-state 'hidden)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1685 (custom-redraw widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1686 (widget-setup)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1687
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1688 (defun custom-toggle-parent (widget &rest ignore)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1689 "Toggle visibility of parent of WIDGET."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1690 (custom-toggle-hide (widget-get widget :parent)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1691
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1692 (defun custom-add-see-also (widget &optional prefix)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1693 "Add `See also ...' to WIDGET if there are any links.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1694 Insert PREFIX first if non-nil."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1695 (let* ((symbol (widget-get widget :value))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1696 (links (get symbol 'custom-links))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1697 (many (> (length links) 2))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1698 (buttons (widget-get widget :buttons))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1699 (indent (widget-get widget :indent)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1700 (when links
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1701 (when indent
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1702 (insert-char ?\ indent))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1703 (when prefix
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1704 (insert prefix))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1705 (insert "See also ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1706 (while links
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1707 (push (widget-create-child-and-convert widget (car links))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1708 buttons)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1709 (setq links (cdr links))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1710 (cond ((null links)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1711 (insert ".\n"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1712 ((null (cdr links))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1713 (if many
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1714 (insert ", and ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1715 (insert " and ")))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1716 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1717 (insert ", "))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1718 (widget-put widget :buttons buttons))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1719
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1720 (defun custom-add-parent-links (widget &optional initial-string)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1721 "Add \"Parent groups: ...\" to WIDGET if the group has parents.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1722 The value if non-nil if any parents were found.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1723 If INITIAL-STRING is non-nil, use that rather than \"Parent groups:\"."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1724 (let ((name (widget-value widget))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1725 (type (widget-type widget))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1726 (buttons (widget-get widget :buttons))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1727 (start (point))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1728 found)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1729 (insert (or initial-string "Parent groups:"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1730 (maphash (lambda (group ignore)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1731 (let ((entry (assq name (get group 'custom-group))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1732 (when (eq (nth 1 entry) type)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1733 (insert " ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1734 (push (widget-create-child-and-convert
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1735 widget 'custom-group-link
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1736 :tag (custom-unlispify-tag-name group)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1737 group)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1738 buttons)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1739 (setq found t))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1740 custom-group-hash-table)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1741 (widget-put widget :buttons buttons)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1742 (if found
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1743 (insert "\n")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1744 (delete-region start (point)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1745 found))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1746
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1747 ;;; The `custom-comment' Widget.
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1748
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1749 ;; like the editable field
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1750 (defface custom-comment-face '((((class grayscale color)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1751 (background light))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1752 (:background "gray85"))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1753 (((class grayscale color)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1754 (background dark))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1755 (:background "dim gray"))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1756 (t
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1757 (:italic t)))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1758 "Face used for comments on variables or faces"
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1759 :group 'custom-faces)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1760
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1761 ;; like font-lock-comment-face
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1762 (defface custom-comment-tag-face
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1763 '((((class color) (background dark)) (:foreground "gray80"))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1764 (((class color) (background light)) (:foreground "blue4"))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1765 (((class grayscale) (background light))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1766 (:foreground "DimGray" :bold t :italic t))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1767 (((class grayscale) (background dark))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1768 (:foreground "LightGray" :bold t :italic t))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1769 (t (:bold t)))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1770 "Face used for variables or faces comment tags"
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1771 :group 'custom-faces)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1772
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1773 (define-widget 'custom-comment 'string
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1774 "User comment"
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1775 :tag "Comment"
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1776 :help-echo "Edit a comment here"
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1777 :sample-face 'custom-comment-tag-face
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1778 :value-face 'custom-comment-face
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1779 :value-set 'custom-comment-value-set
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1780 :create 'custom-comment-create
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1781 :delete 'custom-comment-delete)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1782
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1783 (defun custom-comment-create (widget)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1784 (let (ext)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1785 (widget-default-create widget)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1786 (widget-put widget :comment-extent
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1787 (setq ext (make-extent (widget-get widget :from)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1788 (widget-get widget :to))))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1789 (set-extent-property ext 'start-open t)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1790 (when (equal (widget-get widget :value) "")
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1791 (set-extent-property ext 'invisible t))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1792 ))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1793
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1794 (defun custom-comment-delete (widget)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1795 (widget-default-delete widget)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1796 (delete-extent (widget-get widget :comment-extent)))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1797
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1798 (defun custom-comment-value-set (widget value)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1799 (widget-default-value-set widget value)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1800 (if (equal value "")
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1801 (set-extent-property (widget-get widget :comment-extent)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1802 'invisible t)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1803 (set-extent-property (widget-get widget :comment-extent)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1804 'invisible nil)))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1805
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1806 ;; Those functions are for the menu. WIDGET is NOT the comment widget. It's
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1807 ;; the global custom one
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1808 (defun custom-comment-show (widget)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1809 (set-extent-property
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1810 (widget-get (widget-get widget :comment-widget) :comment-extent)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1811 'invisible nil))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1812
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1813 (defun custom-comment-invisible-p (widget)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1814 (extent-property
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1815 (widget-get (widget-get widget :comment-widget) :comment-extent)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1816 'invisible))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1817
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1818 ;;; The `custom-variable' Widget.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1819
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1820 (defface custom-variable-tag-face '((((class color)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1821 (background dark))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1822 (:foreground "light blue" :underline t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1823 (((class color)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1824 (background light))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1825 (:foreground "blue" :underline t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1826 (t (:underline t)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1827 "Face used for unpushable variable tags."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1828 :group 'custom-faces)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1829
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1830 (defface custom-variable-button-face '((t (:underline t :bold t)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1831 "Face used for pushable variable tags."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1832 :group 'custom-faces)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1833
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
1834 (defcustom custom-variable-default-form 'edit
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
1835 "Default form of displaying variable values."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
1836 :type '(choice (const edit)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
1837 (const lisp))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
1838 :group 'custom-buffer)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
1839
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1840 (define-widget 'custom-variable 'custom
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1841 "Customize variable."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1842 :format "%v"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1843 :help-echo "Set or reset this variable"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1844 :documentation-property 'variable-documentation
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1845 :custom-category 'option
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1846 :custom-state nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1847 :custom-menu 'custom-variable-menu-create
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
1848 :custom-form nil ; defaults to value of `custom-variable-default-form'
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1849 :value-create 'custom-variable-value-create
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1850 :action 'custom-variable-action
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1851 :custom-set 'custom-variable-set
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1852 :custom-save 'custom-variable-save
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1853 :custom-reset-current 'custom-redraw
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1854 :custom-reset-saved 'custom-variable-reset-saved
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1855 :custom-reset-standard 'custom-variable-reset-standard)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1856
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1857 (defun custom-variable-type (symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1858 "Return a widget suitable for editing the value of SYMBOL.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1859 If SYMBOL has a `custom-type' property, use that.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1860 Otherwise, look up symbol in `custom-guess-type-alist'."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1861 (let* ((type (or (get symbol 'custom-type)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1862 (and (not (get symbol 'standard-value))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1863 (custom-guess-type symbol))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1864 'sexp))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1865 (options (get symbol 'custom-options))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1866 (tmp (if (listp type)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1867 (copy-sequence type)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1868 (list type))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1869 (when options
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1870 (widget-put tmp :options options))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1871 tmp))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1872
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1873 (defun custom-variable-value-create (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1874 "Here is where you edit the variables value."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1875 (custom-load-widget widget)
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
1876 (unless (widget-get widget :custom-form)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
1877 (widget-put widget :custom-form custom-variable-default-form))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1878 (let* ((buttons (widget-get widget :buttons))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1879 (children (widget-get widget :children))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1880 (form (widget-get widget :custom-form))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1881 (state (widget-get widget :custom-state))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1882 (symbol (widget-get widget :value))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1883 (tag (widget-get widget :tag))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1884 (type (custom-variable-type symbol))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1885 (conv (widget-convert type))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1886 (get (or (get symbol 'custom-get) 'default-value))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1887 (prefix (widget-get widget :custom-prefix))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1888 (last (widget-get widget :custom-last))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1889 (value (if (default-boundp symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1890 (funcall get symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1891 (widget-get conv :value))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1892 ;; If the widget is new, the child determine whether it is hidden.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1893 (cond (state)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1894 ((custom-show type value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1895 (setq state 'unknown))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1896 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1897 (setq state 'hidden)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1898 ;; If we don't know the state, see if we need to edit it in lisp form.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1899 (when (eq state 'unknown)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1900 (unless (widget-apply conv :match value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1901 ;; (widget-apply (widget-convert type) :match value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1902 (setq form 'mismatch)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1903 ;; Now we can create the child widget.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1904 (cond ((eq custom-buffer-style 'tree)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1905 (insert prefix (if last " `--- " " |--- "))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1906 (push (widget-create-child-and-convert
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1907 widget 'custom-browse-variable-tag)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1908 buttons)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1909 (insert " " tag "\n")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1910 (widget-put widget :buttons buttons))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1911 ((eq state 'hidden)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1912 ;; Indicate hidden value.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1913 (push (widget-create-child-and-convert
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1914 widget 'item
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1915 :format "%{%t%}: "
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1916 :sample-face 'custom-variable-tag-face
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1917 :tag tag
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1918 :parent widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1919 buttons)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1920 (push (widget-create-child-and-convert
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1921 widget 'visibility
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1922 :help-echo "Show the value of this option"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1923 :action 'custom-toggle-parent
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1924 nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1925 buttons))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1926 ((memq form '(lisp mismatch))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1927 ;; In lisp mode edit the saved value when possible.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1928 (let* ((value (cond ((get symbol 'saved-value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1929 (car (get symbol 'saved-value)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1930 ((get symbol 'standard-value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1931 (car (get symbol 'standard-value)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1932 ((default-boundp symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1933 (custom-quote (funcall get symbol)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1934 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1935 (custom-quote (widget-get conv :value))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1936 (insert (symbol-name symbol) ": ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1937 (push (widget-create-child-and-convert
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1938 widget 'visibility
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1939 :help-echo "Hide the value of this option"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1940 :action 'custom-toggle-parent
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1941 t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1942 buttons)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1943 (insert " ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1944 (push (widget-create-child-and-convert
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1945 widget 'sexp
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1946 :button-face 'custom-variable-button-face
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1947 :format "%v"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1948 :tag (symbol-name symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1949 :parent widget
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1950 :value value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1951 children)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1952 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1953 ;; Edit mode.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1954 (let* ((format (widget-get type :format))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1955 tag-format value-format)
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
1956 (while (not (string-match ":" format))
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
1957 (setq format (signal 'error (list "Bad format" format))))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1958 (setq tag-format (substring format 0 (match-end 0)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1959 (setq value-format (substring format (match-end 0)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1960 (push (widget-create-child-and-convert
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1961 widget 'item
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1962 :format tag-format
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1963 :action 'custom-tag-action
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1964 :help-echo "Change value of this option"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1965 :mouse-down-action 'custom-tag-mouse-down-action
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1966 :button-face 'custom-variable-button-face
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1967 :sample-face 'custom-variable-tag-face
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1968 tag)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1969 buttons)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1970 (insert " ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1971 (push (widget-create-child-and-convert
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1972 widget 'visibility
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1973 :help-echo "Hide the value of this option"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1974 :action 'custom-toggle-parent
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1975 t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1976 buttons)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1977 (push (widget-create-child-and-convert
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1978 widget type
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1979 :format value-format
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1980 :value value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1981 children))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1982 (unless (eq custom-buffer-style 'tree)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1983 (unless (eq (preceding-char) ?\n)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1984 (widget-insert "\n"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1985 ;; Create the magic button.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1986 (let ((magic (widget-create-child-and-convert
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1987 widget 'custom-magic nil)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1988 (widget-put widget :custom-magic magic)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1989 (push magic buttons))
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1990 ;; Insert documentation.
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1991 ;; ### NOTE: this is ugly!!!! I need to do update the :buttons property
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1992 ;; before the call to `widget-default-format-handler'. Otherwise, I
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1993 ;; loose my current `buttons'. This function shouldn't be called like
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1994 ;; this anyway. The doc string widget should be added like the others.
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1995 ;; --dv
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
1996 (widget-put widget :buttons buttons)
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1997 (widget-default-format-handler widget ?h)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1998 ;; The comment field
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
1999 (unless (eq state 'hidden)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2000 (let* ((comment (get symbol 'variable-comment))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2001 (comment-widget
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2002 (widget-create-child-and-convert
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2003 widget 'custom-comment
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2004 :parent widget
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2005 :value (or comment ""))))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2006 (widget-put widget :comment-widget comment-widget)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2007 ;; Don't push it !!! Custom assumes that the first child is the
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2008 ;; value one.
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2009 (setq children (append children (list comment-widget)))))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2010 ;; Update the rest of the properties properties.
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2011 (widget-put widget :custom-form form)
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
2012 (widget-put widget :children children)
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2013 ;; Now update the state.
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2014 (if (eq state 'hidden)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2015 (widget-put widget :custom-state state)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2016 (custom-variable-state-set widget))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2017 ;; See also.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2018 (unless (eq state 'hidden)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2019 (when (eq (widget-get widget :custom-level) 1)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2020 (custom-add-parent-links widget))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2021 (custom-add-see-also widget)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2022
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2023 (defun custom-tag-action (widget &rest args)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2024 "Pass :action to first child of WIDGET's parent."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2025 (apply 'widget-apply (car (widget-get (widget-get widget :parent) :children))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2026 :action args))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2027
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2028 (defun custom-tag-mouse-down-action (widget &rest args)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2029 "Pass :mouse-down-action to first child of WIDGET's parent."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2030 (apply 'widget-apply (car (widget-get (widget-get widget :parent) :children))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2031 :mouse-down-action args))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2032
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2033 (defun custom-variable-state-set (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2034 "Set the state of WIDGET."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2035 (let* ((symbol (widget-value widget))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2036 (get (or (get symbol 'custom-get) 'default-value))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2037 (value (if (default-boundp symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2038 (funcall get symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2039 (widget-get widget :value)))
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2040 (comment (get symbol 'variable-comment))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2041 tmp
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2042 temp
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2043 (state (cond ((progn (setq tmp (get symbol 'customized-value))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2044 (setq temp
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2045 (get symbol 'customized-variable-comment))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2046 (or tmp temp))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2047 (if (condition-case nil
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2048 (and (equal value (eval (car tmp)))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2049 (equal comment temp))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2050 (error nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2051 'set
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2052 'changed))
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2053 ((progn (setq tmp (get symbol 'saved-value))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2054 (setq temp (get symbol 'saved-variable-comment))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2055 (or tmp temp))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2056 (if (condition-case nil
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2057 (and (equal value (eval (car tmp)))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2058 (equal comment temp))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2059 (error nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2060 'saved
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2061 'changed))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2062 ((setq tmp (get symbol 'standard-value))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2063 (if (condition-case nil
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2064 (and (equal value (eval (car tmp)))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2065 (equal comment nil))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2066 (error nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2067 'standard
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2068 'changed))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2069 (t 'rogue))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2070 (widget-put widget :custom-state state)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2071
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2072 (defvar custom-variable-menu
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2073 '(("Set for Current Session" custom-variable-set
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2074 (lambda (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2075 (eq (widget-get widget :custom-state) 'modified)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2076 ("Save for Future Sessions" custom-variable-save
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2077 (lambda (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2078 (memq (widget-get widget :custom-state) '(modified set changed rogue))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2079 ("Reset to Current" custom-redraw
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2080 (lambda (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2081 (and (default-boundp (widget-value widget))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2082 (memq (widget-get widget :custom-state) '(modified changed)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2083 ("Reset to Saved" custom-variable-reset-saved
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2084 (lambda (widget)
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2085 (and (or (get (widget-value widget) 'saved-value)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2086 (get (widget-value widget) 'saved-variable-comment))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2087 (memq (widget-get widget :custom-state)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2088 '(modified set changed rogue)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2089 ("Reset to Standard Settings" custom-variable-reset-standard
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2090 (lambda (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2091 (and (get (widget-value widget) 'standard-value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2092 (memq (widget-get widget :custom-state)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2093 '(modified set changed saved rogue)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2094 ("---" ignore ignore)
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2095 ("Add Comment" custom-comment-show custom-comment-invisible-p)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2096 ("---" ignore ignore)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2097 ("Don't show as Lisp expression" custom-variable-edit
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2098 (lambda (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2099 (eq (widget-get widget :custom-form) 'lisp)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2100 ("Show as Lisp expression" custom-variable-edit-lisp
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2101 (lambda (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2102 (eq (widget-get widget :custom-form) 'edit))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2103 "Alist of actions for the `custom-variable' widget.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2104 Each entry has the form (NAME ACTION FILTER) where NAME is the name of
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2105 the menu entry, ACTION is the function to call on the widget when the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2106 menu is selected, and FILTER is a predicate which takes a `custom-variable'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2107 widget as an argument, and returns non-nil if ACTION is valid on that
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2108 widget. If FILTER is nil, ACTION is always valid.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2109
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2110 (defun custom-variable-action (widget &optional event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2111 "Show the menu for `custom-variable' WIDGET.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2112 Optional EVENT is the location for the menu."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2113 (if (eq (widget-get widget :custom-state) 'hidden)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2114 (custom-toggle-hide widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2115 (unless (eq (widget-get widget :custom-state) 'modified)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2116 (custom-variable-state-set widget))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2117 ;; Redrawing magic also depresses the state glyph.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2118 ;(custom-redraw-magic widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2119 (let* ((completion-ignore-case t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2120 (answer (widget-choose (concat "Operation on "
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2121 (custom-unlispify-tag-name
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2122 (widget-get widget :value)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2123 (custom-menu-filter custom-variable-menu
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2124 widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2125 event)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2126 (if answer
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2127 (funcall answer widget)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2128
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2129 (defun custom-variable-edit (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2130 "Edit value of WIDGET."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2131 (widget-put widget :custom-state 'unknown)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2132 (widget-put widget :custom-form 'edit)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2133 (custom-redraw widget))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2134
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2135 (defun custom-variable-edit-lisp (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2136 "Edit the lisp representation of the value of WIDGET."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2137 (widget-put widget :custom-state 'unknown)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2138 (widget-put widget :custom-form 'lisp)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2139 (custom-redraw widget))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2140
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2141 (defun custom-variable-set (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2142 "Set the current value for the variable being edited by WIDGET."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2143 (let* ((form (widget-get widget :custom-form))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2144 (state (widget-get widget :custom-state))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2145 (child (car (widget-get widget :children)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2146 (symbol (widget-value widget))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2147 (set (or (get symbol 'custom-set) 'set-default))
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2148 (comment-widget (widget-get widget :comment-widget))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2149 (comment (widget-value comment-widget))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2150 val)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2151 (cond ((eq state 'hidden)
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
2152 (error "Cannot set hidden variable"))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2153 ((setq val (widget-apply child :validate))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2154 (goto-char (widget-get val :from))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2155 (error "%s" (widget-get val :error)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2156 ((memq form '(lisp mismatch))
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2157 (when (equal comment "")
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2158 (setq comment nil)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2159 ;; Make the comment invisible by hand if it's empty
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2160 (set-extent-property (widget-get comment-widget :comment-extent)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2161 'invisible t))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2162 (funcall set symbol (eval (setq val (widget-value child))))
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2163 (put symbol 'customized-value (list val))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2164 (put symbol 'variable-comment comment)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2165 (put symbol 'customized-variable-comment comment))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2166 (t
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2167 (when (equal comment "")
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2168 (setq comment nil)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2169 ;; Make the comment invisible by hand if it's empty
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2170 (set-extent-property (widget-get comment-widget :comment-extent)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2171 'invisible t))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2172 (funcall set symbol (setq val (widget-value child)))
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2173 (put symbol 'customized-value (list (custom-quote val)))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2174 (put symbol 'variable-comment comment)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2175 (put symbol 'customized-variable-comment comment)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2176 (custom-variable-state-set widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2177 (custom-redraw-magic widget)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2178
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2179 (defun custom-variable-save (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2180 "Set and save the value for the variable being edited by WIDGET."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2181 (let* ((form (widget-get widget :custom-form))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2182 (state (widget-get widget :custom-state))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2183 (child (car (widget-get widget :children)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2184 (symbol (widget-value widget))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2185 (set (or (get symbol 'custom-set) 'set-default))
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2186 (comment-widget (widget-get widget :comment-widget))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2187 (comment (widget-value comment-widget))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2188 val)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2189 (cond ((eq state 'hidden)
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
2190 (error "Cannot set hidden variable"))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2191 ((setq val (widget-apply child :validate))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2192 (goto-char (widget-get val :from))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2193 (error "%s" (widget-get val :error)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2194 ((memq form '(lisp mismatch))
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2195 (when (equal comment "")
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2196 (setq comment nil)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2197 ;; Make the comment invisible by hand if it's empty
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2198 (set-extent-property (widget-get comment-widget :comment-extent)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2199 'invisible t))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2200 (put symbol 'saved-value (list (widget-value child)))
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2201 (custom-push-theme 'theme-value symbol 'user
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2202 'set (list (widget-value child)))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2203 (funcall set symbol (eval (widget-value child)))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2204 (put symbol 'variable-comment comment)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2205 (put symbol 'saved-variable-comment comment))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2206 (t
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2207 (when (equal comment "")
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2208 (setq comment nil)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2209 ;; Make the comment invisible by hand if it's empty
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2210 (set-extent-property (widget-get comment-widget :comment-extent)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2211 'invisible t))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2212 (put symbol
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2213 'saved-value (list (custom-quote (widget-value
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2214 child))))
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2215 (custom-push-theme 'theme-value symbol 'user
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2216 'set (list (custom-quote (widget-value
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2217 child))))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2218 (funcall set symbol (widget-value child))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2219 (put symbol 'variable-comment comment)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2220 (put symbol 'saved-variable-comment comment)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2221 (put symbol 'customized-value nil)
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2222 (put symbol 'customized-variable-comment nil)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2223 (custom-save-all)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2224 (custom-variable-state-set widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2225 (custom-redraw-magic widget)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2226
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2227 (defun custom-variable-reset-saved (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2228 "Restore the saved value for the variable being edited by WIDGET."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2229 (let* ((symbol (widget-value widget))
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2230 (set (or (get symbol 'custom-set) 'set-default))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2231 (comment-widget (widget-get widget :comment-widget))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2232 (value (get symbol 'saved-value))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2233 (comment (get symbol 'saved-variable-comment)))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2234 (cond ((or value comment)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2235 (put symbol 'variable-comment comment)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2236 (condition-case nil
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2237 (funcall set symbol (eval (car value)))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2238 (error nil)))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2239 (t
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2240 (signal 'error (list "No saved value for variable" symbol))))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2241 (put symbol 'customized-value nil)
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2242 (put symbol 'customized-variable-comment nil)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2243 (widget-put widget :custom-state 'unknown)
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2244 ;; This call will possibly make the comment invisible
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2245 (custom-redraw widget)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2246
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2247 (defun custom-variable-reset-standard (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2248 "Restore the standard setting for the variable being edited by WIDGET."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2249 (let* ((symbol (widget-value widget))
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2250 (set (or (get symbol 'custom-set) 'set-default))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2251 (comment-widget (widget-get widget :comment-widget)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2252 (if (get symbol 'standard-value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2253 (funcall set symbol (eval (car (get symbol 'standard-value))))
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
2254 (signal 'error (list "No standard setting known for variable" symbol)))
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2255 (put symbol 'variable-comment nil)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2256 (put symbol 'customized-value nil)
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2257 (put symbol 'customized-variable-comment nil)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2258 (when (or (get symbol 'saved-value) (get symbol 'saved-variable-comment))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2259 (put symbol 'saved-value nil)
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2260 (custom-push-theme 'theme-value symbol 'user 'reset 'standard)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2261 ;; As a special optimizations we do not (explictly)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2262 ;; save resets to standard when no theme set the value.
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2263 (if (null (cdr (get symbol 'theme-value)))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2264 (put symbol 'theme-value nil))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2265 (put symbol 'saved-variable-comment nil)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2266 (custom-save-all))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2267 (widget-put widget :custom-state 'unknown)
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2268 ;; This call will possibly make the comment invisible
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2269 (custom-redraw widget)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2270
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2271 ;;; The `custom-face-edit' Widget.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2272
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2273 (define-widget 'custom-face-edit 'checklist
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2274 "Edit face attributes."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2275 :format "%t: %v"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2276 :tag "Attributes"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2277 :extra-offset 12
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
2278 :button-args '(:help-echo "Control whether this attribute have any effect")
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2279 :args (mapcar (lambda (att)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2280 (list 'group
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2281 :inline t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2282 :sibling-args (widget-get (nth 1 att) :sibling-args)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2283 (list 'const :format "" :value (nth 0 att))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2284 (nth 1 att)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2285 custom-face-attributes))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2286
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2287 ;;; The `custom-display' Widget.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2288
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2289 (define-widget 'custom-display 'menu-choice
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2290 "Select a display type."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2291 :tag "Display"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2292 :value t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2293 :help-echo "Specify frames where the face attributes should be used"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2294 :args '((const :tag "all" t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2295 (checklist
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2296 :offset 0
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2297 :extra-offset 9
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2298 :args ((group :sibling-args (:help-echo "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2299 Only match the specified window systems")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2300 (const :format "Type: "
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2301 type)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2302 (checklist :inline t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2303 :offset 0
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2304 (const :format "X "
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2305 :sibling-args (:help-echo "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2306 The X11 Window System")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2307 x)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2308 (const :format "PM "
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2309 :sibling-args (:help-echo "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2310 OS/2 Presentation Manager")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2311 pm)
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 209
diff changeset
2312 (const :format "MSWindows "
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2313 :sibling-args (:help-echo "\
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
2314 Windows NT/95/97")
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 209
diff changeset
2315 mswindows)
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
2316 (const :format "DOS "
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2317 :sibling-args (:help-echo "\
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
2318 Plain MS-DOS")
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
2319 pc)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2320 (const :format "TTY%n"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2321 :sibling-args (:help-echo "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2322 Plain text terminals")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2323 tty)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2324 (group :sibling-args (:help-echo "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2325 Only match the frames with the specified color support")
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
2326 (const :format "Class: "
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2327 class)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2328 (checklist :inline t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2329 :offset 0
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2330 (const :format "Color "
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2331 :sibling-args (:help-echo "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2332 Match color frames")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2333 color)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2334 (const :format "Grayscale "
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2335 :sibling-args (:help-echo "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2336 Match grayscale frames")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2337 grayscale)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2338 (const :format "Monochrome%n"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2339 :sibling-args (:help-echo "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2340 Match frames with no color support")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2341 mono)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2342 (group :sibling-args (:help-echo "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2343 Only match frames with the specified intensity")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2344 (const :format "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2345 Background brightness: "
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2346 background)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2347 (checklist :inline t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2348 :offset 0
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2349 (const :format "Light "
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2350 :sibling-args (:help-echo "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2351 Match frames with light backgrounds")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2352 light)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2353 (const :format "Dark\n"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2354 :sibling-args (:help-echo "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2355 Match frames with dark backgrounds")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2356 dark)))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2357
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2358 ;;; The `custom-face' Widget.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2359
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2360 (defface custom-face-tag-face '((t (:underline t)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2361 "Face used for face tags."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2362 :group 'custom-faces)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2363
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2364 (defcustom custom-face-default-form 'selected
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2365 "Default form of displaying face definition."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2366 :type '(choice (const all)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2367 (const selected)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2368 (const lisp))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2369 :group 'custom-buffer)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2370
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2371 (define-widget 'custom-face 'custom
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2372 "Customize face."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2373 :sample-face 'custom-face-tag-face
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2374 :help-echo "Set or reset this face"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2375 :documentation-property '(lambda (face)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2376 (face-doc-string face))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2377 :value-create 'custom-face-value-create
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2378 :action 'custom-face-action
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2379 :custom-category 'face
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2380 :custom-form nil ; defaults to value of `custom-face-default-form'
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2381 :custom-set 'custom-face-set
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2382 :custom-save 'custom-face-save
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2383 :custom-reset-current 'custom-redraw
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2384 :custom-reset-saved 'custom-face-reset-saved
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2385 :custom-reset-standard 'custom-face-reset-standard
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2386 :custom-menu 'custom-face-menu-create)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2387
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2388 (define-widget 'custom-face-all 'editable-list
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2389 "An editable list of display specifications and attributes."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2390 :entry-format "%i %d %v"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2391 :insert-button-args '(:help-echo "Insert new display specification here")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2392 :append-button-args '(:help-echo "Append new display specification here")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2393 :delete-button-args '(:help-echo "Delete this display specification")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2394 :args '((group :format "%v" custom-display custom-face-edit)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2395
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2396 (defconst custom-face-all (widget-convert 'custom-face-all)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2397 "Converted version of the `custom-face-all' widget.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2398
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2399 (define-widget 'custom-display-unselected 'item
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2400 "A display specification that doesn't match the selected display."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2401 :match 'custom-display-unselected-match)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2402
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2403 (defun custom-display-unselected-match (widget value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2404 "Non-nil if VALUE is an unselected display specification."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2405 (not (face-spec-set-match-display value (selected-frame))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2406
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2407 (define-widget 'custom-face-selected 'group
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2408 "Edit the attributes of the selected display in a face specification."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2409 :args '((repeat :format ""
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2410 :inline t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2411 (group custom-display-unselected sexp))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2412 (group (sexp :format "") custom-face-edit)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2413 (repeat :format ""
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2414 :inline t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2415 sexp)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2416
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2417 (defconst custom-face-selected (widget-convert 'custom-face-selected)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2418 "Converted version of the `custom-face-selected' widget.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2419
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2420 (defun custom-face-value-create (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2421 "Create a list of the display specifications for WIDGET."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2422 (let ((buttons (widget-get widget :buttons))
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2423 children
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2424 (symbol (widget-get widget :value))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2425 (tag (widget-get widget :tag))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2426 (state (widget-get widget :custom-state))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2427 (begin (point))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2428 (is-last (widget-get widget :custom-last))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2429 (prefix (widget-get widget :custom-prefix)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2430 (unless tag
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2431 (setq tag (prin1-to-string symbol)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2432 (cond ((eq custom-buffer-style 'tree)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2433 (insert prefix (if is-last " `--- " " |--- "))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2434 (push (widget-create-child-and-convert
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2435 widget 'custom-browse-face-tag)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2436 buttons)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2437 (insert " " tag "\n")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2438 (widget-put widget :buttons buttons))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2439 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2440 ;; Create tag.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2441 (insert tag)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2442 (if (eq custom-buffer-style 'face)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2443 (insert " ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2444 (widget-specify-sample widget begin (point))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2445 (insert ": "))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2446 ;; Sample.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2447 (and (not (find-face symbol))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2448 ;; XEmacs cannot display uninitialized faces.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2449 (make-face symbol))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2450 (push (widget-create-child-and-convert widget 'item
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2451 :format "(%{%t%})"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2452 :sample-face symbol
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2453 :tag "sample")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2454 buttons)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2455 ;; Visibility.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2456 (insert " ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2457 (push (widget-create-child-and-convert
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2458 widget 'visibility
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2459 :help-echo "Hide or show this face"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2460 :action 'custom-toggle-parent
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2461 (not (eq state 'hidden)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2462 buttons)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2463 ;; Magic.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2464 (insert "\n")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2465 (let ((magic (widget-create-child-and-convert
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2466 widget 'custom-magic nil)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2467 (widget-put widget :custom-magic magic)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2468 (push magic buttons))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2469 ;; Update buttons.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2470 (widget-put widget :buttons buttons)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2471 ;; Insert documentation.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2472 (widget-default-format-handler widget ?h)
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2473 ;; The comment field
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2474 (unless (eq state 'hidden)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2475 (let* ((comment (get symbol 'face-comment))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2476 (comment-widget
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2477 (widget-create-child-and-convert
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2478 widget 'custom-comment
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2479 :parent widget
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2480 :value (or comment ""))))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2481 (widget-put widget :comment-widget comment-widget)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2482 (push comment-widget children)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2483 ;; See also.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2484 (unless (eq state 'hidden)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2485 (when (eq (widget-get widget :custom-level) 1)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2486 (custom-add-parent-links widget))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2487 (custom-add-see-also widget))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2488 ;; Editor.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2489 (unless (eq (preceding-char) ?\n)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2490 (insert "\n"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2491 (unless (eq state 'hidden)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2492 (message "Creating face editor...")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2493 (custom-load-widget widget)
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2494 (unless (widget-get widget :custom-form)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2495 (widget-put widget :custom-form custom-face-default-form))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2496 (let* ((symbol (widget-value widget))
416
ebe98a74bd68 Import from CVS: tag r21-2-16
cvs
parents: 412
diff changeset
2497 (spec (custom-face-get-spec symbol))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2498 (form (widget-get widget :custom-form))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2499 (indent (widget-get widget :indent))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2500 (edit (widget-create-child-and-convert
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2501 widget
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2502 (cond ((and (eq form 'selected)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2503 (widget-apply custom-face-selected
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2504 :match spec))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2505 (when indent (insert-char ?\ indent))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2506 'custom-face-selected)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2507 ((and (not (eq form 'lisp))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2508 (widget-apply custom-face-all
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2509 :match spec))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2510 'custom-face-all)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2511 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2512 (when indent (insert-char ?\ indent))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2513 'sexp))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2514 :value spec)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2515 (custom-face-state-set widget)
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2516 (push edit children)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2517 (widget-put widget :children children))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2518 (message "Creating face editor...done"))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2519
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2520 (defvar custom-face-menu
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2521 '(("Set for Current Session" custom-face-set)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2522 ("Save for Future Sessions" custom-face-save)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2523 ("Reset to Saved" custom-face-reset-saved
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2524 (lambda (widget)
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2525 (or (get (widget-value widget) 'saved-face)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2526 (get (widget-value widget) 'saved-face-comment))))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2527 ("Reset to Standard Setting" custom-face-reset-standard
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2528 (lambda (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2529 (get (widget-value widget) 'face-defface-spec)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2530 ("---" ignore ignore)
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2531 ("Add Comment" custom-comment-show custom-comment-invisible-p)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2532 ("---" ignore ignore)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2533 ("Show all display specs" custom-face-edit-all
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2534 (lambda (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2535 (not (eq (widget-get widget :custom-form) 'all))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2536 ("Just current attributes" custom-face-edit-selected
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2537 (lambda (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2538 (not (eq (widget-get widget :custom-form) 'selected))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2539 ("Show as Lisp expression" custom-face-edit-lisp
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2540 (lambda (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2541 (not (eq (widget-get widget :custom-form) 'lisp)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2542 "Alist of actions for the `custom-face' widget.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2543 Each entry has the form (NAME ACTION FILTER) where NAME is the name of
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2544 the menu entry, ACTION is the function to call on the widget when the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2545 menu is selected, and FILTER is a predicate which takes a `custom-face'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2546 widget as an argument, and returns non-nil if ACTION is valid on that
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2547 widget. If FILTER is nil, ACTION is always valid.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2548
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2549 (defun custom-face-edit-selected (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2550 "Edit selected attributes of the value of WIDGET."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2551 (widget-put widget :custom-state 'unknown)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2552 (widget-put widget :custom-form 'selected)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2553 (custom-redraw widget))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2554
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2555 (defun custom-face-edit-all (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2556 "Edit all attributes of the value of WIDGET."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2557 (widget-put widget :custom-state 'unknown)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2558 (widget-put widget :custom-form 'all)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2559 (custom-redraw widget))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2560
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2561 (defun custom-face-edit-lisp (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2562 "Edit the lisp representation of the value of WIDGET."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2563 (widget-put widget :custom-state 'unknown)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2564 (widget-put widget :custom-form 'lisp)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2565 (custom-redraw widget))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2566
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2567 (defun custom-face-state-set (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2568 "Set the state of WIDGET."
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2569 (let* ((symbol (widget-value widget))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2570 (comment (get symbol 'face-comment))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2571 tmp temp)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2572 (widget-put widget :custom-state
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2573 (cond ((progn
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2574 (setq tmp (get symbol 'customized-face))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2575 (setq temp (get symbol 'customized-face-comment))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2576 (or tmp temp))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2577 (if (equal temp comment)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2578 'set
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2579 'changed))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2580 ((progn
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2581 (setq tmp (get symbol 'saved-face))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2582 (setq temp (get symbol 'saved-face-comment))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2583 (or tmp temp))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2584 (if (equal temp comment)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2585 'saved
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2586 'changed))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2587 ((get symbol 'face-defface-spec)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2588 (if (equal comment nil)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2589 'standard
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2590 'changed))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2591 (t
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2592 'rogue)))))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2593
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2594 (defun custom-face-action (widget &optional event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2595 "Show the menu for `custom-face' WIDGET.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2596 Optional EVENT is the location for the menu."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2597 (if (eq (widget-get widget :custom-state) 'hidden)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2598 (custom-toggle-hide widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2599 (let* ((completion-ignore-case t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2600 (symbol (widget-get widget :value))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2601 (answer (widget-choose (concat "Operation on "
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2602 (custom-unlispify-tag-name symbol))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2603 (custom-menu-filter custom-face-menu
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2604 widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2605 event)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2606 (if answer
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2607 (funcall answer widget)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2608
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2609 (defun custom-face-set (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2610 "Make the face attributes in WIDGET take effect."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2611 (let* ((symbol (widget-value widget))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2612 (child (car (widget-get widget :children)))
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2613 (value (widget-value child))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2614 (comment-widget (widget-get widget :comment-widget))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2615 (comment (widget-value comment-widget)))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2616 (when (equal comment "")
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2617 (setq comment nil)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2618 ;; Make the comment invisible by hand if it's empty
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2619 (set-extent-property (widget-get comment-widget :comment-extent)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2620 'invisible t))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2621 (put symbol 'customized-face value)
416
ebe98a74bd68 Import from CVS: tag r21-2-16
cvs
parents: 412
diff changeset
2622 (face-spec-set symbol value nil '(custom))
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2623 (put symbol 'customized-face-comment comment)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2624 (put symbol 'face-comment comment)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2625 (custom-face-state-set widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2626 (custom-redraw-magic widget)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2627
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2628 (defun custom-face-save (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2629 "Make the face attributes in WIDGET default."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2630 (let* ((symbol (widget-value widget))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2631 (child (car (widget-get widget :children)))
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2632 (value (widget-value child))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2633 (comment-widget (widget-get widget :comment-widget))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2634 (comment (widget-value comment-widget)))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2635 (when (equal comment "")
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2636 (setq comment nil)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2637 ;; Make the comment invisible by hand if it's empty
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2638 (set-extent-property (widget-get comment-widget :comment-extent)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2639 'invisible t))
416
ebe98a74bd68 Import from CVS: tag r21-2-16
cvs
parents: 412
diff changeset
2640 (face-spec-set symbol value nil '(custom))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2641 (put symbol 'saved-face value)
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2642 (custom-push-theme 'theme-face symbol 'user 'set value)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2643 (put symbol 'customized-face nil)
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2644 (put symbol 'face-comment comment)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2645 (put symbol 'customized-face-comment nil)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2646 (put symbol 'saved-face-comment comment)
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 209
diff changeset
2647 (custom-save-all)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2648 (custom-face-state-set widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2649 (custom-redraw-magic widget)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2650
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2651 (defun custom-face-reset-saved (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2652 "Restore WIDGET to the face's default attributes."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2653 (let* ((symbol (widget-value widget))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2654 (child (car (widget-get widget :children)))
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2655 (value (get symbol 'saved-face))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2656 (comment (get symbol 'saved-face-comment))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2657 (comment-widget (widget-get widget :comment-widget)))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2658 (unless (or value comment)
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
2659 (signal 'error (list "No saved value for this face" symbol)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2660 (put symbol 'customized-face nil)
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2661 (put symbol 'customized-face-comment nil)
416
ebe98a74bd68 Import from CVS: tag r21-2-16
cvs
parents: 412
diff changeset
2662 (face-spec-set symbol value nil '(custom))
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2663 (put symbol 'face-comment comment)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2664 (widget-value-set child value)
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2665 ;; This call manages the comment visibility
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2666 (widget-value-set comment-widget (or comment ""))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2667 (custom-face-state-set widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2668 (custom-redraw-magic widget)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2669
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2670 (defun custom-face-reset-standard (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2671 "Restore WIDGET to the face's standard settings."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2672 (let* ((symbol (widget-value widget))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2673 (child (car (widget-get widget :children)))
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2674 (value (get symbol 'face-defface-spec))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2675 (comment-widget (widget-get widget :comment-widget)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2676 (unless value
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
2677 (signal 'error (list "No standard setting for this face" symbol)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2678 (put symbol 'customized-face nil)
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2679 (put symbol 'customized-face-comment nil)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2680 (when (or (get symbol 'saved-face) (get symbol 'saved-face-comment))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2681 (put symbol 'saved-face nil)
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2682 (custom-push-theme 'theme-face symbol 'user 'reset 'standard)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2683 ;; Do not explictly save resets to standards without themes.
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2684 (if (null (cdr (get symbol 'theme-face)))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2685 (put symbol 'theme-face nil))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2686 (put symbol 'saved-face-comment nil)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2687 (custom-save-all))
416
ebe98a74bd68 Import from CVS: tag r21-2-16
cvs
parents: 412
diff changeset
2688 (face-spec-set symbol value nil '(custom))
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2689 (put symbol 'face-comment nil)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2690 (widget-value-set child value)
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2691 ;; This call manages the comment visibility
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
2692 (widget-value-set comment-widget "")
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2693 (custom-face-state-set widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2694 (custom-redraw-magic widget)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2695
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2696 ;;; The `face' Widget.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2697
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2698 (define-widget 'face 'default
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2699 "Select and customize a face."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2700 :convert-widget 'widget-value-convert-widget
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2701 :button-prefix 'widget-push-button-prefix
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2702 :button-suffix 'widget-push-button-suffix
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2703 :format "%t: %[select face%] %v"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2704 :tag "Face"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2705 :value 'default
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2706 :value-create 'widget-face-value-create
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2707 :value-delete 'widget-face-value-delete
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2708 :value-get 'widget-value-value-get
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2709 :validate 'widget-children-validate
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2710 :action 'widget-face-action
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2711 :match (lambda (widget value) (symbolp value)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2712
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2713 (defun widget-face-value-create (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2714 ;; Create a `custom-face' child.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2715 (let* ((symbol (widget-value widget))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2716 (custom-buffer-style 'face)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2717 (child (widget-create-child-and-convert
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2718 widget 'custom-face
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2719 :custom-level nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2720 :value symbol)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2721 (custom-magic-reset child)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2722 (setq custom-options (cons child custom-options))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2723 (widget-put widget :children (list child))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2724
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2725 (defun widget-face-value-delete (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2726 ;; Remove the child from the options.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2727 (let ((child (car (widget-get widget :children))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2728 (setq custom-options (delq child custom-options))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2729 (widget-children-value-delete widget)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2730
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2731 (defvar face-history nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2732 "History of entered face names.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2733
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2734 (defun widget-face-action (widget &optional event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2735 "Prompt for a face."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2736 (let ((answer (completing-read "Face: "
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2737 (mapcar (lambda (face)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2738 (list (symbol-name face)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2739 (face-list))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2740 nil nil nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2741 'face-history)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2742 (unless (zerop (length answer))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2743 (widget-value-set widget (intern answer))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2744 (widget-apply widget :notify widget event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2745 (widget-setup))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2746
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2747 ;;; The `hook' Widget.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2748
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2749 (define-widget 'hook 'list
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2750 "A emacs lisp hook"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2751 :value-to-internal (lambda (widget value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2752 (if (symbolp value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2753 (list value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2754 value))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2755 :match (lambda (widget value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2756 (or (symbolp value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2757 (widget-group-match widget value)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2758 :convert-widget 'custom-hook-convert-widget
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2759 :tag "Hook")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2760
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2761 (defun custom-hook-convert-widget (widget)
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
2762 ;; Handle `:custom-options'.
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2763 (let* ((options (widget-get widget :options))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2764 (other `(editable-list :inline t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2765 :entry-format "%i %d%v"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2766 (function :format " %v")))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2767 (args (if options
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2768 (list `(checklist :inline t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2769 ,@(mapcar (lambda (entry)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2770 `(function-item ,entry))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2771 options))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2772 other)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2773 (list other))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2774 (widget-put widget :args args)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2775 widget))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2776
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2777 ;;; The `plist' Widget.
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2778
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2779 (define-widget 'plist 'list
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2780 "A property list."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2781 :match (lambda (widget value)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2782 (valid-plist-p value))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2783 :convert-widget 'custom-plist-convert-widget
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2784 :tag "Property List")
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2785
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2786 ;; #### Should handle options better.
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2787 (defun custom-plist-convert-widget (widget)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2788 (let* ((options (widget-get widget :options))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2789 (other `(editable-list :inline t
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2790 (group :inline t
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2791 (symbol :format "%t: %v "
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2792 :size 10
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2793 :tag "Property")
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2794 (sexp :tag "Value"))))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2795 (args
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2796 (if options
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2797 `((checklist :inline t
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2798 ,@(mapcar 'custom-plist-process-option options))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2799 ,other)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2800 (list other))))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2801 (widget-put widget :args args)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2802 widget))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2803
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2804 (defun custom-plist-process-option (entry)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2805 `(group :inline t
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2806 (const :tag "Property"
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2807 :format "%t: %v "
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2808 :size 10
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2809 ,entry)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2810 (sexp :tag "Value")))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
2811
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2812 ;;; The `custom-group-link' Widget.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2813
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2814 (define-widget 'custom-group-link 'link
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2815 "Show parent in other window when activated."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2816 :help-echo 'custom-group-link-help-echo
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2817 :action 'custom-group-link-action)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2818
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2819 (defun custom-group-link-help-echo (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2820 (concat "Create customization buffer for the `"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2821 (custom-unlispify-tag-name (widget-value widget))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2822 "' group"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2823
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2824 (defun custom-group-link-action (widget &rest ignore)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2825 (customize-group (widget-value widget)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2826
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2827 ;;; The `custom-group' Widget.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2828
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2829 (defcustom custom-group-tag-faces nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2830 ;; In XEmacs, this ought to play games with font size.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2831 "Face used for group tags.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2832 The first member is used for level 1 groups, the second for level 2,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2833 and so forth. The remaining group tags are shown with
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2834 `custom-group-tag-face'."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2835 :type '(repeat face)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2836 :group 'custom-faces)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2837
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2838 (defface custom-group-tag-face-1 '((((class color)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2839 (background dark))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2840 (:foreground "pink" :underline t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2841 (((class color)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2842 (background light))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2843 (:foreground "red" :underline t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2844 (t (:underline t)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2845 "Face used for group tags.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2846
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2847 (defface custom-group-tag-face '((((class color)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2848 (background dark))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2849 (:foreground "light blue" :underline t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2850 (((class color)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2851 (background light))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2852 (:foreground "blue" :underline t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2853 (t (:underline t)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2854 "Face used for low level group tags."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2855 :group 'custom-faces)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2856
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2857 (define-widget 'custom-group 'custom
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2858 "Customize group."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2859 :format "%v"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2860 :sample-face-get 'custom-group-sample-face-get
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2861 :documentation-property 'group-documentation
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2862 :help-echo "Set or reset all members of this group"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2863 :value-create 'custom-group-value-create
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2864 :action 'custom-group-action
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2865 :custom-category 'group
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2866 :custom-set 'custom-group-set
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2867 :custom-save 'custom-group-save
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2868 :custom-reset-current 'custom-group-reset-current
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2869 :custom-reset-saved 'custom-group-reset-saved
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2870 :custom-reset-standard 'custom-group-reset-standard
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2871 :custom-menu 'custom-group-menu-create)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2872
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2873 (defun custom-group-sample-face-get (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2874 ;; Use :sample-face.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2875 (or (nth (1- (widget-get widget :custom-level)) custom-group-tag-faces)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2876 'custom-group-tag-face))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2877
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2878 (define-widget 'custom-group-visibility 'visibility
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2879 "An indicator and manipulator for hidden group contents."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2880 :create 'custom-group-visibility-create)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2881
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2882 (defun custom-group-visibility-create (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2883 (let ((visible (widget-value widget)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2884 (if visible
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2885 (insert "--------")))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2886 (widget-default-create widget))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2887
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2888 (defun custom-group-members (symbol groups-only)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2889 "Return SYMBOL's custom group members.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2890 If GROUPS-ONLY non-nil, return only those members that are groups."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2891 (if (not groups-only)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2892 (get symbol 'custom-group)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2893 (let (members)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2894 (dolist (entry (get symbol 'custom-group) (nreverse members))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2895 (when (eq (nth 1 entry) 'custom-group)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2896 (push entry members))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2897
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2898 (defun custom-group-value-create (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2899 "Insert a customize group for WIDGET in the current buffer."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2900 (let* ((state (widget-get widget :custom-state))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2901 (level (widget-get widget :custom-level))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2902 ;; (indent (widget-get widget :indent))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2903 (prefix (widget-get widget :custom-prefix))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2904 (buttons (widget-get widget :buttons))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2905 (tag (widget-get widget :tag))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2906 (symbol (widget-value widget))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2907 (members (custom-group-members symbol
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2908 (and (eq custom-buffer-style 'tree)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2909 custom-browse-only-groups))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2910 (cond ((and (eq custom-buffer-style 'tree)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2911 (eq state 'hidden)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2912 (or members (custom-unloaded-widget-p widget)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2913 (custom-browse-insert-prefix prefix)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2914 (push (widget-create-child-and-convert
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2915 widget 'custom-browse-visibility
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2916 ;; :tag-glyph "plus"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2917 :tag "+")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2918 buttons)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2919 (insert "-- ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2920 ;; (widget-glyph-insert nil "-- " "horizontal")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2921 (push (widget-create-child-and-convert
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2922 widget 'custom-browse-group-tag)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2923 buttons)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2924 (insert " " tag "\n")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2925 (widget-put widget :buttons buttons))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2926 ((and (eq custom-buffer-style 'tree)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2927 (zerop (length members)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2928 (custom-browse-insert-prefix prefix)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2929 (insert "[ ]-- ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2930 ;; (widget-glyph-insert nil "[ ]" "empty")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2931 ;; (widget-glyph-insert nil "-- " "horizontal")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2932 (push (widget-create-child-and-convert
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2933 widget 'custom-browse-group-tag)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2934 buttons)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2935 (insert " " tag "\n")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2936 (widget-put widget :buttons buttons))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2937 ((eq custom-buffer-style 'tree)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2938 (custom-browse-insert-prefix prefix)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2939 (custom-load-widget widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2940 (if (zerop (length members))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2941 (progn
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2942 (custom-browse-insert-prefix prefix)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2943 (insert "[ ]-- ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2944 ;; (widget-glyph-insert nil "[ ]" "empty")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2945 ;; (widget-glyph-insert nil "-- " "horizontal")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2946 (push (widget-create-child-and-convert
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2947 widget 'custom-browse-group-tag)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2948 buttons)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2949 (insert " " tag "\n")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2950 (widget-put widget :buttons buttons))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2951 (push (widget-create-child-and-convert
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2952 widget 'custom-browse-visibility
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2953 ;; :tag-glyph "minus"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2954 :tag "-")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2955 buttons)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2956 (insert "-\\ ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2957 ;; (widget-glyph-insert nil "-\\ " "top")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2958 (push (widget-create-child-and-convert
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2959 widget 'custom-browse-group-tag)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2960 buttons)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2961 (insert " " tag "\n")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2962 (widget-put widget :buttons buttons)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2963 (message "Creating group...")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2964 (let* ((members (custom-sort-items members
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2965 custom-browse-sort-alphabetically
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2966 custom-browse-order-groups))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2967 (prefixes (widget-get widget :custom-prefixes))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2968 (custom-prefix-list (custom-prefix-add symbol prefixes))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2969 (extra-prefix (if (widget-get widget :custom-last)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2970 " "
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2971 " | "))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2972 (prefix (concat prefix extra-prefix))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2973 children entry)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2974 (while members
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2975 (setq entry (car members)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2976 members (cdr members))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2977 (push (widget-create-child-and-convert
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2978 widget (nth 1 entry)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2979 :group widget
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2980 :tag (custom-unlispify-tag-name (nth 0 entry))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2981 :custom-prefixes custom-prefix-list
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2982 :custom-level (1+ level)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2983 :custom-last (null members)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2984 :value (nth 0 entry)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2985 :custom-prefix prefix)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2986 children))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2987 (widget-put widget :children (reverse children)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2988 (message "Creating group...done")))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2989 ;; Nested style.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2990 ((eq state 'hidden)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2991 ;; Create level indicator.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2992 (unless (eq custom-buffer-style 'links)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2993 (insert-char ?\ (* custom-buffer-indent (1- level)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2994 (insert "-- "))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2995 ;; Create link indicator.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2996 (when (eq custom-buffer-style 'links)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2997 (insert " ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2998 (push (widget-create-child-and-convert
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2999 widget 'custom-group-link
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3000 :tag "Open"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3001 :tag-glyph '("open-up" "open-down")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3002 symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3003 buttons)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3004 (insert " "))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3005 ;; Create tag.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3006 (let ((begin (point)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3007 (insert tag)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3008 (widget-specify-sample widget begin (point)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3009 (insert " group")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3010 ;; Create visibility indicator.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3011 (unless (eq custom-buffer-style 'links)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3012 (insert ": ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3013 (push (widget-create-child-and-convert
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3014 widget 'custom-group-visibility
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3015 :help-echo "Show members of this group"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3016 :action 'custom-toggle-parent
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3017 (not (eq state 'hidden)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3018 buttons))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3019 (insert " \n")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3020 ;; Create magic button.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3021 (let ((magic (widget-create-child-and-convert
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3022 widget 'custom-magic nil)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3023 (widget-put widget :custom-magic magic)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3024 (push magic buttons))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3025 ;; Update buttons.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3026 (widget-put widget :buttons buttons)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3027 ;; Insert documentation.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3028 (if (and (eq custom-buffer-style 'links) (> level 1))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3029 (widget-put widget :documentation-indent 0))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3030 (widget-default-format-handler widget ?h))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3031 ;; Nested style.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3032 (t ;Visible.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3033 (custom-load-widget widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3034 ;; Update members
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3035 (setq members (custom-group-members
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3036 symbol (and (eq custom-buffer-style 'tree)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3037 custom-browse-only-groups)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3038 ;; Add parent groups references above the group.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3039 (if t ;;; This should test that the buffer
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3040 ;;; was made to display a group.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3041 (when (eq level 1)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3042 (if (custom-add-parent-links widget
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3043 "Go to parent group:")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3044 (insert "\n"))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3045 ;; Create level indicator.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3046 (insert-char ?\ (* custom-buffer-indent (1- level)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3047 (insert "/- ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3048 ;; Create tag.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3049 (let ((start (point)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3050 (insert tag)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3051 (widget-specify-sample widget start (point)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3052 (insert " group: ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3053 ;; Create visibility indicator.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3054 (unless (eq custom-buffer-style 'links)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3055 (insert "--------")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3056 (push (widget-create-child-and-convert
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3057 widget 'visibility
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3058 :help-echo "Hide members of this group"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3059 :action 'custom-toggle-parent
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3060 (not (eq state 'hidden)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3061 buttons)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3062 (insert " "))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3063 ;; Create more dashes.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3064 ;; Use 76 instead of 75 to compensate for the temporary "<"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3065 ;; added by `widget-insert'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3066 (insert-char ?- (- 76 (current-column)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3067 (* custom-buffer-indent level)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3068 (insert "\\\n")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3069 ;; Create magic button.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3070 (let ((magic (widget-create-child-and-convert
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3071 widget 'custom-magic
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3072 :indent 0
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3073 nil)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3074 (widget-put widget :custom-magic magic)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3075 (push magic buttons))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3076 ;; Update buttons.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3077 (widget-put widget :buttons buttons)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3078 ;; Insert documentation.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3079 (widget-default-format-handler widget ?h)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3080 ;; Parent groups.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3081 (if nil ;;; This should test that the buffer
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3082 ;;; was not made to display a group.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3083 (when (eq level 1)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3084 (insert-char ?\ custom-buffer-indent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3085 (custom-add-parent-links widget)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3086 (custom-add-see-also widget
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3087 (make-string (* custom-buffer-indent level)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3088 ?\ ))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3089 ;; Members.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3090 (message "Creating group...")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3091 (let* ((members (custom-sort-items members
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3092 custom-buffer-sort-alphabetically
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3093 custom-buffer-order-groups))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3094 (prefixes (widget-get widget :custom-prefixes))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3095 (custom-prefix-list (custom-prefix-add symbol prefixes))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3096 (length (length members))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3097 (count 0)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3098 (children (mapcar
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3099 (lambda (entry)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3100 (widget-insert "\n")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3101 (when (zerop (% count custom-skip-messages))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3102 (display-message
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3103 'progress
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3104 (format "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3105 Creating group members... %2d%%"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3106 (/ (* 100.0 count) length))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3107 (incf count)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3108 (prog1
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3109 (widget-create-child-and-convert
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3110 widget (nth 1 entry)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3111 :group widget
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3112 :tag (custom-unlispify-tag-name
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3113 (nth 0 entry))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3114 :custom-prefixes custom-prefix-list
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3115 :custom-level (1+ level)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3116 :value (nth 0 entry))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3117 (unless (eq (preceding-char) ?\n)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3118 (widget-insert "\n"))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3119 members)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3120 (message "Creating group magic...")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3121 (mapc 'custom-magic-reset children)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3122 (message "Creating group state...")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3123 (widget-put widget :children children)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3124 (custom-group-state-update widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3125 (message "Creating group... done"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3126 ;; End line
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3127 (insert "\n")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3128 (insert-char ?\ (* custom-buffer-indent (1- level)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3129 (insert "\\- " (widget-get widget :tag) " group end ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3130 (insert-char ?- (- 75 (current-column) (* custom-buffer-indent level)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3131 (insert "/\n")))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3132
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3133 (defvar custom-group-menu
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3134 '(("Set for Current Session" custom-group-set
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3135 (lambda (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3136 (eq (widget-get widget :custom-state) 'modified)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3137 ("Save for Future Sessions" custom-group-save
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3138 (lambda (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3139 (memq (widget-get widget :custom-state) '(modified set))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3140 ("Reset to Current" custom-group-reset-current
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3141 (lambda (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3142 (memq (widget-get widget :custom-state) '(modified))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3143 ("Reset to Saved" custom-group-reset-saved
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3144 (lambda (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3145 (memq (widget-get widget :custom-state) '(modified set))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3146 ("Reset to standard setting" custom-group-reset-standard
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3147 (lambda (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3148 (memq (widget-get widget :custom-state) '(modified set saved)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3149 "Alist of actions for the `custom-group' widget.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3150 Each entry has the form (NAME ACTION FILTER) where NAME is the name of
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3151 the menu entry, ACTION is the function to call on the widget when the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3152 menu is selected, and FILTER is a predicate which takes a `custom-group'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3153 widget as an argument, and returns non-nil if ACTION is valid on that
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3154 widget. If FILTER is nil, ACTION is always valid.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3155
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3156 (defun custom-group-action (widget &optional event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3157 "Show the menu for `custom-group' WIDGET.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3158 Optional EVENT is the location for the menu."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3159 (if (eq (widget-get widget :custom-state) 'hidden)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3160 (custom-toggle-hide widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3161 (let* ((completion-ignore-case t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3162 (answer (widget-choose (concat "Operation on "
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3163 (custom-unlispify-tag-name
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3164 (widget-get widget :value)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3165 (custom-menu-filter custom-group-menu
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3166 widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3167 event)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3168 (if answer
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3169 (funcall answer widget)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3170
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3171 (defun custom-group-set (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3172 "Set changes in all modified group members."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3173 (let ((children (widget-get widget :children)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3174 (mapc (lambda (child)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3175 (when (eq (widget-get child :custom-state) 'modified)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3176 (widget-apply child :custom-set)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3177 children)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3178
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3179 (defun custom-group-save (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3180 "Save all modified group members."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3181 (let ((children (widget-get widget :children)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3182 (mapc (lambda (child)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3183 (when (memq (widget-get child :custom-state) '(modified set))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3184 (widget-apply child :custom-save)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3185 children)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3186
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3187 (defun custom-group-reset-current (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3188 "Reset all modified group members."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3189 (let ((children (widget-get widget :children)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3190 (mapc (lambda (child)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3191 (when (eq (widget-get child :custom-state) 'modified)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3192 (widget-apply child :custom-reset-current)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3193 children)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3194
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3195 (defun custom-group-reset-saved (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3196 "Reset all modified or set group members."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3197 (let ((children (widget-get widget :children)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3198 (mapc (lambda (child)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3199 (when (memq (widget-get child :custom-state) '(modified set))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3200 (widget-apply child :custom-reset-saved)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3201 children)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3202
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3203 (defun custom-group-reset-standard (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3204 "Reset all modified, set, or saved group members."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3205 (let ((children (widget-get widget :children)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3206 (mapc (lambda (child)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3207 (when (memq (widget-get child :custom-state)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3208 '(modified set saved))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3209 (widget-apply child :custom-reset-standard)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3210 children)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3211
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3212 (defun custom-group-state-update (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3213 "Update magic."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3214 (unless (eq (widget-get widget :custom-state) 'hidden)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3215 (let* ((children (widget-get widget :children))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3216 (states (mapcar (lambda (child)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3217 (widget-get child :custom-state))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3218 children))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3219 (magics custom-magic-alist)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3220 (found 'standard))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3221 (while magics
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3222 (let ((magic (car (car magics))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3223 (if (and (not (eq magic 'hidden))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3224 (memq magic states))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3225 (setq found magic
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3226 magics nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3227 (setq magics (cdr magics)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3228 (widget-put widget :custom-state found)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3229 (custom-magic-reset widget))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3230
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
3231 ;;; The `custom-save-all' Function.
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
3232 ;;;###autoload
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
3233 (defcustom custom-file "~/.emacs"
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
3234 "File used for storing customization information.
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
3235 If you change this from the default \"~/.emacs\" you need to
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
3236 explicitly load that file for the settings to take effect."
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
3237 :type 'file
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
3238 :group 'customize)
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
3239
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3240 (defun custom-save-delete (symbol)
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3241 "Delete the call to SYMBOL form in `custom-file'.
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3242 Leave point at the location of the call, or after the last expression."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3243 (let ((find-file-hooks nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3244 (auto-mode-alist nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3245 (set-buffer (find-file-noselect custom-file)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3246 (goto-char (point-min))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3247 (catch 'found
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3248 (while t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3249 (let ((sexp (condition-case nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3250 (read (current-buffer))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3251 (end-of-file (throw 'found nil)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3252 (when (and (listp sexp)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3253 (eq (car sexp) symbol))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3254 (delete-region (save-excursion
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3255 (backward-sexp)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3256 (point))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3257 (point))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3258 (throw 'found nil))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3259
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3260 (defun custom-save-variables ()
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3261 "Save all customized variables in `custom-file'."
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3262 (save-excursion
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3263 (custom-save-delete 'custom-load-themes)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3264 (custom-save-delete 'custom-reset-variables)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3265 (custom-save-delete 'custom-set-variables)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3266 (custom-save-loaded-themes)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3267 (custom-save-resets 'theme-value 'custom-reset-variables nil)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3268 (let ((standard-output (current-buffer)))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3269 (unless (bolp)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3270 (princ "\n"))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3271 (princ "(custom-set-variables")
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3272 (mapatoms (lambda (symbol)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3273 (let ((spec (car-safe (get symbol 'theme-value)))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3274 (requests (get symbol 'custom-requests))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3275 (now (not (or (get symbol 'standard-value)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3276 (and (not (boundp symbol))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3277 (not (eq (get symbol 'force-value)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3278 'rogue))))))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3279 (comment (get symbol 'saved-variable-comment)))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3280 (when (or (and spec (eq (car spec) 'user)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3281 (eq (second spec) 'set)) comment)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3282 (princ "\n '(")
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents: 422
diff changeset
3283 (prin1 symbol)
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3284 (princ " ")
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3285 ;; This comment stuf is in the way ####
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3286 ;; Is (eq (third spec) (car saved-value)) ????
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3287 ;; (prin1 (third spec))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3288 (prin1 (car (get symbol 'saved-value)))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3289 (when (or now requests comment)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3290 (princ (if now " t" " nil")))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3291 (when (or comment requests)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3292 (princ " ")
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3293 (prin1 requests))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3294 (when comment
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3295 (princ " ")
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3296 (prin1 comment))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3297 (princ ")")))))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3298 (princ ")")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3299 (unless (looking-at "\n")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3300 (princ "\n")))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3301
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3302 (defvar custom-save-face-ignoring nil)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3303
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3304 (defun custom-save-face-internal (symbol)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3305 (let ((theme-spec (car-safe (get symbol 'theme-face)))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3306 (comment (get symbol 'saved-face-comment))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3307 (now (not (or (get symbol 'face-defface-spec)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3308 (and (not (find-face symbol))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3309 (not (eq (get symbol 'force-face) 'rogue)))))))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3310 (when (or (and (not (memq symbol custom-save-face-ignoring))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3311 ;; Don't print default face here.
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3312 theme-spec
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3313 (eq (car theme-spec) 'user)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3314 (eq (second theme-spec) 'set)) comment)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3315 (princ "\n '(")
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents: 422
diff changeset
3316 (prin1 symbol)
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3317 (princ " ")
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3318 (prin1 (get symbol 'saved-face))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3319 (if (or comment now)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3320 (princ (if now " t" " nil")))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3321 (when comment
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3322 (princ " ")
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3323 (prin1 comment))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3324 (princ ")"))))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3325
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3326 (defun custom-save-faces ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3327 "Save all customized faces in `custom-file'."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3328 (save-excursion
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3329 (custom-save-delete 'custom-reset-faces)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3330 (custom-save-delete 'custom-set-faces)
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3331 (custom-save-resets 'theme-face 'custom-reset-faces '(default))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3332 (let ((standard-output (current-buffer)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3333 (unless (bolp)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3334 (princ "\n"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3335 (princ "(custom-set-faces")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3336 ;; The default face must be first, since it affects the others.
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3337 (custom-save-face-internal 'default)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3338 (let ((custom-save-face-ignoring '(default)))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3339 (mapatoms #'custom-save-face-internal))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3340 (princ ")")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3341 (unless (looking-at "\n")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3342 (princ "\n")))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3343
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3344 (defun custom-save-resets (property setter special)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3345 (let (started-writing ignored-special)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3346 ;; (custom-save-delete setter) Done by caller
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3347 (let ((standard-output (current-buffer))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3348 (mapper `(lambda (object)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3349 (let ((spec (car-safe (get object (quote ,property)))))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3350 (when (and (not (memq object ignored-special))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3351 (eq (car spec) 'user)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3352 (eq (second spec) 'reset))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3353 ;; Do not write reset statements unless necessary.
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3354 (unless started-writing
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3355 (setq started-writing t)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3356 (unless (bolp)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3357 (princ "\n"))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3358 (princ "(")
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3359 (princ (quote ,setter))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3360 (princ "\n '(")
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents: 422
diff changeset
3361 (prin1 object)
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3362 (princ " ")
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3363 (prin1 (third spec))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3364 (princ ")")))))))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3365 (mapc mapper special)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3366 (setq ignored-special special)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3367 (mapatoms mapper)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3368 (when started-writing
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3369 (princ ")\n")))))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3370
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3371
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3372 (defun custom-save-loaded-themes ()
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3373 (let ((themes (reverse (get 'user 'theme-loads-themes)))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3374 (standard-output (current-buffer)))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3375 (when themes
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3376 (unless (bolp) (princ "\n"))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3377 (princ "(custom-load-themes")
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3378 (mapc (lambda (theme)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3379 (princ "\n '")
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3380 (prin1 theme)) themes)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3381 (princ " )\n"))))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3382
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3383 ;;;###autoload
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3384 (defun customize-save-customized ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3385 "Save all user options which have been set in this session."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3386 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3387 (mapatoms (lambda (symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3388 (let ((face (get symbol 'customized-face))
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3389 (value (get symbol 'customized-value))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3390 (face-comment (get symbol 'customized-face-comment))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3391 (variable-comment
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3392 (get symbol 'customized-variable-comment)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3393 (when face
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3394 (put symbol 'saved-face face)
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3395 (custom-push-theme 'theme-face symbol 'user 'set value)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3396 (put symbol 'customized-face nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3397 (when value
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3398 (put symbol 'saved-value value)
422
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3399 (custom-push-theme 'theme-value symbol 'user 'set value)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3400 (put symbol 'customized-value nil))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3401 (when variable-comment
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3402 (put symbol 'saved-variable-comment variable-comment)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3403 (put symbol 'customized-variable-comment nil))
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3404 (when face-comment
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3405 (put symbol 'saved-face-comment face-comment)
95016f13131a Import from CVS: tag r21-2-19
cvs
parents: 416
diff changeset
3406 (put symbol 'customized-face-comment nil)))))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3407 ;; We really should update all custom buffers here.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3408 (custom-save-all))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3409
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3410 ;;;###autoload
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3411 (defun custom-save-all ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3412 "Save all customizations in `custom-file'."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3413 (let ((inhibit-read-only t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3414 (custom-save-variables)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3415 (custom-save-faces)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3416 (let ((find-file-hooks nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3417 (auto-mode-alist))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3418 (with-current-buffer (find-file-noselect custom-file)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3419 (save-buffer)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3420
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3421
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3422 ;;; The Customize Menu.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3423
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3424 ;;; Menu support
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3425
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3426 (defun custom-face-menu-create (widget symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3427 "Ignoring WIDGET, create a menu entry for customization face SYMBOL."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3428 (vector (custom-unlispify-menu-entry symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3429 `(customize-face ',symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3430 t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3431
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3432 (defun custom-variable-menu-create (widget symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3433 "Ignoring WIDGET, create a menu entry for customization variable SYMBOL."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3434 (let ((type (get symbol 'custom-type)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3435 (unless (listp type)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3436 (setq type (list type)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3437 (if (and type (widget-get type :custom-menu))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3438 (widget-apply type :custom-menu symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3439 (vector (custom-unlispify-menu-entry symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3440 `(customize-variable ',symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3441 t))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3442
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3443 ;; Add checkboxes to boolean variable entries.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3444 (widget-put (get 'boolean 'widget-type)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3445 :custom-menu (lambda (widget symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3446 `[,(custom-unlispify-menu-entry symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3447 (customize-variable ',symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3448 :style toggle
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3449 :selected ,symbol]))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3450
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3451 ;; XEmacs can create menus dynamically.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3452 (defun custom-group-menu-create (widget symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3453 "Ignoring WIDGET, create a menu entry for customization group SYMBOL."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3454 `( ,(custom-unlispify-menu-entry symbol t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3455 :filter (lambda (&rest junk)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3456 (let ((item (custom-menu-create ',symbol)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3457 (if (listp item)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3458 (cdr item)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3459 (list item))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3460
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3461 ;;;###autoload
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3462 (defun custom-menu-create (symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3463 "Create menu for customization group SYMBOL.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3464 The menu is in a format applicable to `easy-menu-define'."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3465 (let* ((item (vector (custom-unlispify-menu-entry symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3466 `(customize-group ',symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3467 t)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3468 ;; Item is the entry for creating a menu buffer for SYMBOL.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3469 ;; We may nest, if the menu is not too big.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3470 (custom-load-symbol symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3471 (if (< (length (get symbol 'custom-group)) widget-menu-max-size)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3472 ;; The menu is not too big.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3473 (let ((custom-prefix-list (custom-prefix-add symbol
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3474 custom-prefix-list))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3475 (members (custom-sort-items (get symbol 'custom-group)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3476 custom-menu-sort-alphabetically
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3477 custom-menu-order-groups)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3478 ;; Create the menu.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3479 `(,(custom-unlispify-menu-entry symbol t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3480 ,item
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3481 "--"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3482 ,@(mapcar (lambda (entry)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3483 (widget-apply (if (listp (nth 1 entry))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3484 (nth 1 entry)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3485 (list (nth 1 entry)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3486 :custom-menu (nth 0 entry)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3487 members)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3488 ;; The menu was too big.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3489 item)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3490
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3491 ;;;###autoload
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3492 (defun customize-menu-create (symbol &optional name)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3493 "Return a customize menu for customization group SYMBOL.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3494 If optional NAME is given, use that as the name of the menu.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3495 Otherwise the menu will be named `Customize'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3496 The format is suitable for use with `easy-menu-define'."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3497 (unless name
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3498 (setq name "Customize"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3499 `(,name
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3500 :filter (lambda (&rest junk)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3501 (cdr (custom-menu-create ',symbol)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3502
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3503 ;;; The Custom Mode.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3504
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3505 (defvar custom-mode-map nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3506 "Keymap for `custom-mode'.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3507
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3508 (unless custom-mode-map
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3509 (setq custom-mode-map (make-sparse-keymap))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3510 (set-keymap-parents custom-mode-map widget-keymap)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3511 (suppress-keymap custom-mode-map)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3512 (define-key custom-mode-map " " 'scroll-up)
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
3513 (define-key custom-mode-map [delete] 'scroll-down)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
3514 (define-key custom-mode-map "q" 'Custom-buffer-done)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3515 (define-key custom-mode-map "u" 'Custom-goto-parent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3516 (define-key custom-mode-map "n" 'widget-forward)
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
3517 (define-key custom-mode-map "p" 'widget-backward))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3518
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3519 (easy-menu-define Custom-mode-menu
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3520 custom-mode-map
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3521 "Menu used in customization buffers."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3522 `("Custom"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3523 ,(customize-menu-create 'customize)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3524 ["Set" Custom-set t]
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3525 ["Save" Custom-save t]
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3526 ["Reset to Current" Custom-reset-current t]
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3527 ["Reset to Saved" Custom-reset-saved t]
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3528 ["Reset to Standard Settings" Custom-reset-standard t]
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3529 ["Info" (Info-goto-node "(xemacs)Easy Customization") t]))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3530
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3531 (defun Custom-goto-parent ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3532 "Go to the parent group listed at the top of this buffer.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3533 If several parents are listed, go to the first of them."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3534 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3535 (save-excursion
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3536 (goto-char (point-min))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3537 (if (search-forward "\nGo to parent group: " nil t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3538 (let* ((button (get-char-property (point) 'button))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3539 (parent (downcase (widget-get button :tag))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3540 (customize-group parent)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3541
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3542 (defcustom custom-mode-hook nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3543 "Hook called when entering custom-mode."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3544 :type 'hook
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3545 :group 'custom-buffer )
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3546
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3547 (defun custom-state-buffer-message (widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3548 (if (eq (widget-get (widget-get widget :parent) :custom-state) 'modified)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3549 (message
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3550 "To install your edits, invoke [State] and choose the Set operation")))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3551
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3552 (defun custom-mode ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3553 "Major mode for editing customization buffers.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3554
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3555 The following commands are available:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3556
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3557 Move to next button or editable field. \\[widget-forward]
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3558 Move to previous button or editable field. \\[widget-backward]
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3559 \\<widget-field-keymap>\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3560 Complete content of editable text field. \\[widget-complete]
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3561 \\<custom-mode-map>\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3562 Invoke button under point. \\[widget-button-press]
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3563 Set all modifications. \\[Custom-set]
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3564 Make all modifications default. \\[Custom-save]
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3565 Reset all modified options. \\[Custom-reset-current]
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3566 Reset all modified or set options. \\[Custom-reset-saved]
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3567 Reset all options. \\[Custom-reset-standard]
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3568
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3569 Entry to this mode calls the value of `custom-mode-hook'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3570 if that value is non-nil."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3571 (kill-all-local-variables)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3572 (setq major-mode 'custom-mode
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3573 mode-name "Custom")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3574 (use-local-map custom-mode-map)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3575 (easy-menu-add Custom-mode-menu)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3576 (make-local-variable 'custom-options)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3577 (make-local-variable 'widget-documentation-face)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3578 (setq widget-documentation-face 'custom-documentation-face)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3579 (make-local-variable 'widget-button-face)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3580 (setq widget-button-face 'custom-button-face)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3581 (make-local-hook 'widget-edit-functions)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3582 (add-hook 'widget-edit-functions 'custom-state-buffer-message nil t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3583 (run-hooks 'custom-mode-hook))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3584
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3585
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3586 ;;; The End.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3587
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3588 (provide 'cus-edit)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3589
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3590 ;; cus-edit.el ends here