comparison lisp/custom/custom.el @ 153:25f70ba0133c r20-3b3

Import from CVS: tag r20-3b3
author cvs
date Mon, 13 Aug 2007 09:38:25 +0200
parents 538048ae2ab8
children 43dd3413c7c7
comparison
equal deleted inserted replaced
152:4c132ee2d62b 153:25f70ba0133c
2 ;; 2 ;;
3 ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc. 3 ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc.
4 ;; 4 ;;
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk> 5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
6 ;; Keywords: help, faces 6 ;; Keywords: help, faces
7 ;; Version: 1.97 7 ;; Version: 1.98
8 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/ 8 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/
9 9
10 ;; This file is part of GNU Emacs. 10 ;; This file is part of GNU Emacs.
11 11
12 ;; GNU Emacs is free software; you can redistribute it and/or modify 12 ;; GNU Emacs is free software; you can redistribute it and/or modify
35 ;; The code implementing face declarations is in `cus-face.el' 35 ;; The code implementing face declarations is in `cus-face.el'
36 36
37 ;;; Code: 37 ;;; Code:
38 38
39 (require 'widget) 39 (require 'widget)
40 (eval-when-compile (require 'cl))
40 41
41 (define-widget-keywords :initialize :set :get :require :prefix :tag 42 (define-widget-keywords :initialize :set :get :require :prefix :tag
42 :load :link :options :type :group) 43 :load :link :options :type :group)
43 44
44 ;; These autoloads should be deleted eventually. 45 ;; These autoloads should be deleted eventually.
45 (unless (fboundp 'load-gc) 46 (unless (fboundp 'load-gc)
46 ;; From cus-edit.el 47 ;; From cus-edit.el
47 (autoload 'custom-set-value "cus-edit" nil t) 48 (autoload 'custom-set-value "cus-edit" nil t)
48 (autoload 'custom-set-variable "cus-edit" nil t) 49 (autoload 'custom-set-variable "cus-edit" nil t)
49 (autoload 'customize "cus-edit" nil t) 50 (autoload 'customize "cus-edit" nil t)
50 (autoload 'customize-other-window "cus-edit" nil t) 51 (autoload 'customize-group "cus-edit" nil t)
52 (autoload 'customize-group-other-window "cus-edit" nil t)
51 (autoload 'customize-variable "cus-edit" nil t) 53 (autoload 'customize-variable "cus-edit" nil t)
52 (autoload 'customize-variable-other-window "cus-edit" nil t) 54 (autoload 'customize-variable-other-window "cus-edit" nil t)
53 (autoload 'customize-face "cus-edit" nil t) 55 (autoload 'customize-face "cus-edit" nil t)
54 (autoload 'customize-face-other-window "cus-edit" nil t) 56 (autoload 'customize-face-other-window "cus-edit" nil t)
55 (autoload 'customize-apropos "cus-edit" nil t) 57 (autoload 'customize-apropos "cus-edit" nil t)
76 Otherwise, if symbol has a `saved-value' property, it will evaluate 78 Otherwise, if symbol has a `saved-value' property, it will evaluate
77 the car of that and used as the default binding for symbol. 79 the car of that and used as the default binding for symbol.
78 Otherwise, VALUE will be evaluated and used as the default binding for 80 Otherwise, VALUE will be evaluated and used as the default binding for
79 symbol." 81 symbol."
80 (unless (default-boundp symbol) 82 (unless (default-boundp symbol)
81 ;; Use the saved value if it exists, otherwise the factory setting. 83 ;; Use the saved value if it exists, otherwise the standard setting.
82 (set-default symbol (if (get symbol 'saved-value) 84 (set-default symbol (if (get symbol 'saved-value)
83 (eval (car (get symbol 'saved-value))) 85 (eval (car (get symbol 'saved-value)))
84 (eval value))))) 86 (eval value)))))
85 87
86 (defun custom-initialize-set (symbol value) 88 (defun custom-initialize-set (symbol value)
109 (eval value))))) 111 (eval value)))))
110 112
111 (defun custom-initialize-changed (symbol value) 113 (defun custom-initialize-changed (symbol value)
112 "Initialize SYMBOL with VALUE. 114 "Initialize SYMBOL with VALUE.
113 Like `custom-initialize-reset', but only use the `:set' function if the 115 Like `custom-initialize-reset', but only use the `:set' function if the
114 not using the factory setting. Otherwise, use the `set-default'." 116 not using the standard setting. Otherwise, use the `set-default'."
115 (cond ((default-boundp symbol) 117 (cond ((default-boundp symbol)
116 (funcall (or (get symbol 'custom-set) 'set-default) 118 (funcall (or (get symbol 'custom-set) 'set-default)
117 symbol 119 symbol
118 (funcall (or (get symbol 'custom-get) 'default-value) 120 (funcall (or (get symbol 'custom-get) 'default-value)
119 symbol))) 121 symbol)))
124 (t 126 (t
125 (set-default symbol (eval value))))) 127 (set-default symbol (eval value)))))
126 128
127 (defun custom-declare-variable (symbol value doc &rest args) 129 (defun custom-declare-variable (symbol value doc &rest args)
128 "Like `defcustom', but SYMBOL and VALUE are evaluated as normal arguments." 130 "Like `defcustom', but SYMBOL and VALUE are evaluated as normal arguments."
129 ;; Remember the factory setting. 131 ;; Remember the standard setting.
130 (put symbol 'factory-value (list value)) 132 (put symbol 'standard-value (list value))
131 ;; Maybe this option was rogue in an earlier version. It no longer is. 133 ;; Maybe this option was rogue in an earlier version. It no longer is.
132 (when (get symbol 'force-value) 134 (when (get symbol 'force-value)
133 ;; It no longer is. 135 ;; It no longer is.
134 (put symbol 'force-value nil)) 136 (put symbol 'force-value nil))
135 (when doc 137 (when doc
151 ((eq keyword :set) 153 ((eq keyword :set)
152 (put symbol 'custom-set value)) 154 (put symbol 'custom-set value))
153 ((eq keyword :get) 155 ((eq keyword :get)
154 (put symbol 'custom-get value)) 156 (put symbol 'custom-get value))
155 ((eq keyword :require) 157 ((eq keyword :require)
156 (push value requests)) 158 (setq requests (cons value requests)))
157 ((eq keyword :type) 159 ((eq keyword :type)
158 (put symbol 'custom-type value)) 160 (put symbol 'custom-type value))
159 ((eq keyword :options) 161 ((eq keyword :options)
160 (if (get symbol 'custom-options) 162 (if (get symbol 'custom-options)
161 ;; Slow safe code to avoid duplicates. 163 ;; Slow safe code to avoid duplicates.
232 234
233 SPEC should be an alist of the form ((DISPLAY ATTS)...). 235 SPEC should be an alist of the form ((DISPLAY ATTS)...).
234 236
235 ATTS is a list of face attributes and their values. The possible 237 ATTS is a list of face attributes and their values. The possible
236 attributes are defined in the variable `custom-face-attributes'. 238 attributes are defined in the variable `custom-face-attributes'.
237 Alternatively, ATTS can be a face in which case the attributes of that
238 face is used.
239 239
240 The ATTS of the first entry in SPEC where the DISPLAY matches the 240 The ATTS of the first entry in SPEC where the DISPLAY matches the
241 frame should take effect in that frame. DISPLAY can either be the 241 frame should take effect in that frame. DISPLAY can either be the
242 symbol t, which will match all frames, or an alist of the form 242 symbol t, which will match all frames, or an alist of the form
243 \((REQ ITEM...)...) 243 \((REQ ITEM...)...)