annotate lisp/custom.el @ 22254:1deb7d79af00

(detect_coding_system): Treat CODING_EOL_INCONSISTENT like CODING_EOL_UNDECIDED.
author Richard M. Stallman <rms@gnu.org>
date Tue, 26 May 1998 20:46:31 +0000
parents 8ddb49eb4814
children a478a91f3fbb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
1 ;;; custom.el -- Tools for declaring and initializing options.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
2 ;;
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
3 ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc.
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>
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
6 ;; Keywords: help, faces
18033
bccd356a3b7c Synched with version 1.9900.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17949
diff changeset
7 ;; Version: 1.9900
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
8 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
9
17520
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
10 ;; This file is part of GNU Emacs.
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
11
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
12 ;; 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
13 ;; 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
14 ;; the Free Software Foundation; either version 2, or (at your option)
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
15 ;; any later version.
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
16
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
17 ;; 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
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
20 ;; GNU General Public License for more details.
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
21
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
22 ;; 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
23 ;; 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
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
25 ;; Boston, MA 02111-1307, USA.
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
26
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
27 ;;; Commentary:
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
28 ;;
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
29 ;; If you want to use this code, please visit the URL above.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
30 ;;
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
31 ;; This file only contain the code needed to declare and initialize
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
32 ;; user options. The code to customize options is autoloaded from
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
33 ;; `cus-edit.el'.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
34
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
35 ;; The code implementing face declarations is in `cus-face.el'
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
36
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
37 ;;; Code:
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
38
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
39 (require 'widget)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
40
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
41 (define-widget-keywords :initialize :set :get :require :prefix :tag
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
42 :load :link :options :type :group)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
43
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
44
17415
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
45 (defvar custom-define-hook nil
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
46 ;; 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
47 "Hook called after defining each customize option.")
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
48
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
49 ;;; The `defcustom' Macro.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
50
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
51 (defun custom-initialize-default (symbol value)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
52 "Initialize SYMBOL with VALUE.
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
53 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
54 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
55 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
56 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
57 symbol."
17415
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
58 (unless (default-boundp symbol)
18033
bccd356a3b7c Synched with version 1.9900.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17949
diff changeset
59 ;; Use the saved value if it exists, otherwise the standard setting.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
60 (set-default symbol (if (get symbol 'saved-value)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
61 (eval (car (get symbol 'saved-value)))
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
62 (eval value)))))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
63
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
64 (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
65 "Initialize SYMBOL based on VALUE.
e9d8fcec9843 (custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents: 19516
diff changeset
66 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
67 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
68 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
69 if any, or VALUE."
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
70 (unless (default-boundp symbol)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
71 (funcall (or (get symbol 'custom-set) 'set-default)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
72 symbol
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
73 (if (get symbol 'saved-value)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
74 (eval (car (get symbol 'saved-value)))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
75 (eval value)))))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
76
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
77 (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
78 "Initialize SYMBOL based on VALUE.
e9d8fcec9843 (custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents: 19516
diff changeset
79 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
80 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
81 \(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
82 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
83 or (last of all) VALUE."
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
84 (funcall (or (get symbol 'custom-set) 'set-default)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
85 symbol
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
86 (cond ((default-boundp symbol)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
87 (funcall (or (get symbol 'custom-get) 'default-value)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
88 symbol))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
89 ((get symbol 'saved-value)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
90 (eval (car (get symbol 'saved-value))))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
91 (t
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
92 (eval value)))))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
93
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
94 (defun custom-initialize-changed (symbol value)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
95 "Initialize SYMBOL with VALUE.
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
96 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
97 not using the standard setting.
e9d8fcec9843 (custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents: 19516
diff changeset
98 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
99 (cond ((default-boundp symbol)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
100 (funcall (or (get symbol 'custom-set) 'set-default)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
101 symbol
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
102 (funcall (or (get symbol 'custom-get) 'default-value)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
103 symbol)))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
104 ((get symbol 'saved-value)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
105 (funcall (or (get symbol 'custom-set) 'set-default)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
106 symbol
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
107 (eval (car (get symbol 'saved-value)))))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
108 (t
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
109 (set-default symbol (eval value)))))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
110
19516
6591f294b265 (custom-declare-variable): Rename 2nd arg to DEFAULT.
Richard M. Stallman <rms@gnu.org>
parents: 18882
diff changeset
111 (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
112 "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
113 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
114 not the default value itself."
18033
bccd356a3b7c Synched with version 1.9900.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17949
diff changeset
115 ;; Remember the standard setting.
19516
6591f294b265 (custom-declare-variable): Rename 2nd arg to DEFAULT.
Richard M. Stallman <rms@gnu.org>
parents: 18882
diff changeset
116 (put symbol 'standard-value (list default))
17415
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
117 ;; 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
118 (when (get symbol 'force-value)
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
119 ;; It no longer is.
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))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
125 (while args
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
126 (let ((arg (car args)))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
127 (setq args (cdr args))
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
128 (unless (symbolp arg)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
129 (error "Junk in args %S" args))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
130 (let ((keyword arg)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
131 (value (car args)))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
132 (unless args
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
133 (error "Keyword %s is missing an argument" keyword))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
134 (setq args (cdr args))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
135 (cond ((eq keyword :initialize)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
136 (setq initialize value))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
137 ((eq keyword :set)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
138 (put symbol 'custom-set value))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
139 ((eq keyword :get)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
140 (put symbol 'custom-get value))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
141 ((eq keyword :require)
17576
1cc3913deaf8 (custom-declare-variable): Don't use `push'.
Richard M. Stallman <rms@gnu.org>
parents: 17550
diff changeset
142 (setq requests (cons value requests)))
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
143 ((eq keyword :type)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
144 (put symbol 'custom-type value))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
145 ((eq keyword :options)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
146 (if (get symbol 'custom-options)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
147 ;; Slow safe code to avoid duplicates.
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
148 (mapcar (lambda (option)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
149 (custom-add-option symbol option))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
150 value)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
151 ;; Fast code for the common case.
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
152 (put symbol 'custom-options (copy-sequence value))))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
153 (t
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
154 (custom-handle-keyword symbol keyword value
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
155 'custom-variable))))))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
156 (put symbol 'custom-requests requests)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
157 ;; Do the actual initialization.
19516
6591f294b265 (custom-declare-variable): Rename 2nd arg to DEFAULT.
Richard M. Stallman <rms@gnu.org>
parents: 18882
diff changeset
158 (funcall initialize symbol default))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
159 (run-hooks 'custom-define-hook)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
160 symbol)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
161
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
162 (defmacro defcustom (symbol value doc &rest args)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
163 "Declare SYMBOL as a customizable variable that defaults to VALUE.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
164 DOC is the variable documentation.
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 Neither SYMBOL nor VALUE needs to be quoted.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
167 If SYMBOL is not already bound, initialize it to VALUE.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
168 The remaining arguments should have the form
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 [KEYWORD VALUE]...
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
171
22141
8ddb49eb4814 (defcustom): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 21703
diff changeset
172 The following keywords are meaningful:
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
173
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
174 :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
175 The default is `sexp'.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
176 :options VALUE should be a list of valid members of the widget type.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
177 :group VALUE should be a customization group.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
178 Add SYMBOL to that group.
22141
8ddb49eb4814 (defcustom): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 21703
diff changeset
179 :initialize
8ddb49eb4814 (defcustom): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 21703
diff changeset
180 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
181 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
182 given in the `defcustom' call. The default is
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
183 `custom-initialize-default'
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
184 :set VALUE should be a function to set the value of the symbol.
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
185 It takes two arguments, the symbol to set and the value to
22141
8ddb49eb4814 (defcustom): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 21703
diff changeset
186 give it. The default choice of function is `set-default'.
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
187 :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
188 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
189 the current value for that symbol. The default choice of function
8ddb49eb4814 (defcustom): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 21703
diff changeset
190 is `default-value'.
8ddb49eb4814 (defcustom): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 21703
diff changeset
191 :require
8ddb49eb4814 (defcustom): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 21703
diff changeset
192 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
193 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
194 it does (require VALUE) first.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
195
17442
eb87aef64274 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17415
diff changeset
196 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
197 information."
21703
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
198 ;; 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
199 ;; because that makes a bootstrapping problem
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
200 ;; 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
201 (nconc (list 'custom-declare-variable
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
202 (list 'quote symbol)
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
203 (list 'quote value)
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
204 doc)
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
205 args))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
206
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
207 ;;; The `defface' Macro.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
208
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
209 (defmacro defface (face spec doc &rest args)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
210 "Declare FACE as a customizable face that defaults to SPEC.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
211 FACE does not need to be quoted.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
212
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
213 Third argument DOC is the face documentation.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
214
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
215 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
216 as specified by that function, otherwise set the face attributes
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
217 according to SPEC.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
218
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
219 The remaining arguments should have the form
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
220
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
221 [KEYWORD VALUE]...
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
222
17949
3b0f71e1661d (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 17921
diff changeset
223 The following KEYWORDs are defined:
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
224
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
225 :group VALUE should be a customization group.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
226 Add FACE to that group.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
227
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
228 SPEC should be an alist of the form ((DISPLAY ATTS)...).
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
229
17949
3b0f71e1661d (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 17921
diff changeset
230 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
231 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
232 element take effect; the other elements are ignored, on that frame.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
233
17949
3b0f71e1661d (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 17921
diff changeset
234 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
235 (ATTR VALUE ATTR VALUE...)
3b0f71e1661d (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 17921
diff changeset
236 The possible attributes are `:bold', `:italic', `:underline',
3b0f71e1661d (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 17921
diff changeset
237 `:foreground', `:background', `:stipple' and `:inverse-video'.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
238
17949
3b0f71e1661d (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 17921
diff changeset
239 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
240 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
241 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
242 following REQ are defined:
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
243
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
244 `type' (the value of `window-system')
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
245 Should be one of `x' or `tty'.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
246
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
247 `class' (the frame's color support)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
248 Should be one of `color', `grayscale', or `mono'.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
249
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
250 `background' (what color is used for the background text)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
251 Should be one of `light' or `dark'.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
252
17442
eb87aef64274 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17415
diff changeset
253 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
254 information."
21703
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
255 ;; 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
256 ;; because that makes a bootstrapping problem
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
257 ;; 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
258 (nconc (list 'custom-declare-face (list 'quote face) spec doc) args))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
259
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
260 ;;; The `defgroup' Macro.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
261
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
262 (defun custom-declare-group (symbol members doc &rest args)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
263 "Like `defgroup', but SYMBOL is evaluated as a normal argument."
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
264 (while members
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
265 (apply 'custom-add-to-group symbol (car members))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
266 (setq members (cdr members)))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
267 (put symbol 'custom-group (nconc members (get symbol 'custom-group)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
268 (when doc
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
269 (put symbol 'group-documentation doc))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
270 (while args
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
271 (let ((arg (car args)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
272 (setq args (cdr args))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
273 (unless (symbolp arg)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
274 (error "Junk in args %S" args))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
275 (let ((keyword arg)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
276 (value (car args)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
277 (unless args
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
278 (error "Keyword %s is missing an argument" keyword))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
279 (setq args (cdr args))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
280 (cond ((eq keyword :prefix)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
281 (put symbol 'custom-prefix value))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
282 (t
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
283 (custom-handle-keyword symbol keyword value
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
284 'custom-group))))))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
285 (run-hooks 'custom-define-hook)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
286 symbol)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
287
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
288 (defmacro defgroup (symbol members doc &rest args)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
289 "Declare SYMBOL as a customization group containing MEMBERS.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
290 SYMBOL does not need to be quoted.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
291
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
292 Third arg DOC is the group documentation.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
293
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
294 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
295 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
296 Useful widgets are `custom-variable' for editing variables,
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
297 `custom-face' for edit faces, and `custom-group' for editing groups.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
298
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
299 The remaining arguments should have the form
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
300
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
301 [KEYWORD VALUE]...
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
302
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
303 The following KEYWORD's are defined:
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
304
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
305 :group VALUE should be a customization group.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
306 Add SYMBOL to that group.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
307
17442
eb87aef64274 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17415
diff changeset
308 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
309 information."
21703
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
310 ;; 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
311 ;; because that makes a bootstrapping problem
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
312 ;; 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
313 (nconc (list 'custom-declare-group (list 'quote symbol) members doc) args))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
314
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
315 (defun custom-add-to-group (group option widget)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
316 "To existing GROUP add a new OPTION of type WIDGET.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
317 If there already is an entry for that option, overwrite it."
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
318 (let* ((members (get group 'custom-group))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
319 (old (assq option members)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
320 (if old
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
321 (setcar (cdr old) widget)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
322 (put group 'custom-group (nconc members (list (list option widget)))))))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
323
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
324 ;;; Properties.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
325
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
326 (defun custom-handle-all-keywords (symbol args type)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
327 "For customization option SYMBOL, handle keyword arguments ARGS.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
328 Third argument TYPE is the custom option type."
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
329 (while args
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
330 (let ((arg (car args)))
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 (unless (symbolp arg)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
333 (error "Junk in args %S" args))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
334 (let ((keyword arg)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
335 (value (car args)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
336 (unless args
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
337 (error "Keyword %s is missing an argument" keyword))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
338 (setq args (cdr args))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
339 (custom-handle-keyword symbol keyword value type)))))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
340
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
341 (defun custom-handle-keyword (symbol keyword value type)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
342 "For customization option SYMBOL, handle KEYWORD with VALUE.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
343 Fourth argument TYPE is the custom option type."
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
344 (cond ((eq keyword :group)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
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
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
348 ((eq keyword :link)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
349 (custom-add-link symbol value))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
350 ((eq keyword :load)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
351 (custom-add-load symbol value))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
352 ((eq keyword :tag)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
353 (put symbol 'custom-tag value))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
354 (t
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
355 (error "Unknown keyword %s" symbol))))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
356
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
357 (defun custom-add-option (symbol option)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
358 "To the variable SYMBOL add OPTION.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
359
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
360 If SYMBOL is a hook variable, OPTION should be a hook member.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
361 For other types variables, the effect is undefined."
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
362 (let ((options (get symbol 'custom-options)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
363 (unless (member option options)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
364 (put symbol 'custom-options (cons option options)))))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
365
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
366 (defun custom-add-link (symbol widget)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
367 "To the custom option SYMBOL add the link WIDGET."
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
368 (let ((links (get symbol 'custom-links)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
369 (unless (member widget links)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
370 (put symbol 'custom-links (cons widget links)))))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
371
20445
20ff88ac8cc2 (custom-add-version): New function.
Karl Heuer <kwzh@gnu.org>
parents: 19535
diff changeset
372 (defun custom-add-version (symbol version)
20ff88ac8cc2 (custom-add-version): New function.
Karl Heuer <kwzh@gnu.org>
parents: 19535
diff changeset
373 "To the custom option SYMBOL add the version VERSION."
20ff88ac8cc2 (custom-add-version): New function.
Karl Heuer <kwzh@gnu.org>
parents: 19535
diff changeset
374 (put symbol 'custom-version version))
20ff88ac8cc2 (custom-add-version): New function.
Karl Heuer <kwzh@gnu.org>
parents: 19535
diff changeset
375
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
376 (defun custom-add-load (symbol load)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
377 "To the custom option SYMBOL add the dependency LOAD.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
378 LOAD should be either a library file name, or a feature name."
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
379 (let ((loads (get symbol 'custom-loads)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
380 (unless (member load loads)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
381 (put symbol 'custom-loads (cons load loads)))))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
382
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
383 ;;; Initializing.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
384
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
385 (defun custom-set-variables (&rest args)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
386 "Initialize variables according to user preferences.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
387
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
388 The arguments should be a list where each entry has the form:
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
389
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
390 (SYMBOL VALUE [NOW])
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
391
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
392 The unevaluated VALUE is stored as the saved value for SYMBOL.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
393 If NOW is present and non-nil, VALUE is also evaluated and bound as
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
394 the default value for the SYMBOL."
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
395 (while args
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
396 (let ((entry (car args)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
397 (if (listp entry)
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
398 (let* ((symbol (nth 0 entry))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
399 (value (nth 1 entry))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
400 (now (nth 2 entry))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
401 (requests (nth 3 entry))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
402 (set (or (get symbol 'custom-set) 'set-default)))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
403 (put symbol 'saved-value (list value))
17415
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
404 (cond (now
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
405 ;; Rogue variable, set it now.
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
406 (put symbol 'force-value t)
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
407 (funcall set symbol (eval value)))
17415
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
408 ((default-boundp symbol)
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
409 ;; Something already set this, overwrite it.
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
410 (funcall set symbol (eval value))))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
411 (when requests
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
412 (put symbol 'custom-requests requests)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
413 (mapcar 'require requests))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
414 (setq args (cdr args)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
415 ;; Old format, a plist of SYMBOL VALUE pairs.
17415
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
416 (message "Warning: old format `custom-set-variables'")
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
417 (ding)
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
418 (sit-for 2)
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
419 (let ((symbol (nth 0 args))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
420 (value (nth 1 args)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
421 (put symbol 'saved-value (list value)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
422 (setq args (cdr (cdr args)))))))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
423
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
424 ;;; The End.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
425
18882
539611251037 (custom-declare-variable-list): Process already-declared
Richard M. Stallman <rms@gnu.org>
parents: 18033
diff changeset
426 ;; 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
427 (while custom-declare-variable-list
539611251037 (custom-declare-variable-list): Process already-declared
Richard M. Stallman <rms@gnu.org>
parents: 18033
diff changeset
428 (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
429 (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
430
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
431 (provide 'custom)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
432
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
433 ;; custom.el ends here