Mercurial > emacs
annotate lisp/custom.el @ 29720:a297debe5d12
*** empty log message ***
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Mon, 19 Jun 2000 05:04:49 +0000 |
parents | 08317cc36a7b |
children | 00dcb25bfffd |
rev | line source |
---|---|
17334 | 1 ;;; custom.el -- Tools for declaring and initializing options. |
2 ;; | |
25683 | 3 ;; Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc. |
17334 | 4 ;; |
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 | 7 ;; Keywords: help, faces |
8 | |
17520 | 9 ;; This file is part of GNU Emacs. |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
24 ;; Boston, MA 02111-1307, USA. | |
25 | |
17334 | 26 ;;; Commentary: |
27 ;; | |
28 ;; This file only contain the code needed to declare and initialize | |
29 ;; user options. The code to customize options is autoloaded from | |
25683 | 30 ;; `cus-edit.el' and is documented in the Emacs Lisp Reference manual. |
17334 | 31 |
32 ;; The code implementing face declarations is in `cus-face.el' | |
33 | |
34 ;;; Code: | |
35 | |
36 (require 'widget) | |
37 | |
17415 | 38 (defvar custom-define-hook nil |
39 ;; Customize information for this option is in `cus-edit.el'. | |
40 "Hook called after defining each customize option.") | |
41 | |
17334 | 42 ;;; The `defcustom' Macro. |
43 | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
44 (defun custom-initialize-default (symbol value) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
45 "Initialize SYMBOL with VALUE. |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
46 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
|
47 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
|
48 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
|
49 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
|
50 symbol." |
17415 | 51 (unless (default-boundp symbol) |
18033
bccd356a3b7c
Synched with version 1.9900.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17949
diff
changeset
|
52 ;; Use the saved value if it exists, otherwise the standard setting. |
17334 | 53 (set-default symbol (if (get symbol 'saved-value) |
54 (eval (car (get symbol 'saved-value))) | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
55 (eval value))))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
56 |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
57 (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
|
58 "Initialize SYMBOL based on VALUE. |
e9d8fcec9843
(custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents:
19516
diff
changeset
|
59 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
|
60 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
|
61 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
|
62 if any, or VALUE." |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
63 (unless (default-boundp symbol) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
64 (funcall (or (get symbol 'custom-set) 'set-default) |
25683 | 65 symbol |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
66 (if (get symbol 'saved-value) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
67 (eval (car (get symbol 'saved-value))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
68 (eval value))))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
69 |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
70 (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
|
71 "Initialize SYMBOL based on VALUE. |
e9d8fcec9843
(custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents:
19516
diff
changeset
|
72 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
|
73 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
|
74 \(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
|
75 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
|
76 or (last of all) VALUE." |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
77 (funcall (or (get symbol 'custom-set) 'set-default) |
25683 | 78 symbol |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
79 (cond ((default-boundp symbol) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
80 (funcall (or (get symbol 'custom-get) 'default-value) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
81 symbol)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
82 ((get symbol 'saved-value) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
83 (eval (car (get symbol 'saved-value)))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
84 (t |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
85 (eval value))))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
86 |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
87 (defun custom-initialize-changed (symbol value) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
88 "Initialize SYMBOL with VALUE. |
25683 | 89 Like `custom-initialize-reset', but only use the `:set' function if the |
19535
e9d8fcec9843
(custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents:
19516
diff
changeset
|
90 not using the standard setting. |
e9d8fcec9843
(custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents:
19516
diff
changeset
|
91 For the standard setting, use the `set-default'." |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
92 (cond ((default-boundp symbol) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
93 (funcall (or (get symbol 'custom-set) 'set-default) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
94 symbol |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
95 (funcall (or (get symbol 'custom-get) 'default-value) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
96 symbol))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
97 ((get symbol 'saved-value) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
98 (funcall (or (get symbol 'custom-set) 'set-default) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
99 symbol |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
100 (eval (car (get symbol 'saved-value))))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
101 (t |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
102 (set-default symbol (eval value))))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
103 |
19516
6591f294b265
(custom-declare-variable): Rename 2nd arg to DEFAULT.
Richard M. Stallman <rms@gnu.org>
parents:
18882
diff
changeset
|
104 (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
|
105 "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
|
106 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
|
107 not the default value itself." |
18033
bccd356a3b7c
Synched with version 1.9900.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17949
diff
changeset
|
108 ;; Remember the standard setting. |
19516
6591f294b265
(custom-declare-variable): Rename 2nd arg to DEFAULT.
Richard M. Stallman <rms@gnu.org>
parents:
18882
diff
changeset
|
109 (put symbol 'standard-value (list default)) |
17415 | 110 ;; Maybe this option was rogue in an earlier version. It no longer is. |
111 (when (get symbol 'force-value) | |
112 (put symbol 'force-value nil)) | |
17334 | 113 (when doc |
114 (put symbol 'variable-documentation doc)) | |
19535
e9d8fcec9843
(custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents:
19516
diff
changeset
|
115 (let ((initialize 'custom-initialize-reset) |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
116 (requests nil)) |
25683 | 117 (while args |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
118 (let ((arg (car args))) |
17334 | 119 (setq args (cdr args)) |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
120 (unless (symbolp arg) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
121 (error "Junk in args %S" args)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
122 (let ((keyword arg) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
123 (value (car args))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
124 (unless args |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
125 (error "Keyword %s is missing an argument" keyword)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
126 (setq args (cdr args)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
127 (cond ((eq keyword :initialize) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
128 (setq initialize value)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
129 ((eq keyword :set) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
130 (put symbol 'custom-set value)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
131 ((eq keyword :get) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
132 (put symbol 'custom-get value)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
133 ((eq keyword :require) |
17576
1cc3913deaf8
(custom-declare-variable): Don't use `push'.
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
134 (setq requests (cons value requests))) |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
135 ((eq keyword :type) |
26928
755f54893c1f
(custom-declare-variable): Purecopy value.
Dave Love <fx@gnu.org>
parents:
26831
diff
changeset
|
136 (put symbol 'custom-type (purecopy value))) |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
137 ((eq keyword :options) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
138 (if (get symbol 'custom-options) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
139 ;; Slow safe code to avoid duplicates. |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
140 (mapcar (lambda (option) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
141 (custom-add-option symbol option)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
142 value) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
143 ;; Fast code for the common case. |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
144 (put symbol 'custom-options (copy-sequence value)))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
145 (t |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
146 (custom-handle-keyword symbol keyword value |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
147 'custom-variable)))))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
148 (put symbol 'custom-requests requests) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
149 ;; Do the actual initialization. |
19516
6591f294b265
(custom-declare-variable): Rename 2nd arg to DEFAULT.
Richard M. Stallman <rms@gnu.org>
parents:
18882
diff
changeset
|
150 (funcall initialize symbol default)) |
22499
a478a91f3fbb
(custom-declare-variable): Update current-load-list.
Richard M. Stallman <rms@gnu.org>
parents:
22141
diff
changeset
|
151 (setq current-load-list (cons symbol current-load-list)) |
17334 | 152 (run-hooks 'custom-define-hook) |
153 symbol) | |
154 | |
155 (defmacro defcustom (symbol value doc &rest args) | |
156 "Declare SYMBOL as a customizable variable that defaults to VALUE. | |
157 DOC is the variable documentation. | |
158 | |
159 Neither SYMBOL nor VALUE needs to be quoted. | |
160 If SYMBOL is not already bound, initialize it to VALUE. | |
161 The remaining arguments should have the form | |
162 | |
25683 | 163 [KEYWORD VALUE]... |
17334 | 164 |
22141 | 165 The following keywords are meaningful: |
17334 | 166 |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
167 :type VALUE should be a widget type for editing the symbols value. |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
168 The default is `sexp'. |
17334 | 169 :options VALUE should be a list of valid members of the widget type. |
25683 | 170 :group VALUE should be a customization group. |
17334 | 171 Add SYMBOL to that group. |
22141 | 172 :initialize |
173 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
|
174 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
|
175 given in the `defcustom' call. The default is |
25683 | 176 `custom-initialize-default' |
177 :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
|
178 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
|
179 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
|
180 :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
|
181 The function takes one argument, a symbol, and should return |
22141 | 182 the current value for that symbol. The default choice of function |
25683 | 183 is `custom-default-value'. |
22141 | 184 :require |
185 VALUE should be a feature symbol. If you save a value | |
186 for this option, then when your `.emacs' file loads the value, | |
187 it does (require VALUE) first. | |
17334 | 188 |
17442 | 189 Read the section about customization in the Emacs Lisp manual for more |
17334 | 190 information." |
21703
aea35bf72489
(defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents:
20599
diff
changeset
|
191 ;; 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
|
192 ;; because that makes a bootstrapping problem |
aea35bf72489
(defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents:
20599
diff
changeset
|
193 ;; 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
|
194 (nconc (list 'custom-declare-variable |
aea35bf72489
(defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents:
20599
diff
changeset
|
195 (list 'quote symbol) |
aea35bf72489
(defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents:
20599
diff
changeset
|
196 (list 'quote value) |
aea35bf72489
(defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents:
20599
diff
changeset
|
197 doc) |
aea35bf72489
(defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents:
20599
diff
changeset
|
198 args)) |
17334 | 199 |
200 ;;; The `defface' Macro. | |
201 | |
202 (defmacro defface (face spec doc &rest args) | |
203 "Declare FACE as a customizable face that defaults to SPEC. | |
204 FACE does not need to be quoted. | |
205 | |
206 Third argument DOC is the face documentation. | |
207 | |
208 If FACE has been set with `custom-set-face', set the face attributes | |
209 as specified by that function, otherwise set the face attributes | |
210 according to SPEC. | |
211 | |
212 The remaining arguments should have the form | |
213 | |
214 [KEYWORD VALUE]... | |
215 | |
17949 | 216 The following KEYWORDs are defined: |
17334 | 217 |
218 :group VALUE should be a customization group. | |
219 Add FACE to that group. | |
220 | |
221 SPEC should be an alist of the form ((DISPLAY ATTS)...). | |
222 | |
17949 | 223 The first element of SPEC where the DISPLAY matches the frame |
224 is the one that takes effect in that frame. The ATTRs in this | |
225 element take effect; the other elements are ignored, on that frame. | |
17334 | 226 |
17949 | 227 ATTS is a list of face attributes followed by their values: |
228 (ATTR VALUE ATTR VALUE...) | |
24986
cf6d86af7374
(defface): Extend documentation to include new
Gerd Moellmann <gerd@gnu.org>
parents:
24872
diff
changeset
|
229 |
cf6d86af7374
(defface): Extend documentation to include new
Gerd Moellmann <gerd@gnu.org>
parents:
24872
diff
changeset
|
230 The possible attributes are `:family', `:width', `:height', `:weight', |
cf6d86af7374
(defface): Extend documentation to include new
Gerd Moellmann <gerd@gnu.org>
parents:
24872
diff
changeset
|
231 `:slant', `:underline', `:overline', `:strike-through', `:box', |
cf6d86af7374
(defface): Extend documentation to include new
Gerd Moellmann <gerd@gnu.org>
parents:
24872
diff
changeset
|
232 `:foreground', `:background', `:stipple', and `:inverse-video'. |
17334 | 233 |
17949 | 234 DISPLAY can either be the symbol t, which will match all frames, or an |
235 alist of the form \((REQ ITEM...)...). For the DISPLAY to match a | |
236 FRAME, the REQ property of the frame must match one of the ITEM. The | |
237 following REQ are defined: | |
17334 | 238 |
239 `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
|
240 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
|
241 `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
|
242 the Motif toolkit, Lucid toolkit, or any X toolkit is in use. |
17334 | 243 |
244 `class' (the frame's color support) | |
245 Should be one of `color', `grayscale', or `mono'. | |
246 | |
247 `background' (what color is used for the background text) | |
248 Should be one of `light' or `dark'. | |
249 | |
17442 | 250 Read the section about customization in the Emacs Lisp manual for more |
17334 | 251 information." |
21703
aea35bf72489
(defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents:
20599
diff
changeset
|
252 ;; 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
|
253 ;; because that makes a bootstrapping problem |
aea35bf72489
(defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents:
20599
diff
changeset
|
254 ;; 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
|
255 (nconc (list 'custom-declare-face (list 'quote face) spec doc) args)) |
17334 | 256 |
257 ;;; The `defgroup' Macro. | |
258 | |
259 (defun custom-declare-group (symbol members doc &rest args) | |
260 "Like `defgroup', but SYMBOL is evaluated as a normal argument." | |
25683 | 261 (while members |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
262 (apply 'custom-add-to-group symbol (car members)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
263 (setq members (cdr members))) |
17334 | 264 (put symbol 'custom-group (nconc members (get symbol 'custom-group))) |
265 (when doc | |
26582
fbd1f4d3000d
(custom-declare-group): Purecopy DOC.
Dave Love <fx@gnu.org>
parents:
25888
diff
changeset
|
266 ;; This text doesn't get into DOC. |
fbd1f4d3000d
(custom-declare-group): Purecopy DOC.
Dave Love <fx@gnu.org>
parents:
25888
diff
changeset
|
267 (put symbol 'group-documentation (purecopy doc))) |
25683 | 268 (while args |
17334 | 269 (let ((arg (car args))) |
270 (setq args (cdr args)) | |
271 (unless (symbolp arg) | |
272 (error "Junk in args %S" args)) | |
273 (let ((keyword arg) | |
274 (value (car args))) | |
275 (unless args | |
276 (error "Keyword %s is missing an argument" keyword)) | |
277 (setq args (cdr args)) | |
278 (cond ((eq keyword :prefix) | |
279 (put symbol 'custom-prefix value)) | |
280 (t | |
281 (custom-handle-keyword symbol keyword value | |
282 'custom-group)))))) | |
283 (run-hooks 'custom-define-hook) | |
284 symbol) | |
285 | |
286 (defmacro defgroup (symbol members doc &rest args) | |
287 "Declare SYMBOL as a customization group containing MEMBERS. | |
288 SYMBOL does not need to be quoted. | |
289 | |
290 Third arg DOC is the group documentation. | |
291 | |
292 MEMBERS should be an alist of the form ((NAME WIDGET)...) where | |
20599 | 293 NAME is a symbol and WIDGET is a widget for editing that symbol. |
294 Useful widgets are `custom-variable' for editing variables, | |
17334 | 295 `custom-face' for edit faces, and `custom-group' for editing groups. |
296 | |
297 The remaining arguments should have the form | |
298 | |
25683 | 299 [KEYWORD VALUE]... |
17334 | 300 |
301 The following KEYWORD's are defined: | |
302 | |
303 :group VALUE should be a customization group. | |
304 Add SYMBOL to that group. | |
305 | |
17442 | 306 Read the section about customization in the Emacs Lisp manual for more |
17334 | 307 information." |
21703
aea35bf72489
(defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents:
20599
diff
changeset
|
308 ;; 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
|
309 ;; because that makes a bootstrapping problem |
aea35bf72489
(defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents:
20599
diff
changeset
|
310 ;; 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
|
311 (nconc (list 'custom-declare-group (list 'quote symbol) members doc) args)) |
17334 | 312 |
313 (defun custom-add-to-group (group option widget) | |
314 "To existing GROUP add a new OPTION of type WIDGET. | |
315 If there already is an entry for that option, overwrite it." | |
316 (let* ((members (get group 'custom-group)) | |
317 (old (assq option members))) | |
318 (if old | |
319 (setcar (cdr old) widget) | |
320 (put group 'custom-group (nconc members (list (list option widget))))))) | |
321 | |
322 ;;; Properties. | |
323 | |
324 (defun custom-handle-all-keywords (symbol args type) | |
325 "For customization option SYMBOL, handle keyword arguments ARGS. | |
326 Third argument TYPE is the custom option type." | |
25683 | 327 (while args |
17334 | 328 (let ((arg (car args))) |
329 (setq args (cdr args)) | |
330 (unless (symbolp arg) | |
331 (error "Junk in args %S" args)) | |
332 (let ((keyword arg) | |
333 (value (car args))) | |
334 (unless args | |
335 (error "Keyword %s is missing an argument" keyword)) | |
336 (setq args (cdr args)) | |
25683 | 337 (custom-handle-keyword symbol keyword value type))))) |
17334 | 338 |
339 (defun custom-handle-keyword (symbol keyword value type) | |
340 "For customization option SYMBOL, handle KEYWORD with VALUE. | |
341 Fourth argument TYPE is the custom option type." | |
26582
fbd1f4d3000d
(custom-declare-group): Purecopy DOC.
Dave Love <fx@gnu.org>
parents:
25888
diff
changeset
|
342 (if purify-flag |
fbd1f4d3000d
(custom-declare-group): Purecopy DOC.
Dave Love <fx@gnu.org>
parents:
25888
diff
changeset
|
343 (setq value (purecopy value))) |
17334 | 344 (cond ((eq keyword :group) |
345 (custom-add-to-group value symbol type)) | |
20445
20ff88ac8cc2
(custom-add-version): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19535
diff
changeset
|
346 ((eq keyword :version) |
20ff88ac8cc2
(custom-add-version): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19535
diff
changeset
|
347 (custom-add-version symbol value)) |
17334 | 348 ((eq keyword :link) |
349 (custom-add-link symbol value)) | |
350 ((eq keyword :load) | |
351 (custom-add-load symbol value)) | |
352 ((eq keyword :tag) | |
353 (put symbol 'custom-tag value)) | |
26831
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
354 ((eq keyword :set-after) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
355 (custom-add-dependencies symbol value)) |
17334 | 356 (t |
24872
9db8a7ed814e
(custom-handle-keyword): Fix error message.
Karl Heuer <kwzh@gnu.org>
parents:
24438
diff
changeset
|
357 (error "Unknown keyword %s" keyword)))) |
17334 | 358 |
26831
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
359 (defun custom-add-dependencies (symbol value) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
360 "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
|
361 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
|
362 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
|
363 both appear in constructs like `custom-set-variables'." |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
364 (unless (listp value) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
365 (error "Invalid custom dependency `%s'" value)) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
366 (let* ((deps (get symbol 'custom-dependencies)) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
367 (new-deps deps)) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
368 (while value |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
369 (let ((dep (car value))) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
370 (unless (symbolp dep) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
371 (error "Invalid custom dependency `%s'" dep)) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
372 (unless (memq dep new-deps) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
373 (setq new-deps (cons dep new-deps))) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
374 (setq value (cdr value)))) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
375 (unless (eq deps new-deps) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
376 (put symbol 'custom-dependencies new-deps)))) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
377 |
17334 | 378 (defun custom-add-option (symbol option) |
379 "To the variable SYMBOL add OPTION. | |
380 | |
381 If SYMBOL is a hook variable, OPTION should be a hook member. | |
382 For other types variables, the effect is undefined." | |
383 (let ((options (get symbol 'custom-options))) | |
384 (unless (member option options) | |
385 (put symbol 'custom-options (cons option options))))) | |
386 | |
387 (defun custom-add-link (symbol widget) | |
388 "To the custom option SYMBOL add the link WIDGET." | |
389 (let ((links (get symbol 'custom-links))) | |
390 (unless (member widget links) | |
26582
fbd1f4d3000d
(custom-declare-group): Purecopy DOC.
Dave Love <fx@gnu.org>
parents:
25888
diff
changeset
|
391 (put symbol 'custom-links (cons (purecopy widget) links))))) |
17334 | 392 |
20445
20ff88ac8cc2
(custom-add-version): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19535
diff
changeset
|
393 (defun custom-add-version (symbol version) |
20ff88ac8cc2
(custom-add-version): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19535
diff
changeset
|
394 "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
|
395 (put symbol 'custom-version (purecopy version))) |
20445
20ff88ac8cc2
(custom-add-version): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19535
diff
changeset
|
396 |
17334 | 397 (defun custom-add-load (symbol load) |
398 "To the custom option SYMBOL add the dependency LOAD. | |
399 LOAD should be either a library file name, or a feature name." | |
400 (let ((loads (get symbol 'custom-loads))) | |
401 (unless (member load loads) | |
26582
fbd1f4d3000d
(custom-declare-group): Purecopy DOC.
Dave Love <fx@gnu.org>
parents:
25888
diff
changeset
|
402 (put symbol 'custom-loads (cons (purecopy load) loads))))) |
17334 | 403 |
404 ;;; Initializing. | |
405 | |
22606
36171df7d571
(custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22499
diff
changeset
|
406 (defvar custom-local-buffer nil |
36171df7d571
(custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22499
diff
changeset
|
407 "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
|
408 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
|
409 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
|
410 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
|
411 in every Customization buffer.") |
36171df7d571
(custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22499
diff
changeset
|
412 (put 'custom-local-buffer 'permanent-local t) |
36171df7d571
(custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22499
diff
changeset
|
413 |
17334 | 414 (defun custom-set-variables (&rest args) |
25683 | 415 "Initialize variables according to user preferences. |
17334 | 416 |
417 The arguments should be a list where each entry has the form: | |
418 | |
25683 | 419 (SYMBOL VALUE [NOW [REQUEST [COMMENT]]]) |
17334 | 420 |
421 The unevaluated VALUE is stored as the saved value for SYMBOL. | |
422 If NOW is present and non-nil, VALUE is also evaluated and bound as | |
25683 | 423 the default value for the SYMBOL. |
424 REQUEST is a list of features we must require for SYMBOL. | |
425 COMMENT is a comment string about SYMBOL." | |
26831
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
426 (setq args |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
427 (sort args |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
428 (lambda (a1 a2) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
429 (let* ((sym1 (car a1)) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
430 (sym2 (car a2)) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
431 (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
|
432 (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
|
433 (cond ((and 1-then-2 2-then-1) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
434 (error "Circular custom dependency between `%s' and `%s'" |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
435 sym1 sym2)) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
436 (2-then-1 nil) |
ddaafb816c3e
(custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents:
26582
diff
changeset
|
437 (t t)))))) |
25683 | 438 (while args |
17334 | 439 (let ((entry (car args))) |
440 (if (listp entry) | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
441 (let* ((symbol (nth 0 entry)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
442 (value (nth 1 entry)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
443 (now (nth 2 entry)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17529
diff
changeset
|
444 (requests (nth 3 entry)) |
25683 | 445 (comment (nth 4 entry)) |
23354
4a3a39dff0ed
(custom-set-variables): Load the requests first,
Karl Heuer <kwzh@gnu.org>
parents:
22606
diff
changeset
|
446 set) |
4a3a39dff0ed
(custom-set-variables): Load the requests first,
Karl Heuer <kwzh@gnu.org>
parents:
22606
diff
changeset
|
447 (when requests |
4a3a39dff0ed
(custom-set-variables): Load the requests first,
Karl Heuer <kwzh@gnu.org>
parents:
22606
diff
changeset
|
448 (put symbol 'custom-requests requests) |
4a3a39dff0ed
(custom-set-variables): Load the requests first,
Karl Heuer <kwzh@gnu.org>
parents:
22606
diff
changeset
|
449 (mapcar 'require requests)) |
4a3a39dff0ed
(custom-set-variables): Load the requests first,
Karl Heuer <kwzh@gnu.org>
parents:
22606
diff
changeset
|
450 (setq set (or (get symbol 'custom-set) 'custom-set-default)) |
17334 | 451 (put symbol 'saved-value (list value)) |
25683 | 452 (put symbol 'saved-variable-comment comment) |
24438
4a78f6354310
(custom-set-variables): Protect against setter errors.
Dave Love <fx@gnu.org>
parents:
23354
diff
changeset
|
453 ;; Allow for errors in the case where the setter has |
4a78f6354310
(custom-set-variables): Protect against setter errors.
Dave Love <fx@gnu.org>
parents:
23354
diff
changeset
|
454 ;; changed between versions, say. |
4a78f6354310
(custom-set-variables): Protect against setter errors.
Dave Love <fx@gnu.org>
parents:
23354
diff
changeset
|
455 (condition-case nil |
4a78f6354310
(custom-set-variables): Protect against setter errors.
Dave Love <fx@gnu.org>
parents:
23354
diff
changeset
|
456 (cond (now |
4a78f6354310
(custom-set-variables): Protect against setter errors.
Dave Love <fx@gnu.org>
parents:
23354
diff
changeset
|
457 ;; Rogue variable, set it now. |
4a78f6354310
(custom-set-variables): Protect against setter errors.
Dave Love <fx@gnu.org>
parents:
23354
diff
changeset
|
458 (put symbol 'force-value t) |
4a78f6354310
(custom-set-variables): Protect against setter errors.
Dave Love <fx@gnu.org>
parents:
23354
diff
changeset
|
459 (funcall set symbol (eval value))) |
4a78f6354310
(custom-set-variables): Protect against setter errors.
Dave Love <fx@gnu.org>
parents:
23354
diff
changeset
|
460 ((default-boundp symbol) |
4a78f6354310
(custom-set-variables): Protect against setter errors.
Dave Love <fx@gnu.org>
parents:
23354
diff
changeset
|
461 ;; Something already set this, overwrite it. |
4a78f6354310
(custom-set-variables): Protect against setter errors.
Dave Love <fx@gnu.org>
parents:
23354
diff
changeset
|
462 (funcall set symbol (eval value)))) |
4a78f6354310
(custom-set-variables): Protect against setter errors.
Dave Love <fx@gnu.org>
parents:
23354
diff
changeset
|
463 (error nil)) |
25683 | 464 (setq args (cdr args)) |
465 (and (or now (default-boundp symbol)) | |
466 (put symbol 'variable-comment comment))) | |
17334 | 467 ;; Old format, a plist of SYMBOL VALUE pairs. |
17415 | 468 (message "Warning: old format `custom-set-variables'") |
469 (ding) | |
470 (sit-for 2) | |
17334 | 471 (let ((symbol (nth 0 args)) |
472 (value (nth 1 args))) | |
473 (put symbol 'saved-value (list value))) | |
474 (setq args (cdr (cdr args))))))) | |
475 | |
22606
36171df7d571
(custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22499
diff
changeset
|
476 (defun custom-set-default (variable value) |
36171df7d571
(custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22499
diff
changeset
|
477 "Default :set function for a customizable variable. |
36171df7d571
(custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22499
diff
changeset
|
478 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
|
479 but if `custom-local-buffer' is non-nil, |
36171df7d571
(custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22499
diff
changeset
|
480 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
|
481 (if custom-local-buffer |
36171df7d571
(custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22499
diff
changeset
|
482 (with-current-buffer custom-local-buffer |
36171df7d571
(custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22499
diff
changeset
|
483 (set variable value)) |
36171df7d571
(custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22499
diff
changeset
|
484 (set-default variable value))) |
36171df7d571
(custom-set-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22499
diff
changeset
|
485 |
17334 | 486 ;;; The End. |
487 | |
18882
539611251037
(custom-declare-variable-list): Process already-declared
Richard M. Stallman <rms@gnu.org>
parents:
18033
diff
changeset
|
488 ;; 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
|
489 (while custom-declare-variable-list |
539611251037
(custom-declare-variable-list): Process already-declared
Richard M. Stallman <rms@gnu.org>
parents:
18033
diff
changeset
|
490 (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
|
491 (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
|
492 |
17334 | 493 (provide 'custom) |
494 | |
25683 | 495 ;;; custom.el ends here |