annotate lisp/custom.el @ 47797:d0555af982c8

(vc-rcs-find-version): New fun. (vc-rcs-checkout): Remove `workfile' arg and simplify.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Tue, 08 Oct 2002 15:33:18 +0000
parents 8ed8d9b28086
children 46f8bf0fc7b4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38412
253f761ad37b Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents: 36902
diff changeset
1 ;;; custom.el --- tools for declaring and initializing options
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
2 ;;
42503
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
3 ;; Copyright (C) 1996, 1997, 1999, 2001, 2002 Free Software Foundation, Inc.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
4 ;;
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
26582
fbd1f4d3000d (custom-declare-group): Purecopy DOC.
Dave Love <fx@gnu.org>
parents: 25888
diff changeset
6 ;; Maintainer: FSF
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
7 ;; Keywords: help, faces
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
8
17520
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
9 ;; This file is part of GNU Emacs.
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
10
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
14 ;; any later version.
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
15
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
19 ;; GNU General Public License for more details.
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
20
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
21 ;; You should have received a copy of the GNU General Public License
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
24 ;; Boston, MA 02111-1307, USA.
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
25
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
26 ;;; Commentary:
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
27 ;;
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
28 ;; This file only contain the code needed to declare and initialize
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
29 ;; user options. The code to customize options is autoloaded from
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
30 ;; `cus-edit.el' and is documented in the Emacs Lisp Reference manual.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
31
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
32 ;; The code implementing face declarations is in `cus-face.el'
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
33
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
34 ;;; Code:
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
35
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
36 (require 'widget)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
37
17415
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
38 (defvar custom-define-hook nil
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
39 ;; Customize information for this option is in `cus-edit.el'.
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
40 "Hook called after defining each customize option.")
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
41
47570
b65cc673fb00 (custom-dont-initialize): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 45366
diff changeset
42 (defvar custom-dont-initialize nil
b65cc673fb00 (custom-dont-initialize): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 45366
diff changeset
43 "Non-nil means `defcustom' should not initialize the variable.
b65cc673fb00 (custom-dont-initialize): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 45366
diff changeset
44 That is used for the sake of `custom-make-dependencies'.
b65cc673fb00 (custom-dont-initialize): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 45366
diff changeset
45 Users should not set it.")
b65cc673fb00 (custom-dont-initialize): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 45366
diff changeset
46
41224
fc0e6d3f905d (custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39981
diff changeset
47 (defvar custom-current-group-alist nil
fc0e6d3f905d (custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39981
diff changeset
48 "Alist of (FILE . GROUP) indicating the current group to use for FILE.")
fc0e6d3f905d (custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39981
diff changeset
49
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
50 ;;; The `defcustom' Macro.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
51
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
52 (defun custom-initialize-default (symbol value)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
53 "Initialize SYMBOL with VALUE.
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
54 This will do nothing if symbol already has a default binding.
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
55 Otherwise, if symbol has a `saved-value' property, it will evaluate
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
56 the car of that and used as the default binding for symbol.
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
57 Otherwise, VALUE will be evaluated and used as the default binding for
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
58 symbol."
17415
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
59 (unless (default-boundp symbol)
18033
bccd356a3b7c Synched with version 1.9900.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17949
diff changeset
60 ;; Use the saved value if it exists, otherwise the standard setting.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
61 (set-default symbol (if (get symbol 'saved-value)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
62 (eval (car (get symbol 'saved-value)))
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
63 (eval value)))))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
64
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
65 (defun custom-initialize-set (symbol value)
19535
e9d8fcec9843 (custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents: 19516
diff changeset
66 "Initialize SYMBOL based on VALUE.
e9d8fcec9843 (custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents: 19516
diff changeset
67 If the symbol doesn't have a default binding already,
e9d8fcec9843 (custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents: 19516
diff changeset
68 then set it using its `:set' function (or `set-default' if it has none).
e9d8fcec9843 (custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents: 19516
diff changeset
69 The value is either the value in the symbol's `saved-value' property,
e9d8fcec9843 (custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents: 19516
diff changeset
70 if any, or VALUE."
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
71 (unless (default-boundp symbol)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
72 (funcall (or (get symbol 'custom-set) 'set-default)
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
73 symbol
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
74 (if (get symbol 'saved-value)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
75 (eval (car (get symbol 'saved-value)))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
76 (eval value)))))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
77
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
78 (defun custom-initialize-reset (symbol value)
19535
e9d8fcec9843 (custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents: 19516
diff changeset
79 "Initialize SYMBOL based on VALUE.
e9d8fcec9843 (custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents: 19516
diff changeset
80 Set the symbol, using its `:set' function (or `set-default' if it has none).
e9d8fcec9843 (custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents: 19516
diff changeset
81 The value is either the symbol's current value
e9d8fcec9843 (custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents: 19516
diff changeset
82 \(as obtained using the `:get' function), if any,
e9d8fcec9843 (custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents: 19516
diff changeset
83 or the value in the symbol's `saved-value' property if any,
e9d8fcec9843 (custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents: 19516
diff changeset
84 or (last of all) VALUE."
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
85 (funcall (or (get symbol 'custom-set) 'set-default)
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
86 symbol
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
87 (cond ((default-boundp symbol)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
88 (funcall (or (get symbol 'custom-get) 'default-value)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
89 symbol))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
90 ((get symbol 'saved-value)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
91 (eval (car (get symbol 'saved-value))))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
92 (t
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
93 (eval value)))))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
94
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
95 (defun custom-initialize-changed (symbol value)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
96 "Initialize SYMBOL with VALUE.
36269
9a470a7db563 (custom-initialize-changed, defcustom): Doc fix.
Dave Love <fx@gnu.org>
parents: 33027
diff changeset
97 Like `custom-initialize-reset', but only use the `:set' function if
19535
e9d8fcec9843 (custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents: 19516
diff changeset
98 not using the standard setting.
36269
9a470a7db563 (custom-initialize-changed, defcustom): Doc fix.
Dave Love <fx@gnu.org>
parents: 33027
diff changeset
99 For the standard setting, use `set-default'."
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
100 (cond ((default-boundp symbol)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
101 (funcall (or (get symbol 'custom-set) 'set-default)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
102 symbol
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
103 (funcall (or (get symbol 'custom-get) 'default-value)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
104 symbol)))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
105 ((get symbol 'saved-value)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
106 (funcall (or (get symbol 'custom-set) 'set-default)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
107 symbol
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
108 (eval (car (get symbol 'saved-value)))))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
109 (t
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
110 (set-default symbol (eval value)))))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
111
19516
6591f294b265 (custom-declare-variable): Rename 2nd arg to DEFAULT.
Richard M. Stallman <rms@gnu.org>
parents: 18882
diff changeset
112 (defun custom-declare-variable (symbol default doc &rest args)
6591f294b265 (custom-declare-variable): Rename 2nd arg to DEFAULT.
Richard M. Stallman <rms@gnu.org>
parents: 18882
diff changeset
113 "Like `defcustom', but SYMBOL and DEFAULT are evaluated as normal arguments.
6591f294b265 (custom-declare-variable): Rename 2nd arg to DEFAULT.
Richard M. Stallman <rms@gnu.org>
parents: 18882
diff changeset
114 DEFAULT should be an expression to evaluate to compute the default value,
6591f294b265 (custom-declare-variable): Rename 2nd arg to DEFAULT.
Richard M. Stallman <rms@gnu.org>
parents: 18882
diff changeset
115 not the default value itself."
18033
bccd356a3b7c Synched with version 1.9900.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17949
diff changeset
116 ;; Remember the standard setting.
19516
6591f294b265 (custom-declare-variable): Rename 2nd arg to DEFAULT.
Richard M. Stallman <rms@gnu.org>
parents: 18882
diff changeset
117 (put symbol 'standard-value (list default))
17415
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
118 ;; Maybe this option was rogue in an earlier version. It no longer is.
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
119 (when (get symbol 'force-value)
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
120 (put symbol 'force-value nil))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
121 (when doc
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
122 (put symbol 'variable-documentation doc))
19535
e9d8fcec9843 (custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents: 19516
diff changeset
123 (let ((initialize 'custom-initialize-reset)
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
124 (requests nil))
41224
fc0e6d3f905d (custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39981
diff changeset
125 (unless (memq :group args)
fc0e6d3f905d (custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39981
diff changeset
126 (custom-add-to-group (custom-current-group) symbol 'custom-variable))
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
127 (while args
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
128 (let ((arg (car args)))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
129 (setq args (cdr args))
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
130 (unless (symbolp arg)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
131 (error "Junk in args %S" args))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
132 (let ((keyword arg)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
133 (value (car args)))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
134 (unless args
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
135 (error "Keyword %s is missing an argument" keyword))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
136 (setq args (cdr args))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
137 (cond ((eq keyword :initialize)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
138 (setq initialize value))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
139 ((eq keyword :set)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
140 (put symbol 'custom-set value))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
141 ((eq keyword :get)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
142 (put symbol 'custom-get value))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
143 ((eq keyword :require)
17576
1cc3913deaf8 (custom-declare-variable): Don't use `push'.
Richard M. Stallman <rms@gnu.org>
parents: 17550
diff changeset
144 (setq requests (cons value requests)))
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
145 ((eq keyword :type)
26928
755f54893c1f (custom-declare-variable): Purecopy value.
Dave Love <fx@gnu.org>
parents: 26831
diff changeset
146 (put symbol 'custom-type (purecopy value)))
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
147 ((eq keyword :options)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
148 (if (get symbol 'custom-options)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
149 ;; Slow safe code to avoid duplicates.
32225
15a7324321bb (custom-declare-variable, custom-set-variables): Use mapc.
Dave Love <fx@gnu.org>
parents: 31362
diff changeset
150 (mapc (lambda (option)
15a7324321bb (custom-declare-variable, custom-set-variables): Use mapc.
Dave Love <fx@gnu.org>
parents: 31362
diff changeset
151 (custom-add-option symbol option))
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
152 value)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
153 ;; Fast code for the common case.
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
154 (put symbol 'custom-options (copy-sequence value))))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
155 (t
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
156 (custom-handle-keyword symbol keyword value
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
157 'custom-variable))))))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
158 (put symbol 'custom-requests requests)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
159 ;; Do the actual initialization.
47570
b65cc673fb00 (custom-dont-initialize): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 45366
diff changeset
160 (unless custom-dont-initialize
b65cc673fb00 (custom-dont-initialize): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 45366
diff changeset
161 (funcall initialize symbol default)))
22499
a478a91f3fbb (custom-declare-variable): Update current-load-list.
Richard M. Stallman <rms@gnu.org>
parents: 22141
diff changeset
162 (setq current-load-list (cons symbol current-load-list))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
163 (run-hooks 'custom-define-hook)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
164 symbol)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
165
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
166 (defmacro defcustom (symbol value doc &rest args)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
167 "Declare SYMBOL as a customizable variable that defaults to VALUE.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
168 DOC is the variable documentation.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
169
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
170 Neither SYMBOL nor VALUE needs to be quoted.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
171 If SYMBOL is not already bound, initialize it to VALUE.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
172 The remaining arguments should have the form
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
173
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
174 [KEYWORD VALUE]...
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
175
22141
8ddb49eb4814 (defcustom): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 21703
diff changeset
176 The following keywords are meaningful:
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
177
47677
8ed8d9b28086 (defcustom): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 47570
diff changeset
178 :type VALUE should be a widget type for editing the symbol's value.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
179 :options VALUE should be a list of valid members of the widget type.
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
180 :group VALUE should be a customization group.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
181 Add SYMBOL to that group.
42508
37d771fc6685 (defcustom): Fix syntax of previous change.
Richard M. Stallman <rms@gnu.org>
parents: 42503
diff changeset
182 :link LINK-DATA
42503
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
183 Include an external link after the documentation string for this
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
184 item. This is a sentence containing an active field which
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
185 references some other documentation.
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
186
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
187 There are three alternatives you can use for LINK-DATA:
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
188
42508
37d771fc6685 (defcustom): Fix syntax of previous change.
Richard M. Stallman <rms@gnu.org>
parents: 42503
diff changeset
189 (custom-manual INFO-NODE)
42503
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
190 Link to an Info node; INFO-NODE is a string which specifies
42508
37d771fc6685 (defcustom): Fix syntax of previous change.
Richard M. Stallman <rms@gnu.org>
parents: 42503
diff changeset
191 the node name, as in \"(emacs)Top\". The link appears as
42503
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
192 `[manual]' in the customization buffer.
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
193
42508
37d771fc6685 (defcustom): Fix syntax of previous change.
Richard M. Stallman <rms@gnu.org>
parents: 42503
diff changeset
194 (info-link INFO-NODE)
42503
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
195 Like `custom-manual' except that the link appears in the
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
196 customization buffer with the Info node name.
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
197
42508
37d771fc6685 (defcustom): Fix syntax of previous change.
Richard M. Stallman <rms@gnu.org>
parents: 42503
diff changeset
198 (url-link URL)
42503
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
199 Link to a web page; URL is a string which specifies the URL.
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
200 The link appears in the customization buffer as URL.
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
201
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
202 You can specify the text to use in the customization buffer by
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
203 adding `:tag NAME' after the first element of the LINK-DATA; for
42508
37d771fc6685 (defcustom): Fix syntax of previous change.
Richard M. Stallman <rms@gnu.org>
parents: 42503
diff changeset
204 example, (info-link :tag \"foo\" \"(emacs)Top\") makes a link to the
42503
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
205 Emacs manual which appears in the buffer as `foo'.
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
206
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
207 An item can have more than one external link; however, most items
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
208 have none at all.
22141
8ddb49eb4814 (defcustom): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 21703
diff changeset
209 :initialize
8ddb49eb4814 (defcustom): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 21703
diff changeset
210 VALUE should be a function used to initialize the
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
211 variable. It takes two arguments, the symbol and value
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
212 given in the `defcustom' call. The default is
41821
ad017e26a4db Doc fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 41224
diff changeset
213 `custom-initialize-reset'.
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
214 :set VALUE should be a function to set the value of the symbol.
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
215 It takes two arguments, the symbol to set and the value to
22606
36171df7d571 (custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 22499
diff changeset
216 give it. The default choice of function is `custom-set-default'.
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
217 :get VALUE should be a function to extract the value of symbol.
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
218 The function takes one argument, a symbol, and should return
22141
8ddb49eb4814 (defcustom): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 21703
diff changeset
219 the current value for that symbol. The default choice of function
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
220 is `custom-default-value'.
22141
8ddb49eb4814 (defcustom): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 21703
diff changeset
221 :require
8ddb49eb4814 (defcustom): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 21703
diff changeset
222 VALUE should be a feature symbol. If you save a value
8ddb49eb4814 (defcustom): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 21703
diff changeset
223 for this option, then when your `.emacs' file loads the value,
8ddb49eb4814 (defcustom): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 21703
diff changeset
224 it does (require VALUE) first.
29761
00dcb25bfffd (defcustom, defgroup): Doc fix.
Dave Love <fx@gnu.org>
parents: 28171
diff changeset
225 :version
00dcb25bfffd (defcustom, defgroup): Doc fix.
Dave Love <fx@gnu.org>
parents: 28171
diff changeset
226 VALUE should be a string specifying that the variable was
00dcb25bfffd (defcustom, defgroup): Doc fix.
Dave Love <fx@gnu.org>
parents: 28171
diff changeset
227 first introduced, or its default value was changed, in Emacs
00dcb25bfffd (defcustom, defgroup): Doc fix.
Dave Love <fx@gnu.org>
parents: 28171
diff changeset
228 version VERSION.
42503
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
229 :tag LABEL
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
230 Use LABEL, a string, instead of the item's name, to label the item
42556
fc69700db2a3 Fix typo.
Pavel Janík <Pavel@Janik.cz>
parents: 42508
diff changeset
231 in customization menus and buffers.
42503
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
232 :load FILE
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
233 Load file FILE (a string) before displaying this customization
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
234 item. Loading is done with `load-library', and only if the file is
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
235 not already loaded.
38655
782cdc33db66 (defcustom): Doc fix.
Gerd Moellmann <gerd@gnu.org>
parents: 38412
diff changeset
236 :set-after VARIABLE
782cdc33db66 (defcustom): Doc fix.
Gerd Moellmann <gerd@gnu.org>
parents: 38412
diff changeset
237 Specifies that SYMBOL should be set after VARIABLE when
782cdc33db66 (defcustom): Doc fix.
Gerd Moellmann <gerd@gnu.org>
parents: 38412
diff changeset
238 both have been customized.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
239
17442
eb87aef64274 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17415
diff changeset
240 Read the section about customization in the Emacs Lisp manual for more
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
241 information."
21703
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
242 ;; It is better not to use backquote in this file,
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
243 ;; because that makes a bootstrapping problem
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
244 ;; if you need to recompile all the Lisp files using interpreted code.
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
245 (nconc (list 'custom-declare-variable
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
246 (list 'quote symbol)
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
247 (list 'quote value)
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
248 doc)
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
249 args))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
250
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
251 ;;; The `defface' Macro.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
252
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
253 (defmacro defface (face spec doc &rest args)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
254 "Declare FACE as a customizable face that defaults to SPEC.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
255 FACE does not need to be quoted.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
256
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
257 Third argument DOC is the face documentation.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
258
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
259 If FACE has been set with `custom-set-face', set the face attributes
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
260 as specified by that function, otherwise set the face attributes
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
261 according to SPEC.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
262
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
263 The remaining arguments should have the form
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
264
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
265 [KEYWORD VALUE]...
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
266
17949
3b0f71e1661d (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 17921
diff changeset
267 The following KEYWORDs are defined:
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
268
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
269 :group VALUE should be a customization group.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
270 Add FACE to that group.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
271
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
272 SPEC should be an alist of the form ((DISPLAY ATTS)...).
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
273
17949
3b0f71e1661d (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 17921
diff changeset
274 The first element of SPEC where the DISPLAY matches the frame
3b0f71e1661d (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 17921
diff changeset
275 is the one that takes effect in that frame. The ATTRs in this
3b0f71e1661d (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 17921
diff changeset
276 element take effect; the other elements are ignored, on that frame.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
277
17949
3b0f71e1661d (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 17921
diff changeset
278 ATTS is a list of face attributes followed by their values:
3b0f71e1661d (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 17921
diff changeset
279 (ATTR VALUE ATTR VALUE...)
24986
cf6d86af7374 (defface): Extend documentation to include new
Gerd Moellmann <gerd@gnu.org>
parents: 24872
diff changeset
280
cf6d86af7374 (defface): Extend documentation to include new
Gerd Moellmann <gerd@gnu.org>
parents: 24872
diff changeset
281 The possible attributes are `:family', `:width', `:height', `:weight',
cf6d86af7374 (defface): Extend documentation to include new
Gerd Moellmann <gerd@gnu.org>
parents: 24872
diff changeset
282 `:slant', `:underline', `:overline', `:strike-through', `:box',
39981
c576f3427825 (defface): Mention `:inherit' in doc-string.
Miles Bader <miles@gnu.org>
parents: 38857
diff changeset
283 `:foreground', `:background', `:stipple', `:inverse-video', and `:inherit'.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
284
17949
3b0f71e1661d (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 17921
diff changeset
285 DISPLAY can either be the symbol t, which will match all frames, or an
3b0f71e1661d (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 17921
diff changeset
286 alist of the form \((REQ ITEM...)...). For the DISPLAY to match a
3b0f71e1661d (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 17921
diff changeset
287 FRAME, the REQ property of the frame must match one of the ITEM. The
3b0f71e1661d (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 17921
diff changeset
288 following REQ are defined:
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
289
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
290 `type' (the value of `window-system')
25888
7144668076c7 (defface): Extend documentation for new values of `type'.
Gerd Moellmann <gerd@gnu.org>
parents: 25683
diff changeset
291 Under X, in addition to the values `window-system' can take,
7144668076c7 (defface): Extend documentation for new values of `type'.
Gerd Moellmann <gerd@gnu.org>
parents: 25683
diff changeset
292 `motif', `lucid' and `x-toolkit' are allowed, and match when
7144668076c7 (defface): Extend documentation for new values of `type'.
Gerd Moellmann <gerd@gnu.org>
parents: 25683
diff changeset
293 the Motif toolkit, Lucid toolkit, or any X toolkit is in use.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
294
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
295 `class' (the frame's color support)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
296 Should be one of `color', `grayscale', or `mono'.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
297
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
298 `background' (what color is used for the background text)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
299 Should be one of `light' or `dark'.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
300
17442
eb87aef64274 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17415
diff changeset
301 Read the section about customization in the Emacs Lisp manual for more
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
302 information."
21703
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
303 ;; It is better not to use backquote in this file,
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
304 ;; because that makes a bootstrapping problem
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
305 ;; if you need to recompile all the Lisp files using interpreted code.
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
306 (nconc (list 'custom-declare-face (list 'quote face) spec doc) args))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
307
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
308 ;;; The `defgroup' Macro.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
309
41224
fc0e6d3f905d (custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39981
diff changeset
310 (defun custom-current-group ()
fc0e6d3f905d (custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39981
diff changeset
311 (cdr (assoc load-file-name custom-current-group-alist)))
fc0e6d3f905d (custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39981
diff changeset
312
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
313 (defun custom-declare-group (symbol members doc &rest args)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
314 "Like `defgroup', but SYMBOL is evaluated as a normal argument."
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
315 (while members
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
316 (apply 'custom-add-to-group symbol (car members))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
317 (setq members (cdr members)))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
318 (put symbol 'custom-group (nconc members (get symbol 'custom-group)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
319 (when doc
26582
fbd1f4d3000d (custom-declare-group): Purecopy DOC.
Dave Love <fx@gnu.org>
parents: 25888
diff changeset
320 ;; This text doesn't get into DOC.
fbd1f4d3000d (custom-declare-group): Purecopy DOC.
Dave Love <fx@gnu.org>
parents: 25888
diff changeset
321 (put symbol 'group-documentation (purecopy doc)))
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
322 (while args
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
323 (let ((arg (car args)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
324 (setq args (cdr args))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
325 (unless (symbolp arg)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
326 (error "Junk in args %S" args))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
327 (let ((keyword arg)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
328 (value (car args)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
329 (unless args
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
330 (error "Keyword %s is missing an argument" keyword))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
331 (setq args (cdr args))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
332 (cond ((eq keyword :prefix)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
333 (put symbol 'custom-prefix value))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
334 (t
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
335 (custom-handle-keyword symbol keyword value
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
336 'custom-group))))))
41224
fc0e6d3f905d (custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39981
diff changeset
337 ;; Record the group on the `current' list.
fc0e6d3f905d (custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39981
diff changeset
338 (let ((elt (assoc load-file-name custom-current-group-alist)))
fc0e6d3f905d (custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39981
diff changeset
339 (if elt (setcdr elt symbol)
fc0e6d3f905d (custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39981
diff changeset
340 (push (cons load-file-name symbol) custom-current-group-alist)))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
341 (run-hooks 'custom-define-hook)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
342 symbol)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
343
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
344 (defmacro defgroup (symbol members doc &rest args)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
345 "Declare SYMBOL as a customization group containing MEMBERS.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
346 SYMBOL does not need to be quoted.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
347
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
348 Third arg DOC is the group documentation.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
349
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
350 MEMBERS should be an alist of the form ((NAME WIDGET)...) where
20599
a529e09b1fe2 (defgroup): Doc fix.
Andreas Schwab <schwab@suse.de>
parents: 20445
diff changeset
351 NAME is a symbol and WIDGET is a widget for editing that symbol.
a529e09b1fe2 (defgroup): Doc fix.
Andreas Schwab <schwab@suse.de>
parents: 20445
diff changeset
352 Useful widgets are `custom-variable' for editing variables,
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
353 `custom-face' for edit faces, and `custom-group' for editing groups.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
354
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
355 The remaining arguments should have the form
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
356
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
357 [KEYWORD VALUE]...
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
358
29761
00dcb25bfffd (defcustom, defgroup): Doc fix.
Dave Love <fx@gnu.org>
parents: 28171
diff changeset
359 The following KEYWORDs are defined:
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
360
29761
00dcb25bfffd (defcustom, defgroup): Doc fix.
Dave Love <fx@gnu.org>
parents: 28171
diff changeset
361 :group VALUE should be a customization group.
00dcb25bfffd (defcustom, defgroup): Doc fix.
Dave Love <fx@gnu.org>
parents: 28171
diff changeset
362 Add SYMBOL to that group.
00dcb25bfffd (defcustom, defgroup): Doc fix.
Dave Love <fx@gnu.org>
parents: 28171
diff changeset
363
00dcb25bfffd (defcustom, defgroup): Doc fix.
Dave Love <fx@gnu.org>
parents: 28171
diff changeset
364 :version VALUE should be a string specifying that the group was introduced
00dcb25bfffd (defcustom, defgroup): Doc fix.
Dave Love <fx@gnu.org>
parents: 28171
diff changeset
365 in Emacs version VERSION.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
366
17442
eb87aef64274 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17415
diff changeset
367 Read the section about customization in the Emacs Lisp manual for more
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
368 information."
21703
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
369 ;; It is better not to use backquote in this file,
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
370 ;; because that makes a bootstrapping problem
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
371 ;; if you need to recompile all the Lisp files using interpreted code.
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
372 (nconc (list 'custom-declare-group (list 'quote symbol) members doc) args))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
373
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
374 (defun custom-add-to-group (group option widget)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
375 "To existing GROUP add a new OPTION of type WIDGET.
33025
9559a9aeff3c (custom-add-to-group): Allow multiple entries for a given value OPTION,
Miles Bader <miles@gnu.org>
parents: 32225
diff changeset
376 If there already is an entry for OPTION and WIDGET, nothing is done."
9559a9aeff3c (custom-add-to-group): Allow multiple entries for a given value OPTION,
Miles Bader <miles@gnu.org>
parents: 32225
diff changeset
377 (let ((members (get group 'custom-group))
9559a9aeff3c (custom-add-to-group): Allow multiple entries for a given value OPTION,
Miles Bader <miles@gnu.org>
parents: 32225
diff changeset
378 (entry (list option widget)))
9559a9aeff3c (custom-add-to-group): Allow multiple entries for a given value OPTION,
Miles Bader <miles@gnu.org>
parents: 32225
diff changeset
379 (unless (member entry members)
9559a9aeff3c (custom-add-to-group): Allow multiple entries for a given value OPTION,
Miles Bader <miles@gnu.org>
parents: 32225
diff changeset
380 (put group 'custom-group (nconc members (list entry))))))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
381
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
382 ;;; Properties.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
383
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
384 (defun custom-handle-all-keywords (symbol args type)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
385 "For customization option SYMBOL, handle keyword arguments ARGS.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
386 Third argument TYPE is the custom option type."
41224
fc0e6d3f905d (custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39981
diff changeset
387 (unless (memq :group args)
fc0e6d3f905d (custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39981
diff changeset
388 (custom-add-to-group (custom-current-group) symbol 'custom-face))
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
389 (while args
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
390 (let ((arg (car args)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
391 (setq args (cdr args))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
392 (unless (symbolp arg)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
393 (error "Junk in args %S" args))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
394 (let ((keyword arg)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
395 (value (car args)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
396 (unless args
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
397 (error "Keyword %s is missing an argument" keyword))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
398 (setq args (cdr args))
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
399 (custom-handle-keyword symbol keyword value type)))))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
400
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
401 (defun custom-handle-keyword (symbol keyword value type)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
402 "For customization option SYMBOL, handle KEYWORD with VALUE.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
403 Fourth argument TYPE is the custom option type."
26582
fbd1f4d3000d (custom-declare-group): Purecopy DOC.
Dave Love <fx@gnu.org>
parents: 25888
diff changeset
404 (if purify-flag
fbd1f4d3000d (custom-declare-group): Purecopy DOC.
Dave Love <fx@gnu.org>
parents: 25888
diff changeset
405 (setq value (purecopy value)))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
406 (cond ((eq keyword :group)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
407 (custom-add-to-group value symbol type))
20445
20ff88ac8cc2 (custom-add-version): New function.
Karl Heuer <kwzh@gnu.org>
parents: 19535
diff changeset
408 ((eq keyword :version)
20ff88ac8cc2 (custom-add-version): New function.
Karl Heuer <kwzh@gnu.org>
parents: 19535
diff changeset
409 (custom-add-version symbol value))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
410 ((eq keyword :link)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
411 (custom-add-link symbol value))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
412 ((eq keyword :load)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
413 (custom-add-load symbol value))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
414 ((eq keyword :tag)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
415 (put symbol 'custom-tag value))
26831
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
416 ((eq keyword :set-after)
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
417 (custom-add-dependencies symbol value))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
418 (t
24872
9db8a7ed814e (custom-handle-keyword): Fix error message.
Karl Heuer <kwzh@gnu.org>
parents: 24438
diff changeset
419 (error "Unknown keyword %s" keyword))))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
420
26831
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
421 (defun custom-add-dependencies (symbol value)
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
422 "To the custom option SYMBOL, add dependencies specified by VALUE.
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
423 VALUE should be a list of symbols. For each symbol in that list,
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
424 this specifies that SYMBOL should be set after the specified symbol, if
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
425 both appear in constructs like `custom-set-variables'."
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
426 (unless (listp value)
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
427 (error "Invalid custom dependency `%s'" value))
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
428 (let* ((deps (get symbol 'custom-dependencies))
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
429 (new-deps deps))
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
430 (while value
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
431 (let ((dep (car value)))
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
432 (unless (symbolp dep)
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
433 (error "Invalid custom dependency `%s'" dep))
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
434 (unless (memq dep new-deps)
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
435 (setq new-deps (cons dep new-deps)))
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
436 (setq value (cdr value))))
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
437 (unless (eq deps new-deps)
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
438 (put symbol 'custom-dependencies new-deps))))
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
439
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
440 (defun custom-add-option (symbol option)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
441 "To the variable SYMBOL add OPTION.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
442
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
443 If SYMBOL is a hook variable, OPTION should be a hook member.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
444 For other types variables, the effect is undefined."
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
445 (let ((options (get symbol 'custom-options)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
446 (unless (member option options)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
447 (put symbol 'custom-options (cons option options)))))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
448
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
449 (defun custom-add-link (symbol widget)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
450 "To the custom option SYMBOL add the link WIDGET."
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
451 (let ((links (get symbol 'custom-links)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
452 (unless (member widget links)
26582
fbd1f4d3000d (custom-declare-group): Purecopy DOC.
Dave Love <fx@gnu.org>
parents: 25888
diff changeset
453 (put symbol 'custom-links (cons (purecopy widget) links)))))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
454
20445
20ff88ac8cc2 (custom-add-version): New function.
Karl Heuer <kwzh@gnu.org>
parents: 19535
diff changeset
455 (defun custom-add-version (symbol version)
20ff88ac8cc2 (custom-add-version): New function.
Karl Heuer <kwzh@gnu.org>
parents: 19535
diff changeset
456 "To the custom option SYMBOL add the version VERSION."
26582
fbd1f4d3000d (custom-declare-group): Purecopy DOC.
Dave Love <fx@gnu.org>
parents: 25888
diff changeset
457 (put symbol 'custom-version (purecopy version)))
20445
20ff88ac8cc2 (custom-add-version): New function.
Karl Heuer <kwzh@gnu.org>
parents: 19535
diff changeset
458
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
459 (defun custom-add-load (symbol load)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
460 "To the custom option SYMBOL add the dependency LOAD.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
461 LOAD should be either a library file name, or a feature name."
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
462 (let ((loads (get symbol 'custom-loads)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
463 (unless (member load loads)
26582
fbd1f4d3000d (custom-declare-group): Purecopy DOC.
Dave Love <fx@gnu.org>
parents: 25888
diff changeset
464 (put symbol 'custom-loads (cons (purecopy load) loads)))))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
465
44911
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
466 ;;; Loading files needed to customize a symbol.
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
467 ;;; This is in custom.el because menu-bar.el needs it for toggle cmds.
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
468
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
469 (defvar custom-load-recursion nil
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
470 "Hack to avoid recursive dependencies.")
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
471
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
472 (defun custom-load-symbol (symbol)
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
473 "Load all dependencies for SYMBOL."
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
474 (unless custom-load-recursion
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
475 (let ((custom-load-recursion t)
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
476 (loads (get symbol 'custom-loads))
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
477 load)
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
478 (while loads
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
479 (setq load (car loads)
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
480 loads (cdr loads))
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
481 (cond ((symbolp load)
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
482 (condition-case nil
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
483 (require load)
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
484 (error nil)))
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
485 ;; Don't reload a file already loaded.
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
486 ((and (boundp 'preloaded-file-list)
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
487 (member load preloaded-file-list)))
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
488 ((assoc load load-history))
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
489 ;; This was just (assoc (locate-library load) load-history)
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
490 ;; but has been optimized not to load locate-library
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
491 ;; if not necessary.
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
492 ((let (found (regexp (regexp-quote load)))
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
493 (dolist (loaded load-history)
45366
c9338efa3fd9 (custom-load-symbol): Verify that LOADED is a string.
Richard M. Stallman <rms@gnu.org>
parents: 44911
diff changeset
494 (and (stringp (car loaded))
c9338efa3fd9 (custom-load-symbol): Verify that LOADED is a string.
Richard M. Stallman <rms@gnu.org>
parents: 44911
diff changeset
495 (string-match regexp (car loaded))
44911
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
496 (eq (locate-library load) (car loaded))
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
497 (setq found t)))
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
498 found))
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
499 ;; Without this, we would load cus-edit recursively.
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
500 ;; We are still loading it when we call this,
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
501 ;; and it is not in load-history yet.
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
502 ((equal load "cus-edit"))
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
503 (t
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
504 (condition-case nil
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
505 (load-library load)
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
506 (error nil))))))))
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
507
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
508 ;;; Initializing.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
509
22606
36171df7d571 (custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 22499
diff changeset
510 (defvar custom-local-buffer nil
36171df7d571 (custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 22499
diff changeset
511 "Non-nil, in a Customization buffer, means customize a specific buffer.
36171df7d571 (custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 22499
diff changeset
512 If this variable is non-nil, it should be a buffer,
36171df7d571 (custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 22499
diff changeset
513 and it means customize the local bindings of that buffer.
36171df7d571 (custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 22499
diff changeset
514 This variable is a permanent local, and it normally has a local binding
36171df7d571 (custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 22499
diff changeset
515 in every Customization buffer.")
36171df7d571 (custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 22499
diff changeset
516 (put 'custom-local-buffer 'permanent-local t)
36171df7d571 (custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 22499
diff changeset
517
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
518 (defun custom-set-variables (&rest args)
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
519 "Initialize variables according to user preferences.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
520
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
521 The arguments should be a list where each entry has the form:
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
522
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
523 (SYMBOL VALUE [NOW [REQUEST [COMMENT]]])
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
524
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
525 The unevaluated VALUE is stored as the saved value for SYMBOL.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
526 If NOW is present and non-nil, VALUE is also evaluated and bound as
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
527 the default value for the SYMBOL.
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
528 REQUEST is a list of features we must require for SYMBOL.
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
529 COMMENT is a comment string about SYMBOL."
26831
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
530 (setq args
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
531 (sort args
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
532 (lambda (a1 a2)
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
533 (let* ((sym1 (car a1))
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
534 (sym2 (car a2))
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
535 (1-then-2 (memq sym1 (get sym2 'custom-dependencies)))
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
536 (2-then-1 (memq sym2 (get sym1 'custom-dependencies))))
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
537 (cond ((and 1-then-2 2-then-1)
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
538 (error "Circular custom dependency between `%s' and `%s'"
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
539 sym1 sym2))
36902
06affc73c4ea (custom-set-variables): Avoid reversing the list
Gerd Moellmann <gerd@gnu.org>
parents: 36269
diff changeset
540 (1-then-2 t)
38657
040e14876399 (custom-set-variables): Set options with :require
Gerd Moellmann <gerd@gnu.org>
parents: 38655
diff changeset
541 (2-then-1 nil)
040e14876399 (custom-set-variables): Set options with :require
Gerd Moellmann <gerd@gnu.org>
parents: 38655
diff changeset
542 ;; Put symbols with :require last. The macro
040e14876399 (custom-set-variables): Set options with :require
Gerd Moellmann <gerd@gnu.org>
parents: 38655
diff changeset
543 ;; define-minor-mode generates a defcustom
040e14876399 (custom-set-variables): Set options with :require
Gerd Moellmann <gerd@gnu.org>
parents: 38655
diff changeset
544 ;; with a :require and a :set, where the
040e14876399 (custom-set-variables): Set options with :require
Gerd Moellmann <gerd@gnu.org>
parents: 38655
diff changeset
545 ;; setter function calls the mode function.
040e14876399 (custom-set-variables): Set options with :require
Gerd Moellmann <gerd@gnu.org>
parents: 38655
diff changeset
546 ;; Putting symbols with :require last ensures
040e14876399 (custom-set-variables): Set options with :require
Gerd Moellmann <gerd@gnu.org>
parents: 38655
diff changeset
547 ;; that the mode function will see other
040e14876399 (custom-set-variables): Set options with :require
Gerd Moellmann <gerd@gnu.org>
parents: 38655
diff changeset
548 ;; customized values rather than default
040e14876399 (custom-set-variables): Set options with :require
Gerd Moellmann <gerd@gnu.org>
parents: 38655
diff changeset
549 ;; values.
38681
75739984c6c4 (custom-set-variables): Don't test `custom-requests'
Gerd Moellmann <gerd@gnu.org>
parents: 38657
diff changeset
550 (t (nth 3 a2)))))))
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
551 (while args
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
552 (let ((entry (car args)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
553 (if (listp entry)
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
554 (let* ((symbol (nth 0 entry))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
555 (value (nth 1 entry))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
556 (now (nth 2 entry))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
557 (requests (nth 3 entry))
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
558 (comment (nth 4 entry))
23354
4a3a39dff0ed (custom-set-variables): Load the requests first,
Karl Heuer <kwzh@gnu.org>
parents: 22606
diff changeset
559 set)
4a3a39dff0ed (custom-set-variables): Load the requests first,
Karl Heuer <kwzh@gnu.org>
parents: 22606
diff changeset
560 (when requests
4a3a39dff0ed (custom-set-variables): Load the requests first,
Karl Heuer <kwzh@gnu.org>
parents: 22606
diff changeset
561 (put symbol 'custom-requests requests)
32225
15a7324321bb (custom-declare-variable, custom-set-variables): Use mapc.
Dave Love <fx@gnu.org>
parents: 31362
diff changeset
562 (mapc 'require requests))
23354
4a3a39dff0ed (custom-set-variables): Load the requests first,
Karl Heuer <kwzh@gnu.org>
parents: 22606
diff changeset
563 (setq set (or (get symbol 'custom-set) 'custom-set-default))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
564 (put symbol 'saved-value (list value))
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
565 (put symbol 'saved-variable-comment comment)
24438
4a78f6354310 (custom-set-variables): Protect against setter errors.
Dave Love <fx@gnu.org>
parents: 23354
diff changeset
566 ;; Allow for errors in the case where the setter has
31362
652b5c65769a (custom-set-variables): Print message about errors in
Dave Love <fx@gnu.org>
parents: 29761
diff changeset
567 ;; changed between versions, say, but let the user know.
652b5c65769a (custom-set-variables): Print message about errors in
Dave Love <fx@gnu.org>
parents: 29761
diff changeset
568 (condition-case data
24438
4a78f6354310 (custom-set-variables): Protect against setter errors.
Dave Love <fx@gnu.org>
parents: 23354
diff changeset
569 (cond (now
4a78f6354310 (custom-set-variables): Protect against setter errors.
Dave Love <fx@gnu.org>
parents: 23354
diff changeset
570 ;; Rogue variable, set it now.
4a78f6354310 (custom-set-variables): Protect against setter errors.
Dave Love <fx@gnu.org>
parents: 23354
diff changeset
571 (put symbol 'force-value t)
4a78f6354310 (custom-set-variables): Protect against setter errors.
Dave Love <fx@gnu.org>
parents: 23354
diff changeset
572 (funcall set symbol (eval value)))
4a78f6354310 (custom-set-variables): Protect against setter errors.
Dave Love <fx@gnu.org>
parents: 23354
diff changeset
573 ((default-boundp symbol)
4a78f6354310 (custom-set-variables): Protect against setter errors.
Dave Love <fx@gnu.org>
parents: 23354
diff changeset
574 ;; Something already set this, overwrite it.
4a78f6354310 (custom-set-variables): Protect against setter errors.
Dave Love <fx@gnu.org>
parents: 23354
diff changeset
575 (funcall set symbol (eval value))))
31362
652b5c65769a (custom-set-variables): Print message about errors in
Dave Love <fx@gnu.org>
parents: 29761
diff changeset
576 (error
652b5c65769a (custom-set-variables): Print message about errors in
Dave Love <fx@gnu.org>
parents: 29761
diff changeset
577 (message "Error setting %s: %s" symbol data)))
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
578 (setq args (cdr args))
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
579 (and (or now (default-boundp symbol))
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
580 (put symbol 'variable-comment comment)))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
581 ;; Old format, a plist of SYMBOL VALUE pairs.
17415
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
582 (message "Warning: old format `custom-set-variables'")
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
583 (ding)
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
584 (sit-for 2)
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
585 (let ((symbol (nth 0 args))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
586 (value (nth 1 args)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
587 (put symbol 'saved-value (list value)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
588 (setq args (cdr (cdr args)))))))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
589
22606
36171df7d571 (custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 22499
diff changeset
590 (defun custom-set-default (variable value)
36171df7d571 (custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 22499
diff changeset
591 "Default :set function for a customizable variable.
36171df7d571 (custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 22499
diff changeset
592 Normally, this sets the default value of VARIABLE to VALUE,
36171df7d571 (custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 22499
diff changeset
593 but if `custom-local-buffer' is non-nil,
36171df7d571 (custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 22499
diff changeset
594 this sets the local binding in that buffer instead."
36171df7d571 (custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 22499
diff changeset
595 (if custom-local-buffer
36171df7d571 (custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 22499
diff changeset
596 (with-current-buffer custom-local-buffer
36171df7d571 (custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 22499
diff changeset
597 (set variable value))
36171df7d571 (custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 22499
diff changeset
598 (set-default variable value)))
36171df7d571 (custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 22499
diff changeset
599
44683
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
600 (defun custom-quote (sexp)
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
601 "Quote SEXP iff it is not self quoting."
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
602 (if (or (memq sexp '(t nil))
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
603 (keywordp sexp)
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
604 (and (listp sexp)
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
605 (memq (car sexp) '(lambda)))
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
606 (stringp sexp)
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
607 (numberp sexp)
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
608 (vectorp sexp)
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
609 ;;; (and (fboundp 'characterp)
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
610 ;;; (characterp sexp))
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
611 )
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
612 sexp
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
613 (list 'quote sexp)))
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
614
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
615 (defun customize-mark-to-save (symbol)
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
616 "Mark SYMBOL for later saving.
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
617
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
618 If the default value of SYMBOL is different from the standard value,
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
619 set the `saved-value' property to a list whose car evaluates to the
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
620 default value. Otherwise, set it til nil.
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
621
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
622 To actually save the value, call `custom-save-all'.
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
623
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
624 Return non-nil iff the `saved-value' property actually changed."
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
625 (let* ((get (or (get symbol 'custom-get) 'default-value))
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
626 (value (funcall get symbol))
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
627 (saved (get symbol 'saved-value))
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
628 (standard (get symbol 'standard-value))
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
629 (comment (get symbol 'customized-variable-comment)))
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
630 ;; Save default value iff different from standard value.
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
631 (if (or (null standard)
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
632 (not (equal value (condition-case nil
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
633 (eval (car standard))
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
634 (error nil)))))
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
635 (put symbol 'saved-value (list (custom-quote value)))
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
636 (put symbol 'saved-value nil))
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
637 ;; Clear customized information (set, but not saved).
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
638 (put symbol 'customized-value nil)
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
639 ;; Save any comment that might have been set.
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
640 (when comment
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
641 (put symbol 'saved-variable-comment comment))
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
642 (not (equal saved (get symbol 'saved-value)))))
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
643
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
644 (defun customize-mark-as-set (symbol)
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
645 "Mark current value of SYMBOL as being set from customize.
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
646
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
647 If the default value of SYMBOL is different from the saved value if any,
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
648 or else if it is different from the standard value, set the
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
649 `customized-value' property to a list whose car evaluates to the
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
650 default value. Otherwise, set it til nil.
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
651
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
652 Return non-nil iff the `customized-value' property actually changed."
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
653 (let* ((get (or (get symbol 'custom-get) 'default-value))
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
654 (value (funcall get symbol))
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
655 (customized (get symbol 'customized-value))
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
656 (old (or (get symbol 'saved-value) (get symbol 'standard-value))))
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
657 ;; Mark default value as set iff different from old value.
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
658 (if (or (null old)
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
659 (not (equal value (condition-case nil
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
660 (eval (car old))
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
661 (error nil)))))
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
662 (put symbol 'customized-value (list (custom-quote value)))
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
663 (put symbol 'customized-value nil))
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
664 ;; Changed?
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
665 (not (equal customized (get symbol 'customized-value)))))
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
666
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
667 ;;; The End.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
668
18882
539611251037 (custom-declare-variable-list): Process already-declared
Richard M. Stallman <rms@gnu.org>
parents: 18033
diff changeset
669 ;; Process the defcustoms for variables loaded before this file.
539611251037 (custom-declare-variable-list): Process already-declared
Richard M. Stallman <rms@gnu.org>
parents: 18033
diff changeset
670 (while custom-declare-variable-list
539611251037 (custom-declare-variable-list): Process already-declared
Richard M. Stallman <rms@gnu.org>
parents: 18033
diff changeset
671 (apply 'custom-declare-variable (car custom-declare-variable-list))
539611251037 (custom-declare-variable-list): Process already-declared
Richard M. Stallman <rms@gnu.org>
parents: 18033
diff changeset
672 (setq custom-declare-variable-list (cdr custom-declare-variable-list)))
539611251037 (custom-declare-variable-list): Process already-declared
Richard M. Stallman <rms@gnu.org>
parents: 18033
diff changeset
673
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
674 (provide 'custom)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
675
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
676 ;;; custom.el ends here