comparison lisp/custom.el @ 1333:1b0339b048ce

[xemacs-hg @ 2003-03-02 09:38:37 by ben] To: xemacs-patches@xemacs.org PROBLEMS: Include nt/PROBLEMS and update. Add note about incremental linking badness. cmdloop.el, custom.el, dumped-lisp.el, files.el, keydefs.el, keymap.el, lisp-mode.el, make-docfile.el, replace.el, simple.el, subr.el, view-less.el, wid-edit.el: Lots of syncing with FSF 21.2. Use if-fboundp in wid-edit.el. New file newcomment.el from FSF. internals/internals.texi: Fix typo. (Build-Time Dependencies): New node. PROBLEMS: Delete. config.inc.samp, xemacs.mak: Eliminate HAVE_VC6, use SUPPORT_EDIT_AND_CONTINUE in its place. No incremental linking unless SUPPORT_EDIT_AND_CONTINUE, since it can cause nasty crashes in pdump. Put warnings about this in config.inc.samp. Report the full compile flags used for src and lib-src in the Installation output. alloc.c, lisp.h, ralloc.c, regex.c: Use ALLOCA() in regex.c to avoid excessive stack allocation. Also fix subtle problem with REL_ALLOC() -- any call to malloc() (direct or indirect) may relocate rel-alloced data, causing buffer text to shift. After any such call, regex must update all its pointers to such data. Add a system, when ERROR_CHECK_MALLOC, whereby regex.c indicates all the places it is prepared to handle malloc()/realloc()/free(), and any calls anywhere in XEmacs outside of this will trigger an abort. alloc.c, dialog-msw.c, eval.c, event-stream.c, general-slots.h, insdel.c, lisp.h, menubar-msw.c, menubar-x.c: Change *run_hook*_trapping_problems to take a warning class, not a string. Factor out code to issue warnings, add flag to call_trapping_problems() to postpone warning issue, and make *run_hook*_trapping_problems issue their own warnings tailored to the hook, postponed in the case of safe_run_hook_trapping_problems() so that the appropriate message can be issued about resetting to nil only when not `quit'. Make record_unwind_protect_restoring_int() non-static. dumper.c: Issue notes about incremental linking problems under Windows. fileio.c: Mule-ize encrypt/decrypt-string code. text.h: Spacing changes.
author ben
date Sun, 02 Mar 2003 09:38:54 +0000
parents 5df795348f45
children c9b6a2fec10d
comparison
equal deleted inserted replaced
1332:6aa23bb3da6b 1333:1b0339b048ce
23 ;; You should have received a copy of the GNU General Public License 23 ;; You should have received a copy of the GNU General Public License
24 ;; along with XEmacs; see the file COPYING. If not, write to the 24 ;; along with XEmacs; see the file COPYING. If not, write to the
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 ;; Boston, MA 02111-1307, USA. 26 ;; Boston, MA 02111-1307, USA.
27 27
28 ;;; Synched with: ??? Partially synched to 21.2 by Ben Wing.
29
28 ;;; Commentary: 30 ;;; Commentary:
29 31
30 ;; This file is dumped with XEmacs. 32 ;; This file is dumped with XEmacs.
31 33
32 ;; This file only contain the code needed to declare and initialize 34 ;; This file only contain the code needed to declare and initialize
39 41
40 ;; it is now safe to put the `provide' anywhere. if an error occurs while 42 ;; it is now safe to put the `provide' anywhere. if an error occurs while
41 ;; loading, all provides (and fsets) will be undone. put it first to 43 ;; loading, all provides (and fsets) will be undone. put it first to
42 ;; prevent require/provide loop with custom and cus-face. 44 ;; prevent require/provide loop with custom and cus-face.
43 (provide 'custom) 45 (provide 'custom)
46
47 ;; BEGIN SYNC WITH FSF 21.2
44 48
45 (eval-when-compile 49 (eval-when-compile
46 (load "cl-macs" nil t) 50 (load "cl-macs" nil t)
47 ;; To elude warnings. 51 ;; To elude warnings.
48 (require 'cus-face)) 52 (require 'cus-face))
71 (eval (car (get symbol 'saved-value))) 75 (eval (car (get symbol 'saved-value)))
72 (eval value))))) 76 (eval value)))))
73 77
74 (defun custom-initialize-set (symbol value) 78 (defun custom-initialize-set (symbol value)
75 "Initialize SYMBOL with VALUE. 79 "Initialize SYMBOL with VALUE.
76 Like `custom-initialize-default', but use the function specified by 80 If the symbol doesn't have a default binding already,
81 then set it using its `:set' function (or `set-default' if it has none).
82 The value is either the value in the symbol's `saved-value' property,
83 if any, or VALUE.
84
85 This is like `custom-initialize-default', but uses the function specified by
77 `:set' to initialize SYMBOL." 86 `:set' to initialize SYMBOL."
78 (unless (default-boundp symbol) 87 (unless (default-boundp symbol)
79 (funcall (or (get symbol 'custom-set) 'set-default) 88 (funcall (or (get symbol 'custom-set) 'set-default)
80 symbol 89 symbol
81 (if (get symbol 'saved-value) 90 (if (get symbol 'saved-value)
82 (eval (car (get symbol 'saved-value))) 91 (eval (car (get symbol 'saved-value)))
83 (eval value))))) 92 (eval value)))))
84 93
85 (defun custom-initialize-reset (symbol value) 94 (defun custom-initialize-reset (symbol value)
86 "Initialize SYMBOL with VALUE. 95 "Initialize SYMBOL with VALUE.
96 Set the symbol, using its `:set' function (or `set-default' if it has none).
97 The value is either the symbol's current value
98 \(as obtained using the `:get' function), if any,
99 or the value in the symbol's `saved-value' property if any,
100 or (last of all) VALUE.
101
87 Like `custom-initialize-set', but use the function specified by 102 Like `custom-initialize-set', but use the function specified by
88 `:get' to reinitialize SYMBOL if it is already bound." 103 `:get' to reinitialize SYMBOL if it is already bound."
89 (funcall (or (get symbol 'custom-set) 'set-default) 104 (funcall (or (get symbol 'custom-set) 'set-default)
90 symbol 105 symbol
91 (cond ((default-boundp symbol) 106 (cond ((default-boundp symbol)
97 (eval value))))) 112 (eval value)))))
98 113
99 (defun custom-initialize-changed (symbol value) 114 (defun custom-initialize-changed (symbol value)
100 "Initialize SYMBOL with VALUE. 115 "Initialize SYMBOL with VALUE.
101 Like `custom-initialize-reset', but only use the `:set' function if the 116 Like `custom-initialize-reset', but only use the `:set' function if the
102 not using the standard setting. Otherwise, use the `set-default'." 117 not using the standard setting.
118 For the standard setting, use `set-default'."
103 (cond ((default-boundp symbol) 119 (cond ((default-boundp symbol)
104 (funcall (or (get symbol 'custom-set) 'set-default) 120 (funcall (or (get symbol 'custom-set) 'set-default)
105 symbol 121 symbol
106 (funcall (or (get symbol 'custom-get) 'default-value) 122 (funcall (or (get symbol 'custom-get) 'default-value)
107 symbol))) 123 symbol)))
110 symbol 126 symbol
111 (eval (car (get symbol 'saved-value))))) 127 (eval (car (get symbol 'saved-value)))))
112 (t 128 (t
113 (set-default symbol (eval value))))) 129 (set-default symbol (eval value)))))
114 130
115 (defun custom-declare-variable (symbol value doc &rest args) 131 (defun custom-declare-variable (symbol default doc &rest args)
116 "Like `defcustom', but SYMBOL and VALUE are evaluated as normal arguments." 132 "Like `defcustom', but SYMBOL and DEFAULT are evaluated as normal arguments.
133 DEFAULT should be an expression to evaluate to compute the default value,
134 not the default value itself."
117 ;; Remember the standard setting. 135 ;; Remember the standard setting.
118 (put symbol 'standard-value (list value)) 136 (put symbol 'standard-value (list default))
119 ;; Maybe this option was rogue in an earlier version. It no longer is. 137 ;; Maybe this option was rogue in an earlier version. It no longer is.
120 (when (eq (get symbol 'force-value) 'rogue) 138 (when (eq (get symbol 'force-value) 'rogue)
121 ;; It no longer is. 139 ;; It no longer is.
122 (put symbol 'force-value nil)) 140 (put symbol 'force-value nil))
123 (when doc 141 (when doc
154 (t 172 (t
155 (custom-handle-keyword symbol keyword value 173 (custom-handle-keyword symbol keyword value
156 'custom-variable)))))) 174 'custom-variable))))))
157 (put symbol 'custom-requests requests) 175 (put symbol 'custom-requests requests)
158 ;; Do the actual initialization. 176 ;; Do the actual initialization.
159 (funcall initialize symbol value)) 177 (funcall initialize symbol default))
160 ;; #### This is a rough equivalent of LOADHIST_ATTACH. However, 178 ;; #### This is a rough equivalent of LOADHIST_ATTACH. However,
161 ;; LOADHIST_ATTACH also checks for `initialized'. 179 ;; LOADHIST_ATTACH also checks for `initialized'.
162 (push symbol current-load-list) 180 (push symbol current-load-list)
163 (run-hooks 'custom-define-hook) 181 (run-hooks 'custom-define-hook)
164 symbol) 182 symbol)
171 If SYMBOL is not already bound, initialize it to VALUE. 189 If SYMBOL is not already bound, initialize it to VALUE.
172 The remaining arguments should have the form 190 The remaining arguments should have the form
173 191
174 [KEYWORD VALUE]... 192 [KEYWORD VALUE]...
175 193
176 The following KEYWORD's are defined: 194 The following keywords are meaningful:
177 195
178 :type VALUE should be a widget type for editing the symbols value. 196 :type VALUE should be a widget type for editing the symbols value.
179 The default is `sexp'. 197 The default is `sexp'.
180 :options VALUE should be a list of valid members of the widget type. 198 :options VALUE should be a list of valid members of the widget type.
181 :group VALUE should be a customization group. 199 :group VALUE should be a customization group.
182 Add SYMBOL to that group. 200 Add SYMBOL to that group.
183 :initialize VALUE should be a function used to initialize the 201 :initialize
202 VALUE should be a function used to initialize the
184 variable. It takes two arguments, the symbol and value 203 variable. It takes two arguments, the symbol and value
185 given in the `defcustom' call. The default is 204 given in the `defcustom' call. The default is
186 `custom-initialize-set' 205 `custom-initialize-reset'
187 :set VALUE should be a function to set the value of the symbol. 206 :set VALUE should be a function to set the value of the symbol.
188 It takes two arguments, the symbol to set and the value to 207 It takes two arguments, the symbol to set and the value to
189 give it. The default is `custom-set-default'. 208 give it. The default choice of function is `custom-set-default'.
190 :get VALUE should be a function to extract the value of symbol. 209 :get VALUE should be a function to extract the value of symbol.
191 The function takes one argument, a symbol, and should return 210 The function takes one argument, a symbol, and should return
192 the current value for that symbol. The default is 211 the current value for that symbol. The default choice of function
193 `default-value'. 212 is `custom-default-value'. #### XEmacs used to say `default-value';
194 :require VALUE should be a feature symbol. Each feature will be 213 is that right?
195 required after initialization, of the user have saved this 214 :require
196 option. 215 VALUE should be a feature symbol. If you save a value
197 :version VALUE should be a string specifying that the variable was 216 for this option, then when your custom init file loads the value,
217 it does (require VALUE) first.
218 :version
219 VALUE should be a string specifying that the variable was
198 first introduced, or its default value was changed, in Emacs 220 first introduced, or its default value was changed, in Emacs
199 version VERSION. 221 version VERSION.
200 :set-after VARIABLE specifies that SYMBOL should be set after VARIABLE when 222 :set-after VARIABLE
223 Specifies that SYMBOL should be set after VARIABLE when
201 both have been customized. 224 both have been customized.
202 225
203 Read the section about customization in the Emacs Lisp manual for more 226 Read the section about customization in the Emacs Lisp manual for more
204 information." 227 information."
205 `(custom-declare-variable (quote ,symbol) (quote ,value) ,doc ,@args)) 228 `(custom-declare-variable (quote ,symbol) (quote ,value) ,doc ,@args))
229
230 ;; END SYNC WITH FSF 21.2
206 231
207 ;;; The `defface' Macro. 232 ;;; The `defface' Macro.
208 233
209 (defmacro defface (face spec doc &rest args) 234 (defmacro defface (face spec doc &rest args)
210 "Declare FACE as a customizable face that defaults to SPEC. 235 "Declare FACE as a customizable face that defaults to SPEC.
711 (set variable value)) 736 (set variable value))
712 (set-default variable value))) 737 (set-default variable value)))
713 738
714 ;;; The End. 739 ;;; The End.
715 740
741 ;; BEGIN SYNC WITH FSF 21.2
742
743 ;; Process the defcustoms for variables loaded before this file.
744 (while custom-declare-variable-list
745 (apply 'custom-declare-variable (car custom-declare-variable-list))
746 (setq custom-declare-variable-list (cdr custom-declare-variable-list)))
747
748 ;; END SYNC WITH FSF 21.2
749
716 ;; custom.el ends here 750 ;; custom.el ends here