annotate lisp/custom/cus-edit.el @ 175:2d532a89d707 r20-3b14

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