annotate lisp/cus-edit.el @ 5645:5d3bb1100832

Remove some utility functions from the global namespace, lisp/ lisp/ChangeLog addition: 2012-04-07 Aidan Kehoe <kehoea@parhasard.net> Remove some utility functions from the global namespace, it's more appropriate to have them as labels (that is, lexically-visible functions.) * behavior.el: * behavior.el (behavior-menu-filter-1): Moved to being a label. * behavior.el (behavior-menu-filter): Use the label. * cus-edit.el (custom-load-symbol-1): Moved to being a label. * cus-edit.el (custom-load-symbol): Use the label. * menubar.el (find-menu-item-1): Moved to being a label. * menubar.el (find-menu-item): Use the label. * window-xemacs.el: * window-xemacs.el (display-buffer-1): Moved to being a label. * window-xemacs.el (display-buffer): Use the label; use (block ...) instead of (catch ...), use prog1 instead of needlessly binding a variable.
author Aidan Kehoe <kehoea@parhasard.net>
date Sat, 07 Apr 2012 21:57:31 +0100
parents 4dee0387b9de
children cc6f0266bc36
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 ;;; cus-edit.el --- Tools for customizating Emacs and Lisp packages.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 ;;
4434
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
3 ;; Copyright (C) 2007, 2008 Didier Verna
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
4 ;; Copyright (C) 2003 Ben Wing
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
5 ;; Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 ;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
8 ;; Maintainer: Didier Verna <didier@xemacs.org>
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 ;; Keywords: help, faces
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 ;; Version: 1.9960-x
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ;; This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4806
diff changeset
15 ;; XEmacs is free software: you can redistribute it and/or modify it
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4806
diff changeset
16 ;; under the terms of the GNU General Public License as published by the
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4806
diff changeset
17 ;; Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4806
diff changeset
18 ;; option) any later version.
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4806
diff changeset
19
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4806
diff changeset
20 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4806
diff changeset
21 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4806
diff changeset
22 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4806
diff changeset
23 ;; for more details.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 ;; You should have received a copy of the GNU General Public License
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4806
diff changeset
26 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 ;;; Commentary:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 ;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 ;; This file implements the code to create and edit customize buffers.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 ;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 ;; See `custom.el'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 ;; No commands should have names starting with `custom-' because
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 ;; that interferes with completion. Use `customize-' for commands
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 ;; that the user will run with M-x, and `Custom-' for interactive commands.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 ;; NOTE: In many places within this file we use `mapatoms', which is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 ;; very slow in an average XEmacs because of the large number of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 ;; symbols requiring a large number of funcalls -- XEmacs with Gnus
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 ;; can grow to some 17000 symbols without ever doing anything fancy.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 ;; It would probably pay off to make a hash table of symbols known to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 ;; Custom, similar to custom-group-hash-table.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 ;; This is not top priority, because none of the functions that do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 ;; mapatoms are speed-critical (the one that was now uses
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 ;; custom-group-hash-table), but it would be nice to have.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 ;;; Code:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 (require 'cus-face)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 (require 'wid-edit)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 (require 'easymenu)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 (require 'cus-load)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 (require 'cus-start)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
58 (require 'cus-file)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 ;; Huh? This looks dirty!
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 (put 'custom-define-hook 'custom-type 'hook)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 (put 'custom-define-hook 'standard-value '(nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 (custom-add-to-group 'customize 'custom-define-hook 'custom-variable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 ;;; Customization Groups.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 (defgroup emacs nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 "Customization of the One True Editor."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 :link '(custom-manual "(XEmacs)Top"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 ;; Most of these groups are stolen from `finder.el',
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 (defgroup editing nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 "Basic text editing facilities."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 :group 'emacs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 (defgroup matching nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 "Various sorts of searching and matching."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 :group 'editing)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 (defgroup emulations nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 "Emulations of other editors."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 :group 'editing)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 (defgroup outlines nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 "Support for hierarchical outlining."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 :group 'editing)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 (defgroup external nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 "Interfacing to external utilities."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 :group 'emacs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 (defgroup bib nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 "Code related to the `bib' bibliography processor."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 :tag "Bibliography"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 :group 'external)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 (defgroup programming nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 "Support for programming in other languages."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 :group 'emacs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 (defgroup languages nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 "Specialized modes for editing programming languages."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 :group 'programming)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 ;; #### This should be in cc-vars.el
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 (defgroup c nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 "Support for the C language and related languages."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 :group 'languages)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 (defgroup tools nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 "Programming tools."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 :group 'programming)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 (defgroup oop nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 "Support for object-oriented programming."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 :group 'programming)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 (defgroup applications nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 "Applications written in Emacs."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 :group 'emacs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 ;; #### This should be in calendar.el
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 (defgroup calendar nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 "Calendar and time management support."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 :group 'applications)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 (defgroup mail nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 "Modes for electronic-mail handling."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 :group 'applications)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 (defgroup news nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 "Support for netnews reading and posting."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 :group 'applications)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 (defgroup games nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 "Games, jokes and amusements."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 :group 'applications)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 (defgroup development nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 "Support for further development of Emacs."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 :group 'emacs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 (defgroup docs nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 "Support for Emacs documentation."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 :group 'development)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 (defgroup extensions nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 "Emacs Lisp language extensions."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 :group 'development)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 (defgroup internal nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 "Code for Emacs internals, build process, defaults."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 :group 'development)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 (defgroup maint nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 "Maintenance aids for the Emacs development group."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 :tag "Maintenance"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 :group 'development)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 (defgroup environment nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 "Fitting Emacs with its environment."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 :group 'emacs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 (defgroup comm nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 "Communications, networking, remote access to files."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 :tag "Communication"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 :group 'environment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 (defgroup hardware nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 "Support for interfacing with exotic hardware."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 :group 'environment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 (defgroup terminals nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 "Support for terminal types."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 :group 'environment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 (defgroup unix nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 "Front-ends/assistants for, or emulators of, UNIX features."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 :group 'environment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 (defgroup i18n nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 "Internationalization and alternate character-set support."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 :group 'environment
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 :group 'editing)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 (defgroup data nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 "Support editing files of data."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 :group 'emacs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 (defgroup wp nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 "Word processing."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 :group 'emacs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 (defgroup tex nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 "Code related to the TeX formatter."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 :group 'wp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 (defgroup hypermedia nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 "Support for links between text or other media types."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 :group 'emacs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 (defgroup local nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 "Code local to your site."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 :group 'emacs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 (defgroup customize '((widgets custom-group))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 "Customization of the Customization support."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 :link '(custom-manual "(custom)Top")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 :link '(url-link :tag "Development Page"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 "http://www.dina.kvl.dk/~abraham/custom/")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 :prefix "custom-"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 :group 'help)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 (defgroup custom-faces nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 "Faces used by customize."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 :group 'customize
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 :group 'faces)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 (defgroup custom-browse nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 "Control customize browser."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 :prefix "custom-"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 :group 'customize)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 (defgroup custom-buffer nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 "Control customize buffers."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 :prefix "custom-"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 :group 'customize)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 (defgroup custom-menu nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 "Control customize menus."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 :prefix "custom-"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 :group 'customize)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 (defgroup alloc nil
613
023b83f4e54b [xemacs-hg @ 2001-06-10 10:42:16 by ben]
ben
parents: 555
diff changeset
235 "Storage allocation and gc for XEmacs Lisp interpreter."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 :tag "Storage Allocation"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 :group 'internal)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 (defgroup undo nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 "Undoing changes in buffers."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 :group 'editing)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 (defgroup editing-basics nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 "Most basic editing facilities."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 :group 'editing)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 (defgroup display nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 "How characters are displayed in buffers."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 :group 'environment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 (defgroup installation nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 "The Emacs installation."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 :group 'environment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 (defgroup limits nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 "Internal Emacs limits."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 :group 'internal)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 (defgroup debug nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 "Debugging Emacs itself."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 :group 'development)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 (defgroup mule nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 "Mule XEmacs internationalization."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 :group 'i18n)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 ;;; Utilities.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 (defun custom-split-regexp-maybe (regexp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 "If REGEXP is a string, split it to a list at `\\|'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 You can get the original back with from the result with:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 (mapconcat #'identity result \"\\|\")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 IF REGEXP is not a string, return it unchanged."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 (if (stringp regexp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 (split-string regexp "\\\\|")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 regexp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 (defun custom-variable-prompt ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 ;; Code stolen from `help.el'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 "Prompt for a variable, defaulting to the variable at point.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 Return a list suitable for use in `interactive'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 (let ((v (variable-at-point))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 (enable-recursive-minibuffers t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 (setq val (completing-read
4701
684f0ed6cd4f Behave better when #'variable-at-point gives nil, #'custom-variable-prompt.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4628
diff changeset
288 (if (and v (symbolp v))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 (format "Customize variable: (default %s) " v)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 "Customize variable: ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 obarray (lambda (symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 (and (boundp symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 (or (get symbol 'custom-type)
476
6a8b2ec80a19 [xemacs-hg @ 2001-04-18 18:18:46 by didierv]
didierv
parents: 456
diff changeset
294 (user-variable-p symbol))))
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
295 t nil nil (and v (symbol-name v))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 (list (if (equal val "")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 (if (symbolp v) v nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 (intern val)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 ;; Here we take not only the actual groups, but the loads, too.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 (defun custom-group-prompt (prompt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 "Read group from minibuffer."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 (let ((completion-ignore-case t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 (list (completing-read
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 prompt obarray
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 (lambda (symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 (or (get symbol 'custom-group)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 (get symbol 'custom-loads)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 t))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 (defun custom-menu-filter (menu widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 "Convert MENU to the form used by `widget-choose'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 MENU should be in the same format as `custom-variable-menu'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 WIDGET is the widget to apply the filter entries of MENU on."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 (let ((result nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 current name action filter)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 (while menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 (setq current (car menu)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 name (nth 0 current)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 action (nth 1 current)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 filter (nth 2 current)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 menu (cdr menu))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 (if (or (null filter) (funcall filter widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 (push (cons name action) result)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 (push name result)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 (nreverse result)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 ;;; Unlispify.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 (defvar custom-prefix-list nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 "List of prefixes that should be ignored by `custom-unlispify'")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333
848
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
334 (defcustom custom-save-pretty-print t
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
335 "Non-nil means pretty-print values of customized variables if available."
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
336 :group 'customize
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
337 :type 'boolean)
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
338
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
339
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 (defcustom custom-unlispify-menu-entries t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 "Display menu entries as words instead of symbols if non nil."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 :group 'custom-menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 :type 'boolean)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 (defcustom custom-unlispify-remove-prefixes t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 "Non-nil means remove group prefixes from option names in buffers and menus.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 This only has an effect when `custom-unlispify-tag-names' or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 `custom-unlispify-menu-entries' is on."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 :group 'custom-menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 :type 'boolean)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 (defun custom-unlispify-menu-entry (symbol &optional no-suffix)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 "Convert symbol into a menu entry."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 (cond ((not custom-unlispify-menu-entries)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 (symbol-name symbol))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 ((get symbol 'custom-tag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 (if no-suffix
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 (get symbol 'custom-tag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 (concat (get symbol 'custom-tag) "...")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 (with-current-buffer (get-buffer-create " *Custom-Work*")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 (erase-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 (princ symbol (current-buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 (goto-char (point-min))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 (when (and (eq (get symbol 'custom-type) 'boolean)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 (re-search-forward "-p\\'" nil t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 (replace-match "" t t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 (goto-char (point-min)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 (when custom-unlispify-remove-prefixes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 (let ((prefixes custom-prefix-list)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 prefix)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 (while prefixes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 (setq prefix (car prefixes))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 (if (search-forward prefix (+ (point) (length prefix)) t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 (setq prefixes nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 (delete-region (point-min) (point)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 (setq prefixes (cdr prefixes))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 (subst-char-in-region (point-min) (point-max) ?- ?\ t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 (capitalize-region (point-min) (point-max))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 (unless no-suffix
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 (goto-char (point-max))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 (insert "..."))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 (buffer-string)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 (defcustom custom-unlispify-tag-names t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 "Display tag names as words instead of symbols if non nil."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 :group 'custom-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 :type 'boolean)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 (defun custom-unlispify-tag-name (symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 "Convert symbol into a menu entry."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 (let ((custom-unlispify-menu-entries custom-unlispify-tag-names))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 (custom-unlispify-menu-entry symbol t)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 (defun custom-prefix-add (symbol prefixes)
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
397 ;; Add SYMBOL to list of ignored PREFIXES.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 (cons (or (get symbol 'custom-prefix)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 (concat (symbol-name symbol) "-"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 prefixes))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 ;;; Guess.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 (defcustom custom-guess-name-alist
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 '(("-p\\'" boolean)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 ("-hooks?\\'" hook)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 ("-face\\'" face)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 ("-file\\'" file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 ("-function\\'" function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 ("-functions\\'" (repeat function))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 ("-list\\'" (repeat sexp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 ("-alist\\'" (repeat (cons sexp sexp))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 "Alist of (MATCH TYPE).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 MATCH should be a regexp matching the name of a symbol, and TYPE should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 be a widget suitable for editing the value of that symbol. The TYPE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 of the first entry where MATCH matches the name of the symbol will be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 used.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 This is used for guessing the type of variables not declared with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 customize."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 :type '(repeat (group (regexp :tag "Match") (sexp :tag "Type")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 :group 'customize)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 (defcustom custom-guess-doc-alist
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 '(("\\`\\*?Non-nil " boolean))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 "Alist of (MATCH TYPE).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 MATCH should be a regexp matching a documentation string, and TYPE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 should be a widget suitable for editing the value of a variable with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 that documentation string. The TYPE of the first entry where MATCH
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 matches the name of the symbol will be used.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 This is used for guessing the type of variables not declared with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 customize."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 :type '(repeat (group (regexp :tag "Match") (sexp :tag "Type")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 :group 'customize)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 (defun custom-guess-type (symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 "Guess a widget suitable for editing the value of SYMBOL.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 This is done by matching SYMBOL with `custom-guess-name-alist' and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 if that fails, the doc string with `custom-guess-doc-alist'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 (let ((name (symbol-name symbol))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 (names custom-guess-name-alist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 current found)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 (while names
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 (setq current (car names)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 names (cdr names))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 (when (string-match (nth 0 current) name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 (setq found (nth 1 current)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 names nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 (unless found
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 (let ((doc (documentation-property symbol 'variable-documentation))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 (docs custom-guess-doc-alist))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 (when doc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 (while docs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 (setq current (car docs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 docs (cdr docs))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 (when (string-match (nth 0 current) doc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 (setq found (nth 1 current)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 docs nil))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 found))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 ;;; Sorting.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 (defcustom custom-browse-sort-alphabetically nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 "If non-nil, sort members of each customization group alphabetically."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 :type 'boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 :group 'custom-browse)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 (defcustom custom-browse-order-groups nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 "If non-nil, order group members within each customization group.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 If `first', order groups before non-groups.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 If `last', order groups after non-groups."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 :type '(choice (const first)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 (const last)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 (const :tag "none" nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 :group 'custom-browse)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 (defcustom custom-browse-only-groups nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 "If non-nil, show group members only within each customization group."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 :type 'boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 :group 'custom-browse)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 (defcustom custom-buffer-sort-alphabetically nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 "If non-nil, sort members of each customization group alphabetically."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 :type 'boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 :group 'custom-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 (defcustom custom-buffer-order-groups 'last
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 "If non-nil, order group members within each customization group.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 If `first', order groups before non-groups.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 If `last', order groups after non-groups."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 :type '(choice (const first)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 (const last)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 (const :tag "none" nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 :group 'custom-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 (defcustom custom-menu-sort-alphabetically nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 "If non-nil, sort members of each customization group alphabetically."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 :type 'boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 :group 'custom-menu)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 (defcustom custom-menu-order-groups 'first
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 "If non-nil, order group members within each customization group.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 If `first', order groups before non-groups.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 If `last', order groups after non-groups."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 :type '(choice (const first)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 (const last)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 (const :tag "none" nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 :group 'custom-menu)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 (defun custom-sort-items (items sort-alphabetically order-groups)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 "Return a sorted copy of ITEMS.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 ITEMS should be a `custom-group' property.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 If SORT-ALPHABETICALLY non-nil, sort alphabetically.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 If ORDER-GROUPS is `first' order groups before non-groups, if `last' order
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 groups after non-groups, if nil do not order groups at all."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 (sort (copy-sequence items)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 (lambda (a b)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 (let ((typea (nth 1 a)) (typeb (nth 1 b))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 (namea (symbol-name (nth 0 a))) (nameb (symbol-name (nth 0 b))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 (cond ((not order-groups)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 ;; Since we don't care about A and B order, maybe sort.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 (when sort-alphabetically
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 (string-lessp namea nameb)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 ((eq typea 'custom-group)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 ;; If B is also a group, maybe sort. Otherwise, order A and B.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 (if (eq typeb 'custom-group)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 (when sort-alphabetically
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 (string-lessp namea nameb))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 (eq order-groups 'first)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 ((eq typeb 'custom-group)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 ;; Since A cannot be a group, order A and B.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 (eq order-groups 'last))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 (sort-alphabetically
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 ;; Since A and B cannot be groups, sort.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 (string-lessp namea nameb)))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 ;;; Custom Mode Commands.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 (defvar custom-options nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 "Customization widgets in the current buffer.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 (defun Custom-set ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 "Set changes in all modified options."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 (let ((children custom-options))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 (mapc (lambda (child)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 (when (eq (widget-get child :custom-state) 'modified)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 (widget-apply child :custom-set)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 children)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 (defun Custom-save ()
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
558 "Set all modified options and save them."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 (interactive)
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
560 (let ((all-children custom-options)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
561 children)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 (mapc (lambda (child)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 (when (memq (widget-get child :custom-state) '(modified set))
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
564 (push child children)))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
565 all-children)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
566 (let ((the-children children)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
567 child)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
568 (while (setq child (pop the-children))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
569 (widget-apply child :custom-pre-save)))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
570 (custom-save-all)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
571 (let ((the-children children)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
572 child)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
573 (while (setq child (pop the-children))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
574 (widget-apply child :custom-post-save)))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
575 ))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 (defvar custom-reset-menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 '(("Current" . Custom-reset-current)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 ("Saved" . Custom-reset-saved)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 ("Standard Settings" . Custom-reset-standard))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 "Alist of actions for the `Reset' button.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 The key is a string containing the name of the action, the value is a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 lisp function taking the widget as an element which will be called
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 when the action is chosen.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 (defun custom-reset (event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 "Select item from reset menu."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 (let* ((completion-ignore-case t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 (answer (widget-choose "Reset to"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 custom-reset-menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 event)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 (if answer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 (funcall answer))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 (defun Custom-reset-current (&rest ignore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 "Reset all modified group members to their current value."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 (let ((children custom-options))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 (mapc (lambda (child)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 (when (eq (widget-get child :custom-state) 'modified)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 (widget-apply child :custom-reset-current)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 children)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 (defun Custom-reset-saved (&rest ignore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 "Reset all modified or set group members to their saved value."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 (let ((children custom-options))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 (mapc (lambda (child)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 (when (eq (widget-get child :custom-state) 'modified)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 (widget-apply child :custom-reset-saved)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 children)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 (defun Custom-reset-standard (&rest ignore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 "Reset all modified, set, or saved group members to their standard settings."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 (interactive)
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
616 (let ((all-children custom-options)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
617 children must-save)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 (mapc (lambda (child)
476
6a8b2ec80a19 [xemacs-hg @ 2001-04-18 18:18:46 by didierv]
didierv
parents: 456
diff changeset
619 (when (memq (widget-get child :custom-state) '(modified set saved))
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
620 (push child children)))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
621 all-children)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
622 (let ((the-children children)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
623 child)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
624 (while (setq child (pop the-children))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
625 (and (widget-apply child :custom-pre-reset-standard)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
626 (setq must-save t))))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
627 (and must-save (custom-save-all))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
628 (let ((the-children children)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
629 child)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
630 (while (setq child (pop the-children))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
631 (widget-apply child :custom-post-reset-standard)))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
632 ))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 ;;; The Customize Commands
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 (defun custom-prompt-variable (prompt-var prompt-val &optional comment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 "Prompt for a variable and a value and return them as a list.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 PROMPT-VAR is the prompt for the variable, and PROMPT-VAL is the
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
640 prompt for the value. A %s escape in PROMPT-VAL is replaced with
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
641 the name of the variable. A final colon is appended to both prompts.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 If the variable has a `variable-interactive' property, that is used as if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 it were the arg to `interactive' (which see) to interactively read the value.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 If the variable has a `custom-type' property, it must be a widget and the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 `:prompt-value' property of that widget will be used for reading the value.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 If optional COMMENT argument is non nil, also prompt for a comment and return
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 it as the third element in the list."
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
651 (let* ((var (read-variable (concat prompt-var ": ")))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 (minibuffer-help-form '(describe-variable var))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 (val
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 (let ((prop (get var 'variable-interactive))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 (type (get var 'custom-type))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 (prompt (format prompt-val var)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 (unless (listp type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 (setq type (list type)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 (cond (prop
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 ;; Use VAR's `variable-interactive' property
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 ;; as an interactive spec for prompting.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 (call-interactively (list 'lambda '(arg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 (list 'interactive prop)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 'arg)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 (type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 (widget-prompt-value type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 prompt
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 (if (boundp var)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 (symbol-value var))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 (not (boundp var))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 (t
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
672 (eval-minibuffer (concat prompt ": ")))))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 (if comment
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 (list var val
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 (read-string "Comment: " (get var 'variable-comment)))
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
676 (list var val))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 (defun customize-set-value (var val &optional comment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 "Set VARIABLE to VALUE. VALUE is a Lisp object.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 If VARIABLE has a `variable-interactive' property, that is used as if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 it were the arg to `interactive' (which see) to interactively read the value.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 If VARIABLE has a `custom-type' property, it must be a widget and the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 `:prompt-value' property of that widget will be used for reading the value.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 If given a prefix (or a COMMENT argument), also prompt for a comment."
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
689 (interactive (custom-prompt-variable "Set variable"
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
690 "Set value of %s"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 current-prefix-arg))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 (set var val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 (cond ((string= comment "")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 (put var 'variable-comment nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 (comment
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 (put var 'variable-comment comment))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 ;;;###autoload
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
700 (defun customize-set-variable (variable value &optional comment)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
701 "Set the default for VARIABLE to VALUE. VALUE is any Lisp object.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703 If VARIABLE has a `custom-set' property, that is used for setting
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 VARIABLE, otherwise `set-default' is used.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 The `customized-value' property of the VARIABLE will be set to a list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 with a quoted VALUE as its sole list member.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 If VARIABLE has a `variable-interactive' property, that is used as if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 it were the arg to `interactive' (which see) to interactively read the value.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 If VARIABLE has a `custom-type' property, it must be a widget and the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 `:prompt-value' property of that widget will be used for reading the value.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 If given a prefix (or a COMMENT argument), also prompt for a comment."
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
716 (interactive (custom-prompt-variable "Set variable"
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
717 "Set customized value of %s"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 current-prefix-arg))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
719 (funcall (or (get variable 'custom-set) 'set-default) variable value)
4744
17f7e9191c0b Rationalise duplicated functionality, #'custom-quote, #'quote-maybe.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4701
diff changeset
720 (put variable 'customized-value (list (quote-maybe value)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 (cond ((string= comment "")
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
722 (put variable 'variable-comment nil)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
723 (put variable 'customized-variable-comment nil))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 (comment
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
725 (put variable 'variable-comment comment)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
726 (put variable 'customized-variable-comment comment))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 ;;;###autoload
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
730 (defun customize-save-variable (variable value &optional comment)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 "Set the default for VARIABLE to VALUE, and save it for future sessions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 If VARIABLE has a `custom-set' property, that is used for setting
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 VARIABLE, otherwise `set-default' is used.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 The `customized-value' property of the VARIABLE will be set to a list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 with a quoted VALUE as its sole list member.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 If VARIABLE has a `variable-interactive' property, that is used as if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 it were the arg to `interactive' (which see) to interactively read the value.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 If VARIABLE has a `custom-type' property, it must be a widget and the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 `:prompt-value' property of that widget will be used for reading the value.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 If given a prefix (or a COMMENT argument), also prompt for a comment."
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
745 (interactive (custom-prompt-variable "Set and save variable"
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
746 "Set and save value of %s"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 current-prefix-arg))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
748 (funcall (or (get variable 'custom-set) 'set-default) variable value)
4744
17f7e9191c0b Rationalise duplicated functionality, #'custom-quote, #'quote-maybe.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4701
diff changeset
749 (put variable 'saved-value (list (quote-maybe value)))
17f7e9191c0b Rationalise duplicated functionality, #'custom-quote, #'quote-maybe.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4701
diff changeset
750 (custom-push-theme 'theme-value variable 'user 'set (list (quote-maybe value)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 (cond ((string= comment "")
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
752 (put variable 'variable-comment nil)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
753 (put variable 'saved-variable-comment nil))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 (comment
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
755 (put variable 'variable-comment comment)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
756 (put variable 'saved-variable-comment comment)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 (custom-save-all))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 (defun customize (group)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 "Select a customization buffer which you can use to set user options.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 User options are structured into \"groups\".
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 The default group is `Emacs'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764 (interactive (custom-group-prompt
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 "Customize group: (default emacs) "))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 (when (stringp group)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 (if (string-equal "" group)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 (setq group 'emacs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769 (setq group (intern group))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 (let ((name (format "*Customize Group: %s*"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 (custom-unlispify-tag-name group))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 (if (get-buffer name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 (switch-to-buffer name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 (custom-buffer-create (list (list group 'custom-group))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 (concat " for group "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 (custom-unlispify-tag-name group))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 (defalias 'customize-group 'customize)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 (defun customize-other-window (symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784 "Customize SYMBOL, which must be a customization group."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785 (interactive (custom-group-prompt
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786 "Customize group: (default emacs) "))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 (when (stringp symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788 (if (string-equal "" symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 (setq symbol 'emacs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790 (setq symbol (intern symbol))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 (custom-buffer-create-other-window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 (list (list symbol 'custom-group))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793 (format "*Customize Group: %s*" (custom-unlispify-tag-name symbol))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796 (defalias 'customize-group-other-window 'customize-other-window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799 (defalias 'customize-option 'customize-variable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 (defun customize-variable (symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803 "Customize SYMBOL, which must be a user option variable."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804 (interactive (custom-variable-prompt))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 (custom-buffer-create (list (list symbol 'custom-variable))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806 (format "*Customize Variable: %s*"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 (custom-unlispify-tag-name symbol))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 (defun customize-changed-options (since-version)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811 "Customize all user option variables whose default values changed recently.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 This means, in other words, variables defined with a `:version' keyword."
4289
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4257
diff changeset
813 (interactive
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4257
diff changeset
814 "sCustomize options changed, since version (default all versions): ")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 (if (equal since-version "")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816 (setq since-version nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817 (let ((found nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818 (mapatoms (lambda (symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 (and (boundp symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820 (let ((version (get symbol 'custom-version)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821 (and version
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822 (or (null since-version)
4289
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4257
diff changeset
823 (customize-version-lessp since-version
4434
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
824 version))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
825 (push (list symbol 'custom-variable) found))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826 (unless found
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827 (error "No user options have changed defaults %s"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828 (if since-version
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829 (format "since XEmacs %s" since-version)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 "in recent Emacs versions")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831 (custom-buffer-create (custom-sort-items found t nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832 "*Customize Changed Options*")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834 (defun customize-version-lessp (version1 version2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835 (let (major1 major2 minor1 minor2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836 (string-match "\\([0-9]+\\)[.]\\([0-9]+\\)" version1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837 (setq major1 (read (match-string 1 version1)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 (setq minor1 (read (match-string 2 version1)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839 (string-match "\\([0-9]+\\)[.]\\([0-9]+\\)" version2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840 (setq major2 (read (match-string 1 version2)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841 (setq minor2 (read (match-string 2 version2)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842 (or (< major1 major2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 (and (= major1 major2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844 (< minor1 minor2)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 (defalias 'customize-variable-other-window 'customize-option-other-window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 (defun customize-option-other-window (symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851 "Customize SYMBOL, which must be a user option variable.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 Show the buffer in another window, but don't select it."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853 (interactive (custom-variable-prompt))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854 (custom-buffer-create-other-window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855 (list (list symbol 'custom-variable))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856 (format "*Customize Option: %s*" (custom-unlispify-tag-name symbol))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857
4434
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
858
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
859 (defun custom-face-prompt ()
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
860 ;; Interactive call for `customize-face' and `customize-face-other-window'.
4628
877ad4697eea Fix typo in comment in cus-edit.el. <87vdqk5bqf.fsf@xemacs.org>
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4434
diff changeset
861 ;; See their docstrings for more information. Note that this call returns
877ad4697eea Fix typo in comment in cus-edit.el. <87vdqk5bqf.fsf@xemacs.org>
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4434
diff changeset
862 ;; a list of only one element. This is because the callers' second arg
877ad4697eea Fix typo in comment in cus-edit.el. <87vdqk5bqf.fsf@xemacs.org>
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4434
diff changeset
863 ;; AT-POINT is only used in interactive calls.
4434
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
864 (let ((faces (get-char-property (point) 'face)))
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
865 (if (or (null faces) (not current-prefix-arg))
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
866 ;; The default behavior, which is to prompt for all faces, is also
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
867 ;; used as a fall back when a prefix is given but there's no face
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
868 ;; under point:
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
869 (let ((choice (completing-read "Customize face: (default all) "
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
870 obarray 'find-face)))
5366
f00192e1cd49 Examining the result of #'length: `eql', not `=', it's better style & cheaper
Aidan Kehoe <kehoea@parhasard.net>
parents: 4806
diff changeset
871 (if (eql (length choice) 0)
4434
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
872 nil
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
873 (list (intern choice))))
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
874 (cond ((symbolp faces)
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
875 ;; Customize only this one:
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
876 (list (list faces)))
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
877 ((listp faces)
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
878 ;; Make a choice only amongst the faces under point:
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
879 (let ((choice (completing-read
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
880 "Customize face: (default all faces at point) "
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
881 (mapcar (lambda (face)
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
882 (list (symbol-name face) face))
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
883 faces)
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
884 nil t)))
5366
f00192e1cd49 Examining the result of #'length: `eql', not `=', it's better style & cheaper
Aidan Kehoe <kehoea@parhasard.net>
parents: 4806
diff changeset
885 (if (eql (length choice) 0)
4434
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
886 (list faces)
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
887 (list (intern choice)))))))))
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
888
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
889 (defun customize-face-1 (face custom-buffer-create-fn)
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
890 ;; Customize FACE in a buffer created with BUFFER-CREATE-FN.
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
891 ;; See the docstring of `customize-face' and `customize-face-other-window'
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
892 ;; for more information.
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
893 (cond ((null face)
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
894 (funcall custom-buffer-create-fn
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
895 (custom-sort-items
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
896 (mapcar (lambda (symbol)
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
897 (list symbol 'custom-face))
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
898 (face-list))
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
899 t nil)
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
900 "*Customize All Faces*"))
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
901 ((listp face)
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
902 (funcall custom-buffer-create-fn
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
903 (custom-sort-items
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
904 (mapcar (lambda (symbol)
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
905 (list symbol 'custom-face))
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
906 face)
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
907 t nil)
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
908 "*Customize Some Faces*"))
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
909 ((symbolp face)
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
910 (funcall custom-buffer-create-fn
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
911 (list (list face 'custom-face))
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
912 (format "*Customize Face: %s*"
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
913 (custom-unlispify-tag-name face))))
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
914 (t
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
915 (signal-error 'wrong-type-argument
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
916 '((or null listp symbolp) face)))))
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
917
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919 ;;;###autoload
4434
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
920 (defun customize-face (&optional face at-point)
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
921 "Open a customization buffer for FACE.
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
922 FACE should be either:
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
923 - nil, meaning to customize all faces,
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
924 - a list of symbols naming faces, meaning to customize only those,
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
925 - a symbol naming a face, meaning to customize this face only.
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
926
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
927 When called interactively, use a prefix (the AT-POINT argument) to
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
928 make a choice among the faces found at current position."
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
929 (interactive (custom-face-prompt))
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
930 (customize-face-1 face #'custom-buffer-create))
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
931
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
932 ;;;###autoload
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
933 (defun customize-face-other-window (&optional face at-point)
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
934 "Like `customize-face', but use another window."
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
935 (interactive (custom-face-prompt))
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
936 (customize-face-1 face #'custom-buffer-create-other-window))
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
937
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940 (defun customize-customized ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
941 "Customize all user options set since the last save in this session."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
942 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943 (let ((found nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944 (mapatoms (lambda (symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
945 (and (or (get symbol 'customized-face)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946 (get symbol 'customized-face-comment))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 (find-face symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948 (push (list symbol 'custom-face) found))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949 (and (or (get symbol 'customized-value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950 (get symbol 'customized-variable-comment))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951 (boundp symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952 (push (list symbol 'custom-variable) found))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
953 (if (not found)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954 (error "No customized user options")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 (custom-buffer-create (custom-sort-items found t nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 "*Customize Customized*"))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
958 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959 (defun customize-saved ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960 "Customize all already saved user options."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
961 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962 (let ((found nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963 (mapatoms (lambda (symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964 (and (or (get symbol 'saved-face)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
965 (get symbol 'saved-face-comment))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966 (find-face symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
967 (push (list symbol 'custom-face) found))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
968 (and (or (get symbol 'saved-value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969 (get symbol 'saved-variable-comment))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
970 (boundp symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971 (push (list symbol 'custom-variable) found))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972 (if (not found )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973 (error "No saved user options")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
974 (custom-buffer-create (custom-sort-items found t nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
975 "*Customize Saved*"))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
977 ;;;###autoload
1655
6f3d0f871934 [xemacs-hg @ 2003-08-31 01:28:00 by adrian]
adrian
parents: 848
diff changeset
978 (defalias 'apropos-customize 'customize-apropos)
6f3d0f871934 [xemacs-hg @ 2003-08-31 01:28:00 by adrian]
adrian
parents: 848
diff changeset
979
6f3d0f871934 [xemacs-hg @ 2003-08-31 01:28:00 by adrian]
adrian
parents: 848
diff changeset
980 ;;;###autoload
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
981 (defun customize-apropos (regexp &optional all)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
982 "Customize all user options matching REGEXP.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
983 If ALL is `options', include only options.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984 If ALL is `faces', include only faces.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985 If ALL is `groups', include only groups.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
986 If ALL is t (interactively, with prefix arg), include options which are not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
987 user-settable, as well as faces and groups."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988 (interactive "sCustomize regexp: \nP")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989 (let ((found nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990 (mapatoms (lambda (symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
991 (when (string-match regexp (symbol-name symbol))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
992 (when (and (not (memq all '(faces options)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993 (get symbol 'custom-group))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
994 (push (list symbol 'custom-group) found))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995 (when (and (not (memq all '(options groups)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996 (find-face symbol))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997 (push (list symbol 'custom-face) found))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998 (when (and (not (memq all '(groups faces)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999 (boundp symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1000 (or (get symbol 'saved-value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1001 (get symbol 'standard-value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1002 (if (memq all '(nil options))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003 (user-variable-p symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004 (get symbol 'variable-documentation))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005 (push (list symbol 'custom-variable) found)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006 (if (not found)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1007 (error "No matches")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008 (custom-buffer-create (custom-sort-items found t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009 custom-buffer-order-groups)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1010 "*Customize Apropos*"))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1011
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1012 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1013 (defun customize-apropos-options (regexp &optional arg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1014 "Customize all user options matching REGEXP.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1015 With prefix arg, include options which are not user-settable."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016 (interactive "sCustomize regexp: \nP")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017 (customize-apropos regexp (or arg 'options)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1018
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1019 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1020 (defun customize-apropos-faces (regexp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1021 "Customize all user faces matching REGEXP."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022 (interactive "sCustomize regexp: \n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1023 (customize-apropos regexp 'faces))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1024
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1026 (defun customize-apropos-groups (regexp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1027 "Customize all user groups matching REGEXP."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1028 (interactive "sCustomize regexp: \n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1029 (customize-apropos regexp 'groups))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1030
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1031
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032 ;;; Buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034 (defcustom custom-buffer-style 'links
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1035 "*Control the presentation style for customization buffers.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1036 The value should be a symbol, one of:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1037
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1038 brackets: groups nest within each other with big horizontal brackets.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1039 links: groups have links to subgroups."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1040 :type '(radio (const :tag "brackets: Groups nest within each others" brackets)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1041 (const :tag "links: Group have links to subgroups" links))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1042 :group 'custom-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1043
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1044 (defcustom custom-buffer-done-function 'kill-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1045 "*Function to be used to remove the buffer when the user is done with it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1046 Choices include `kill-buffer' (the default) and `bury-buffer'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1047 The function will be called with one argument, the buffer to remove."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1048 :type '(radio (function-item kill-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1049 (function-item bury-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1050 (function :tag "Other" nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1051 :group 'custom-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1053 (defcustom custom-buffer-indent 3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1054 "Number of spaces to indent nested groups."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055 :type 'integer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1056 :group 'custom-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1058 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059 (defun custom-buffer-create (options &optional name description)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060 "Create a buffer containing OPTIONS.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061 Optional NAME is the name of the buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1062 OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063 SYMBOL is a customization option, and WIDGET is a widget for editing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1064 that option."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1065 (unless name (setq name "*Customization*"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1066 (kill-buffer (get-buffer-create name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1067 (switch-to-buffer (get-buffer-create name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1068 (custom-buffer-create-internal options description))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1069
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1070 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071 (defun custom-buffer-create-other-window (options &optional name description)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1072 "Create a buffer containing OPTIONS.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1073 Optional NAME is the name of the buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1074 OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1075 SYMBOL is a customization option, and WIDGET is a widget for editing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1076 that option."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1077 (unless name (setq name "*Customization*"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1078 (kill-buffer (get-buffer-create name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1079 (let ((window (selected-window)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1080 (switch-to-buffer-other-window (get-buffer-create name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081 (custom-buffer-create-internal options description)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1082 (select-window window)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1083
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1084 (defcustom custom-reset-button-menu t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1085 "If non-nil, only show a single reset button in customize buffers.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1086 This button will have a menu with all three reset operations."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1087 :type 'boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1088 :group 'custom-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1089
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1090 (defconst custom-skip-messages 5)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1091
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1092 (defun Custom-buffer-done ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1093 "Remove current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1094 This works by calling the function specified by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1095 `custom-buffer-done-function'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1096 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1097 (funcall custom-buffer-done-function (current-buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1098
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1099 (defun custom-buffer-create-buttons ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1100 (message "Creating customization buttons...")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1101 (widget-insert "\nOperate on everything in this buffer:\n ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1102 (widget-create 'push-button
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1103 :tag "Set"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1104 :help-echo "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1105 Make your editing in this buffer take effect for this session"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1106 :action (lambda (widget &optional event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1107 (Custom-set)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1108 (widget-insert " ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109 (widget-create 'push-button
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1110 :tag "Save"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1111 :help-echo "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1112 Make your editing in this buffer take effect for future Emacs sessions"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1113 :action (lambda (widget &optional event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1114 (Custom-save)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1115 (if custom-reset-button-menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1116 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1117 (widget-insert " ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1118 (widget-create 'push-button
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1119 :tag "Reset"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1120 :tag-glyph '("reset-up" "reset-down")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1121 :help-echo "Show a menu with reset operations"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1122 :mouse-down-action (lambda (&rest junk) t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1123 :action (lambda (widget &optional event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1124 (custom-reset event))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1125 (widget-insert " ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1126 (widget-create 'push-button
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1127 :tag "Reset"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1128 :help-echo "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1129 Reset all edited text in this buffer to reflect current values"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1130 :action 'Custom-reset-current)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1131 (widget-insert " ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1132 (widget-create 'push-button
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1133 :tag "Reset to Saved"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1134 :help-echo "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1135 Reset all values in this buffer to their saved settings"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1136 :action 'Custom-reset-saved)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1137 (widget-insert " ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1138 (widget-create 'push-button
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1139 :tag "Reset to Standard"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1140 :help-echo "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1141 Reset all values in this buffer to their standard settings"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1142 :action 'Custom-reset-standard))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1143 (widget-insert " ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1144 (widget-create 'push-button
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1145 :tag "Done"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1146 :help-echo "Remove the buffer"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1147 :action (lambda (widget &optional event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1148 (Custom-buffer-done)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1149 (widget-insert "\n"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1150
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1151 (defcustom custom-novice t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1152 "If non-nil, show help message at top of customize buffers."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1153 :type 'boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1154 :group 'custom-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1155
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1156 (defcustom custom-display-global-buttons 'top
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1157 "If `nil' don't display the global buttons. If `top' display at the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1158 beginning of custom buffers. If `bottom', display at the end."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1159 :type '(choice (const top)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1160 (const bottom)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1161 (const :tag "don't" nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1162 :group 'custom-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1163
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1164 (defun custom-buffer-create-internal (options &optional description)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1165 (message "Creating customization buffer...")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1166 (custom-mode)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1167 (widget-insert "This is a customization buffer")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1168 (if description
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1169 (widget-insert description))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1170 (when custom-novice
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1171 (widget-insert ".\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1172 Type RET or click button2 on an active field to invoke its action.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1173 Invoke ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1174 (widget-create 'info-link
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1175 :tag "Help"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1176 :help-echo "Read the online help"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1177 "(XEmacs)Easy Customization")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1178 (widget-insert " for more information."))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1179 (widget-insert "\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1180 (if (equal custom-display-global-buttons 'top)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1181 (custom-buffer-create-buttons))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1182 (widget-insert "\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1183 (message "Creating customization items...")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1184 (setq custom-options
5366
f00192e1cd49 Examining the result of #'length: `eql', not `=', it's better style & cheaper
Aidan Kehoe <kehoea@parhasard.net>
parents: 4806
diff changeset
1185 (if (eql (length options) 1)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1186 (mapcar (lambda (entry)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1187 (widget-create (nth 1 entry)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1188 :documentation-shown t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1189 :custom-state 'unknown
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1190 :tag (custom-unlispify-tag-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1191 (nth 0 entry))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1192 :value (nth 0 entry)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1193 options)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1194 (let ((count 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1195 (length (length options)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1196 (mapcar (lambda (entry)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1197 (prog2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1198 (display-message
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1199 'progress
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1200 (format "Creating customization items %2d%%..."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1201 (/ (* 100.0 count) length)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1202 (widget-create (nth 1 entry)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1203 :tag (custom-unlispify-tag-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1204 (nth 0 entry))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1205 :value (nth 0 entry))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1206 (incf count)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1207 (unless (eq (preceding-char) ?\n)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1208 (widget-insert "\n"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1209 (widget-insert "\n")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1210 options))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1211 (unless (eq (preceding-char) ?\n)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1212 (widget-insert "\n"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1213 (if (equal custom-display-global-buttons 'bottom)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1214 (custom-buffer-create-buttons))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1215 (display-message 'progress
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1216 (format
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1217 "Creating customization items %2d%%...done" 100))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1218 (unless (eq custom-buffer-style 'tree)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1219 (mapc 'custom-magic-reset custom-options))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1220 (message "Creating customization setup...")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1221 (widget-setup)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1222 (goto-char (point-min))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1223 (message "Creating customization buffer...done"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1224
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1225
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1226 ;;; The Tree Browser.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1227
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1228 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1229 (defun customize-browse (&optional group)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1230 "Create a tree browser for the customize hierarchy."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1231 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1232 (unless group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1233 (setq group 'emacs))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1234 (let ((name "*Customize Browser*"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1235 (kill-buffer (get-buffer-create name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1236 (switch-to-buffer (get-buffer-create name)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1237 (custom-mode)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1238 (widget-insert "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1239 Square brackets show active fields; type RET or click button2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1240 on an active field to invoke its action.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1241 Invoke [+] below to expand a group, and [-] to collapse an expanded group.\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1242 (if custom-browse-only-groups
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1243 (widget-insert "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1244 Invoke the [Group] button below to edit that item in another window.\n\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1245 (widget-insert "Invoke the ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1246 (widget-create 'item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1247 :format "%t"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1248 :tag "[Group]"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1249 :tag-glyph "folder")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1250 (widget-insert ", ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1251 (widget-create 'item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1252 :format "%t"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1253 :tag "[Face]"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1254 :tag-glyph "face")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1255 (widget-insert ", and ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1256 (widget-create 'item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1257 :format "%t"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1258 :tag "[Option]"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1259 :tag-glyph "option")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1260 (widget-insert " buttons below to edit that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1261 item in another window.\n\n"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1262 (let ((custom-buffer-style 'tree))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1263 (widget-create 'custom-group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1264 :custom-last t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1265 :custom-state 'unknown
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1266 :tag (custom-unlispify-tag-name group)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1267 :value group))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1268 (widget-add-change)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1269 (goto-char (point-min)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1270
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1271 (define-widget 'custom-browse-visibility 'item
2118
e28998a020ec [xemacs-hg @ 2004-06-07 21:50:57 by adrian]
adrian
parents: 1655
diff changeset
1272 "Control visibility of items in the customize tree browser."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1273 :format "%[[%t]%]"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1274 :action 'custom-browse-visibility-action)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1275
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1276 (defun custom-browse-visibility-action (widget &rest ignore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1277 (let ((custom-buffer-style 'tree))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1278 (custom-toggle-parent widget)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1279
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1280 (define-widget 'custom-browse-group-tag 'push-button
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1281 "Show parent in other window when activated."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1282 :tag "Group"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1283 :tag-glyph "folder"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1284 :action 'custom-browse-group-tag-action)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1285
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1286 (defun custom-browse-group-tag-action (widget &rest ignore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1287 (let ((parent (widget-get widget :parent)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1288 (customize-group-other-window (widget-value parent))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1289
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1290 (define-widget 'custom-browse-variable-tag 'push-button
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1291 "Show parent in other window when activated."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1292 :tag "Option"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1293 :tag-glyph "option"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1294 :action 'custom-browse-variable-tag-action)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1295
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1296 (defun custom-browse-variable-tag-action (widget &rest ignore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1297 (let ((parent (widget-get widget :parent)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1298 (customize-variable-other-window (widget-value parent))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1299
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1300 (define-widget 'custom-browse-face-tag 'push-button
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1301 "Show parent in other window when activated."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1302 :tag "Face"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1303 :tag-glyph "face"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1304 :action 'custom-browse-face-tag-action)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1305
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1306 (defun custom-browse-face-tag-action (widget &rest ignore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1307 (let ((parent (widget-get widget :parent)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1308 (customize-face-other-window (widget-value parent))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1309
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1310 (defconst custom-browse-alist '((" " "space")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1311 (" | " "vertical")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1312 ("-\\ " "top")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1313 (" |-" "middle")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1314 (" `-" "bottom")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1315
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1316 (defun custom-browse-insert-prefix (prefix)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1317 "Insert PREFIX. On XEmacs convert it to line graphics."
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1318 ;; #### Unfinished.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1319 (if nil ; (string-match "XEmacs" emacs-version)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1320 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1321 (insert "*")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1322 (while (not (string-equal prefix ""))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1323 (let ((entry (substring prefix 0 3)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1324 (setq prefix (substring prefix 3))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1325 (let ((overlay (make-overlay (1- (point)) (point) nil t nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1326 (name (nth 1 (assoc entry custom-browse-alist))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1327 (overlay-put overlay 'end-glyph (widget-glyph-find name entry))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1328 (overlay-put overlay 'start-open t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1329 (overlay-put overlay 'end-open t)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1330 (insert prefix)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1331
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1332
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1333 ;;; Modification of Basic Widgets.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1334 ;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1335 ;; We add extra properties to the basic widgets needed here. This is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1336 ;; fine, as long as we are careful to stay within out own namespace.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1337 ;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1338 ;; We want simple widgets to be displayed by default, but complex
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1339 ;; widgets to be hidden.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1340
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1341 (widget-put (get 'item 'widget-type) :custom-show t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1342 (widget-put (get 'editable-field 'widget-type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1343 :custom-show (lambda (widget value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1344 ;; This used to call pp-to-string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1345 (let ((pp (widget-prettyprint-to-string value)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1346 (cond ((string-match "\n" pp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1347 nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1348 ((> (length pp) 40)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1349 nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1350 (t t)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1351 (widget-put (get 'menu-choice 'widget-type) :custom-show t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1352
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1353 ;;; The `custom-manual' Widget.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1354
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1355 (define-widget 'custom-manual 'info-link
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1356 "Link to the manual entry for this customization option."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1357 :tag "Manual")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1358
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1359 ;;; The `custom-magic' Widget.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1360
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1361 (defgroup custom-magic-faces nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1362 "Faces used by the magic button."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1363 :group 'custom-faces
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1364 :group 'custom-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1365
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1366 (defface custom-invalid-face '((((class color))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1367 (:foreground "yellow" :background "red"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1368 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1369 (:bold t :italic t :underline t)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1370 "Face used when the customize item is invalid."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1371 :group 'custom-magic-faces)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1372
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1373 (defface custom-rogue-face '((((class color))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1374 (:foreground "pink" :background "black"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1375 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1376 (:underline t)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1377 "Face used when the customize item is not defined for customization."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1378 :group 'custom-magic-faces)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1379
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1380 (defface custom-modified-face '((((class color))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1381 (:foreground "white" :background "blue"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1382 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1383 (:italic t :bold)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1384 "Face used when the customize item has been modified."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1385 :group 'custom-magic-faces)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1386
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1387 (defface custom-set-face '((((class color))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1388 (:foreground "blue" :background "white"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1389 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1390 (:italic t)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1391 "Face used when the customize item has been set."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1392 :group 'custom-magic-faces)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1393
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1394 (defface custom-changed-face '((((class color))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1395 (:foreground "white" :background "blue"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1396 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1397 (:italic t)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1398 "Face used when the customize item has been changed."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1399 :group 'custom-magic-faces)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1400
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1401 (defface custom-saved-face '((t (:underline t)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1402 "Face used when the customize item has been saved."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1403 :group 'custom-magic-faces)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1404
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1405 (defconst custom-magic-alist '((nil "#" underline "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1406 uninitialized, you should not see this.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1407 (unknown "?" italic "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1408 unknown, you should not see this.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1409 (hidden "-" default "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1410 hidden, invoke \"Show\" button in the previous line to show." "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1411 group now hidden, invoke the above \"Show\" button to show contents.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1412 (invalid "x" custom-invalid-face "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1413 the value displayed for this %c is invalid and cannot be set.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1414 (modified "*" custom-modified-face "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1415 you have edited the value as text, but you have not set the %c." "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1416 you have edited something in this group, but not set it.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1417 (set "+" custom-set-face "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1418 you have set this %c, but not saved it for future sessions." "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1419 something in this group has been set, but not saved.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1420 (changed ":" custom-changed-face "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1421 this %c has been changed outside the customize buffer." "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1422 something in this group has been changed outside customize.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1423 (saved "!" custom-saved-face "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1424 this %c has been set and saved." "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1425 something in this group has been set and saved.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1426 (rogue "@" custom-rogue-face "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1427 this %c has not been changed with customize." "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1428 something in this group is not prepared for customization.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1429 (standard " " nil "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1430 this %c is unchanged from its standard setting." "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1431 visible group members are all at standard settings."))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1432 "Alist of customize option states.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1433 Each entry is of the form (STATE MAGIC FACE ITEM-DESC [ GROUP-DESC ]), where
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1434
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1435 STATE is one of the following symbols:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1436
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1437 `nil'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1438 For internal use, should never occur.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1439 `unknown'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1440 For internal use, should never occur.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1441 `hidden'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1442 This item is not being displayed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1443 `invalid'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1444 This item is modified, but has an invalid form.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1445 `modified'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1446 This item is modified, and has a valid form.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1447 `set'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1448 This item has been set but not saved.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1449 `changed'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1450 The current value of this item has been changed temporarily.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1451 `saved'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1452 This item is marked for saving.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1453 `rogue'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1454 This item has no customization information.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1455 `standard'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1456 This item is unchanged from the standard setting.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1457
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1458 MAGIC is a string used to present that state.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1459
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1460 FACE is a face used to present the state.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1461
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1462 ITEM-DESC is a string describing the state for options.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1463
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1464 GROUP-DESC is a string describing the state for groups. If this is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1465 left out, ITEM-DESC will be used.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1466
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1467 The string %c in either description will be replaced with the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1468 category of the item. These are `group'. `option', and `face'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1469
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1470 The list should be sorted most significant first.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1471
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1472 (defcustom custom-magic-show 'long
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1473 "If non-nil, show textual description of the state.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1474 If `long', show a full-line description, not just one word."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1475 :type '(choice (const :tag "no" nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1476 (const short)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1477 (const long))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1478 :group 'custom-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1479
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1480 (defcustom custom-magic-show-hidden '(option face)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1481 "Control whether the State button is shown for hidden items.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1482 The value should be a list with the custom categories where the State
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1483 button should be visible. Possible categories are `group', `option',
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1484 and `face'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1485 :type '(set (const group) (const option) (const face))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1486 :group 'custom-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1487
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1488 (defcustom custom-magic-show-button nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1489 "Show a \"magic\" button indicating the state of each customization option."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1490 :type 'boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1491 :group 'custom-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1492
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1493 (define-widget 'custom-magic 'default
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1494 "Show and manipulate state for a customization option."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1495 :format "%v"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1496 :action 'widget-parent-action
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1497 :notify 'ignore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1498 :value-get 'ignore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1499 :value-create 'custom-magic-value-create
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1500 :value-delete 'widget-children-value-delete)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1501
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1502 (defun widget-magic-mouse-down-action (widget &optional event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1503 ;; Non-nil unless hidden.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1504 (not (eq (widget-get (widget-get (widget-get widget :parent) :parent)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1505 :custom-state)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1506 'hidden)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1507
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1508 (defun custom-magic-value-create (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1509 ;; Create compact status report for WIDGET.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1510 (let* ((parent (widget-get widget :parent))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1511 (state (widget-get parent :custom-state))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1512 (hidden (eq state 'hidden))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1513 (entry (assq state custom-magic-alist))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1514 (magic (nth 1 entry))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1515 (face (nth 2 entry))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1516 (category (widget-get parent :custom-category))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1517 (text (or (and (eq category 'group)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1518 (nth 4 entry))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1519 (nth 3 entry)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1520 (form (widget-get parent :custom-form))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1521 children)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1522 (while (string-match "\\`\\(.*\\)%c\\(.*\\)\\'" text)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1523 (setq text (concat (match-string 1 text)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1524 (symbol-name category)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1525 (match-string 2 text))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1526 (when (and custom-magic-show
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1527 (or (not hidden)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1528 (memq category custom-magic-show-hidden)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1529 (insert " ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1530 (when (and (eq category 'group)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1531 (not (and (eq custom-buffer-style 'links)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1532 (> (widget-get parent :custom-level) 1))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1533 (insert-char ?\ (* custom-buffer-indent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1534 (widget-get parent :custom-level))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1535 (push (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1536 widget 'choice-item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1537 :help-echo "Change the state of this item"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1538 :format (if hidden "%t" "%[%t%]")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1539 :button-prefix 'widget-push-button-prefix
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1540 :button-suffix 'widget-push-button-suffix
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1541 :mouse-down-action 'widget-magic-mouse-down-action
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1542 :tag "State"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1543 ;;:tag-glyph (or hidden '("state-up" "state-down"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1544 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1545 children)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1546 (insert ": ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1547 (let ((start (point)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1548 (if (eq custom-magic-show 'long)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1549 (insert text)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1550 (insert (symbol-name state)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1551 (cond ((eq form 'lisp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1552 (insert " (lisp)"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1553 ((eq form 'mismatch)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1554 (insert " (mismatch)")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1555 (put-text-property start (point) 'face 'custom-state-face))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1556 (insert "\n"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1557 (when (and (eq category 'group)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1558 (not (and (eq custom-buffer-style 'links)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1559 (> (widget-get parent :custom-level) 1))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1560 (insert-char ?\ (* custom-buffer-indent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1561 (widget-get parent :custom-level))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1562 (when custom-magic-show-button
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1563 (when custom-magic-show
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1564 (let ((indent (widget-get parent :indent)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1565 (when indent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1566 (insert-char ?\ indent))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1567 (push (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1568 widget 'choice-item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1569 :mouse-down-action 'widget-magic-mouse-down-action
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1570 :button-face face
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1571 :button-prefix ""
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1572 :button-suffix ""
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1573 :help-echo "Change the state"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1574 :format (if hidden "%t" "%[%t%]")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1575 :tag (if (memq form '(lisp mismatch))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1576 (concat "(" magic ")")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1577 (concat "[" magic "]")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1578 children)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1579 (insert " "))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1580 (widget-put widget :children children)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1581
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1582 (defun custom-magic-reset (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1583 "Redraw the :custom-magic property of WIDGET."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1584 (let ((magic (widget-get widget :custom-magic)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1585 (widget-value-set magic (widget-value magic))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1586
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1587 ;;; The `custom' Widget.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1588
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1589 (defface custom-button-face '((t (:bold t)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1590 "Face used for buttons in customization buffers."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1591 :group 'custom-faces)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1592
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1593 (defface custom-documentation-face nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1594 "Face used for documentation strings in customization buffers."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1595 :group 'custom-faces)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1596
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1597 (defface custom-state-face '((((class color)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1598 (background dark))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1599 (:foreground "lime green"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1600 (((class color)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1601 (background light))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1602 (:foreground "dark green"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1603 (t nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1604 "Face used for State descriptions in the customize buffer."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1605 :group 'custom-faces)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1606
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1607 (define-widget 'custom 'default
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1608 "Customize a user option."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1609 :format "%v"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1610 :convert-widget 'custom-convert-widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1611 :notify 'custom-notify
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1612 :custom-prefix ""
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1613 :custom-level 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1614 :custom-state 'hidden
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1615 :documentation-property 'widget-subclass-responsibility
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1616 :value-create 'widget-subclass-responsibility
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1617 :value-delete 'widget-children-value-delete
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1618 :value-get 'widget-value-value-get
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1619 :validate 'widget-children-validate
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1620 :match (lambda (widget value) (symbolp value)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1621
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1622 (defun custom-convert-widget (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1623 ;; Initialize :value and :tag from :args in WIDGET.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1624 (let ((args (widget-get widget :args)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1625 (when args
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1626 (widget-put widget :value (widget-apply widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1627 :value-to-internal (car args)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1628 (widget-put widget :tag (custom-unlispify-tag-name (car args)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1629 (widget-put widget :args nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1630 widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1631
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1632 (defun custom-notify (widget &rest args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1633 "Keep track of changes."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1634 (let ((state (widget-get widget :custom-state)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1635 (unless (eq state 'modified)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1636 (unless (memq state '(nil unknown hidden))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1637 (widget-put widget :custom-state 'modified))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1638 (custom-magic-reset widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1639 (apply 'widget-default-notify widget args))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1640
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1641 (defun custom-redraw (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1642 "Redraw WIDGET with current settings."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1643 (let ((line (count-lines (point-min) (point)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1644 (column (current-column))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1645 (pos (point))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1646 (from (marker-position (widget-get widget :from)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1647 (to (marker-position (widget-get widget :to))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1648 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1649 (widget-value-set widget (widget-value widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1650 (custom-redraw-magic widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1651 (when (and (>= pos from) (<= pos to))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1652 (condition-case nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1653 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1654 (if (> column 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1655 (goto-line line)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1656 (goto-line (1+ line)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1657 (move-to-column column))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1658 (error nil)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1659
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1660 (defun custom-redraw-magic (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1661 "Redraw WIDGET state with current settings."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1662 (while widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1663 (let ((magic (widget-get widget :custom-magic)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1664 (cond (magic
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1665 (widget-value-set magic (widget-value magic))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1666 (when (setq widget (widget-get widget :group))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1667 (custom-group-state-update widget)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1668 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1669 (setq widget nil)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1670 (widget-setup))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1671
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1672 (defun custom-show (widget value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1673 "Non-nil if WIDGET should be shown with VALUE by default."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1674 (let ((show (widget-get widget :custom-show)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1675 (cond ((null show)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1676 nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1677 ((eq t show)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1678 t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1679 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1680 (funcall show widget value)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1681
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1682 (defvar custom-load-recursion nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1683 "Hack to avoid recursive dependencies.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1684
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1685 (defun custom-load-symbol (symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1686 "Load all dependencies for SYMBOL."
5645
5d3bb1100832 Remove some utility functions from the global namespace, lisp/
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1687 (labels
5d3bb1100832 Remove some utility functions from the global namespace, lisp/
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1688 ((custom-load-symbol-1 (load)
5d3bb1100832 Remove some utility functions from the global namespace, lisp/
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1689 (cond ((symbolp load)
5d3bb1100832 Remove some utility functions from the global namespace, lisp/
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1690 (condition-case nil
5d3bb1100832 Remove some utility functions from the global namespace, lisp/
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1691 (require load)
5d3bb1100832 Remove some utility functions from the global namespace, lisp/
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1692 (error nil)))
5d3bb1100832 Remove some utility functions from the global namespace, lisp/
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1693 ;; Don't reload a file already loaded.
5d3bb1100832 Remove some utility functions from the global namespace, lisp/
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1694 ((and (boundp 'preloaded-file-list)
5d3bb1100832 Remove some utility functions from the global namespace, lisp/
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1695 (member load preloaded-file-list)))
5d3bb1100832 Remove some utility functions from the global namespace, lisp/
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1696 ((assoc load load-history))
5d3bb1100832 Remove some utility functions from the global namespace, lisp/
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1697 ((assoc (locate-library load) load-history))
5d3bb1100832 Remove some utility functions from the global namespace, lisp/
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1698 (t
5d3bb1100832 Remove some utility functions from the global namespace, lisp/
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1699 (condition-case nil
5d3bb1100832 Remove some utility functions from the global namespace, lisp/
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1700 ;; Without this, we would load cus-edit recursively.
5d3bb1100832 Remove some utility functions from the global namespace, lisp/
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1701 ;; We are still loading it when we call this,
5d3bb1100832 Remove some utility functions from the global namespace, lisp/
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1702 ;; and it is not in load-history yet.
5d3bb1100832 Remove some utility functions from the global namespace, lisp/
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1703 (or (equal load "cus-edit")
5d3bb1100832 Remove some utility functions from the global namespace, lisp/
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1704 (load-library load))
5d3bb1100832 Remove some utility functions from the global namespace, lisp/
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1705 (error nil))))))
5d3bb1100832 Remove some utility functions from the global namespace, lisp/
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1706 (unless custom-load-recursion
5d3bb1100832 Remove some utility functions from the global namespace, lisp/
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1707 (let ((custom-load-recursion t))
5d3bb1100832 Remove some utility functions from the global namespace, lisp/
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1708 (map nil #'custom-load-symbol-1 (get symbol 'custom-loads))))))
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1709
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1710 (defvar custom-already-loaded-custom-defines nil
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1711 "List of already-loaded `custom-defines' files.")
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1712 (defvar custom-define-current-source-file nil)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1713 (defvar custom-warn-when-reloading-necessary nil
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1714 "For package-debugging purposes: Warn when an error hit in custom-defines.el.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1715 When this happens, the file from which the defcustom or defgroup was taken
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1716 is loaded, and custom-defines.el is then reloaded. This works in most
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1717 cases, but may not be completely safe. It's better if the package itself
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1718 arranges for the necessary functions and variables to be available, using
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1719 \;;;###autoload declarations. When this variable is non-nil, warnings are
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1720 issued (with backtrace), to aid in tracking down the problems.")
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1721
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1722 (defun custom-load-custom-defines (symbol)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1723 "Load custom-defines for SYMBOL."
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1724 (unless custom-load-recursion
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1725 (let ((custom-load-recursion t)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1726 (loads (get symbol 'custom-loads))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1727 load)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1728 (while loads
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1729 (setq load (car loads)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1730 loads (cdr loads))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1731 (let* ((found (locate-library
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1732 (if (symbolp load) (symbol-name load) load)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1733 (dir (and found (file-name-directory found))))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1734 ;; If we find a custom-defines file, assume the package is smart
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1735 ;; enough to have put all its defcustoms and defgroups here, and
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1736 ;; load it instead of the file itself. Otherwise, do it the
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1737 ;; hard way.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1738 (if (and found (or (file-exists-p
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1739 (expand-file-name "custom-defines.elc" dir))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1740 (file-exists-p
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1741 (expand-file-name "custom-defines.el" dir))))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1742 (when (not (member dir custom-already-loaded-custom-defines))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1743 (push dir custom-already-loaded-custom-defines)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1744 (custom-load-custom-defines-1 dir))))))))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1745
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1746 (defun custom-load-custom-defines-1 (dir)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1747 ;; Actually load the custom-defines.el file in DIR.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1748
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1749 ;; If we get an error loading the custom-defines, it may be because of a
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1750 ;; reference to something (e.g. a constant) that hasn't yet been defined
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1751 ;; yet. Properly, these should have been marked, so they either go into
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1752 ;; the custom-defines.el file or are autoloaded. But not everyone is so
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1753 ;; careful, so for the moment we try to load the file that the
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1754 ;; error-generating defcustom came from, and then reload the
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1755 ;; custom-defines.el file. We might loop a number of times if we have
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1756 ;; various files that need loading. If at any point we get an error that
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1757 ;; can't be solved just by loading the appropriate file (e.g. we hit the
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1758 ;; same error as before, the file is already loaded, etc.) then we signal
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1759 ;; it as a real error.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1760 (let (source)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1761 ;; here's how this works: if we get an error loading custom-defines,
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1762 ;; the condition handler is called; if we need to reload, we
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1763 ;; `return-from', which throws out of the handler and returns nil from
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1764 ;; the `block', which continues the while statement, executing the
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1765 ;; `load' at the bottom of this function and then entering the block
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1766 ;; again. if the condition handler doesn't throw, but instead returns
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1767 ;; normally, `signal' will continue as if nothing happened, and end up
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1768 ;; signalling the error normally.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1769 (while
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1770 (not
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1771 (block custom-load
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1772 ;; Use call-with-condition-handler so the error can be seen
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1773 ;; with the stack intact.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1774 (call-with-condition-handler
4806
fd36a980d701 Use uninterned symbols in various information-hiding contexts.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4744
diff changeset
1775 ((macro
fd36a980d701 Use uninterned symbols in various information-hiding contexts.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4744
diff changeset
1776 . (lambda (lambda-expression)
fd36a980d701 Use uninterned symbols in various information-hiding contexts.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4744
diff changeset
1777 ;; Be more serious about information hiding here:
fd36a980d701 Use uninterned symbols in various information-hiding contexts.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4744
diff changeset
1778 (nsublis
fd36a980d701 Use uninterned symbols in various information-hiding contexts.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4744
diff changeset
1779 '((custom-load-handler-arg . #:custom-load-g9JBHiZHD))
fd36a980d701 Use uninterned symbols in various information-hiding contexts.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4744
diff changeset
1780 lambda-expression)))
fd36a980d701 Use uninterned symbols in various information-hiding contexts.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4744
diff changeset
1781 #'(lambda (custom-load-handler-arg)
fd36a980d701 Use uninterned symbols in various information-hiding contexts.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4744
diff changeset
1782 (when (and
fd36a980d701 Use uninterned symbols in various information-hiding contexts.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4744
diff changeset
1783 custom-define-current-source-file
fd36a980d701 Use uninterned symbols in various information-hiding contexts.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4744
diff changeset
1784 (progn
fd36a980d701 Use uninterned symbols in various information-hiding contexts.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4744
diff changeset
1785 (setq source (expand-file-name
fd36a980d701 Use uninterned symbols in various information-hiding contexts.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4744
diff changeset
1786 custom-define-current-source-file
fd36a980d701 Use uninterned symbols in various information-hiding contexts.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4744
diff changeset
1787 dir))
fd36a980d701 Use uninterned symbols in various information-hiding contexts.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4744
diff changeset
1788 (let ((nondir (file-name-nondirectory source)))
fd36a980d701 Use uninterned symbols in various information-hiding contexts.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4744
diff changeset
1789 (and (file-exists-p source)
fd36a980d701 Use uninterned symbols in various information-hiding contexts.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4744
diff changeset
1790 (not (assoc source load-history))
fd36a980d701 Use uninterned symbols in various information-hiding contexts.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4744
diff changeset
1791 (not (assoc nondir load-history))
fd36a980d701 Use uninterned symbols in various information-hiding contexts.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4744
diff changeset
1792 (not (and (boundp 'preloaded-file-list)
fd36a980d701 Use uninterned symbols in various information-hiding contexts.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4744
diff changeset
1793 (member nondir
fd36a980d701 Use uninterned symbols in various information-hiding contexts.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4744
diff changeset
1794 preloaded-file-list)))))))
fd36a980d701 Use uninterned symbols in various information-hiding contexts.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4744
diff changeset
1795 (if custom-warn-when-reloading-necessary
fd36a980d701 Use uninterned symbols in various information-hiding contexts.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4744
diff changeset
1796 (lwarn 'custom-defines 'warning
fd36a980d701 Use uninterned symbols in various information-hiding contexts.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4744
diff changeset
1797 "Error while loading custom-defines, fetching \
fd36a980d701 Use uninterned symbols in various information-hiding contexts.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4744
diff changeset
1798 source and reloading ...\n
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1799 Error: %s\n
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1800 Source file: %s\n\n
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1801 Backtrace follows:\n\n%s"
4806
fd36a980d701 Use uninterned symbols in various information-hiding contexts.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4744
diff changeset
1802 (error-message-string custom-load-handler-arg)
fd36a980d701 Use uninterned symbols in various information-hiding contexts.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4744
diff changeset
1803 source
fd36a980d701 Use uninterned symbols in various information-hiding contexts.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4744
diff changeset
1804 (backtrace-in-condition-handler-eliminating-handler
fd36a980d701 Use uninterned symbols in various information-hiding contexts.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4744
diff changeset
1805 'custom-load-handler-arg
fd36a980d701 Use uninterned symbols in various information-hiding contexts.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4744
diff changeset
1806 )))
fd36a980d701 Use uninterned symbols in various information-hiding contexts.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4744
diff changeset
1807 (return-from custom-load nil))))
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1808 #'(lambda ()
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1809 (load (expand-file-name "custom-defines" dir))))))
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
1810 ;; we get here only from the `return-from'; see above
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
1811 (load source))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1812
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1813 (defun custom-load-widget (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1814 "Load all dependencies for WIDGET."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1815 (custom-load-symbol (widget-value widget)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1816
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1817 (defun custom-unloaded-symbol-p (symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1818 "Return non-nil if the dependencies of SYMBOL has not yet been loaded."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1819 (let ((found nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1820 (loads (get symbol 'custom-loads))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1821 load)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1822 (while loads
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1823 (setq load (car loads)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1824 loads (cdr loads))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1825 (cond ((symbolp load)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1826 (unless (featurep load)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1827 (setq found t)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1828 ((assoc load load-history))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1829 ((assoc (locate-library load) load-history)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1830 ;; #### WTF???
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1831 (message nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1832 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1833 (setq found t))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1834 found))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1835
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1836 (defun custom-unloaded-widget-p (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1837 "Return non-nil if the dependencies of WIDGET has not yet been loaded."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1838 (custom-unloaded-symbol-p (widget-value widget)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1839
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1840 (defun custom-toggle-hide (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1841 "Toggle visibility of WIDGET."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1842 (custom-load-widget widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1843 (let ((state (widget-get widget :custom-state)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1844 (cond ((memq state '(invalid modified))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1845 (error "There are unset changes"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1846 ((eq state 'hidden)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1847 (widget-put widget :custom-state 'unknown))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1848 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1849 (widget-put widget :documentation-shown nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1850 (widget-put widget :custom-state 'hidden)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1851 (custom-redraw widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1852 (widget-setup)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1853
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1854 (defun custom-toggle-parent (widget &rest ignore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1855 "Toggle visibility of parent of WIDGET."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1856 (custom-toggle-hide (widget-get widget :parent)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1857
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1858 (defun custom-add-see-also (widget &optional prefix)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1859 "Add `See also ...' to WIDGET if there are any links.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1860 Insert PREFIX first if non-nil."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1861 (let* ((symbol (widget-get widget :value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1862 (links (get symbol 'custom-links))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1863 (many (> (length links) 2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1864 (buttons (widget-get widget :buttons))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1865 (indent (widget-get widget :indent)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1866 (when links
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1867 (when indent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1868 (insert-char ?\ indent))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1869 (when prefix
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1870 (insert prefix))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1871 (insert "See also ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1872 (while links
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1873 (push (widget-create-child-and-convert widget (car links))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1874 buttons)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1875 (setq links (cdr links))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1876 (cond ((null links)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1877 (insert ".\n"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1878 ((null (cdr links))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1879 (if many
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1880 (insert ", and ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1881 (insert " and ")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1882 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1883 (insert ", "))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1884 (widget-put widget :buttons buttons))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1885
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1886 (defun custom-add-parent-links (widget &optional initial-string)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1887 "Add \"Parent groups: ...\" to WIDGET if the group has parents.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1888 The value if non-nil if any parents were found.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1889 If INITIAL-STRING is non-nil, use that rather than \"Parent groups:\"."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1890 (let ((name (widget-value widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1891 (type (widget-type widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1892 (buttons (widget-get widget :buttons))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1893 (start (point))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1894 found)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1895 (insert (or initial-string "Parent groups:"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1896 (maphash (lambda (group ignore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1897 (let ((entry (assq name (get group 'custom-group))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1898 (when (eq (nth 1 entry) type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1899 (insert " ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1900 (push (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1901 widget 'custom-group-link
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1902 :tag (custom-unlispify-tag-name group)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1903 group)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1904 buttons)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1905 (setq found t))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1906 custom-group-hash-table)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1907 (widget-put widget :buttons buttons)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1908 (if found
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1909 (insert "\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1910 (delete-region start (point)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1911 found))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1912
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1913 ;;; The `custom-comment' Widget.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1914
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1915 ;; like the editable field
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1916 (defface custom-comment-face '((((class grayscale color)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1917 (background light))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1918 (:background "gray85"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1919 (((class grayscale color)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1920 (background dark))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1921 (:background "dim gray"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1922 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1923 (:italic t)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1924 "Face used for comments on variables or faces"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1925 :group 'custom-faces)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1926
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1927 ;; like font-lock-comment-face
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1928 (defface custom-comment-tag-face
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1929 '((((class color) (background dark)) (:foreground "gray80"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1930 (((class color) (background light)) (:foreground "blue4"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1931 (((class grayscale) (background light))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1932 (:foreground "DimGray" :bold t :italic t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1933 (((class grayscale) (background dark))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1934 (:foreground "LightGray" :bold t :italic t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1935 (t (:bold t)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1936 "Face used for variables or faces comment tags"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1937 :group 'custom-faces)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1938
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1939 (define-widget 'custom-comment 'string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1940 "User comment"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1941 :tag "Comment"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1942 :help-echo "Edit a comment here"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1943 :sample-face 'custom-comment-tag-face
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1944 :value-face 'custom-comment-face
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1945 :value-set 'custom-comment-value-set
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1946 :create 'custom-comment-create
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1947 :delete 'custom-comment-delete)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1948
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1949 (defun custom-comment-create (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1950 (let (ext)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1951 (widget-default-create widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1952 (widget-put widget :comment-extent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1953 (setq ext (make-extent (widget-get widget :from)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1954 (widget-get widget :to))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1955 (set-extent-property ext 'start-open t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1956 (when (equal (widget-get widget :value) "")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1957 (set-extent-property ext 'invisible t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1958 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1959
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1960 (defun custom-comment-delete (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1961 (widget-default-delete widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1962 (delete-extent (widget-get widget :comment-extent)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1963
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1964 (defun custom-comment-value-set (widget value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1965 (widget-default-value-set widget value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1966 (if (equal value "")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1967 (set-extent-property (widget-get widget :comment-extent)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1968 'invisible t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1969 (set-extent-property (widget-get widget :comment-extent)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1970 'invisible nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1971
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1972 ;; Those functions are for the menu. WIDGET is NOT the comment widget. It's
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1973 ;; the global custom one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1974 (defun custom-comment-show (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1975 (set-extent-property
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1976 (widget-get (widget-get widget :comment-widget) :comment-extent)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1977 'invisible nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1978
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1979 (defun custom-comment-invisible-p (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1980 (extent-property
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1981 (widget-get (widget-get widget :comment-widget) :comment-extent)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1982 'invisible))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1983
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1984 ;;; The `custom-variable' Widget.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1985
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1986 (defface custom-variable-tag-face '((((class color)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1987 (background dark))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1988 (:foreground "light blue" :underline t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1989 (((class color)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1990 (background light))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1991 (:foreground "blue" :underline t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1992 (t (:underline t)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1993 "Face used for unpushable variable tags."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1994 :group 'custom-faces)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1995
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1996 (defface custom-variable-button-face '((t (:underline t :bold t)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1997 "Face used for pushable variable tags."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1998 :group 'custom-faces)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1999
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2000 (defcustom custom-variable-default-form 'edit
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2001 "Default form of displaying variable values."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2002 :type '(choice (const edit)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2003 (const lisp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2004 :group 'custom-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2005
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2006 (define-widget 'custom-variable 'custom
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2007 "Customize variable."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2008 :format "%v"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2009 :help-echo "Set or reset this variable"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2010 :documentation-property 'variable-documentation
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2011 :custom-category 'option
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2012 :custom-state nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2013 :custom-menu 'custom-variable-menu-create
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2014 :custom-form nil ; defaults to value of `custom-variable-default-form'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2015 :value-create 'custom-variable-value-create
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2016 :action 'custom-variable-action
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2017 :custom-set 'custom-variable-set
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2018 :custom-pre-save 'custom-variable-pre-save
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2019 :custom-save 'custom-variable-save
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2020 :custom-post-save 'custom-variable-post-save
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2021 :custom-reset-current 'custom-redraw
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2022 :custom-reset-saved 'custom-variable-reset-saved
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2023 :custom-pre-reset-standard 'custom-variable-pre-reset-standard
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2024 :custom-reset-standard 'custom-variable-reset-standard
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2025 :custom-post-reset-standard 'custom-variable-post-reset-standard)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2026
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2027 (defun custom-variable-type (symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2028 "Return a widget suitable for editing the value of SYMBOL.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2029 If SYMBOL has a `custom-type' property, use that.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2030 Otherwise, look up symbol in `custom-guess-type-alist'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2031 (let* ((type (or (get symbol 'custom-type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2032 (and (not (get symbol 'standard-value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2033 (custom-guess-type symbol))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2034 'sexp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2035 (options (get symbol 'custom-options))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2036 (tmp (if (listp type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2037 (copy-sequence type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2038 (list type))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2039 (when options
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2040 (widget-put tmp :options options))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2041 tmp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2042
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2043 (defun custom-variable-value-create (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2044 "Here is where you edit the variables value."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2045 (custom-load-widget widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2046 (unless (widget-get widget :custom-form)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2047 (widget-put widget :custom-form custom-variable-default-form))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2048 (let* ((buttons (widget-get widget :buttons))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2049 (children (widget-get widget :children))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2050 (form (widget-get widget :custom-form))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2051 (state (widget-get widget :custom-state))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2052 (symbol (widget-get widget :value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2053 (tag (widget-get widget :tag))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2054 (type (custom-variable-type symbol))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2055 (conv (widget-convert type))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2056 (get (or (get symbol 'custom-get) 'default-value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2057 (prefix (widget-get widget :custom-prefix))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2058 (last (widget-get widget :custom-last))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2059 (value (if (default-boundp symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2060 (funcall get symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2061 (widget-get conv :value))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2062 ;; If the widget is new, the child determine whether it is hidden.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2063 (cond (state)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2064 ((custom-show type value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2065 (setq state 'unknown))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2066 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2067 (setq state 'hidden)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2068 ;; If we don't know the state, see if we need to edit it in lisp form.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2069 (when (eq state 'unknown)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2070 (unless (widget-apply conv :match value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2071 ;; (widget-apply (widget-convert type) :match value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2072 (setq form 'mismatch)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2073 ;; Now we can create the child widget.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2074 (cond ((eq custom-buffer-style 'tree)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2075 (insert prefix (if last " `--- " " |--- "))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2076 (push (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2077 widget 'custom-browse-variable-tag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2078 buttons)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2079 (insert " " tag "\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2080 (widget-put widget :buttons buttons))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2081 ((eq state 'hidden)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2082 ;; Indicate hidden value.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2083 (push (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2084 widget 'item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2085 :format "%{%t%}: "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2086 :sample-face 'custom-variable-tag-face
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2087 :tag tag
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2088 :parent widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2089 buttons)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2090 (push (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2091 widget 'visibility
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2092 :help-echo "Show the value of this option"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2093 :action 'custom-toggle-parent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2094 nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2095 buttons))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2096 ((memq form '(lisp mismatch))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2097 ;; In lisp mode edit the saved value when possible.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2098 (let* ((value (cond ((get symbol 'saved-value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2099 (car (get symbol 'saved-value)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2100 ((get symbol 'standard-value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2101 (car (get symbol 'standard-value)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2102 ((default-boundp symbol)
4744
17f7e9191c0b Rationalise duplicated functionality, #'custom-quote, #'quote-maybe.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4701
diff changeset
2103 (quote-maybe (funcall get symbol)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2104 (t
4744
17f7e9191c0b Rationalise duplicated functionality, #'custom-quote, #'quote-maybe.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4701
diff changeset
2105 (quote-maybe (widget-get conv :value))))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2106 (insert (symbol-name symbol) ": ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2107 (push (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2108 widget 'visibility
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2109 :help-echo "Hide the value of this option"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2110 :action 'custom-toggle-parent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2111 t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2112 buttons)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2113 (insert " ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2114 (push (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2115 widget 'sexp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2116 :button-face 'custom-variable-button-face
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2117 :format "%v"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2118 :tag (symbol-name symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2119 :parent widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2120 :value value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2121 children)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2122 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2123 ;; Edit mode.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2124 (let* ((format (widget-get type :format))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2125 tag-format value-format)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2126 (while (not (string-match ":" format))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2127 (setq format (signal 'error (list "Bad format" format))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2128 (setq tag-format (substring format 0 (match-end 0)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2129 (setq value-format (substring format (match-end 0)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2130 (push (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2131 widget 'item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2132 :format tag-format
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2133 :action 'custom-tag-action
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2134 :help-echo "Change value of this option"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2135 :mouse-down-action 'custom-tag-mouse-down-action
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2136 :button-face 'custom-variable-button-face
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2137 :sample-face 'custom-variable-tag-face
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2138 tag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2139 buttons)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2140 (insert " ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2141 (push (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2142 widget 'visibility
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2143 :help-echo "Hide the value of this option"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2144 :action 'custom-toggle-parent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2145 t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2146 buttons)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2147 (push (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2148 widget type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2149 :format value-format
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2150 :value value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2151 children))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2152 (unless (eq custom-buffer-style 'tree)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2153 (unless (eq (preceding-char) ?\n)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2154 (widget-insert "\n"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2155 ;; Create the magic button.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2156 (let ((magic (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2157 widget 'custom-magic nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2158 (widget-put widget :custom-magic magic)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2159 (push magic buttons))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2160 ;; Insert documentation.
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2161 ;; #### NOTE: this is ugly!!!! I need to do update the :buttons property
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2162 ;; before the call to `widget-default-format-handler'. Otherwise, I
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2163 ;; lose my current `buttons'. This function shouldn't be called like
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2164 ;; this anyway. The doc string widget should be added like the others.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2165 ;; --dv
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2166 (widget-put widget :buttons buttons)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2167 (widget-default-format-handler widget ?h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2168 ;; The comment field
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2169 (unless (eq state 'hidden)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2170 (let* ((comment (get symbol 'variable-comment))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2171 (comment-widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2172 (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2173 widget 'custom-comment
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2174 :parent widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2175 :value (or comment ""))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2176 (widget-put widget :comment-widget comment-widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2177 ;; Don't push it !!! Custom assumes that the first child is the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2178 ;; value one.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2179 (setq children (append children (list comment-widget)))))
2118
e28998a020ec [xemacs-hg @ 2004-06-07 21:50:57 by adrian]
adrian
parents: 1655
diff changeset
2180 ;; Update the rest of the properties.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2181 (widget-put widget :custom-form form)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2182 (widget-put widget :children children)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2183 ;; Now update the state.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2184 (if (eq state 'hidden)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2185 (widget-put widget :custom-state state)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2186 (custom-variable-state-set widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2187 ;; See also.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2188 (unless (eq state 'hidden)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2189 (when (eq (widget-get widget :custom-level) 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2190 (custom-add-parent-links widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2191 (custom-add-see-also widget)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2192
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2193 (defun custom-tag-action (widget &rest args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2194 "Pass :action to first child of WIDGET's parent."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2195 (apply 'widget-apply (car (widget-get (widget-get widget :parent) :children))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2196 :action args))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2197
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2198 (defun custom-tag-mouse-down-action (widget &rest args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2199 "Pass :mouse-down-action to first child of WIDGET's parent."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2200 (apply 'widget-apply (car (widget-get (widget-get widget :parent) :children))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2201 :mouse-down-action args))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2202
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2203 (defun custom-variable-state-set (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2204 "Set the state of WIDGET."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2205 (let* ((symbol (widget-value widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2206 (get (or (get symbol 'custom-get) 'default-value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2207 (value (if (default-boundp symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2208 (funcall get symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2209 (widget-get widget :value)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2210 (comment (get symbol 'variable-comment))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2211 tmp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2212 temp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2213 (state (cond ((progn (setq tmp (get symbol 'customized-value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2214 (setq temp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2215 (get symbol 'customized-variable-comment))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2216 (or tmp temp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2217 (if (condition-case nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2218 (and (equal value (eval (car tmp)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2219 (equal comment temp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2220 (error nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2221 'set
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2222 'changed))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2223 ((progn (setq tmp (get symbol 'saved-value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2224 (setq temp (get symbol 'saved-variable-comment))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2225 (or tmp temp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2226 (if (condition-case nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2227 (and (equal value (eval (car tmp)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2228 (equal comment temp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2229 (error nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2230 'saved
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2231 'changed))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2232 ((setq tmp (get symbol 'standard-value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2233 (if (condition-case nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2234 (and (equal value (eval (car tmp)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2235 (equal comment nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2236 (error nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2237 'standard
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2238 'changed))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2239 (t 'rogue))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2240 (widget-put widget :custom-state state)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2241
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2242 (defvar custom-variable-menu
4289
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4257
diff changeset
2243 `(("Set for Current Session" custom-variable-set
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4257
diff changeset
2244 ,#'(lambda (widget)
4434
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
2245 (eq (widget-get widget :custom-state) 'modified)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2246 ("Save for Future Sessions" custom-variable-save
4289
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4257
diff changeset
2247 ,#'(lambda (widget)
4434
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
2248 (memq (widget-get widget :custom-state)
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
2249 '(modified set changed rogue))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2250 ("Reset to Current" custom-redraw
4289
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4257
diff changeset
2251 ,#'(lambda (widget)
4434
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
2252 (and (default-boundp (widget-value widget))
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
2253 (memq (widget-get widget :custom-state) '(modified changed)))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2254 ("Reset to Saved" custom-variable-reset-saved
4289
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4257
diff changeset
2255 ,#'(lambda (widget)
4434
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
2256 (and (or (get (widget-value widget) 'saved-value)
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
2257 (get (widget-value widget) 'saved-variable-comment))
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
2258 (memq (widget-get widget :custom-state)
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
2259 '(modified set changed rogue)))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2260 ("Reset to Standard Settings" custom-variable-reset-standard
4289
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4257
diff changeset
2261 ,#'(lambda (widget)
4434
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
2262 (and (get (widget-value widget) 'standard-value)
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
2263 (memq (widget-get widget :custom-state)
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
2264 '(modified set changed saved rogue)))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2265 ("---" ignore ignore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2266 ("Add Comment" custom-comment-show custom-comment-invisible-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2267 ("---" ignore ignore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2268 ("Don't show as Lisp expression" custom-variable-edit
4289
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4257
diff changeset
2269 ,#'(lambda (widget)
4434
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
2270 (eq (widget-get widget :custom-form) 'lisp)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2271 ("Show as Lisp expression" custom-variable-edit-lisp
4289
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4257
diff changeset
2272 ,#'(lambda (widget)
4434
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
2273 (eq (widget-get widget :custom-form) 'edit))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2274 "Alist of actions for the `custom-variable' widget.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2275 Each entry has the form (NAME ACTION FILTER) where NAME is the name of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2276 the menu entry, ACTION is the function to call on the widget when the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2277 menu is selected, and FILTER is a predicate which takes a `custom-variable'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2278 widget as an argument, and returns non-nil if ACTION is valid on that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2279 widget. If FILTER is nil, ACTION is always valid.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2280
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2281 (defun custom-variable-action (widget &optional event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2282 "Show the menu for `custom-variable' WIDGET.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2283 Optional EVENT is the location for the menu."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2284 (if (eq (widget-get widget :custom-state) 'hidden)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2285 (custom-toggle-hide widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2286 (unless (eq (widget-get widget :custom-state) 'modified)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2287 (custom-variable-state-set widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2288 ;; Redrawing magic also depresses the state glyph.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2289 ;(custom-redraw-magic widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2290 (let* ((completion-ignore-case t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2291 (answer (widget-choose (concat "Operation on "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2292 (custom-unlispify-tag-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2293 (widget-get widget :value)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2294 (custom-menu-filter custom-variable-menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2295 widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2296 event)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2297 (if answer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2298 (funcall answer widget)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2299
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2300 (defun custom-variable-edit (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2301 "Edit value of WIDGET."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2302 (widget-put widget :custom-state 'unknown)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2303 (widget-put widget :custom-form 'edit)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2304 (custom-redraw widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2305
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2306 (defun custom-variable-edit-lisp (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2307 "Edit the lisp representation of the value of WIDGET."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2308 (widget-put widget :custom-state 'unknown)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2309 (widget-put widget :custom-form 'lisp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2310 (custom-redraw widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2311
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2312 (defun custom-variable-set (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2313 "Set the current value for the variable being edited by WIDGET."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2314 (let* ((form (widget-get widget :custom-form))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2315 (state (widget-get widget :custom-state))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2316 (child (car (widget-get widget :children)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2317 (symbol (widget-value widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2318 (set (or (get symbol 'custom-set) 'set-default))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2319 (comment-widget (widget-get widget :comment-widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2320 (comment (widget-value comment-widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2321 val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2322 (cond ((eq state 'hidden)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2323 (error "Cannot set hidden variable"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2324 ((setq val (widget-apply child :validate))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2325 (goto-char (widget-get val :from))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2326 (error "%s" (widget-get val :error)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2327 ((memq form '(lisp mismatch))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2328 (when (equal comment "")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2329 (setq comment nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2330 ;; Make the comment invisible by hand if it's empty
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2331 (set-extent-property (widget-get comment-widget :comment-extent)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2332 'invisible t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2333 (funcall set symbol (eval (setq val (widget-value child))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2334 (put symbol 'customized-value (list val))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2335 (put symbol 'variable-comment comment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2336 (put symbol 'customized-variable-comment comment))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2337 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2338 (when (equal comment "")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2339 (setq comment nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2340 ;; Make the comment invisible by hand if it's empty
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2341 (set-extent-property (widget-get comment-widget :comment-extent)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2342 'invisible t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2343 (funcall set symbol (setq val (widget-value child)))
4744
17f7e9191c0b Rationalise duplicated functionality, #'custom-quote, #'quote-maybe.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4701
diff changeset
2344 (put symbol 'customized-value (list (quote-maybe val)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2345 (put symbol 'variable-comment comment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2346 (put symbol 'customized-variable-comment comment)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2347 (custom-variable-state-set widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2348 (custom-redraw-magic widget)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2349
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2350 (defun custom-variable-pre-save (widget)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2351 "Prepare for saving the value for the variable being edited by WIDGET."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2352 (let* ((form (widget-get widget :custom-form))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2353 (state (widget-get widget :custom-state))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2354 (child (car (widget-get widget :children)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2355 (symbol (widget-value widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2356 (set (or (get symbol 'custom-set) 'set-default))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2357 (comment-widget (widget-get widget :comment-widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2358 (comment (widget-value comment-widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2359 val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2360 (cond ((eq state 'hidden)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2361 (error "Cannot set hidden variable"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2362 ((setq val (widget-apply child :validate))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2363 (goto-char (widget-get val :from))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2364 (error "%s" (widget-get val :error)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2365 ((memq form '(lisp mismatch))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2366 (when (equal comment "")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2367 (setq comment nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2368 ;; Make the comment invisible by hand if it's empty
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2369 (set-extent-property (widget-get comment-widget :comment-extent)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2370 'invisible t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2371 (put symbol 'saved-value (list (widget-value child)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2372 (custom-push-theme 'theme-value symbol 'user
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2373 'set (list (widget-value child)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2374 (funcall set symbol (eval (widget-value child)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2375 (put symbol 'variable-comment comment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2376 (put symbol 'saved-variable-comment comment))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2377 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2378 (when (equal comment "")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2379 (setq comment nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2380 ;; Make the comment invisible by hand if it's empty
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2381 (set-extent-property (widget-get comment-widget :comment-extent)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2382 'invisible t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2383 (put symbol
4744
17f7e9191c0b Rationalise duplicated functionality, #'custom-quote, #'quote-maybe.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4701
diff changeset
2384 'saved-value (list (quote-maybe (widget-value
17f7e9191c0b Rationalise duplicated functionality, #'custom-quote, #'quote-maybe.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4701
diff changeset
2385 child))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2386 (custom-push-theme 'theme-value symbol 'user
4744
17f7e9191c0b Rationalise duplicated functionality, #'custom-quote, #'quote-maybe.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4701
diff changeset
2387 'set (list (quote-maybe (widget-value
17f7e9191c0b Rationalise duplicated functionality, #'custom-quote, #'quote-maybe.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4701
diff changeset
2388 child))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2389 (funcall set symbol (widget-value child))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2390 (put symbol 'variable-comment comment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2391 (put symbol 'saved-variable-comment comment)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2392 (put symbol 'customized-value nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2393 (put symbol 'customized-variable-comment nil)
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2394 ))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2395
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2396 (defun custom-variable-post-save (widget)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2397 "Finish saving the variable being edited by WIDGET."
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2398 (custom-variable-state-set widget)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2399 (custom-redraw-magic widget))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2400
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2401 (defun custom-variable-save (widget)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2402 "Set and save the value for the variable being edited by WIDGET."
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2403 (custom-variable-pre-save widget)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2404 (custom-save-all)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2405 (custom-variable-post-save widget))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2406
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2407 (defun custom-variable-reset-saved (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2408 "Restore the saved value for the variable being edited by WIDGET."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2409 (let* ((symbol (widget-value widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2410 (set (or (get symbol 'custom-set) 'set-default))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2411 (value (get symbol 'saved-value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2412 (comment (get symbol 'saved-variable-comment)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2413 (cond ((or value comment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2414 (put symbol 'variable-comment comment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2415 (condition-case nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2416 (funcall set symbol (eval (car value)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2417 (error nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2418 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2419 (signal 'error (list "No saved value for variable" symbol))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2420 (put symbol 'customized-value nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2421 (put symbol 'customized-variable-comment nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2422 (widget-put widget :custom-state 'unknown)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2423 ;; This call will possibly make the comment invisible
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2424 (custom-redraw widget)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2425
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2426 ;; This function returns non nil if we need to re-save the options --dv.
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2427 (defun custom-variable-pre-reset-standard (widget)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2428 "Prepare for restoring the variable being edited by WIDGET to its
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2429 standard setting."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2430 (let* ((symbol (widget-value widget))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2431 (set (or (get symbol 'custom-set) 'set-default)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2432 (if (get symbol 'standard-value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2433 (funcall set symbol (eval (car (get symbol 'standard-value))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2434 (signal 'error (list "No standard setting known for variable" symbol)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2435 (put symbol 'variable-comment nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2436 (put symbol 'customized-value nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2437 (put symbol 'customized-variable-comment nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2438 (when (or (get symbol 'saved-value) (get symbol 'saved-variable-comment))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2439 (put symbol 'saved-value nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2440 (custom-push-theme 'theme-value symbol 'user 'reset 'standard)
5384
3889ef128488 Fix misspelled words, and some grammar, across the entire source tree.
Jerry James <james@xemacs.org>
parents: 5366
diff changeset
2441 ;; As a special optimization we do not (explicitly)
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2442 ;; save resets to standard when no theme sets the value.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2443 (if (null (cdr (get symbol 'theme-value)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2444 (put symbol 'theme-value nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2445 (put symbol 'saved-variable-comment nil)
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2446 widget)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2447 ))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2448
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2449 (defun custom-variable-post-reset-standard (widget)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2450 "Finish resetting the variable being edited by WIDGET to its standard
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2451 value."
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2452 (widget-put widget :custom-state 'unknown)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2453 ;; This call will possibly make the comment invisible
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2454 (custom-redraw widget))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2455
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2456 (defun custom-variable-reset-standard (widget)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2457 "Restore the standard setting for the variable being edited by WIDGET."
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2458 (when (custom-variable-pre-reset-standard widget)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2459 (custom-save-all))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2460 (custom-variable-post-reset-standard widget))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2461
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2462
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2463 ;;; The `custom-face-edit' Widget.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2464
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2465 (define-widget 'custom-face-edit 'checklist
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2466 "Edit face attributes."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2467 :format "%t: %v"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2468 :tag "Attributes"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2469 :extra-offset 12
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
2470 :button-args '(:help-echo "Control whether this attribute has any effect")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2471 :args (mapcar (lambda (att)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2472 (list 'group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2473 :inline t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2474 :sibling-args (widget-get (nth 1 att) :sibling-args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2475 (list 'const :format "" :value (nth 0 att))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2476 (nth 1 att)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2477 custom-face-attributes))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2478
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2479 ;;; The `custom-display' Widget.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2480
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2481 (define-widget 'custom-display 'menu-choice
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2482 "Select a display type."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2483 :tag "Display"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2484 :value t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2485 :help-echo "Specify frames where the face attributes should be used"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2486 :args '((const :tag "all" t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2487 (checklist
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2488 :offset 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2489 :extra-offset 9
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2490 :args ((group :sibling-args (:help-echo "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2491 Only match the specified window systems")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2492 (const :format "Type: "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2493 type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2494 (checklist :inline t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2495 :offset 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2496 (const :format "X "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2497 :sibling-args (:help-echo "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2498 The X11 Window System")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2499 x)
555
93749ba3e629 [xemacs-hg @ 2001-05-21 08:07:13 by yoshiki]
yoshiki
parents: 480
diff changeset
2500 (const :format "GTK "
93749ba3e629 [xemacs-hg @ 2001-05-21 08:07:13 by yoshiki]
yoshiki
parents: 480
diff changeset
2501 :sibling-args (:help-echo "\
93749ba3e629 [xemacs-hg @ 2001-05-21 08:07:13 by yoshiki]
yoshiki
parents: 480
diff changeset
2502 The GTK Window System")
93749ba3e629 [xemacs-hg @ 2001-05-21 08:07:13 by yoshiki]
yoshiki
parents: 480
diff changeset
2503 gtk)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2504 (const :format "PM "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2505 :sibling-args (:help-echo "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2506 OS/2 Presentation Manager")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2507 pm)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2508 (const :format "MSWindows "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2509 :sibling-args (:help-echo "\
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2510 Microsoft Windows, displays")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2511 mswindows)
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2512 (const :format "MSPrinter "
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2513 :sibling-args (:help-echo "\
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2514 Microsoft Windows, printers")
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2515 msprinter)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2516 (const :format "TTY%n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2517 :sibling-args (:help-echo "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2518 Plain text terminals")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2519 tty)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2520 (group :sibling-args (:help-echo "\
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2521 Only match display or printer devices")
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2522 (const :format "Output: "
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2523 class)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2524 (checklist :inline t
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2525 :offset 0
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2526 (const :format "Display "
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2527 :sibling-args (:help-echo "\
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2528 Match display devices")
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2529 display)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2530 (const :format "Printer%n"
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2531 :sibling-args (:help-echo "\
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2532 Match printer devices")
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2533 printer)))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2534 (group :sibling-args (:help-echo "\
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2535 Only match the frames with the specified color support")
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2536 (const :format "Color support: "
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2537 class)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2538 (checklist :inline t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2539 :offset 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2540 (const :format "Color "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2541 :sibling-args (:help-echo "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2542 Match color frames")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2543 color)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2544 (const :format "Grayscale "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2545 :sibling-args (:help-echo "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2546 Match grayscale frames")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2547 grayscale)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2548 (const :format "Monochrome%n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2549 :sibling-args (:help-echo "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2550 Match frames with no color support")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2551 mono)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2552 (group :sibling-args (:help-echo "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2553 Only match frames with the specified intensity")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2554 (const :format "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2555 Background brightness: "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2556 background)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2557 (checklist :inline t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2558 :offset 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2559 (const :format "Light "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2560 :sibling-args (:help-echo "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2561 Match frames with light backgrounds")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2562 light)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2563 (const :format "Dark\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2564 :sibling-args (:help-echo "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2565 Match frames with dark backgrounds")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2566 dark)))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2567
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2568 ;;; The `custom-face' Widget.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2569
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2570 (defface custom-face-tag-face '((t (:underline t)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2571 "Face used for face tags."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2572 :group 'custom-faces)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2573
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2574 (defcustom custom-face-default-form 'selected
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2575 "Default form of displaying face definition."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2576 :type '(choice (const all)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2577 (const selected)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2578 (const lisp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2579 :group 'custom-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2580
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2581 (define-widget 'custom-face 'custom
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2582 "Customize face."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2583 :sample-face 'custom-face-tag-face
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2584 :help-echo "Set or reset this face"
4021
cef5f57bb9e2 [xemacs-hg @ 2007-06-21 13:39:08 by aidan]
aidan
parents: 2544
diff changeset
2585 :documentation-property #'(lambda (face)
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
2586 (face-doc-string face))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2587 :value-create 'custom-face-value-create
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2588 :action 'custom-face-action
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2589 :custom-category 'face
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2590 :custom-form nil ; defaults to value of `custom-face-default-form'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2591 :custom-set 'custom-face-set
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2592 :custom-pre-save 'custom-face-pre-save
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2593 :custom-save 'custom-face-save
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2594 :custom-post-save 'custom-face-post-save
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2595 :custom-reset-current 'custom-redraw
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2596 :custom-reset-saved 'custom-face-reset-saved
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2597 :custom-pre-reset-standard 'custom-face-pre-reset-standard
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2598 :custom-reset-standard 'custom-face-reset-standard
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2599 :custom-post-reset-standard 'custom-face-post-reset-standard
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2600 :custom-menu 'custom-face-menu-create)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2601
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2602 (define-widget 'custom-face-all 'editable-list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2603 "An editable list of display specifications and attributes."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2604 :entry-format "%i %d %v"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2605 :insert-button-args '(:help-echo "Insert new display specification here")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2606 :append-button-args '(:help-echo "Append new display specification here")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2607 :delete-button-args '(:help-echo "Delete this display specification")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2608 :args '((group :format "%v" custom-display custom-face-edit)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2609
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2610 (defconst custom-face-all (widget-convert 'custom-face-all)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2611 "Converted version of the `custom-face-all' widget.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2612
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2613 (define-widget 'custom-display-unselected 'item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2614 "A display specification that doesn't match the selected display."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2615 :match 'custom-display-unselected-match)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2616
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2617 (defun custom-display-unselected-match (widget value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2618 "Non-nil if VALUE is an unselected display specification."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2619 (not (face-spec-set-match-display value (selected-frame))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2620
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2621 (define-widget 'custom-face-selected 'group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2622 "Edit the attributes of the selected display in a face specification."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2623 :args '((repeat :format ""
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2624 :inline t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2625 (group custom-display-unselected sexp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2626 (group (sexp :format "") custom-face-edit)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2627 (repeat :format ""
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2628 :inline t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2629 sexp)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2630
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2631 (defconst custom-face-selected (widget-convert 'custom-face-selected)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2632 "Converted version of the `custom-face-selected' widget.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2633
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2634 (defun custom-face-value-create (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2635 "Create a list of the display specifications for WIDGET."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2636 (let ((buttons (widget-get widget :buttons))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2637 children
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2638 (symbol (widget-get widget :value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2639 (tag (widget-get widget :tag))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2640 (state (widget-get widget :custom-state))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2641 (begin (point))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2642 (is-last (widget-get widget :custom-last))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2643 (prefix (widget-get widget :custom-prefix)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2644 (unless tag
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2645 (setq tag (prin1-to-string symbol)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2646 (cond ((eq custom-buffer-style 'tree)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2647 (insert prefix (if is-last " `--- " " |--- "))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2648 (push (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2649 widget 'custom-browse-face-tag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2650 buttons)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2651 (insert " " tag "\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2652 (widget-put widget :buttons buttons))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2653 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2654 ;; Create tag.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2655 (insert tag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2656 (if (eq custom-buffer-style 'face)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2657 (insert " ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2658 (widget-specify-sample widget begin (point))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2659 (insert ": "))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2660 ;; Sample.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2661 (and (not (find-face symbol))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2662 ;; XEmacs cannot display uninitialized faces.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2663 (make-face symbol))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2664 (push (widget-create-child-and-convert widget 'item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2665 :format "(%{%t%})"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2666 :sample-face symbol
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2667 :tag "sample")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2668 buttons)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2669 ;; Visibility.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2670 (insert " ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2671 (push (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2672 widget 'visibility
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2673 :help-echo "Hide or show this face"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2674 :action 'custom-toggle-parent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2675 (not (eq state 'hidden)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2676 buttons)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2677 ;; Magic.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2678 (insert "\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2679 (let ((magic (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2680 widget 'custom-magic nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2681 (widget-put widget :custom-magic magic)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2682 (push magic buttons))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2683 ;; Update buttons.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2684 (widget-put widget :buttons buttons)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2685 ;; Insert documentation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2686 (widget-default-format-handler widget ?h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2687 ;; The comment field
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2688 (unless (eq state 'hidden)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2689 (let* ((comment (get symbol 'face-comment))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2690 (comment-widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2691 (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2692 widget 'custom-comment
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2693 :parent widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2694 :value (or comment ""))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2695 (widget-put widget :comment-widget comment-widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2696 (push comment-widget children)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2697 ;; See also.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2698 (unless (eq state 'hidden)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2699 (when (eq (widget-get widget :custom-level) 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2700 (custom-add-parent-links widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2701 (custom-add-see-also widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2702 ;; Editor.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2703 (unless (eq (preceding-char) ?\n)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2704 (insert "\n"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2705 (unless (eq state 'hidden)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2706 (message "Creating face editor...")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2707 (custom-load-widget widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2708 (unless (widget-get widget :custom-form)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2709 (widget-put widget :custom-form custom-face-default-form))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2710 (let* ((symbol (widget-value widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2711 (spec (custom-face-get-spec symbol))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2712 (form (widget-get widget :custom-form))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2713 (indent (widget-get widget :indent))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2714 (edit (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2715 widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2716 (cond ((and (eq form 'selected)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2717 (widget-apply custom-face-selected
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2718 :match spec))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2719 (when indent (insert-char ?\ indent))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2720 'custom-face-selected)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2721 ((and (not (eq form 'lisp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2722 (widget-apply custom-face-all
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2723 :match spec))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2724 'custom-face-all)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2725 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2726 (when indent (insert-char ?\ indent))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2727 'sexp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2728 :value spec)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2729 (custom-face-state-set widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2730 (push edit children)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2731 (widget-put widget :children children))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2732 (message "Creating face editor...done"))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2733
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2734 (defvar custom-face-menu
4289
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4257
diff changeset
2735 `(("Set for Current Session" custom-face-set)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2736 ("Save for Future Sessions" custom-face-save)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2737 ("Reset to Saved" custom-face-reset-saved
4289
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4257
diff changeset
2738 ,#'(lambda (widget)
4434
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
2739 (or (get (widget-value widget) 'saved-face)
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
2740 (get (widget-value widget) 'saved-face-comment))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2741 ("Reset to Standard Setting" custom-face-reset-standard
4289
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4257
diff changeset
2742 ,#'(lambda (widget)
4434
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
2743 (get (widget-value widget) 'face-defface-spec)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2744 ("---" ignore ignore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2745 ("Add Comment" custom-comment-show custom-comment-invisible-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2746 ("---" ignore ignore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2747 ("Show all display specs" custom-face-edit-all
4289
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4257
diff changeset
2748 ,#'(lambda (widget)
4434
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
2749 (not (eq (widget-get widget :custom-form) 'all))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2750 ("Just current attributes" custom-face-edit-selected
4289
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4257
diff changeset
2751 ,#'(lambda (widget)
4434
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
2752 (not (eq (widget-get widget :custom-form) 'selected))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2753 ("Show as Lisp expression" custom-face-edit-lisp
4289
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4257
diff changeset
2754 ,#'(lambda (widget)
4434
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
2755 (not (eq (widget-get widget :custom-form) 'lisp)))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2756 "Alist of actions for the `custom-face' widget.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2757 Each entry has the form (NAME ACTION FILTER) where NAME is the name of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2758 the menu entry, ACTION is the function to call on the widget when the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2759 menu is selected, and FILTER is a predicate which takes a `custom-face'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2760 widget as an argument, and returns non-nil if ACTION is valid on that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2761 widget. If FILTER is nil, ACTION is always valid.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2762
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2763 (defun custom-face-edit-selected (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2764 "Edit selected attributes of the value of WIDGET."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2765 (widget-put widget :custom-state 'unknown)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2766 (widget-put widget :custom-form 'selected)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2767 (custom-redraw widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2768
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2769 (defun custom-face-edit-all (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2770 "Edit all attributes of the value of WIDGET."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2771 (widget-put widget :custom-state 'unknown)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2772 (widget-put widget :custom-form 'all)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2773 (custom-redraw widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2774
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2775 (defun custom-face-edit-lisp (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2776 "Edit the lisp representation of the value of WIDGET."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2777 (widget-put widget :custom-state 'unknown)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2778 (widget-put widget :custom-form 'lisp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2779 (custom-redraw widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2780
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2781 (defun custom-face-state-set (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2782 "Set the state of WIDGET."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2783 (let* ((symbol (widget-value widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2784 (comment (get symbol 'face-comment))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2785 tmp temp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2786 (widget-put widget :custom-state
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2787 (cond ((progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2788 (setq tmp (get symbol 'customized-face))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2789 (setq temp (get symbol 'customized-face-comment))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2790 (or tmp temp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2791 (if (equal temp comment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2792 'set
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2793 'changed))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2794 ((progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2795 (setq tmp (get symbol 'saved-face))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2796 (setq temp (get symbol 'saved-face-comment))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2797 (or tmp temp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2798 (if (equal temp comment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2799 'saved
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2800 'changed))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2801 ((get symbol 'face-defface-spec)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2802 (if (equal comment nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2803 'standard
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2804 'changed))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2805 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2806 'rogue)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2807
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2808 (defun custom-face-action (widget &optional event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2809 "Show the menu for `custom-face' WIDGET.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2810 Optional EVENT is the location for the menu."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2811 (if (eq (widget-get widget :custom-state) 'hidden)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2812 (custom-toggle-hide widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2813 (let* ((completion-ignore-case t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2814 (symbol (widget-get widget :value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2815 (answer (widget-choose (concat "Operation on "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2816 (custom-unlispify-tag-name symbol))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2817 (custom-menu-filter custom-face-menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2818 widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2819 event)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2820 (if answer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2821 (funcall answer widget)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2822
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2823 (defun custom-face-set (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2824 "Make the face attributes in WIDGET take effect."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2825 (let* ((symbol (widget-value widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2826 (child (car (widget-get widget :children)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2827 (value (widget-value child))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2828 (comment-widget (widget-get widget :comment-widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2829 (comment (widget-value comment-widget)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2830 (when (equal comment "")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2831 (setq comment nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2832 ;; Make the comment invisible by hand if it's empty
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2833 (set-extent-property (widget-get comment-widget :comment-extent)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2834 'invisible t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2835 (put symbol 'customized-face value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2836 (face-spec-set symbol value nil '(custom))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2837 (put symbol 'customized-face-comment comment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2838 (put symbol 'face-comment comment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2839 (custom-face-state-set widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2840 (custom-redraw-magic widget)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2841
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2842 (defun custom-face-pre-save (widget)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2843 "Prepare for saving the face being edited by WIDGET."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2844 (let* ((symbol (widget-value widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2845 (child (car (widget-get widget :children)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2846 (value (widget-value child))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2847 (comment-widget (widget-get widget :comment-widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2848 (comment (widget-value comment-widget)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2849 (when (equal comment "")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2850 (setq comment nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2851 ;; Make the comment invisible by hand if it's empty
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2852 (set-extent-property (widget-get comment-widget :comment-extent)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2853 'invisible t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2854 (face-spec-set symbol value nil '(custom))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2855 (put symbol 'saved-face value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2856 (custom-push-theme 'theme-face symbol 'user 'set value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2857 (put symbol 'customized-face nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2858 (put symbol 'face-comment comment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2859 (put symbol 'customized-face-comment nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2860 (put symbol 'saved-face-comment comment)
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2861 ))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2862
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2863 (defun custom-face-post-save (widget)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2864 "Finish saving the face being edited by WIDGET."
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2865 (custom-face-state-set widget)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2866 (custom-redraw-magic widget))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2867
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2868 (defun custom-face-save (widget)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2869 "Save the face being edited by WIDGET."
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2870 (custom-face-pre-save widget)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2871 (custom-save-all)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2872 (custom-face-post-save widget))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2873
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2874 (defun custom-face-reset-saved (widget)
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2875 "Reset the face being edited by WIDGET to its saved value."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2876 (let* ((symbol (widget-value widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2877 (child (car (widget-get widget :children)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2878 (value (get symbol 'saved-face))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2879 (comment (get symbol 'saved-face-comment))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2880 (comment-widget (widget-get widget :comment-widget)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2881 (unless (or value comment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2882 (signal 'error (list "No saved value for this face" symbol)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2883 (put symbol 'customized-face nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2884 (put symbol 'customized-face-comment nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2885 (face-spec-set symbol value nil '(custom))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2886 (put symbol 'face-comment comment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2887 (widget-value-set child value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2888 ;; This call manages the comment visibility
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2889 (widget-value-set comment-widget (or comment ""))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2890 (custom-face-state-set widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2891 (custom-redraw-magic widget)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2892
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2893 ;; This function returns non nil if we need to re-save the options --dv.
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2894 (defun custom-face-pre-reset-standard (widget)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2895 "Prepare for restoring the face edited by WIDGET to its standard
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2896 settings."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2897 (let* ((symbol (widget-value widget))
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2898 (value (get symbol 'face-defface-spec)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2899 (unless value
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2900 (signal 'error (list "No standard setting for this face" symbol)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2901 (put symbol 'customized-face nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2902 (put symbol 'customized-face-comment nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2903 (when (or (get symbol 'saved-face) (get symbol 'saved-face-comment))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2904 (put symbol 'saved-face nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2905 (custom-push-theme 'theme-face symbol 'user 'reset 'standard)
5384
3889ef128488 Fix misspelled words, and some grammar, across the entire source tree.
Jerry James <james@xemacs.org>
parents: 5366
diff changeset
2906 ;; Do not explicitly save resets to standards without themes.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2907 (if (null (cdr (get symbol 'theme-face)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2908 (put symbol 'theme-face nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2909 (put symbol 'saved-face-comment nil)
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2910 widget)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2911 ))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2912
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2913 (defun custom-face-post-reset-standard (widget)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2914 "Finish restoring the face edited by WIDGET to its standard settings."
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2915 (let* ((symbol (widget-value widget))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2916 (child (car (widget-get widget :children)))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2917 (value (get symbol 'face-defface-spec))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2918 (comment-widget (widget-get widget :comment-widget)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2919 (face-spec-set symbol value nil '(custom))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2920 (put symbol 'face-comment nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2921 (widget-value-set child value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2922 ;; This call manages the comment visibility
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2923 (widget-value-set comment-widget "")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2924 (custom-face-state-set widget)
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2925 (custom-redraw-magic widget)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2926 ))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2927
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2928 (defun custom-face-reset-standard (widget)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2929 "Restore the face edited by WIDGET to its standard settings."
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2930 (when (custom-face-pre-reset-standard widget)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2931 (custom-save-all))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2932 (custom-face-post-reset-standard widget))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
2933
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2934
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2935 ;;; The `face' Widget.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2936
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2937 (define-widget 'face 'default
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2938 "Select and customize a face."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2939 :convert-widget 'widget-value-convert-widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2940 :button-prefix 'widget-push-button-prefix
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2941 :button-suffix 'widget-push-button-suffix
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2942 :format "%t: %[select face%] %v"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2943 :tag "Face"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2944 :value 'default
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2945 :value-create 'widget-face-value-create
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2946 :value-delete 'widget-face-value-delete
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2947 :value-get 'widget-value-value-get
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2948 :validate 'widget-children-validate
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2949 :action 'widget-face-action
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2950 :match (lambda (widget value) (symbolp value)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2951
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2952 (defun widget-face-value-create (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2953 ;; Create a `custom-face' child.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2954 (let* ((symbol (widget-value widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2955 (custom-buffer-style 'face)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2956 (child (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2957 widget 'custom-face
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2958 :custom-level nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2959 :value symbol)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2960 (custom-magic-reset child)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2961 (setq custom-options (cons child custom-options))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2962 (widget-put widget :children (list child))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2963
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2964 (defun widget-face-value-delete (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2965 ;; Remove the child from the options.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2966 (let ((child (car (widget-get widget :children))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2967 (setq custom-options (delq child custom-options))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2968 (widget-children-value-delete widget)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2969
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2970 (defvar face-history nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2971 "History of entered face names.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2972
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2973 (defun widget-face-action (widget &optional event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2974 "Prompt for a face."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2975 (let ((answer (completing-read "Face: "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2976 (mapcar (lambda (face)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2977 (list (symbol-name face)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2978 (face-list))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2979 nil nil nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2980 'face-history)))
5366
f00192e1cd49 Examining the result of #'length: `eql', not `=', it's better style & cheaper
Aidan Kehoe <kehoea@parhasard.net>
parents: 4806
diff changeset
2981 (unless (eql (length answer) 0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2982 (widget-value-set widget (intern answer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2983 (widget-apply widget :notify widget event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2984 (widget-setup))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2985
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2986 ;;; The `hook' Widget.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2987
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2988 (define-widget 'hook 'list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2989 "A emacs lisp hook"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2990 :value-to-internal (lambda (widget value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2991 (if (symbolp value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2992 (list value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2993 value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2994 :match (lambda (widget value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2995 (or (symbolp value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2996 (widget-group-match widget value)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2997 :convert-widget 'custom-hook-convert-widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2998 :tag "Hook")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2999
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3000 (defun custom-hook-convert-widget (widget)
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
3001 ;; Handle `:options'.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3002 (let* ((options (widget-get widget :options))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3003 (other `(editable-list :inline t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3004 :entry-format "%i %d%v"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3005 (function :format " %v")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3006 (args (if options
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3007 (list `(checklist :inline t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3008 ,@(mapcar (lambda (entry)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3009 `(function-item ,entry))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3010 options))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3011 other)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3012 (list other))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3013 (widget-put widget :args args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3014 widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3015
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3016 ;;; The `plist' Widget.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3017
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3018 (define-widget 'plist 'list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3019 "A property list."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3020 :match (lambda (widget value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3021 (valid-plist-p value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3022 :convert-widget 'custom-plist-convert-widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3023 :tag "Property List")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3024
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3025 ;; #### Should handle options better.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3026 (defun custom-plist-convert-widget (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3027 (let* ((options (widget-get widget :options))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3028 (other `(editable-list :inline t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3029 (group :inline t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3030 (symbol :format "%t: %v "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3031 :size 10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3032 :tag "Property")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3033 (sexp :tag "Value"))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3034 (args
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3035 (if options
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3036 `((checklist :inline t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3037 ,@(mapcar 'custom-plist-process-option options))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3038 ,other)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3039 (list other))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3040 (widget-put widget :args args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3041 widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3042
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3043 (defun custom-plist-process-option (entry)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3044 `(group :inline t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3045 (const :tag "Property"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3046 :format "%t: %v "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3047 :size 10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3048 ,entry)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3049 (sexp :tag "Value")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3050
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3051 ;;; The `custom-group-link' Widget.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3052
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3053 (define-widget 'custom-group-link 'link
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3054 "Show parent in other window when activated."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3055 :help-echo 'custom-group-link-help-echo
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3056 :action 'custom-group-link-action)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3057
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3058 (defun custom-group-link-help-echo (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3059 (concat "Create customization buffer for the `"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3060 (custom-unlispify-tag-name (widget-value widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3061 "' group"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3062
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3063 (defun custom-group-link-action (widget &rest ignore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3064 (customize-group (widget-value widget)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3065
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3066 ;;; The `custom-group' Widget.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3067
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3068 (defcustom custom-group-tag-faces nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3069 ;; In XEmacs, this ought to play games with font size.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3070 "Face used for group tags.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3071 The first member is used for level 1 groups, the second for level 2,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3072 and so forth. The remaining group tags are shown with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3073 `custom-group-tag-face'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3074 :type '(repeat face)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3075 :group 'custom-faces)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3076
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3077 (defface custom-group-tag-face-1 '((((class color)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3078 (background dark))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3079 (:foreground "pink" :underline t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3080 (((class color)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3081 (background light))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3082 (:foreground "red" :underline t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3083 (t (:underline t)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3084 "Face used for group tags.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3085
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3086 (defface custom-group-tag-face '((((class color)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3087 (background dark))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3088 (:foreground "light blue" :underline t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3089 (((class color)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3090 (background light))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3091 (:foreground "blue" :underline t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3092 (t (:underline t)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3093 "Face used for low level group tags."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3094 :group 'custom-faces)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3095
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3096 (define-widget 'custom-group 'custom
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3097 "Customize group."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3098 :format "%v"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3099 :sample-face-get 'custom-group-sample-face-get
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3100 :documentation-property 'group-documentation
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3101 :help-echo "Set or reset all members of this group"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3102 :value-create 'custom-group-value-create
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3103 :action 'custom-group-action
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3104 :custom-category 'group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3105 :custom-set 'custom-group-set
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3106 :custom-pre-save 'custom-group-pre-save
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3107 :custom-save 'custom-group-save
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3108 :custom-post-save 'custom-group-post-save
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3109 :custom-reset-current 'custom-group-reset-current
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3110 :custom-reset-saved 'custom-group-reset-saved
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3111 :custom-pre-reset-standard 'custom-group-pre-reset-standard
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3112 :custom-reset-standard 'custom-group-reset-standard
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3113 :custom-post-reset-standard 'custom-group-post-reset-standard
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3114 :custom-menu 'custom-group-menu-create)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3115
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3116 (defun custom-group-sample-face-get (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3117 ;; Use :sample-face.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3118 (or (nth (1- (widget-get widget :custom-level)) custom-group-tag-faces)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3119 'custom-group-tag-face))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3120
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3121 (define-widget 'custom-group-visibility 'visibility
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3122 "An indicator and manipulator for hidden group contents."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3123 :create 'custom-group-visibility-create)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3124
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3125 (defun custom-group-visibility-create (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3126 (let ((visible (widget-value widget)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3127 (if visible
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3128 (insert "--------")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3129 (widget-default-create widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3130
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3131 (defun custom-group-members (symbol groups-only)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3132 "Return SYMBOL's custom group members.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3133 If GROUPS-ONLY non-nil, return only those members that are groups."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3134 (if (not groups-only)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3135 (get symbol 'custom-group)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3136 (let (members)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3137 (dolist (entry (get symbol 'custom-group) (nreverse members))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3138 (when (eq (nth 1 entry) 'custom-group)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3139 (push entry members))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3140
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3141 (defun custom-group-value-create (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3142 "Insert a customize group for WIDGET in the current buffer."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3143 (let* ((state (widget-get widget :custom-state))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3144 (level (widget-get widget :custom-level))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3145 ;; (indent (widget-get widget :indent))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3146 (prefix (widget-get widget :custom-prefix))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3147 (buttons (widget-get widget :buttons))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3148 (tag (widget-get widget :tag))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3149 (symbol (widget-value widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3150 (members (custom-group-members symbol
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3151 (and (eq custom-buffer-style 'tree)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3152 custom-browse-only-groups))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3153 (cond ((and (eq custom-buffer-style 'tree)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3154 (eq state 'hidden)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3155 (or members (custom-unloaded-widget-p widget)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3156 (custom-browse-insert-prefix prefix)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3157 (push (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3158 widget 'custom-browse-visibility
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3159 ;; :tag-glyph "plus"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3160 :tag "+")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3161 buttons)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3162 (insert "-- ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3163 ;; (widget-glyph-insert nil "-- " "horizontal")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3164 (push (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3165 widget 'custom-browse-group-tag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3166 buttons)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3167 (insert " " tag "\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3168 (widget-put widget :buttons buttons))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3169 ((and (eq custom-buffer-style 'tree)
5366
f00192e1cd49 Examining the result of #'length: `eql', not `=', it's better style & cheaper
Aidan Kehoe <kehoea@parhasard.net>
parents: 4806
diff changeset
3170 (eql (length members) 0))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3171 (custom-browse-insert-prefix prefix)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3172 (insert "[ ]-- ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3173 ;; (widget-glyph-insert nil "[ ]" "empty")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3174 ;; (widget-glyph-insert nil "-- " "horizontal")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3175 (push (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3176 widget 'custom-browse-group-tag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3177 buttons)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3178 (insert " " tag "\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3179 (widget-put widget :buttons buttons))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3180 ((eq custom-buffer-style 'tree)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3181 (custom-browse-insert-prefix prefix)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3182 (custom-load-widget widget)
5366
f00192e1cd49 Examining the result of #'length: `eql', not `=', it's better style & cheaper
Aidan Kehoe <kehoea@parhasard.net>
parents: 4806
diff changeset
3183 (if (eql (length members) 0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3184 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3185 (custom-browse-insert-prefix prefix)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3186 (insert "[ ]-- ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3187 ;; (widget-glyph-insert nil "[ ]" "empty")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3188 ;; (widget-glyph-insert nil "-- " "horizontal")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3189 (push (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3190 widget 'custom-browse-group-tag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3191 buttons)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3192 (insert " " tag "\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3193 (widget-put widget :buttons buttons))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3194 (push (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3195 widget 'custom-browse-visibility
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3196 ;; :tag-glyph "minus"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3197 :tag "-")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3198 buttons)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3199 (insert "-\\ ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3200 ;; (widget-glyph-insert nil "-\\ " "top")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3201 (push (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3202 widget 'custom-browse-group-tag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3203 buttons)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3204 (insert " " tag "\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3205 (widget-put widget :buttons buttons)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3206 (message "Creating group...")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3207 (let* ((members (custom-sort-items members
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3208 custom-browse-sort-alphabetically
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3209 custom-browse-order-groups))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3210 (prefixes (widget-get widget :custom-prefixes))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3211 (custom-prefix-list (custom-prefix-add symbol prefixes))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3212 (extra-prefix (if (widget-get widget :custom-last)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3213 " "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3214 " | "))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3215 (prefix (concat prefix extra-prefix))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3216 children entry)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3217 (while members
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3218 (setq entry (car members)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3219 members (cdr members))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3220 (push (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3221 widget (nth 1 entry)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3222 :group widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3223 :tag (custom-unlispify-tag-name (nth 0 entry))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3224 :custom-prefixes custom-prefix-list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3225 :custom-level (1+ level)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3226 :custom-last (null members)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3227 :value (nth 0 entry)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3228 :custom-prefix prefix)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3229 children))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3230 (widget-put widget :children (reverse children)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3231 (message "Creating group...done")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3232 ;; Nested style.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3233 ((eq state 'hidden)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3234 ;; Create level indicator.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3235 (unless (eq custom-buffer-style 'links)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3236 (insert-char ?\ (* custom-buffer-indent (1- level)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3237 (insert "-- "))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3238 ;; Create link indicator.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3239 (when (eq custom-buffer-style 'links)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3240 (insert " ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3241 (push (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3242 widget 'custom-group-link
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3243 :tag "Open"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3244 :tag-glyph '("open-up" "open-down")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3245 symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3246 buttons)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3247 (insert " "))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3248 ;; Create tag.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3249 (let ((begin (point)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3250 (insert tag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3251 (widget-specify-sample widget begin (point)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3252 (insert " group")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3253 ;; Create visibility indicator.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3254 (unless (eq custom-buffer-style 'links)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3255 (insert ": ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3256 (push (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3257 widget 'custom-group-visibility
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3258 :help-echo "Show members of this group"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3259 :action 'custom-toggle-parent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3260 (not (eq state 'hidden)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3261 buttons))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3262 (insert " \n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3263 ;; Create magic button.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3264 (let ((magic (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3265 widget 'custom-magic nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3266 (widget-put widget :custom-magic magic)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3267 (push magic buttons))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3268 ;; Update buttons.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3269 (widget-put widget :buttons buttons)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3270 ;; Insert documentation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3271 (if (and (eq custom-buffer-style 'links) (> level 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3272 (widget-put widget :documentation-indent 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3273 (widget-default-format-handler widget ?h))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3274 ;; Nested style.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3275 (t ;Visible.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3276 (custom-load-widget widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3277 ;; Update members
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3278 (setq members (custom-group-members
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3279 symbol (and (eq custom-buffer-style 'tree)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3280 custom-browse-only-groups)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3281 ;; Add parent groups references above the group.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3282 (if t ;;; This should test that the buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3283 ;;; was made to display a group.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3284 (when (eq level 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3285 (if (custom-add-parent-links widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3286 "Go to parent group:")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3287 (insert "\n"))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3288 ;; Create level indicator.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3289 (insert-char ?\ (* custom-buffer-indent (1- level)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3290 (insert "/- ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3291 ;; Create tag.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3292 (let ((start (point)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3293 (insert tag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3294 (widget-specify-sample widget start (point)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3295 (insert " group: ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3296 ;; Create visibility indicator.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3297 (unless (eq custom-buffer-style 'links)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3298 (insert "--------")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3299 (push (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3300 widget 'visibility
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3301 :help-echo "Hide members of this group"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3302 :action 'custom-toggle-parent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3303 (not (eq state 'hidden)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3304 buttons)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3305 (insert " "))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3306 ;; Create more dashes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3307 ;; Use 76 instead of 75 to compensate for the temporary "<"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3308 ;; added by `widget-insert'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3309 (insert-char ?- (- 76 (current-column)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3310 (* custom-buffer-indent level)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3311 (insert "\\\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3312 ;; Create magic button.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3313 (let ((magic (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3314 widget 'custom-magic
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3315 :indent 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3316 nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3317 (widget-put widget :custom-magic magic)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3318 (push magic buttons))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3319 ;; Update buttons.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3320 (widget-put widget :buttons buttons)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3321 ;; Insert documentation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3322 (widget-default-format-handler widget ?h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3323 ;; Parent groups.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3324 (if nil ;;; This should test that the buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3325 ;;; was not made to display a group.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3326 (when (eq level 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3327 (insert-char ?\ custom-buffer-indent)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3328 (custom-add-parent-links widget)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3329 (custom-add-see-also widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3330 (make-string (* custom-buffer-indent level)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3331 ?\ ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3332 ;; Members.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3333 (message "Creating group...")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3334 (let* ((members (custom-sort-items members
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3335 custom-buffer-sort-alphabetically
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3336 custom-buffer-order-groups))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3337 (prefixes (widget-get widget :custom-prefixes))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3338 (custom-prefix-list (custom-prefix-add symbol prefixes))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3339 (length (length members))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3340 (count 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3341 (children (mapcar
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3342 (lambda (entry)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3343 (widget-insert "\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3344 (when (zerop (% count custom-skip-messages))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3345 (display-message
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3346 'progress
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3347 (format "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3348 Creating group members... %2d%%"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3349 (/ (* 100.0 count) length))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3350 (incf count)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3351 (prog1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3352 (widget-create-child-and-convert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3353 widget (nth 1 entry)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3354 :group widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3355 :tag (custom-unlispify-tag-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3356 (nth 0 entry))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3357 :custom-prefixes custom-prefix-list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3358 :custom-level (1+ level)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3359 :value (nth 0 entry))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3360 (unless (eq (preceding-char) ?\n)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3361 (widget-insert "\n"))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3362 members)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3363 (message "Creating group magic...")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3364 (mapc 'custom-magic-reset children)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3365 (message "Creating group state...")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3366 (widget-put widget :children children)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3367 (custom-group-state-update widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3368 (message "Creating group... done"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3369 ;; End line
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3370 (insert "\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3371 (insert-char ?\ (* custom-buffer-indent (1- level)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3372 (insert "\\- " (widget-get widget :tag) " group end ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3373 (insert-char ?- (- 75 (current-column) (* custom-buffer-indent level)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3374 (insert "/\n")))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3375
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3376 (defvar custom-group-menu
4289
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4257
diff changeset
3377 `(("Set for Current Session" custom-group-set
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4257
diff changeset
3378 ,#'(lambda (widget)
4434
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
3379 (eq (widget-get widget :custom-state) 'modified)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3380 ("Save for Future Sessions" custom-group-save
4289
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4257
diff changeset
3381 ,#'(lambda (widget)
4434
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
3382 (memq (widget-get widget :custom-state) '(modified set))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3383 ("Reset to Current" custom-group-reset-current
4289
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4257
diff changeset
3384 ,#'(lambda (widget)
4434
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
3385 (memq (widget-get widget :custom-state) '(modified))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3386 ("Reset to Saved" custom-group-reset-saved
4289
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4257
diff changeset
3387 ,#'(lambda (widget)
4434
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
3388 (memq (widget-get widget :custom-state) '(modified set))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3389 ("Reset to standard setting" custom-group-reset-standard
4289
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4257
diff changeset
3390 ,#'(lambda (widget)
4434
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
3391 (memq (widget-get widget :custom-state) '(modified set saved)))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3392 "Alist of actions for the `custom-group' widget.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3393 Each entry has the form (NAME ACTION FILTER) where NAME is the name of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3394 the menu entry, ACTION is the function to call on the widget when the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3395 menu is selected, and FILTER is a predicate which takes a `custom-group'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3396 widget as an argument, and returns non-nil if ACTION is valid on that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3397 widget. If FILTER is nil, ACTION is always valid.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3398
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3399 (defun custom-group-action (widget &optional event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3400 "Show the menu for `custom-group' WIDGET.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3401 Optional EVENT is the location for the menu."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3402 (if (eq (widget-get widget :custom-state) 'hidden)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3403 (custom-toggle-hide widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3404 (let* ((completion-ignore-case t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3405 (answer (widget-choose (concat "Operation on "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3406 (custom-unlispify-tag-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3407 (widget-get widget :value)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3408 (custom-menu-filter custom-group-menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3409 widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3410 event)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3411 (if answer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3412 (funcall answer widget)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3413
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3414 (defun custom-group-set (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3415 "Set changes in all modified group members."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3416 (let ((children (widget-get widget :children)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3417 (mapc (lambda (child)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3418 (when (eq (widget-get child :custom-state) 'modified)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3419 (widget-apply child :custom-set)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3420 children)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3421
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3422 (defun custom-group-pre-save (widget)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3423 "Prepare for saving all modified group members."
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3424 (let ((children (widget-get widget :children)))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3425 (mapc (lambda (child)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3426 (when (memq (widget-get child :custom-state) '(modified set))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3427 (widget-apply child :custom-pre-save)))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3428 children)))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3429
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3430 (defun custom-group-post-save (widget)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3431 "Save all modified group members."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3432 (let ((children (widget-get widget :children)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3433 (mapc (lambda (child)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3434 (when (memq (widget-get child :custom-state) '(modified set))
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3435 (widget-apply child :custom-post-save)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3436 children)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3437
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3438 (defun custom-group-save (widget)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3439 "Save all modified group members."
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3440 (custom-group-pre-save widget)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3441 (custom-save-all)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3442 (custom-group-post-save widget))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3443
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3444 (defun custom-group-reset-current (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3445 "Reset all modified group members."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3446 (let ((children (widget-get widget :children)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3447 (mapc (lambda (child)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3448 (when (eq (widget-get child :custom-state) 'modified)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3449 (widget-apply child :custom-reset-current)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3450 children)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3451
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3452 (defun custom-group-reset-saved (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3453 "Reset all modified or set group members."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3454 (let ((children (widget-get widget :children)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3455 (mapc (lambda (child)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3456 (when (memq (widget-get child :custom-state) '(modified set))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3457 (widget-apply child :custom-reset-saved)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3458 children)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3459
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3460 ;; This function returns non nil when we need to re-save the options --dv.
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3461 (defun custom-group-pre-reset-standard (widget)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3462 "Prepare for resetting all modified, set, or saved group members."
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3463 (let ((children (widget-get widget :children))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3464 must-save)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3465 (mapc (lambda (child)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3466 (when (memq (widget-get child :custom-state)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3467 '(modified set saved))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3468 (and (widget-apply child :custom-pre-reset-standard)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3469 (setq must-save t))))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3470 children)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3471 must-save
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3472 ))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3473
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3474 (defun custom-group-post-reset-standard (widget)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3475 "Finish resetting all modified, set, or saved group members."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3476 (let ((children (widget-get widget :children)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3477 (mapc (lambda (child)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3478 (when (memq (widget-get child :custom-state)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3479 '(modified set saved))
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3480 (widget-apply child :custom-post-reset-standard)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3481 children)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3482
480
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3483 (defun custom-group-reset-standard (widget)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3484 "Reset all modified, set, or saved group members."
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3485 (when (custom-group-pre-reset-standard widget)
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3486 (custom-save-all))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3487 (custom-group-post-reset-standard widget))
e07227fed94e [xemacs-hg @ 2001-04-23 16:18:04 by didierv]
didierv
parents: 476
diff changeset
3488
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3489 (defun custom-group-state-update (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3490 "Update magic."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3491 (unless (eq (widget-get widget :custom-state) 'hidden)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3492 (let* ((children (widget-get widget :children))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3493 (states (mapcar (lambda (child)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3494 (widget-get child :custom-state))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3495 children))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3496 (magics custom-magic-alist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3497 (found 'standard))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3498 (while magics
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3499 (let ((magic (car (car magics))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3500 (if (and (not (eq magic 'hidden))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3501 (memq magic states))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3502 (setq found magic
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3503 magics nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3504 (setq magics (cdr magics)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3505 (widget-put widget :custom-state found)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3506 (custom-magic-reset widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3507
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3508 (defun custom-save-delete (symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3509 "Delete the call to SYMBOL form in `custom-file'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3510 Leave point at the location of the call, or after the last expression."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3511 (let ((find-file-hooks nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3512 (auto-mode-alist nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3513 (set-buffer (find-file-noselect custom-file)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3514 (goto-char (point-min))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3515 (catch 'found
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3516 (while t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3517 (let ((sexp (condition-case nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3518 (read (current-buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3519 (end-of-file (throw 'found nil)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3520 (when (and (listp sexp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3521 (eq (car sexp) symbol))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3522 (delete-region (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3523 (backward-sexp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3524 (point))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3525 (point))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3526 (throw 'found nil))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3527
848
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3528 (defun custom-save-delete-any (&rest symbols)
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3529 "Delete the call to any symbol among SYMBOLS in `custom-file'.
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3530 Leave the point at the end of the file."
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3531 (let ((find-file-hooks nil)
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3532 (auto-mode-alist nil))
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3533 (set-buffer (find-file-noselect custom-file)))
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3534 (goto-char (point-min))
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3535 (condition-case nil
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3536 (while (not (eobp))
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3537 (let ((sexp (read (current-buffer))))
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3538 (when (and (listp sexp)
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3539 (memq (car sexp) symbols))
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3540 (delete-region (save-excursion
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3541 (backward-sexp)
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3542 (point))
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3543 (point))
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3544 (while (and (eolp) (not (eobp)))
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3545 (delete-region (point) (prog2 (forward-line 1) (point))))
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3546 )))
848
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3547 (end-of-file nil)))
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3548
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3549 (defsubst custom-save-variable-p (symbol)
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3550 "Return non-nil if symbol SYMBOL is a customized variable."
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3551 (and (symbolp symbol)
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3552 (let ((spec (car-safe (get symbol 'theme-value))))
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3553 (or (and spec (eq (car spec) 'user)
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3554 (eq (second spec) 'set))
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3555 (get symbol 'saved-variable-comment)
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3556 ;; support non-themed vars
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3557 (and (null spec) (get symbol 'saved-value))))))
848
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3558
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3559 (defun custom-save-variable-internal (symbol)
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3560 "Print variable SYMBOL to the standard output.
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3561 SYMBOL must be a customized variable."
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3562 (let ((requests (get symbol 'custom-requests))
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3563 (now (not (or (get symbol 'standard-value)
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3564 (and (not (boundp symbol))
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3565 (not (eq (get symbol 'force-value)
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3566 'rogue))))))
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3567 (comment (get symbol 'saved-variable-comment))
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3568 ;; Print everything, no placeholders `...'
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3569 (print-level nil)
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3570 (print-length nil))
848
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3571 (unless (custom-save-variable-p symbol)
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3572 (error 'wrong-type-argument "Not a customized variable" symbol))
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3573 (princ "\n '(")
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3574 (prin1 symbol)
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3575 (princ " ")
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3576 ;; This comment stuff is in the way ####
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3577 ;; Is (eq (third spec) (car saved-value)) ????
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3578 ;; (prin1 (third spec))
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3579 ;; XEmacs -- pretty-print value if available
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3580 (if (and custom-save-pretty-print
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3581 (fboundp 'pp))
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3582 ;; To suppress bytecompiler warning
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3583 (with-fboundp 'pp
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3584 (pp (car (get symbol 'saved-value))))
848
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3585 (prin1 (car (get symbol 'saved-value))))
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3586 (when (or now requests comment)
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3587 (princ (if now " t" " nil")))
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3588 (when (or comment requests)
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3589 (princ " ")
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3590 (prin1 requests))
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3591 (when comment
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3592 (princ " ")
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3593 (prin1 comment))
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3594 (princ ")")))
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3595
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3596 (defun custom-save-variables ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3597 "Save all customized variables in `custom-file'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3598 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3599 (custom-save-delete 'custom-load-themes)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3600 (custom-save-delete 'custom-reset-variables)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3601 (custom-save-delete 'custom-set-variables)
848
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3602 ;; This leaves point at the end of file.
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3603 ;; Adrian Aichner <adrian@xemacs.org> stated it is
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3604 ;; a bad behavior <npak@ispras.ru>
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3605 ;;(custom-save-delete-any 'custom-load-themes
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3606 ;; 'custom-reset-variables
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3607 ;; 'custom-set-variables)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3608 (custom-save-loaded-themes)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3609 (custom-save-resets 'theme-value 'custom-reset-variables nil)
848
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3610 (let ((standard-output (current-buffer))
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3611 (sorted-list ()))
848
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3612 ;; First create a sorted list of saved variables.
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3613 (mapatoms
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3614 (lambda (symbol)
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3615 (when (custom-save-variable-p symbol)
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3616 (push symbol sorted-list))))
2122
3c70cbcc7ae8 [xemacs-hg @ 2004-06-10 12:20:00 by adrian]
adrian
parents: 2118
diff changeset
3617 (setq sorted-list (sort sorted-list 'string<))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3618 (unless (bolp)
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3619 (princ "\n"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3620 (princ "(custom-set-variables")
848
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3621 (mapc 'custom-save-variable-internal
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3622 sorted-list)
848
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3623 (princ ")")
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3624 (unless (looking-at "\n")
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3625 (princ "\n")))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3626
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3627 (defvar custom-save-face-ignoring nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3628
848
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3629 (defsubst custom-save-face-p (symbol)
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3630 "Return non-nil if SYMBOL is a customized face."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3631 (let ((theme-spec (car-safe (get symbol 'theme-face)))
848
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3632 (comment (get symbol 'saved-face-comment)))
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3633 (or (and (not (memq symbol custom-save-face-ignoring))
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3634 ;; Don't print default face here.
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3635 (or (and theme-spec
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3636 (eq (car theme-spec) 'user)
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3637 (eq (second theme-spec) 'set))
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3638 ;; cope with non-themed faces
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3639 (and (null theme-spec)
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3640 (get symbol 'saved-face))))
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3641 comment)))
848
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3642
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3643 (defun custom-save-face-internal (symbol)
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3644 "Print face SYMBOL to the standard output.
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3645 SYMBOL must be a customized face."
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3646 (let ((comment (get symbol 'saved-face-comment))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3647 (now (not (or (get symbol 'face-defface-spec)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3648 (and (not (find-face symbol))
848
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3649 (not (eq (get symbol 'force-face) 'rogue))))))
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3650 ;; Print everything, no placeholders `...'
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3651 (print-level nil)
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3652 (print-length nil))
848
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3653 (if (memq symbol custom-save-face-ignoring)
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3654 ;; Do nothing
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3655 nil
848
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3656 ;; Print face
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3657 (unless (custom-save-face-p symbol)
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3658 (error 'wrong-type-argument "Not a customized face" symbol))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3659 (princ "\n '(")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3660 (prin1 symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3661 (princ " ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3662 (prin1 (get symbol 'saved-face))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3663 (if (or comment now)
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3664 (princ (if now " t" " nil")))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3665 (when comment
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3666 (princ " ")
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3667 (prin1 comment))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3668 (princ ")"))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3669
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3670 (defun custom-save-faces ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3671 "Save all customized faces in `custom-file'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3672 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3673 (custom-save-delete 'custom-reset-faces)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3674 (custom-save-delete 'custom-set-faces)
848
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3675 ;; This leaves point at the end of file.
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3676 ;; Adrian Aichner <adrian@xemacs.org> stated it is
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3677 ;; a bad behavior <npak@ispras.ru>
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3678 ;;(custom-save-delete-any 'custom-reset-faces
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3679 ;; 'custom-set-faces)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3680 (custom-save-resets 'theme-face 'custom-reset-faces '(default))
848
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3681 (let ((standard-output (current-buffer))
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3682 (sorted-list ()))
848
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3683 ;; Create a sorted list of faces
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3684 (mapatoms
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3685 (lambda (symbol)
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3686 (when (custom-save-face-p symbol)
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3687 (push symbol sorted-list))))
2122
3c70cbcc7ae8 [xemacs-hg @ 2004-06-10 12:20:00 by adrian]
adrian
parents: 2118
diff changeset
3688 (setq sorted-list (sort sorted-list 'string<))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3689 (unless (bolp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3690 (princ "\n"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3691 (princ "(custom-set-faces")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3692 ;; The default face must be first, since it affects the others.
848
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3693 (when (custom-save-face-p 'default)
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3694 (custom-save-face-internal 'default))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3695 (let ((custom-save-face-ignoring '(default)))
848
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3696 (mapc 'custom-save-face-internal
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3697 sorted-list))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3698 (princ ")")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3699 (unless (looking-at "\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3700 (princ "\n")))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3701
848
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3702 (defmacro make-custom-save-resets-mapper (property setter)
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3703 "Create a mapper for `custom-save-resets'."
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3704 `(lambda (object)
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3705 (let ((spec (car-safe (get object (quote ,property))))
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3706 (print-level nil)
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3707 (print-length nil))
848
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3708 (with-boundp '(ignored-special started-writing)
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3709 (when (and (not (memq object ignored-special))
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3710 (eq (car spec) 'user)
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3711 (eq (second spec) 'reset))
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3712 ;; Do not write reset statements unless necessary.
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3713 (unless started-writing
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3714 (setq started-writing t)
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3715 (unless (bolp)
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3716 (princ "\n"))
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3717 (princ "(")
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3718 (princ (quote ,setter))
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3719 (princ "\n '(")
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3720 (prin1 object)
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3721 (princ " ")
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3722 (prin1 (third spec))
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3723 (princ ")")))))))
848
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3724
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3725 (defconst custom-save-resets-mapper-alist
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3726 (eval-when-compile
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3727 (list (list 'theme-value 'custom-reset-variables
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3728 (byte-compile
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3729 (make-custom-save-resets-mapper
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3730 'theme-value 'custom-reset-variables)))
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3731 (list 'theme-face 'custom-reset-faces
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3732 (byte-compile
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3733 (make-custom-save-resets-mapper
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3734 'theme-face 'custom-reset-faces)))))
848
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3735 "Never use it.
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3736 Hashes several heavily used functions for `custom-save-resets'")
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3737
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3738 (defun custom-save-resets (property setter special)
848
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3739 (declare (special ignored-special))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3740 (let (started-writing ignored-special)
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
3741 ;; (custom-save-delete setter) Done by caller
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3742 (let ((standard-output (current-buffer))
848
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3743 (mapper (let ((triple (assq property custom-save-resets-mapper-alist)))
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3744 (if (and triple (eq (second triple) setter))
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3745 (third triple)
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3746 (make-custom-save-resets-mapper property setter)))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3747 (mapc mapper special)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3748 (setq ignored-special special)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3749 (mapatoms mapper)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3750 (when started-writing
848
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3751 (princ ")\n")))))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
3752
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3753
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3754 (defun custom-save-loaded-themes ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3755 (let ((themes (reverse (get 'user 'theme-loads-themes)))
848
0cb55b2a2c66 [xemacs-hg @ 2002-05-17 18:28:45 by adrian]
adrian
parents: 782
diff changeset
3756 (standard-output (current-buffer))
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3757 (print-level nil)
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3758 (print-length nil))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3759 (when themes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3760 (unless (bolp) (princ "\n"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3761 (princ "(custom-load-themes")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3762 (mapc (lambda (theme)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3763 (princ "\n '")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3764 (prin1 theme)) themes)
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
3765 (princ " )\n"))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3766
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3767 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3768 (defun customize-save-customized ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3769 "Save all user options which have been set in this session."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3770 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3771 (mapatoms (lambda (symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3772 (let ((face (get symbol 'customized-face))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3773 (value (get symbol 'customized-value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3774 (face-comment (get symbol 'customized-face-comment))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3775 (variable-comment
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3776 (get symbol 'customized-variable-comment)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3777 (when face
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3778 (put symbol 'saved-face face)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3779 (custom-push-theme 'theme-face symbol 'user 'set value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3780 (put symbol 'customized-face nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3781 (when value
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3782 (put symbol 'saved-value value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3783 (custom-push-theme 'theme-value symbol 'user 'set value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3784 (put symbol 'customized-value nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3785 (when variable-comment
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3786 (put symbol 'saved-variable-comment variable-comment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3787 (put symbol 'customized-variable-comment nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3788 (when face-comment
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3789 (put symbol 'saved-face-comment face-comment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3790 (put symbol 'customized-face-comment nil)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3791 ;; We really should update all custom buffers here.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3792 (custom-save-all))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3793
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3794 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3795 (defun custom-save-all ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3796 "Save all customizations in `custom-file'."
4257
ef6c55ab3090 [xemacs-hg @ 2007-11-08 14:43:38 by aidan]
aidan
parents: 4178
diff changeset
3797 (when init-file-had-error
ef6c55ab3090 [xemacs-hg @ 2007-11-08 14:43:38 by aidan]
aidan
parents: 4178
diff changeset
3798 (error 'invalid-change
ef6c55ab3090 [xemacs-hg @ 2007-11-08 14:43:38 by aidan]
aidan
parents: 4178
diff changeset
3799 "Cannot save customizations; init file was not fully loaded"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3800 (let ((inhibit-read-only t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3801 (custom-save-variables)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3802 (custom-save-faces)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3803 (let ((find-file-hooks nil)
4382
12ff8dc2b57e Create the containing directory for the custom and init files if necessary.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4289
diff changeset
3804 (auto-mode-alist)
4434
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
3805 custom-file-directory)
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
3806 (unless (file-directory-p (setq custom-file-directory
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
3807 (file-name-directory custom-file)))
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
3808 (message "Creating %s... " custom-file-directory)
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
3809 (make-directory custom-file-directory t)
7f3d065a56a1 Ease customization of faces under point...
Didier Verna <didier@xemacs.org>
parents: 4382
diff changeset
3810 (message "Creating %s... done." custom-file-directory))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3811 (with-current-buffer (find-file-noselect custom-file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3812 (save-buffer)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3813
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3814
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3815 ;;; The Customize Menu.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3816
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3817 ;;; Menu support
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3818
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3819 (defun custom-face-menu-create (widget symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3820 "Ignoring WIDGET, create a menu entry for customization face SYMBOL."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3821 (vector (custom-unlispify-menu-entry symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3822 `(customize-face ',symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3823 t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3824
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3825 (defun custom-variable-menu-create (widget symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3826 "Ignoring WIDGET, create a menu entry for customization variable SYMBOL."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3827 (let ((type (get symbol 'custom-type)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3828 (unless (listp type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3829 (setq type (list type)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3830 (if (and type (widget-get type :custom-menu))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3831 (widget-apply type :custom-menu symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3832 (vector (custom-unlispify-menu-entry symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3833 `(customize-variable ',symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3834 t))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3835
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3836 ;; Add checkboxes to boolean variable entries.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3837 (widget-put (get 'boolean 'widget-type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3838 :custom-menu (lambda (widget symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3839 `[,(custom-unlispify-menu-entry symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3840 (customize-variable ',symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3841 :style toggle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3842 :selected ,symbol]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3843
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3844 ;; XEmacs can create menus dynamically.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3845 (defun custom-group-menu-create (widget symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3846 "Ignoring WIDGET, create a menu entry for customization group SYMBOL."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3847 `( ,(custom-unlispify-menu-entry symbol t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3848 :filter (lambda (&rest junk)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3849 (let ((item (custom-menu-create ',symbol)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3850 (if (listp item)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3851 (cdr item)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3852 (list item))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3853
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3854 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3855 (defun custom-menu-create (symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3856 "Create menu for customization group SYMBOL.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3857 The menu is in a format applicable to `easy-menu-define'."
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
3858 (menu-split-long-menu
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
3859 (let* ((item (vector (custom-unlispify-menu-entry symbol)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
3860 `(customize-group ',symbol)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
3861 t)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
3862 ;; Item is the entry for creating a menu buffer for SYMBOL.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
3863 ;; We may nest, if the menu is not too big.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
3864 (custom-load-custom-defines symbol)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
3865 (if t ;(< (length (get symbol 'custom-group)) widget-menu-max-size)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
3866 ;; The menu is not too big.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
3867 (let ((custom-prefix-list (custom-prefix-add symbol
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
3868 custom-prefix-list))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
3869 (members (custom-sort-items (get symbol 'custom-group)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
3870 custom-menu-sort-alphabetically
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
3871 custom-menu-order-groups)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
3872 ;; Create the menu.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
3873 `(,(custom-unlispify-menu-entry symbol t)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
3874 ,item
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
3875 "--"
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
3876 ,@(mapcar (lambda (entry)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
3877 (widget-apply (if (listp (nth 1 entry))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
3878 (nth 1 entry)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
3879 (list (nth 1 entry)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
3880 :custom-menu (nth 0 entry)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
3881 members)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
3882 ; else ;; The menu was too big.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
3883 item
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 2122
diff changeset
3884 ))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3885
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3886 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3887 (defun customize-menu-create (symbol &optional name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3888 "Return a customize menu for customization group SYMBOL.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3889 If optional NAME is given, use that as the name of the menu.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3890 Otherwise the menu will be named `Customize'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3891 The format is suitable for use with `easy-menu-define'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3892 (unless name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3893 (setq name "Customize"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3894 `(,name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3895 :filter (lambda (&rest junk)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3896 (cdr (custom-menu-create ',symbol)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3897
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3898 ;;; The Custom Mode.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3899
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3900 (defvar custom-mode-map nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3901 "Keymap for `custom-mode'.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3902
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3903 (unless custom-mode-map
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3904 (setq custom-mode-map (make-sparse-keymap))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3905 (set-keymap-parents custom-mode-map widget-keymap)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3906 (suppress-keymap custom-mode-map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3907 (define-key custom-mode-map " " 'scroll-up)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3908 (define-key custom-mode-map [delete] 'scroll-down)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3909 (define-key custom-mode-map "q" 'Custom-buffer-done)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3910 (define-key custom-mode-map "u" 'Custom-goto-parent)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3911 (define-key custom-mode-map "n" 'widget-forward)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3912 (define-key custom-mode-map "p" 'widget-backward))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3913
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3914 (easy-menu-define Custom-mode-menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3915 custom-mode-map
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3916 "Menu used in customization buffers."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3917 `("Custom"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3918 ,(customize-menu-create 'customize)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3919 ["Set" Custom-set t]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3920 ["Save" Custom-save t]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3921 ["Reset to Current" Custom-reset-current t]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3922 ["Reset to Saved" Custom-reset-saved t]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3923 ["Reset to Standard Settings" Custom-reset-standard t]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3924 ["Info" (Info-goto-node "(xemacs)Easy Customization") t]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3925
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3926 (defun Custom-goto-parent ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3927 "Go to the parent group listed at the top of this buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3928 If several parents are listed, go to the first of them."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3929 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3930 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3931 (goto-char (point-min))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3932 (if (search-forward "\nGo to parent group: " nil t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3933 (let* ((button (get-char-property (point) 'button))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3934 (parent (downcase (widget-get button :tag))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3935 (customize-group parent)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3936
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3937 (defcustom custom-mode-hook nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3938 "Hook called when entering custom-mode."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3939 :type 'hook
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3940 :group 'custom-buffer )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3941
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3942 (defun custom-state-buffer-message (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3943 (if (eq (widget-get (widget-get widget :parent) :custom-state) 'modified)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3944 (message
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3945 "To install your edits, invoke [State] and choose the Set operation")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3946
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3947 (defun custom-mode ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3948 "Major mode for editing customization buffers.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3949
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3950 The following commands are available:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3951
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3952 Move to next button or editable field. \\[widget-forward]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3953 Move to previous button or editable field. \\[widget-backward]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3954 \\<widget-field-keymap>\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3955 Complete content of editable text field. \\[widget-complete]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3956 \\<custom-mode-map>\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3957 Invoke button under point. \\[widget-button-press]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3958 Set all modifications. \\[Custom-set]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3959 Make all modifications default. \\[Custom-save]
4178
e687f1912d5b [xemacs-hg @ 2007-09-20 21:18:33 by didierv]
didierv
parents: 4021
diff changeset
3960 Reset all modified options. \\[Custom-reset-current]
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3961 Reset all modified or set options. \\[Custom-reset-saved]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3962 Reset all options. \\[Custom-reset-standard]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3963
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3964 Entry to this mode calls the value of `custom-mode-hook'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3965 if that value is non-nil."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3966 (kill-all-local-variables)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3967 (setq major-mode 'custom-mode
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3968 mode-name "Custom")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3969 (use-local-map custom-mode-map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3970 (easy-menu-add Custom-mode-menu)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3971 (make-local-variable 'custom-options)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3972 (make-local-variable 'widget-documentation-face)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3973 (setq widget-documentation-face 'custom-documentation-face)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3974 (make-local-variable 'widget-button-face)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3975 (setq widget-button-face 'custom-button-face)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3976 (make-local-hook 'widget-edit-functions)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3977 (add-hook 'widget-edit-functions 'custom-state-buffer-message nil t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3978 (run-hooks 'custom-mode-hook))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3979
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3980
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3981 ;;;###autoload
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3982 (defun custom-migrate-custom-file (new-custom-file-name)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3983 "Migrate custom file from home directory."
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3984 (mapc 'custom-save-delete
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3985 '(custom-load-themes custom-reset-variables
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3986 custom-set-variables
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3987 custom-set-faces
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3988 custom-reset-faces))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3989 (with-current-buffer (find-file-noselect custom-file)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3990 (save-buffer))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3991 (setq custom-file new-custom-file-name)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3992 (custom-save-all))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3993
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3994 ;;; The End.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3995
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3996 (provide 'cus-edit)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3997
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3998 ;; cus-edit.el ends here