annotate lisp/gnus/custom.el @ 9:6f2bbbbbe05a

Added tag r19-15b5 for changeset 4b173ad71786
author cvs
date Mon, 13 Aug 2007 08:47:36 +0200
parents ac2d302a0011
children 0293115a14e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; custom.el --- User friendly customization support.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1995, 1996 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Author: Per Abrahamsen <abraham@iesd.auc.dk>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Keywords: help
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Version: 0.5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; WARNING: This package is still under construction and not all of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; the features below are implemented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; This package provides a framework for adding user friendly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; customization support to Emacs. Having to do customization by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; editing a text file in some arcane syntax is user hostile in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; extreme, and to most users emacs lisp definitely count as arcane.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; The intent is that authors of emacs lisp packages declare the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; variables intended for user customization with `custom-declare'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; Custom can then automatically generate a customization buffer with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; `custom-buffer-create' where the user can edit the package
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; variables in a simple and intuitive way, as well as a menu with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; `custom-menu-create' where he can set the more commonly used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; variables interactively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; It is also possible to use custom for modifying the properties of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; other objects than the package itself, by specifying extra optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; arguments to `custom-buffer-create'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;; Custom is inspired by OPEN LOOK property windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;;; Todo:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;; - Toggle documentation in three states `none', `one-line', `full'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;; - Function to generate an XEmacs menu from a CUSTOM.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;; - Write TeXinfo documentation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;; - Make it possible to hide sections by clicking at the level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;; - Declare AUC TeX variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; - Declare (ding) Gnus variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;; - Declare Emacs variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;; - Implement remaining types.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;; - XEmacs port.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;; - Allow `URL', `info', and internal hypertext buttons.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;; - Support meta-variables and goal directed customization.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;; - Make it easy to declare custom types independently.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;; - Make it possible to declare default value and type for a single
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;; variable, storing the data in a symbol property.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;; - Syntactic sugar for CUSTOM declarations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;; - Use W3 for variable documentation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (require 'cl))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;;; Compatibility:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (defun custom-xmas-add-text-properties (start end props &optional object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (add-text-properties start end props object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (put-text-property start end 'start-open t object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (put-text-property start end 'end-open t object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (defun custom-xmas-put-text-property (start end prop value &optional object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (put-text-property start end prop value object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (put-text-property start end 'start-open t object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (put-text-property start end 'end-open t object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (defun custom-xmas-extent-start-open ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (map-extents (lambda (extent arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (set-extent-property extent 'start-open t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 nil (point) (min (1+ (point)) (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (if (string-match "XEmacs\\|Lucid" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (fset 'custom-add-text-properties 'custom-xmas-add-text-properties)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (fset 'custom-put-text-property 'custom-xmas-put-text-property)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (fset 'custom-extent-start-open 'custom-xmas-extent-start-open)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (fset 'custom-set-text-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (if (fboundp 'set-text-properties)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 'set-text-properties))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (fset 'custom-buffer-substring-no-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (if (fboundp 'buffer-substring-no-properties)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 'buffer-substring-no-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 'custom-xmas-buffer-substring-no-properties)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (fset 'custom-add-text-properties 'add-text-properties)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (fset 'custom-put-text-property 'put-text-property)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (fset 'custom-extent-start-open 'ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (fset 'custom-set-text-properties 'set-text-properties)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (fset 'custom-buffer-substring-no-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 'buffer-substring-no-properties))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (defun custom-xmas-buffer-substring-no-properties (beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 "Return the text from BEG to END, without text properties, as a string."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (let ((string (buffer-substring beg end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (custom-set-text-properties 0 (length string) nil string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;; XEmacs and Emacs 19.29 facep does different things.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
117 (defalias 'custom-facep
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
118 (cond ((fboundp 'find-face)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
119 'find-face)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
120 ((fboundp 'facep)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
121 'facep)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
122 (t
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
123 'ignore)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (if (custom-facep 'underline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;; No underline face in XEmacs 19.12.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (and (fboundp 'make-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (funcall (intern "make-face") 'underline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;; Must avoid calling set-face-underline-p directly, because it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;; is a defsubst in emacs19, and will make the .elc files non
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;; portable!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (or (and (fboundp 'face-differs-from-default-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (face-differs-from-default-p 'underline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (and (fboundp 'set-face-underline-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (funcall 'set-face-underline-p 'underline t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (defun custom-xmas-set-text-properties (start end props &optional buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (if (null buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (if props
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (while props
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (custom-put-text-property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 start end (car props) (nth 1 props) buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (setq props (nthcdr 2 props)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (remove-text-properties start end ()))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (or (fboundp 'event-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ;; Missing in Emacs 19.29.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (defun event-point (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 "Return the character position of the given mouse-motion, button-press,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 or button-release event. If the event did not occur over a window, or did
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 not occur over text, then this returns nil. Otherwise, it returns an index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 into the buffer visible in the event's window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (posn-point (event-start event))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (defvar x-colors nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (defvar custom-button-face nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (defvar custom-field-uninitialized-face nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (defvar custom-field-invalid-face nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (defvar custom-field-modified-face nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (defvar custom-field-face nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (defvar custom-mouse-face nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (defvar custom-field-active-face nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ;; We can't easily check for a working intangible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (defconst intangible (if (and (boundp 'emacs-minor-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (or (> emacs-major-version 19)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (and (> emacs-major-version 18)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (> emacs-minor-version 28))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (setq intangible 'intangible)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (setq intangible 'intangible-if-it-had-been-working))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 "The symbol making text intangible.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (defconst rear-nonsticky (if (string-match "XEmacs" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 'end-open
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 'rear-nonsticky)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 "The symbol making text properties non-sticky in the rear end.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (defconst front-sticky (if (string-match "XEmacs" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 'front-closed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 'front-sticky)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 "The symbol making text properties sticky in the front.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (defconst mouse-face (if (string-match "XEmacs" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 'highlight
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 'mouse-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 "Symbol used for highlighting text under mouse.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;; Put it in the Help menu, if possible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (if (string-match "XEmacs" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (if (featurep 'menubar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ;; XEmacs (disabled because it doesn't work)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (and current-menubar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (add-menu-item '("Help") "Customize..." 'customize t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 ;; Emacs 19.28 and earlier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (global-set-key [ menu-bar help customize ]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 '("Customize..." . customize))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ;; Emacs 19.29 and later
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (global-set-key [ menu-bar help-menu customize ]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 '("Customize..." . customize)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 ;; XEmacs popup-menu stolen from w3.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (defun custom-x-really-popup-menu (pos title menudesc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 "My hacked up function to do a blocking popup menu..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (let ((echo-keystrokes 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 event menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (while menudesc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (setq menu (cons (vector (car (car menudesc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (list (car (car menudesc))) t) menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 menudesc (cdr menudesc)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (setq menu (cons title menu))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (popup-menu menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (catch 'popup-done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (while t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (setq event (next-command-event event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (cond ((and (misc-user-event-p event) (stringp (car-safe (event-object event))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (throw 'popup-done (event-object event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 ((and (misc-user-event-p event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (or (eq (event-object event) 'abort)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (eq (event-object event) 'menu-no-selection-hook)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 ((not (popup-menu-up-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (throw 'popup-done nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 ((button-release-event-p event);; don't beep twice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (message "please make a choice from the menu.")))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ;;; Categories:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 ;; XEmacs use inheritable extents for the same purpose as Emacs uses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 ;; the category text property.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (if (string-match "XEmacs" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 ;; XEmacs categories.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (defun custom-category-create (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (set name (make-extent nil nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 "Create a text property category named NAME.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (defun custom-category-put (name property value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 "In CATEGORY set PROPERTY to VALUE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (set-extent-property (symbol-value name) property value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (defun custom-category-get (name property)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 "In CATEGORY get PROPERTY."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (extent-property (symbol-value name) property))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (defun custom-category-set (from to category)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 "Make text between FROM and TWO have category CATEGORY."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (let ((extent (make-extent from to)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (set-extent-parent extent (symbol-value category)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 ;; Emacs categories.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (defun custom-category-create (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 "Create a text property category named NAME."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (set name name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (defun custom-category-put (name property value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 "In CATEGORY set PROPERTY to VALUE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (put name property value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (defun custom-category-get (name property)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 "In CATEGORY get PROPERTY."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (get name property))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (defun custom-category-set (from to category)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 "Make text between FROM and TWO have category CATEGORY."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (custom-put-text-property from to 'category category)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 ;;; External Data:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 ;; The following functions and variables defines the interface for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 ;; connecting a CUSTOM with an external entity, by default an emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 ;; lisp variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (defvar custom-external 'default-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 "Function returning the external value of NAME.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (defvar custom-external-set 'set-default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 "Function setting the external value of NAME to VALUE.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (defun custom-external (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 "Get the external value associated with NAME."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (funcall custom-external name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (defun custom-external-set (name value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 "Set the external value associated with NAME to VALUE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (funcall custom-external-set name value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (defvar custom-name-fields nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 "Alist of custom names and their associated editing field.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (make-variable-buffer-local 'custom-name-fields)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (defun custom-name-enter (name field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 "Associate NAME with FIELD."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (if (null name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (custom-assert 'field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (setq custom-name-fields (cons (cons name field) custom-name-fields))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (defun custom-name-field (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 "The editing field associated with NAME."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (cdr (assq name custom-name-fields)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (defun custom-name-value (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 "The value currently displayed for NAME in the customization buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (let* ((field (custom-name-field name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (custom (custom-field-custom field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (custom-field-parse field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (funcall (custom-property custom 'export) custom
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (car (custom-field-extract custom field)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (defvar custom-save 'custom-save
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 "Function that will save current customization buffer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 ;;; Custom Functions:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 ;; The following functions are part of the public interface to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 ;; CUSTOM datastructure. Each CUSTOM describes a group of variables,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 ;; a single variable, or a component of a structured variable. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 ;; CUSTOM instances are part of two hierarchies, the first is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 ;; `part-of' hierarchy in which each CUSTOM is a component of another
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 ;; CUSTOM, except for the top level CUSTOM which is contained in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 ;; `custom-data'. The second hierarchy is a `is-a' type hierarchy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 ;; where each CUSTOM is a leaf in the hierarchy defined by the `type'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 ;; property and `custom-type-properties'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (defvar custom-file "~/.custom.el"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 "Name of file with customization information.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (defconst custom-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 '((tag . "Emacs")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (doc . "The extensible self-documenting text editor.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (type . group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (data "\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 ((header . nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (compact . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (type . group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (doc . "\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 Press [Save] to save any changes permanently after you are done editing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 You can load customization information from other files by editing the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 `File' field and pressing the [Load] button. When you press [Save] the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 customization information of all files you have loaded, plus any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 changes you might have made manually, will be stored in the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 specified by the `File' field.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (data ((tag . "Load")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (type . button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (query . custom-load))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 ((tag . "Save")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (type . button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (query . custom-save))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 ((name . custom-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (default . "~/.custom.el")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (doc . "Name of file with customization information.\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (tag . "File")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (type . file))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 "The global customization information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 A custom association list.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (defun custom-declare (path custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 "Declare variables for customization.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 PATH is a list of tags leading to the place in the customization
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 hierarchy the new entry should be added. CUSTOM is the entry to add."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (custom-initialize custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (let ((current (custom-travel-path custom-data path)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (or (member custom (custom-data current))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (nconc (custom-data current) (list custom)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (put 'custom-declare 'lisp-indent-hook 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (defconst custom-type-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 '((repeat (type . default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 ;; See `custom-match'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (import . custom-repeat-import)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (eval . custom-repeat-eval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (quote . custom-repeat-quote)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (accept . custom-repeat-accept)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (extract . custom-repeat-extract)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (validate . custom-repeat-validate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (insert . custom-repeat-insert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (match . custom-repeat-match)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (query . custom-repeat-query)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (prefix . "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (del-tag . "[DEL]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (add-tag . "[INS]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (pair (type . group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 ;; A cons-cell.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (accept . custom-pair-accept)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (eval . custom-pair-eval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (import . custom-pair-import)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (quote . custom-pair-quote)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (valid . (lambda (c d) (consp d)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (extract . custom-pair-extract))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (list (type . group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 ;; A lisp list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (quote . custom-list-quote)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (valid . (lambda (c d)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (listp d)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (extract . custom-list-extract))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (group (type . default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 ;; See `custom-match'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (face-tag . nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (eval . custom-group-eval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (import . custom-group-import)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (initialize . custom-group-initialize)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (apply . custom-group-apply)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (reset . custom-group-reset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (factory-reset . custom-group-factory-reset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (extract . nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (validate . custom-group-validate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (query . custom-toggle-hide)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (accept . custom-group-accept)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (insert . custom-group-insert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (find . custom-group-find))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (toggle (type . choice)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 ;; Booleans.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (data ((type . const)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (tag . "On ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (default . t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 ((type . const)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (tag . "Off")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (default . nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (triggle (type . choice)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 ;; On/Off/Default.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (data ((type . const)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (tag . "On ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (default . t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 ((type . const)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (tag . "Off")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (default . nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 ((type . const)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (tag . "Def")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (default . custom:asis))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (choice (type . default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 ;; See `custom-match'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (query . custom-choice-query)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (accept . custom-choice-accept)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (extract . custom-choice-extract)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (validate . custom-choice-validate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (insert . custom-choice-insert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (none (tag . "Unknown")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (default . __uninitialized__)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (type . const)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (const (type . default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 ;; A `const' only matches a single lisp value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (extract . (lambda (c f) (list (custom-default c))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (validate . (lambda (c f) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (valid . custom-const-valid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (update . custom-const-update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (insert . custom-const-insert))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (face-doc (type . doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 ;; A variable containing a face.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (doc . "\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 You can customize the look of Emacs by deciding which faces should be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 used when. If you push one of the face buttons below, you will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 given a choice between a number of standard faces. The name of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 selected face is shown right after the face button, and it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 displayed its own face so you can see how it looks. If you know of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 another standard face not listed and want to use it, you can select
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 `Other' and write the name in the editing field.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 If none of the standard faces suits you, you can select `Customize' to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 create your own face. This will make six fields appear under the face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 button. The `Fg' and `Bg' fields are the foreground and background
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 colors for the face, respectively. You should type the name of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 color in the field. You can use any X11 color name. A list of X11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 color names may be available in the file `/usr/lib/X11/rgb.txt' on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 your system. The special color name `default' means that the face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 will not change the color of the text. The `Stipple' field is weird,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 so just ignore it. The three remaining fields are toggles, which will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 make the text `bold', `italic', or `underline' respectively. For some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 fonts `bold' or `italic' will not make any visible change."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (face (type . choice)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (eval . custom-face-eval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (import . custom-face-import)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (data ((tag . "None")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (default . nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (type . const))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 ((tag . "Default")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (default . default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (face . custom-const-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (type . const))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 ((tag . "Bold")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (default . bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (face . custom-const-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (type . const))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 ((tag . "Bold-italic")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (default . bold-italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (face . custom-const-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (type . const))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 ((tag . "Italic")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (default . italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (face . custom-const-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (type . const))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 ((tag . "Underline")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (default . underline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (face . custom-const-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (type . const))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 ((tag . "Highlight")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (default . highlight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (face . custom-const-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (type . const))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 ((tag . "Modeline")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (default . modeline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (face . custom-const-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (type . const))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 ((tag . "Region")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (default . region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (face . custom-const-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (type . const))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 ((tag . "Secondary Selection")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (default . secondary-selection)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (face . custom-const-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (type . const))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 ((tag . "Customized")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (compact . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (face-tag . custom-face-hack)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (eval . custom-face-eval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (data ((hidden . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (tag . "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (doc . "\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 Select the properties you want this face to have.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (default . custom-face-lookup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (type . const))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 "\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 ((tag . "Fg")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (hidden . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (default . "default")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (width . 20)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (type . string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 ((tag . "Bg")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (default . "default")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (width . 20)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (type . string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 ((tag . "Stipple")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (default . "default")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (width . 20)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (type . string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 "\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 ((tag . "Bold")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (default . custom:asis)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (type . triggle))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 ((tag . "Italic")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (default . custom:asis)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (type . triggle))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 ((tag . "Underline")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (hidden . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (default . custom:asis)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (type . triggle)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (default . (custom-face-lookup "default" "default" "default"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 nil nil nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (type . list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 ((prompt . "Other")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (face . custom-field-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (default . __uninitialized__)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (type . symbol))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (file (type . string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 ;; A string containing a file or directory name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (directory . nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (default-file . nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (query . custom-file-query))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (sexp (type . default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 ;; Any lisp expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (width . 40)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (default . (__uninitialized__ . "Uninitialized"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (read . custom-sexp-read)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (write . custom-sexp-write))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (symbol (type . sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 ;; A lisp symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (width . 40)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (valid . (lambda (c d) (symbolp d))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (integer (type . sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 ;; A lisp integer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (width . 10)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (valid . (lambda (c d) (integerp d))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (string (type . default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 ;; A lisp string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (width . 40)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (valid . (lambda (c d) (stringp d)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (read . custom-string-read)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (write . custom-string-write))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (button (type . default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 ;; Push me.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (accept . ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (extract . nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (validate . ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (insert . custom-button-insert))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (doc (type . default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 ;; A documentation only entry with no value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (header . nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (reset . ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (extract . nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (validate . ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (insert . custom-documentation-insert))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (default (width . 20)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (valid . (lambda (c v) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (insert . custom-default-insert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (update . custom-default-update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (query . custom-default-query)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (tag . nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (prompt . nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (doc . nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (header . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (padding . ? )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (quote . custom-default-quote)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (eval . (lambda (c v) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (export . custom-default-export)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (import . (lambda (c v) (list v)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (synchronize . ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (initialize . custom-default-initialize)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (extract . custom-default-extract)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (validate . custom-default-validate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (apply . custom-default-apply)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (reset . custom-default-reset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (factory-reset . custom-default-factory-reset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (accept . custom-default-accept)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (match . custom-default-match)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (name . nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (compact . nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (hidden . nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (face . custom-default-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (data . nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (calculate . nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (default . __uninitialized__)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 "Alist of default properties for type symbols.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 The format is `((SYMBOL (PROPERTY . VALUE)... )... )'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (defconst custom-local-type-properties nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 "Local type properties.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 Entries in this list take precedence over `custom-type-properties'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (make-variable-buffer-local 'custom-local-type-properties)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (defconst custom-nil '__uninitialized__
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 "Special value representing an uninitialized field.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (defconst custom-invalid '__invalid__
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 "Special value representing an invalid field.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (defconst custom:asis 'custom:asis)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 ;; Bad, ugly, and horrible kludge.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (defun custom-property (custom property)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 "Extract from CUSTOM property PROPERTY."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (let ((entry (assq property custom)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (while (null entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 ;; Look in superclass.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (let ((type (custom-type custom)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (setq custom (cdr (or (assq type custom-local-type-properties)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (assq type custom-type-properties)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 entry (assq property custom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (custom-assert 'custom)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (cdr entry)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 (defun custom-super (custom property)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 "Extract from CUSTOM property PROPERTY. Start with CUSTOM's superclass."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (let ((entry nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (while (null entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 ;; Look in superclass.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (let ((type (custom-type custom)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (setq custom (cdr (or (assq type custom-local-type-properties)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 (assq type custom-type-properties)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 entry (assq property custom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (custom-assert 'custom)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (cdr entry)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (defun custom-property-set (custom property value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 "Set CUSTOM PROPERTY to VALUE by side effect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 CUSTOM must have at least one property already."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (let ((entry (assq property custom)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 (if entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (setcdr entry value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (setcdr custom (cons (cons property value) (cdr custom))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (defun custom-type (custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 "Extract `type' from CUSTOM."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (cdr (assq 'type custom)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 (defun custom-name (custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 "Extract `name' from CUSTOM."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (custom-property custom 'name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (defun custom-tag (custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 "Extract `tag' from CUSTOM."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (custom-property custom 'tag))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 (defun custom-face-tag (custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 "Extract `face-tag' from CUSTOM."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (custom-property custom 'face-tag))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 (defun custom-prompt (custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 "Extract `prompt' from CUSTOM.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 If none exist, default to `tag' or, failing that, `type'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 (or (custom-property custom 'prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 (custom-property custom 'tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (capitalize (symbol-name (custom-type custom)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (defun custom-default (custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 "Extract `default' from CUSTOM."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (let ((value (custom-property custom 'calculate)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (if value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (eval value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (custom-property custom 'default))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 (defun custom-data (custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 "Extract the `data' from CUSTOM."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 (custom-property custom 'data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (defun custom-documentation (custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 "Extract `doc' from CUSTOM."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (custom-property custom 'doc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (defun custom-width (custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 "Extract `width' from CUSTOM."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (custom-property custom 'width))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (defun custom-compact (custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 "Extract `compact' from CUSTOM."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (custom-property custom 'compact))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (defun custom-padding (custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 "Extract `padding' from CUSTOM."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 (custom-property custom 'padding))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (defun custom-valid (custom value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 "Non-nil if CUSTOM may validly be set to VALUE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (and (not (and (listp value) (eq custom-invalid (car value))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (funcall (custom-property custom 'valid) custom value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 (defun custom-import (custom value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 "Import CUSTOM VALUE from external variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 This function change VALUE into a form that makes it easier to edit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 internally. What the internal form is exactly depends on CUSTOM.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 The internal form is returned."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (if (eq custom-nil value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 (list custom-nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 (funcall (custom-property custom 'import) custom value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (defun custom-eval (custom value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 "Return non-nil if CUSTOM's VALUE needs to be evaluated."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 (funcall (custom-property custom 'eval) custom value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (defun custom-quote (custom value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 "Quote CUSTOM's VALUE if necessary."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (funcall (custom-property custom 'quote) custom value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (defun custom-write (custom value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 "Convert CUSTOM VALUE to a string."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (cond ((eq value custom-nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 ((and (listp value) (eq (car value) custom-invalid))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (cdr value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (funcall (custom-property custom 'write) custom value))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (defun custom-read (custom string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 "Convert CUSTOM field content STRING into lisp."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (funcall (custom-property custom 'read) custom string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (error (cons custom-invalid string))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 (defun custom-match (custom values)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 "Match CUSTOM with a list of VALUES.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 Return a cons-cell where the car is the sublist of VALUES matching CUSTOM,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 and the cdr is the remaining VALUES.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 A CUSTOM is actually a regular expression over the alphabet of lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 types. Most CUSTOM types are just doing a literal match, e.g. the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 `symbol' type matches any lisp symbol. The exceptions are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 group: which corresponds to a `(' and `)' group in a regular expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 choice: which corresponds to a group of `|' in a regular expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 repeat: which corresponds to a `*' in a regular expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 optional: which corresponds to a `?', and isn't implemented yet."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (if (memq values (list custom-nil nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 ;; Nothing matches the uninitialized or empty list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 (cons custom-nil nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 (funcall (custom-property custom 'match) custom values)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (defun custom-initialize (custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 "Initialize `doc' and `default' attributes of CUSTOM."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 (funcall (custom-property custom 'initialize) custom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 (defun custom-find (custom tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 "Find child in CUSTOM with `tag' TAG."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 (funcall (custom-property custom 'find) custom tag))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 (defun custom-travel-path (custom path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 "Find decedent of CUSTOM by looking through PATH."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 (if (null path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 custom
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (custom-travel-path (custom-find custom (car path)) (cdr path))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (defun custom-field-extract (custom field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 "Extract CUSTOM's value in FIELD."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (if (stringp custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (funcall (custom-property (custom-field-custom field) 'extract)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 custom field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (defun custom-field-validate (custom field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 "Validate CUSTOM's value in FIELD.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 Return nil if valid, otherwise return a cons-cell where the car is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 position of the error, and the cdr is a text describing the error."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 (if (stringp custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (funcall (custom-property custom 'validate) custom field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 ;;; Field Functions:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 ;; This section defines the public functions for manipulating the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 ;; FIELD datatype. The FIELD instance hold information about a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 ;; specific editing field in the customization buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 ;; Each FIELD can be seen as an instantiation of a CUSTOM.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 (defvar custom-field-last nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 ;; Last field containing point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (make-variable-buffer-local 'custom-field-last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (defvar custom-modified-list nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 ;; List of modified fields.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (make-variable-buffer-local 'custom-modified-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 (defun custom-field-create (custom value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 "Create a field structure of type CUSTOM containing VALUE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 A field structure is an array [ CUSTOM VALUE ORIGINAL START END ], where
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 CUSTOM defines the type of the field,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 VALUE is the current value of the field,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 ORIGINAL is the original value when created, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 START and END are markers to the start and end of the field."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (vector custom value custom-nil nil nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (defun custom-field-custom (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 "Return the `custom' attribute of FIELD."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (aref field 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (defun custom-field-value (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 "Return the `value' attribute of FIELD."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (aref field 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (defun custom-field-original (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 "Return the `original' attribute of FIELD."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (aref field 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (defun custom-field-start (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 "Return the `start' attribute of FIELD."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (aref field 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (defun custom-field-end (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 "Return the `end' attribute of FIELD."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 (aref field 4))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 (defun custom-field-value-set (field value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 "Set the `value' attribute of FIELD to VALUE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 (aset field 1 value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 (defun custom-field-original-set (field original)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 "Set the `original' attribute of FIELD to ORIGINAL."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (aset field 2 original))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 (defun custom-field-move (field start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 "Set the `start'and `end' attributes of FIELD to START and END."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 (set-marker (or (aref field 3) (aset field 3 (make-marker))) start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (set-marker (or (aref field 4) (aset field 4 (make-marker))) end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 (defun custom-field-query (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 "Query user for content of current field."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 (funcall (custom-property (custom-field-custom field) 'query) field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 (defun custom-field-accept (field value &optional original)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 "Store a new value into field FIELD, taking it from VALUE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 If optional ORIGINAL is non-nil, consider VALUE for the original value."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 (let ((inhibit-point-motion-hooks t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (funcall (custom-property (custom-field-custom field) 'accept)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 field value original)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 (defun custom-field-face (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 "The face used for highlighting FIELD."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 (let ((custom (custom-field-custom field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 (if (stringp custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 (let ((face (funcall (custom-property custom 'face) field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 (if (custom-facep face) face nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 (defun custom-field-update (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 "Update the screen appearance of FIELD to correspond with the field's value."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (let ((custom (custom-field-custom field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (if (stringp custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (funcall (custom-property custom 'update) field))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 ;;; Types:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 ;; The following functions defines type specific actions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (defun custom-repeat-eval (custom value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 "Non-nil if CUSTOM's VALUE needs to be evaluated."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 (if (eq value custom-nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 (let ((child (custom-data custom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 (found nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (mapcar (lambda (v) (if (custom-eval child v) (setq found t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 value))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 (defun custom-repeat-quote (custom value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 "A list of CUSTOM's VALUEs quoted."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 (let ((child (custom-data custom)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 (apply 'append (mapcar (lambda (v) (custom-quote child v))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 value))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 (defun custom-repeat-import (custom value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 "Modify CUSTOM's VALUE to match internal expectations."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 (let ((child (custom-data custom)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 (apply 'append (mapcar (lambda (v) (custom-import child v))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 value))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 (defun custom-repeat-accept (field value &optional original)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 "Store a new value into field FIELD, taking it from VALUE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 (let ((values (copy-sequence (custom-field-value field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (all (custom-field-value field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 (start (custom-field-start field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 current new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 (if original
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 (custom-field-original-set field value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 (while (consp value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 (setq new (car value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 value (cdr value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 (if values
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 ;; Change existing field.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 (setq current (car values)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 values (cdr values))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 ;; Insert new field if series has grown.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 (setq current (custom-repeat-insert-entry field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 (setq all (custom-insert-before all nil current))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 (custom-field-value-set field all))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 (custom-field-accept current new original))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 (while (consp values)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 ;; Delete old field if series has scrunk.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 (setq current (car values)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 values (cdr values))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 (let ((pos (custom-field-start current))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 (while (not data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 (setq pos (previous-single-property-change pos 'custom-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 (custom-assert 'pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 (setq data (get-text-property pos 'custom-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 (or (and (arrayp data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 (> (length data) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 (eq current (aref data 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 (setq data nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 (custom-repeat-delete data)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 (defun custom-repeat-insert (custom level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 "Insert field for CUSTOM at nesting LEVEL in customization buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 (let* ((field (custom-field-create custom nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (add-tag (custom-property custom 'add-tag))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 (start (make-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 (data (vector field nil start nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 (custom-text-insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 (let ((pos (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 (custom-text-insert (custom-property custom 'prefix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 (custom-tag-insert add-tag 'custom-repeat-add data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 (set-marker start pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 (custom-field-move field start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 (custom-documentation-insert custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 (defun custom-repeat-insert-entry (repeat)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 "Insert entry at point in the REPEAT field."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 (let* ((inhibit-point-motion-hooks t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 (inhibit-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 (before-change-functions nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 (after-change-functions nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 (custom (custom-field-custom repeat))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 (add-tag (custom-property custom 'add-tag))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 (del-tag (custom-property custom 'del-tag))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 (start (make-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 (end (make-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 (data (vector repeat nil start end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 (custom-extent-start-open)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 (insert-before-markers "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 (backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 (set-marker start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 (custom-text-insert " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 (aset data 1 (setq field (custom-insert (custom-data custom) nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 (custom-text-insert " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 (set-marker end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 (custom-text-insert (custom-property custom 'prefix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 (custom-tag-insert add-tag 'custom-repeat-add data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 (custom-text-insert " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 (custom-tag-insert del-tag 'custom-repeat-delete data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 (defun custom-repeat-add (data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 "Add list entry."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 (let ((parent (aref data 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 (field (aref data 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 (at (aref data 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 (goto-char at)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 (setq new (custom-repeat-insert-entry parent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 (custom-field-value-set parent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 (custom-insert-before (custom-field-value parent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 field new))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 (defun custom-repeat-delete (data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 "Delete list entry."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 (let ((inhibit-point-motion-hooks t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 (inhibit-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 (before-change-functions nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 (after-change-functions nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 (parent (aref data 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 (field (aref data 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 (delete-region (aref data 2) (1+ (aref data 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 (custom-field-untouch (aref data 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 (custom-field-value-set parent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 (delq field (custom-field-value parent)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 (defun custom-repeat-match (custom values)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 "Match CUSTOM with VALUES."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 (let* ((child (custom-data custom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 (match (custom-match child values))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 matches)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 (while (not (eq (car match) custom-nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 (setq matches (cons (car match) matches)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 values (cdr match)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 match (custom-match child values)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 (cons (nreverse matches) values)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 (defun custom-repeat-extract (custom field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 "Extract list of children's values."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 (let ((values (custom-field-value field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 (data (custom-data custom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 (if (eq values custom-nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 (while values
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 (setq result (append result (custom-field-extract data (car values)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 values (cdr values))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 (defun custom-repeat-validate (custom field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 "Validate children."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 (let ((values (custom-field-value field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 (data (custom-data custom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 (if (eq values custom-nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 (setq result (cons (custom-field-start field) "Uninitialized list")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 (while (and values (not result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 (setq result (custom-field-validate data (car values))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 values (cdr values)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 (defun custom-pair-accept (field value &optional original)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 "Store a new value into field FIELD, taking it from VALUE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 (custom-group-accept field (list (car value) (cdr value)) original))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 (defun custom-pair-eval (custom value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 "Non-nil if CUSTOM's VALUE needs to be evaluated."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 (custom-group-eval custom (list (car value) (cdr value))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 (defun custom-pair-import (custom value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 "Modify CUSTOM's VALUE to match internal expectations."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 (let ((result (car (custom-group-import custom
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 (list (car value) (cdr value))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 (custom-assert '(eq (length result) 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 (list (cons (nth 0 result) (nth 1 result)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 (defun custom-pair-quote (custom value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 "Quote CUSTOM's VALUE if necessary."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 (if (custom-eval custom value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 (let ((v (car (custom-group-quote custom
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 (list (car value) (cdr value))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 (list (list 'cons (nth 0 v) (nth 1 v))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 (custom-default-quote custom value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 (defun custom-pair-extract (custom field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 "Extract cons of children's values."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 (let ((values (custom-field-value field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 (data (custom-data custom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 (custom-assert '(eq (length values) (length data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 (while values
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 (setq result (append result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 (custom-field-extract (car data) (car values)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 data (cdr data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 values (cdr values)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 (custom-assert '(null data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 (list (cons (nth 0 result) (nth 1 result)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 (defun custom-list-quote (custom value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 "Quote CUSTOM's VALUE if necessary."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 (if (custom-eval custom value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 (let ((v (car (custom-group-quote custom value))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 (list (cons 'list v)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 (custom-default-quote custom value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 (defun custom-list-extract (custom field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 "Extract list of children's values."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 (let ((values (custom-field-value field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 (data (custom-data custom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 (custom-assert '(eq (length values) (length data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 (while values
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 (setq result (append result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 (custom-field-extract (car data) (car values)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 data (cdr data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 values (cdr values)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 (custom-assert '(null data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 (list result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 (defun custom-group-validate (custom field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 "Validate children."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 (let ((values (custom-field-value field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 (data (custom-data custom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 (if (eq values custom-nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 (setq result (cons (custom-field-start field) "Uninitialized list"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 (custom-assert '(eq (length values) (length data))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 (while (and values (not result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 (setq result (custom-field-validate (car data) (car values))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 data (cdr data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 values (cdr values)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 (defun custom-group-eval (custom value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 "Non-nil if CUSTOM's VALUE needs to be evaluated."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 (let ((found nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 (mapcar (lambda (c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 (or (stringp c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 (let ((match (custom-match c value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 (if (custom-eval c (car match))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 (setq found t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 (setq value (cdr match)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 (custom-data custom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 (defun custom-group-quote (custom value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 "A list of CUSTOM's VALUE members, quoted."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 (list (apply 'append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 (mapcar (lambda (c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 (if (stringp c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 (let ((match (custom-match c value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 (prog1 (custom-quote c (car match))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 (setq value (cdr match))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 (custom-data custom)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 (defun custom-group-import (custom value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 "Modify CUSTOM's VALUE to match internal expectations."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 (list (apply 'append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 (mapcar (lambda (c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 (if (stringp c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 (let ((match (custom-match c value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 (prog1 (custom-import c (car match))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 (setq value (cdr match))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 (custom-data custom)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 (defun custom-group-initialize (custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 "Initialize `doc' and `default' entries in CUSTOM."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 (if (custom-name custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 (custom-default-initialize custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 (mapcar 'custom-initialize (custom-data custom))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 (defun custom-group-apply (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 "Reset `value' in FIELD to `original'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 (let ((custom (custom-field-custom field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 (values (custom-field-value field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 (if (custom-name custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 (custom-default-apply field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 (mapcar 'custom-field-apply values))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 (defun custom-group-reset (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 "Reset `value' in FIELD to `original'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 (let ((custom (custom-field-custom field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 (values (custom-field-value field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 (if (custom-name custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 (custom-default-reset field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 (mapcar 'custom-field-reset values))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 (defun custom-group-factory-reset (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 "Reset `value' in FIELD to `default'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 (let ((custom (custom-field-custom field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 (values (custom-field-value field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 (if (custom-name custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 (custom-default-factory-reset field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 (mapcar 'custom-field-factory-reset values))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 (defun custom-group-find (custom tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 "Find child in CUSTOM with `tag' TAG."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 (let ((data (custom-data custom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 (result nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 (while (not result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 (custom-assert 'data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 (if (equal (custom-tag (car data)) tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 (setq result (car data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 (setq data (cdr data))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 (defun custom-group-accept (field value &optional original)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 "Store a new value into field FIELD, taking it from VALUE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 (let* ((values (custom-field-value field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 (custom (custom-field-custom field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 (from (custom-field-start field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 (face-tag (custom-face-tag custom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 current)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 (if face-tag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 (custom-put-text-property from (+ from (length (custom-tag custom)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 'face (funcall face-tag field value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 (if original
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 (custom-field-original-set field value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 (while values
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 (setq current (car values)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 values (cdr values))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 (if current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 (let* ((custom (custom-field-custom current))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 (match (custom-match custom value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 (setq value (cdr match))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 (custom-field-accept current (car match) original))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 (defun custom-group-insert (custom level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 "Insert field for CUSTOM at nesting LEVEL in customization buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 (let* ((field (custom-field-create custom nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 fields hidden
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 (from (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 (compact (custom-compact custom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 (tag (custom-tag custom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 (face-tag (custom-face-tag custom)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 (cond (face-tag (custom-text-insert tag))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 (tag (custom-tag-insert tag field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 (or compact (custom-documentation-insert custom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 (or compact (custom-text-insert "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 (let ((data (custom-data custom)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 (while data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 (setq fields (cons (custom-insert (car data) (if level (1+ level)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 fields))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 (setq hidden (or (stringp (car data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 (custom-property (car data) 'hidden)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 (setq data (cdr data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 (if data (custom-text-insert (cond (hidden "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 (compact " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 (t "\n"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 (if compact (custom-documentation-insert custom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 (custom-field-value-set field (nreverse fields))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 (custom-field-move field from (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 (defun custom-choice-insert (custom level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 "Insert field for CUSTOM at nesting LEVEL in customization buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 (let* ((field (custom-field-create custom nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 (from (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 (custom-text-insert "lars er en nisse")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 (custom-field-move field from (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 (custom-documentation-insert custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 (custom-field-reset field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 (defun custom-choice-accept (field value &optional original)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 "Store a new value into field FIELD, taking it from VALUE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 (let ((custom (custom-field-custom field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 (start (custom-field-start field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 (end (custom-field-end field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 (inhibit-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 (before-change-functions nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 (after-change-functions nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 from)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 (cond (original
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 (setq custom-modified-list (delq field custom-modified-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 (custom-field-original-set field value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 ((equal value (custom-field-original field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 (setq custom-modified-list (delq field custom-modified-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 (add-to-list 'custom-modified-list field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 (custom-field-untouch (custom-field-value field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 (delete-region start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 (setq from (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 (insert-before-markers " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 (backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 (custom-category-set (point) (1+ (point)) 'custom-hidden-properties)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 (custom-tag-insert (custom-tag custom) field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 (custom-text-insert ": ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 (let ((data (custom-data custom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 found begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 (while (and data (not found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 (if (not (custom-valid (car data) value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 (setq data (cdr data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 (setq found (custom-insert (car data) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 (setq data nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 (if found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 (setq begin (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 found (custom-insert (custom-property custom 'none) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 (custom-add-text-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 begin (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 (list rear-nonsticky t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 'face custom-field-uninitialized-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 (or original
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 (custom-field-original-set found (custom-field-original field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 (custom-field-accept found value original)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 (custom-field-value-set field found)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 (custom-field-move field from end))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 (defun custom-choice-extract (custom field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 "Extract child's value."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 (let ((value (custom-field-value field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 (custom-field-extract (custom-field-custom value) value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 (defun custom-choice-validate (custom field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 "Validate child's value."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 (let ((value (custom-field-value field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 (custom (custom-field-custom field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 (if (or (eq value custom-nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 (eq (custom-field-custom value) (custom-property custom 'none)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 (cons (custom-field-start field) "Make a choice")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 (custom-field-validate (custom-field-custom value) value))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 (defun custom-choice-query (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 "Choose a child."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 (let* ((custom (custom-field-custom field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 (old (custom-field-custom (custom-field-value field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 (default (custom-prompt old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 (tag (custom-prompt custom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 (data (custom-data custom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 current alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 (if (eq (length data) 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 (custom-field-accept field (custom-default (if (eq (nth 0 data) old)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 (nth 1 data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 (nth 0 data))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 (while data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 (setq current (car data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 data (cdr data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 (setq alist (cons (cons (custom-prompt current) current) alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 (let ((answer (cond ((and (fboundp 'button-press-event-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 (fboundp 'popup-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 (button-press-event-p last-input-event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 (cdr (assoc (car (custom-x-really-popup-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 last-input-event tag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 (reverse alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 ((listp last-input-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 (x-popup-menu last-input-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 (list tag (cons "" (reverse alist)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 (let ((choice (completing-read (concat tag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 " (default "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 "): ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 alist nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 (if (or (null choice) (string-equal choice ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 (setq choice default))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 (cdr (assoc choice alist)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 (if answer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 (custom-field-accept field (custom-default answer)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 (defun custom-file-query (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 "Prompt for a file name"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 (let* ((value (custom-field-value field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 (custom (custom-field-custom field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 (valid (custom-valid custom value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 (directory (custom-property custom 'directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 (default (and (not valid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 (custom-property custom 'default-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 (tag (custom-tag custom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 (prompt (if default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 (concat tag " (" default "): ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 (concat tag ": "))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 (custom-field-accept field
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 (if (custom-valid custom value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 (read-file-name prompt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 (if (file-name-absolute-p value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 default nil value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 (read-file-name prompt directory default)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 (defun custom-face-eval (custom value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 "Return non-nil if CUSTOM's VALUE needs to be evaluated."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 (not (symbolp value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 (defun custom-face-import (custom value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 "Modify CUSTOM's VALUE to match internal expectations."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 (let ((name (or (and (facep value) (symbol-name (face-name value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 (symbol-name value))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 (list (if (string-match "\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 custom-face-\\(.*\\)-\\(.*\\)-\\(.*\\)-\\(.*\\)-\\(.*\\)-\\(.*\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 (list 'custom-face-lookup
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 (match-string 1 name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 (match-string 2 name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 (match-string 3 name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 (intern (match-string 4 name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 (intern (match-string 5 name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 (intern (match-string 6 name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 value))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 (defun custom-face-lookup (&optional fg bg stipple bold italic underline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 "Lookup or create a face with specified attributes."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 (let ((name (intern (format "custom-face-%s-%s-%s-%S-%S-%S"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 (or fg "default")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 (or bg "default")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 (or stipple "default")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 bold italic underline))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 (if (and (custom-facep name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 (fboundp 'make-face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 (copy-face 'default name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 (when (and fg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 (not (string-equal fg "default")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 (set-face-foreground name fg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 (when (and bg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 (not (string-equal bg "default")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 (set-face-background name bg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 (when (and stipple
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 (not (string-equal stipple "default"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 (not (eq stipple 'custom:asis))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 (fboundp 'set-face-stipple))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 (set-face-stipple name stipple))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 (when (and bold
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 (not (eq bold 'custom:asis)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 (make-face-bold name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 (when (and italic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 (not (eq italic 'custom:asis)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 (make-face-italic name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 (when (and underline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 (not (eq underline 'custom:asis)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 (set-face-underline-p name t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 (error nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 (defun custom-face-hack (field value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 "Face that should be used for highlighting FIELD containing VALUE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 (let* ((custom (custom-field-custom field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 (form (funcall (custom-property custom 'export) custom value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 (face (apply (car form) (cdr form))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 (if (custom-facep face) face nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 (defun custom-const-insert (custom level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 "Insert field for CUSTOM at nesting LEVEL in customization buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 (let* ((field (custom-field-create custom custom-nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 (face (custom-field-face field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 (from (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 (custom-text-insert (custom-tag custom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 (custom-add-text-properties from (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 (list 'face face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 rear-nonsticky t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 (custom-documentation-insert custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 (custom-field-move field from (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 (defun custom-const-update (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 "Update face of FIELD."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 (let ((from (custom-field-start field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 (custom (custom-field-custom field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 (custom-put-text-property from (+ from (length (custom-tag custom)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 'face (custom-field-face field))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 (defun custom-const-valid (custom value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 "Non-nil if CUSTOM can validly have the value VALUE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 (equal (custom-default custom) value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 (defun custom-const-face (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 "Face used for a FIELD."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 (custom-default (custom-field-custom field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 (defun custom-sexp-read (custom string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 "Read from CUSTOM an STRING."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 (save-match-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 (set-buffer (get-buffer-create " *Custom Scratch*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 (insert string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 (prog1 (read (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 (or (looking-at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 (concat (regexp-quote (char-to-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 (custom-padding custom)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 "*\\'"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 (error "Junk at end of expression"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 (autoload 'pp-to-string "pp")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 (defun custom-sexp-write (custom sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 "Write CUSTOM SEXP as string."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 (let ((string (prin1-to-string sexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 (if (<= (length string) (custom-width custom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 (setq string (pp-to-string sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 (string-match "[ \t\n]*\\'" string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 (concat "\n" (substring string 0 (match-beginning 0))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 (defun custom-string-read (custom string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 "Read string by ignoring trailing padding characters."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 (let ((last (length string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 (padding (custom-padding custom)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 (while (and (> last 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 (eq (aref string (1- last)) padding))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 (setq last (1- last)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 (substring string 0 last)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 (defun custom-string-write (custom string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 "Write raw string."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 (defun custom-button-insert (custom level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 "Insert field for CUSTOM at nesting LEVEL in customization buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 (custom-tag-insert (concat "[" (custom-tag custom) "]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 (custom-property custom 'query))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 (custom-documentation-insert custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 (defun custom-default-export (custom value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 ;; Convert CUSTOM's VALUE to external representation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 ;; See `custom-import'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 (if (custom-eval custom value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 (eval (car (custom-quote custom value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 (defun custom-default-quote (custom value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 "Quote CUSTOM's VALUE if necessary."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 (list (if (and (not (custom-eval custom value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 (or (and (symbolp value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 (not (eq t value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 (and (listp value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 (not (memq (car value) '(quote function lambda))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 (list 'quote value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 (defun custom-default-initialize (custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 "Initialize `doc' and `default' entries in CUSTOM."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 (let ((name (custom-name custom)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 (if (null name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 (let ((default (custom-default custom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 (doc (custom-documentation custom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 (vdoc (documentation-property name 'variable-documentation t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 (if doc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 (or vdoc (put name 'variable-documentation doc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 (if vdoc (custom-property-set custom 'doc vdoc)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 (if (eq default custom-nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 (if (boundp name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 (custom-property-set custom 'default (symbol-value name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 (or (boundp name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 (set name default)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 (defun custom-default-insert (custom level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 "Insert field for CUSTOM at nesting LEVEL in customization buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 (let ((field (custom-field-create custom custom-nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 (tag (custom-tag custom)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 (if (null tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 (custom-tag-insert tag field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 (custom-text-insert ": "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 (custom-field-insert field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 (custom-documentation-insert custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 (defun custom-default-accept (field value &optional original)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 "Store a new value into field FIELD, taking it from VALUE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 (if original
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 (custom-field-original-set field value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 (custom-field-value-set field value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 (custom-field-update field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 (defun custom-default-apply (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 "Apply any changes in FIELD since the last apply."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592 (let* ((custom (custom-field-custom field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 (name (custom-name custom)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 (if (null name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 (error "This field cannot be applied alone"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 (custom-external-set name (custom-name-value name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 (custom-field-reset field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 (defun custom-default-reset (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 "Reset content of editing FIELD to `original'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601 (custom-field-accept field (custom-field-original field) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 (defun custom-default-factory-reset (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 "Reset content of editing FIELD to `default'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 (let* ((custom (custom-field-custom field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 (default (car (custom-import custom (custom-default custom)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 (or (eq default custom-nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608 (custom-field-accept field default nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 (defun custom-default-query (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 "Prompt for a FIELD"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 (let* ((custom (custom-field-custom field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 (value (custom-field-value field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 (initial (custom-write custom value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 (prompt (concat (custom-prompt custom) ": ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616 (custom-field-accept field
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617 (custom-read custom
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 (if (custom-valid custom value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 (read-string prompt (cons initial 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 (read-string prompt))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 (defun custom-default-match (custom values)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623 "Match CUSTOM with VALUES."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 values)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 (defun custom-default-extract (custom field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 "Extract CUSTOM's content in FIELD."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 (list (custom-field-value field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 (defun custom-default-validate (custom field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 "Validate FIELD."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 (let ((value (custom-field-value field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 (start (custom-field-start field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 (cond ((eq value custom-nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 (cons start "Uninitialized field"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 ((and (consp value) (eq (car value) custom-invalid))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 (cons start "Unparsable field content"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 ((custom-valid custom value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 (cons start "Wrong type of field content")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 (defun custom-default-face (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 "Face used for a FIELD."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645 (let ((value (custom-field-value field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 (cond ((eq value custom-nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 custom-field-uninitialized-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648 ((not (custom-valid (custom-field-custom field) value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 custom-field-invalid-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 ((not (equal (custom-field-original field) value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 custom-field-modified-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 custom-field-face))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 (defun custom-default-update (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 "Update the content of FIELD."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 (let ((inhibit-point-motion-hooks t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 (before-change-functions nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659 (after-change-functions nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 (start (custom-field-start field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 (end (custom-field-end field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 (pos (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663 ;; Keep track of how many modified fields we have.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 (cond ((equal (custom-field-value field) (custom-field-original field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 (setq custom-modified-list (delq field custom-modified-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666 ((memq field custom-modified-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 (setq custom-modified-list (cons field custom-modified-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 ;; Update the field.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 (goto-char end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 (insert-before-markers " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 (delete-region start (1- end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 (custom-field-insert field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 (goto-char end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 (delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 (goto-char pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 (and (<= start pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679 (<= pos end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 (custom-field-enter field))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682 ;;; Create Buffer:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 ;; Public functions to create a customization buffer and to insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685 ;; various forms of text, fields, and buttons in it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 (defun customize ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 "Customize GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689 Create a *Customize* buffer with editable customization information
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 about GNU Emacs."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 (custom-buffer-create "*Customize*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693 (custom-reset-all))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 (defun custom-buffer-create (name &optional custom types set get save)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696 "Create a customization buffer named NAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 If the optional argument CUSTOM is non-nil, use that as the custom declaration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 If the optional argument TYPES is non-nil, use that as the local types.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699 If the optional argument SET is non-nil, use that to set external data.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700 If the optional argument GET is non-nil, use that to get external data.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 If the optional argument SAVE is non-nil, use that for saving changes."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 (switch-to-buffer name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703 (buffer-disable-undo (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704 (custom-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 (setq custom-local-type-properties types)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706 (if (null custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 (make-local-variable 'custom-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709 (setq custom-data custom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 (if (null set)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 (make-local-variable 'custom-external-set)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 (setq custom-external-set set))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714 (if (null get)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 (make-local-variable 'custom-external)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 (setq custom-external get))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 (if (null save)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720 (make-local-variable 'custom-save)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 (setq custom-save save))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 (let ((inhibit-point-motion-hooks t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 (before-change-functions nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 (after-change-functions nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 (custom-text-insert "This is a customization buffer.\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729 (custom-help-insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730 (custom-help-button 'custom-forward-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731 (custom-help-button 'custom-backward-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 (custom-help-button 'custom-enter-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733 (custom-help-button 'custom-field-factory-reset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 (custom-help-button 'custom-field-reset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 (custom-help-button 'custom-field-apply)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 (custom-help-button 'custom-save-and-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 (custom-help-button 'custom-toggle-documentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 (custom-help-insert "\nClick mouse-2 on any button to activate it.\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 (custom-text-insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740 (custom-insert custom-data 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 (goto-char (point-min))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 (defun custom-insert (custom level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 "Insert custom declaration CUSTOM in current buffer at level LEVEL."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 (if (stringp custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 (custom-text-insert custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 (and level (null (custom-property custom 'header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 (setq level nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 (and level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 (> level 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753 (custom-text-insert (concat "\n" (make-string level ?*) " ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754 (let ((field (funcall (custom-property custom 'insert) custom level)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 (custom-name-enter (custom-name custom) field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758 (defun custom-text-insert (text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 "Insert TEXT in current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 (insert text))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 (defun custom-tag-insert (tag field &optional data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 "Insert TAG for FIELD in current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 (let ((from (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 (insert tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 (custom-category-set from (point) 'custom-button-properties)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767 (custom-put-text-property from (point) 'custom-tag field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 (if data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769 (custom-add-text-properties from (point) (list 'custom-data data)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 (defun custom-documentation-insert (custom &rest ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 "Insert documentation from CUSTOM in current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 (let ((doc (custom-documentation custom)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774 (if (null doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 (custom-help-insert "\n" doc))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 (defun custom-help-insert (&rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779 "Insert ARGS as documentation text."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 (let ((from (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 (apply 'insert args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 (custom-category-set from (point) 'custom-documentation-properties)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 (defun custom-help-button (command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 "Describe how to execute COMMAND."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786 (let ((from (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787 (insert "`" (key-description (where-is-internal command nil t)) "'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 (custom-set-text-properties from (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 (list 'face custom-button-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 mouse-face custom-mouse-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791 'custom-jump t ;Make TAB jump over it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 'custom-tag command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793 'start-open t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794 'end-open t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 (custom-category-set from (point) 'custom-documentation-properties))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796 (custom-help-insert ": " (custom-first-line (documentation command)) "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 ;;; Mode:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800 ;; The Customization major mode and interactive commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 (defvar custom-mode-map nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 "Keymap for Custom Mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804 (if custom-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806 (setq custom-mode-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807 (define-key custom-mode-map (if (string-match "XEmacs" emacs-version) [button2] [mouse-2]) 'custom-push-button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 (define-key custom-mode-map "\t" 'custom-forward-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809 (define-key custom-mode-map "\M-\t" 'custom-backward-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810 (define-key custom-mode-map "\r" 'custom-enter-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811 (define-key custom-mode-map "\C-k" 'custom-kill-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812 (define-key custom-mode-map "\C-c\C-r" 'custom-field-reset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 (define-key custom-mode-map "\C-c\M-\C-r" 'custom-reset-all)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 (define-key custom-mode-map "\C-c\C-z" 'custom-field-factory-reset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 (define-key custom-mode-map "\C-c\M-\C-z" 'custom-factory-reset-all)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 (define-key custom-mode-map "\C-c\C-a" 'custom-field-apply)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817 (define-key custom-mode-map "\C-c\M-\C-a" 'custom-apply-all)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 (define-key custom-mode-map "\C-c\C-c" 'custom-save-and-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819 (define-key custom-mode-map "\C-c\C-d" 'custom-toggle-documentation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821 ;; C-c keymap ideas: C-a field-beginning, C-e field-end, C-f
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 ;; forward-field, C-b backward-field, C-n next-field, C-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 ;; previous-field, ? describe-field.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825 (defun custom-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 "Major mode for doing customizations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 \\{custom-mode-map}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 (kill-all-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830 (setq major-mode 'custom-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831 mode-name "Custom")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832 (use-local-map custom-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 (make-local-variable 'before-change-functions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 (setq before-change-functions '(custom-before-change))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 (make-local-variable 'after-change-functions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 (setq after-change-functions '(custom-after-change))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837 (if (not (fboundp 'make-local-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838 ;; Emacs 19.28 and earlier.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839 (add-hook 'post-command-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840 (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841 (if (eq major-mode 'custom-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842 (custom-post-command))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843 ;; Emacs 19.29.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 (make-local-hook 'post-command-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845 (add-hook 'post-command-hook 'custom-post-command nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847 (defun custom-forward-field (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848 "Move point to the next field or button.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849 With optional ARG, move across that many fields."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 (while (> arg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 (let ((next (if (get-text-property (point) 'custom-tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 (next-single-property-change (point) 'custom-tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855 (setq next (or (next-single-property-change next 'custom-tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 (next-single-property-change (point-min) 'custom-tag)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857 (if next
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 (goto-char next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859 (error "No customization fields in this buffer.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860 (or (get-text-property (point) 'custom-jump)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 (setq arg (1- arg))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 (while (< arg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863 (let ((previous (if (get-text-property (1- (point)) 'custom-tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 (previous-single-property-change (point) 'custom-tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866 (setq previous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867 (or (previous-single-property-change previous 'custom-tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868 (previous-single-property-change (point-max) 'custom-tag)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 (if previous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870 (goto-char previous)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871 (error "No customization fields in this buffer.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872 (or (get-text-property (1- (point)) 'custom-jump)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873 (setq arg (1+ arg)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1874
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875 (defun custom-backward-field (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 "Move point to the previous field or button.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 With optional ARG, move across that many fields."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879 (custom-forward-field (- arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881 (defun custom-toggle-documentation (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 "Toggle display of documentation text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 If the optional argument is non-nil, show text iff the argument is positive."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885 (let ((hide (or (and (null arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 (null (custom-category-get
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887 'custom-documentation-properties 'invisible)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 (<= (prefix-numeric-value arg) 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889 (custom-category-put 'custom-documentation-properties 'invisible hide)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 (custom-category-put 'custom-documentation-properties intangible hide))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891 (redraw-display))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 (defun custom-enter-value (field data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894 "Enter value for current customization field or push button."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895 (interactive (list (get-text-property (point) 'custom-tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896 (get-text-property (point) 'custom-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897 (cond (data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898 (funcall field data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899 ((eq field 'custom-enter-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900 (error "Don't be silly"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901 ((and (symbolp field) (fboundp field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902 (call-interactively field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903 (field
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 (custom-field-query field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906 (message "Nothing to enter here"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1908 (defun custom-kill-line ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909 "Kill to end of field or end of line, whichever is first."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1911 (let ((field (get-text-property (point) 'custom-field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912 (newline (save-excursion (search-forward "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913 (next (next-single-property-change (point) 'custom-field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1914 (if (and field (> newline next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1915 (kill-region (point) next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1916 (call-interactively 'kill-line))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1917
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918 (defun custom-push-button (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919 "Activate button below mouse pointer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920 (interactive "@e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1921 (let* ((pos (event-point event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922 (field (get-text-property pos 'custom-field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923 (tag (get-text-property pos 'custom-tag))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924 (data (get-text-property pos 'custom-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925 (cond (data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 (funcall tag data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927 ((and (symbolp tag) (fboundp tag))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928 (call-interactively tag))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929 (field
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930 (call-interactively (lookup-key global-map (this-command-keys))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931 (tag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932 (custom-enter-value tag data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1933 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934 (error "Nothing to click on here.")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936 (defun custom-reset-all ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937 "Undo any changes since the last apply in all fields."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938 (interactive (and custom-modified-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 (not (y-or-n-p "Discard all changes? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940 (error "Reset aborted")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1941 (let ((all custom-name-fields)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1942 current field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1943 (while all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1944 (setq current (car all)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945 field (cdr current)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946 all (cdr all))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947 (custom-field-reset field))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1948
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1949 (defun custom-field-reset (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1950 "Undo any changes in FIELD since the last apply."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1951 (interactive (list (or (get-text-property (point) 'custom-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1952 (get-text-property (point) 'custom-tag))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1953 (if (arrayp field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1954 (let* ((custom (custom-field-custom field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1955 (name (custom-name custom)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1956 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1957 (if name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1958 (custom-field-original-set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1959 field (car (custom-import custom (custom-external name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1960 (if (not (custom-valid custom (custom-field-original field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1961 (error "This field cannot be reset alone")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1962 (funcall (custom-property custom 'reset) field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1963 (funcall (custom-property custom 'synchronize) field))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1964
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1965 (defun custom-factory-reset-all ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966 "Reset all field to their default values."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1967 (interactive (and custom-modified-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1968 (not (y-or-n-p "Discard all changes? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1969 (error "Reset aborted")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1970 (let ((all custom-name-fields)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1971 field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1972 (while all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1973 (setq field (cdr (car all))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1974 all (cdr all))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1975 (custom-field-factory-reset field))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1976
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1977 (defun custom-field-factory-reset (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1978 "Reset FIELD to its default value."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1979 (interactive (list (or (get-text-property (point) 'custom-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980 (get-text-property (point) 'custom-tag))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981 (if (arrayp field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983 (funcall (custom-property (custom-field-custom field) 'factory-reset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984 field))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986 (defun custom-apply-all ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1987 "Apply any changes since the last reset in all fields."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988 (interactive (if custom-modified-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1989 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1990 (error "No changes to apply.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1991 (custom-field-parse custom-field-last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1992 (let ((all custom-name-fields)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993 field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1994 (while all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1995 (setq field (cdr (car all))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1996 all (cdr all))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1997 (let ((error (custom-field-validate (custom-field-custom field) field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1998 (if (null error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1999 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2000 (goto-char (car error))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2001 (error (cdr error))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2002 (let ((all custom-name-fields)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2003 field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2004 (while all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2005 (setq field (cdr (car all))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2006 all (cdr all))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007 (custom-field-apply field))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009 (defun custom-field-apply (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010 "Apply any changes in FIELD since the last apply."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011 (interactive (list (or (get-text-property (point) 'custom-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012 (get-text-property (point) 'custom-tag))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013 (custom-field-parse custom-field-last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014 (if (arrayp field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015 (let* ((custom (custom-field-custom field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016 (error (custom-field-validate custom field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2017 (if error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2018 (error (cdr error)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2019 (funcall (custom-property custom 'apply) field))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2020
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2021 (defun custom-toggle-hide (&rest ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2022 "Hide or show entry."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2023 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024 (error "This button is not yet implemented"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2025
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2026 (defun custom-save-and-exit ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2027 "Save and exit customization buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2028 (interactive "@")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2029 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2030 (funcall custom-save))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2031 (kill-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2032
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2033 (defun custom-save ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2034 "Save customization information."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2036 (custom-apply-all)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2037 (let ((new custom-name-fields))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2038 (set-buffer (find-file-noselect custom-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2039 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2040 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2041 (let ((old (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2042 (read (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2043 (end-of-file (append '(setq custom-dummy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2044 'custom-dummy) ())))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2045 (or (eq (car old) 'setq)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2046 (error "Invalid customization file: %s" custom-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2047 (while new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2048 (let* ((field (cdr (car new)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2049 (custom (custom-field-custom field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2050 (value (custom-field-original field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2051 (default (car (custom-import custom (custom-default custom))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2052 (name (car (car new))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2053 (setq new (cdr new))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2054 (custom-assert '(eq name (custom-name custom)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2055 (if (equal default value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2056 (setcdr old (custom-plist-delq name (cdr old)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2057 (setcdr old (plist-put (cdr old) name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2058 (car (custom-quote custom value)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2059 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2060 (insert ";; " custom-file "\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2061 --- Automatically generated customization information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2062 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2063 ;; Feel free to edit by hand, but the entire content should consist of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2064 ;; a single setq. Any other lisp expressions will confuse the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2065 ;; automatic configuration engine.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2066
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2067 \(setq ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2068 (setq old (cdr old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2069 (while old
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2070 (prin1 (car old) (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2071 (setq old (cdr old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2072 (insert " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2073 (pp (car old) (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2074 (setq old (cdr old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2075 (if old (insert "\n ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2076 (insert ")\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2077 (save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2078 (kill-buffer (current-buffer))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2079
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2080 (defun custom-load ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2081 "Save customization information."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2082 (interactive (and custom-modified-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2083 (not (equal (list (custom-name-field 'custom-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2084 custom-modified-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2085 (not (y-or-n-p "Discard all changes? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2086 (error "Load aborted")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2087 (load-file (custom-name-value 'custom-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2088 (custom-reset-all))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2089
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2090 ;;; Field Editing:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2091 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2092 ;; Various internal functions for implementing the direct editing of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2093 ;; fields in the customization buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2094
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2095 (defun custom-field-untouch (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2096 ;; Remove FIELD and its children from `custom-modified-list'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2097 (setq custom-modified-list (delq field custom-modified-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2098 (if (arrayp field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2099 (let ((value (custom-field-value field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2100 (cond ((null (custom-data (custom-field-custom field))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2101 ((arrayp value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2102 (custom-field-untouch value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2103 ((listp value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2104 (mapcar 'custom-field-untouch value))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2105
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2107 (defun custom-field-insert (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2108 ;; Insert editing FIELD in current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2109 (let ((from (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2110 (custom (custom-field-custom field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2111 (value (custom-field-value field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2112 (insert (custom-write custom value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2113 (insert-char (custom-padding custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2114 (- (custom-width custom) (- (point) from)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2115 (custom-field-move field from (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2116 (custom-set-text-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2117 from (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2118 (list 'custom-field field
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2119 'custom-tag field
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2120 'face (custom-field-face field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2121 'start-open t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2122 'end-open t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2124 (defun custom-field-read (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2125 ;; Read the screen content of FIELD.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2126 (custom-read (custom-field-custom field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2127 (custom-buffer-substring-no-properties (custom-field-start field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2128 (custom-field-end field))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2130 ;; Fields are shown in a special `active' face when point is inside
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2131 ;; it. You activate the field by moving point inside (entering) it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2132 ;; and deactivate the field by moving point outside (leaving) it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2134 (defun custom-field-leave (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2135 ;; Deactivate FIELD.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2136 (let ((before-change-functions nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2137 (after-change-functions nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2138 (custom-put-text-property (custom-field-start field) (custom-field-end field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2139 'face (custom-field-face field))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2141 (defun custom-field-enter (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2142 ;; Activate FIELD.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2143 (let* ((start (custom-field-start field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2144 (end (custom-field-end field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2145 (custom (custom-field-custom field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2146 (padding (custom-padding custom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2147 (before-change-functions nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2148 (after-change-functions nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2149 (or (eq this-command 'self-insert-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2150 (let ((pos end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2151 (while (and (< start pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2152 (eq (char-after (1- pos)) padding))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2153 (setq pos (1- pos)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2154 (if (< pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2155 (goto-char pos))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2156 (custom-put-text-property start end 'face custom-field-active-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2157
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2158 (defun custom-field-resize (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2159 ;; Resize FIELD after change.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2160 (let* ((custom (custom-field-custom field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2161 (begin (custom-field-start field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2162 (end (custom-field-end field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2163 (pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2164 (padding (custom-padding custom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2165 (width (custom-width custom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2166 (size (- end begin)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2167 (cond ((< size width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2168 (goto-char end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2169 (if (fboundp 'insert-before-markers-and-inherit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2170 ;; Emacs 19.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2171 (insert-before-markers-and-inherit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2172 (make-string (- width size) padding))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2173 ;; XEmacs: BUG: Doesn't work!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2174 (insert-before-markers (make-string (- width size) padding)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2175 (goto-char pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2176 ((> size width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2177 (let ((start (if (and (< (+ begin width) pos) (<= pos end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2178 pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2179 (+ begin width))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2180 (goto-char end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2181 (while (and (< start (point)) (= (preceding-char) padding))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2182 (backward-delete-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2183 (goto-char pos))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2184
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2185 (defvar custom-field-changed nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2186 ;; List of fields changed on the screen but whose VALUE attribute has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2187 ;; not yet been updated to reflect the new screen content.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2188 (make-variable-buffer-local 'custom-field-changed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2190 (defun custom-field-parse (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2191 ;; Parse FIELD content iff changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2192 (if (memq field custom-field-changed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2193 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2194 (setq custom-field-changed (delq field custom-field-changed))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2195 (custom-field-value-set field (custom-field-read field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2196 (custom-field-update field))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2197
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2198 (defun custom-post-command ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2199 ;; Keep track of their active field.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2200 (custom-assert '(eq major-mode 'custom-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2201 (let ((field (custom-field-property (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2202 (if (eq field custom-field-last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2203 (if (memq field custom-field-changed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2204 (custom-field-resize field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2205 (custom-field-parse custom-field-last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2206 (if custom-field-last
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2207 (custom-field-leave custom-field-last))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2208 (if field
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2209 (custom-field-enter field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2210 (setq custom-field-last field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2211 (set-buffer-modified-p (or custom-modified-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2212 custom-field-changed))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2214 (defvar custom-field-was nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2215 ;; The custom data before the change.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2216 (make-variable-buffer-local 'custom-field-was)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2218 (defun custom-before-change (begin end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2219 ;; Check that we the modification is allowed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2220 (if (not (eq major-mode 'custom-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2221 (message "Aargh! Why is custom-before-change called here?")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2222 (let ((from (custom-field-property begin))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2223 (to (custom-field-property end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2224 (cond ((or (null from) (null to))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2225 (error "You can only modify the fields"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2226 ((not (eq from to))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2227 (error "Changes must be limited to a single field."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2228 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2229 (setq custom-field-was from))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2231 (defun custom-after-change (begin end length)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2232 ;; Keep track of field content.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2233 (if (not (eq major-mode 'custom-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2234 (message "Aargh! Why is custom-after-change called here?")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2235 (let ((field custom-field-was))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2236 (custom-assert '(prog1 field (setq custom-field-was nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2237 ;; Prevent mixing fields properties.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2238 (custom-put-text-property begin end 'custom-field field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2239 ;; Update the field after modification.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2240 (if (eq (custom-field-property begin) field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2241 (let ((field-end (custom-field-end field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2242 (if (> end field-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2243 (set-marker field-end end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2244 (add-to-list 'custom-field-changed field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2245 ;; We deleted the entire field, reinsert it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2246 (custom-assert '(eq begin end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2247 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2248 (goto-char begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2249 (custom-field-value-set field
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2250 (custom-read (custom-field-custom field) ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2251 (custom-field-insert field))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2253 (defun custom-field-property (pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2254 ;; The `custom-field' text property valid for POS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2255 (or (get-text-property pos 'custom-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2256 (and (not (eq pos (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2257 (get-text-property (1- pos) 'custom-field))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2259 ;;; Generic Utilities:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2260 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2261 ;; Some utility functions that are not really specific to custom.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2263 (defun custom-assert (expr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2264 "Assert that EXPR evaluates to non-nil at this point"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2265 (or (eval expr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2266 (error "Assertion failed: %S" expr)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2268 (defun custom-first-line (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2269 "Return the part of STRING before the first newline."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2270 (let ((pos 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2271 (len (length string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2272 (while (and (< pos len) (not (eq (aref string pos) ?\n)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2273 (setq pos (1+ pos)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2274 (if (eq pos len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2275 string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2276 (substring string 0 pos))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2278 (defun custom-insert-before (list old new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2279 "In LIST insert before OLD a NEW element."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2280 (cond ((null list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2281 (list new))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2282 ((null old)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2283 (nconc list (list new)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2284 ((eq old (car list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2285 (cons new list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2286 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2287 (let ((list list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2288 (while (not (eq old (car (cdr list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2289 (setq list (cdr list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2290 (custom-assert '(cdr list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2291 (setcdr list (cons new (cdr list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2292 list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2294 (defun custom-strip-padding (string padding)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2295 "Remove padding from STRING."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2296 (let ((regexp (concat (regexp-quote (char-to-string padding)) "+")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2297 (while (string-match regexp string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2298 (setq string (concat (substring string 0 (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2299 (substring string (match-end 0))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2300 string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2302 (defun custom-plist-memq (prop plist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2303 "Return non-nil if PROP is a property of PLIST. Comparison done with EQ."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2304 (let (result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2305 (while plist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2306 (if (eq (car plist) prop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2307 (setq result plist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2308 plist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2309 (setq plist (cdr (cdr plist)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2310 result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2312 (defun custom-plist-delq (prop plist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2313 "Delete property PROP from property list PLIST."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2314 (while (eq (car plist) prop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2315 (setq plist (cdr (cdr plist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2316 (let ((list plist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2317 (next (cdr (cdr plist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2318 (while next
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2319 (if (eq (car next) prop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2320 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2321 (setq next (cdr (cdr next)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2322 (setcdr (cdr list) next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2323 (setq list next
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2324 next (cdr (cdr next))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2325 plist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2326
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2327 ;;; Meta Customization:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2329 (custom-declare '()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2330 '((tag . "Meta Customization")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2331 (doc . "Customization of the customization support.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2332 (type . group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2333 (data ((type . face-doc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2334 ((tag . "Button Face")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2335 (default . bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2336 (doc . "Face used for tags in customization buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2337 (name . custom-button-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2338 (synchronize . (lambda (f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2339 (custom-category-put 'custom-button-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2340 'face custom-button-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2341 (type . face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2342 ((tag . "Mouse Face")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2343 (default . highlight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2344 (doc . "\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2345 Face used when mouse is above a button in customization buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2346 (name . custom-mouse-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2347 (synchronize . (lambda (f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2348 (custom-category-put 'custom-button-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2349 mouse-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2350 custom-mouse-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2351 (type . face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2352 ((tag . "Field Face")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2353 (default . italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2354 (doc . "Face used for customization fields.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2355 (name . custom-field-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2356 (type . face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2357 ((tag . "Uninitialized Face")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2358 (default . modeline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2359 (doc . "Face used for uninitialized customization fields.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2360 (name . custom-field-uninitialized-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2361 (type . face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2362 ((tag . "Invalid Face")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2363 (default . highlight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2364 (doc . "\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2365 Face used for customization fields containing invalid data.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2366 (name . custom-field-invalid-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2367 (type . face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2368 ((tag . "Modified Face")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2369 (default . bold-italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2370 (doc . "Face used for modified customization fields.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2371 (name . custom-field-modified-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2372 (type . face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2373 ((tag . "Active Face")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2374 (default . underline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2375 (doc . "\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2376 Face used for customization fields while they are being edited.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2377 (name . custom-field-active-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2378 (type . face)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2379
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2380 ;; custom.el uses two categories.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2381
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2382 (custom-category-create 'custom-documentation-properties)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2383 (custom-category-put 'custom-documentation-properties rear-nonsticky t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2384
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2385 (custom-category-create 'custom-button-properties)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2386 (custom-category-put 'custom-button-properties 'face custom-button-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2387 (custom-category-put 'custom-button-properties mouse-face custom-mouse-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2388 (custom-category-put 'custom-button-properties rear-nonsticky t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2389
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2390 (custom-category-create 'custom-hidden-properties)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2391 (custom-category-put 'custom-hidden-properties 'invisible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2392 (not (string-match "XEmacs" emacs-version)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2393 (custom-category-put 'custom-hidden-properties intangible t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2394
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2395 (if (file-readable-p custom-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2396 (load-file custom-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2398 (provide 'custom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2399
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2400 ;;; custom.el ends here