annotate lisp/cus-edit.el @ 214:c5d88c05e1e9

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