annotate lisp/custom/cus-edit.el @ 163:0132846995bd r20-3b8

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