annotate lisp/custom.el @ 18012:d0f4e2e9e1f8

(gulp-send-requests): Sort maintainers alphabetically. (gulp-create-m-p-alist): Don't print message here. Bind fl-tm. (gulp-request-header, gulp-request-end): Update the default text.
author Richard M. Stallman <rms@gnu.org>
date Thu, 29 May 1997 00:17:57 +0000
parents 3b0f71e1661d
children bccd356a3b7c
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
17799
0df9495348e7 Synched with 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17751
diff changeset
7 ;; Version: 1.97
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)
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
59 ;; Use the saved value if it exists, otherwise the factory 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)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
65 "Initialize SYMBOL with VALUE.
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
66 Like `custom-initialize-default', but use the function specified by
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
67 `:set' to initialize SYMBOL."
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
68 (unless (default-boundp symbol)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
69 (funcall (or (get symbol 'custom-set) 'set-default)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
70 symbol
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
71 (if (get symbol 'saved-value)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
72 (eval (car (get symbol 'saved-value)))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
73 (eval value)))))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
74
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
75 (defun custom-initialize-reset (symbol value)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
76 "Initialize SYMBOL with VALUE.
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
77 Like `custom-initialize-set', but use the function specified by
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
78 `:get' to reinitialize SYMBOL if it is already bound."
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
79 (funcall (or (get symbol 'custom-set) 'set-default)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
80 symbol
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
81 (cond ((default-boundp symbol)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
82 (funcall (or (get symbol 'custom-get) 'default-value)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
83 symbol))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
84 ((get symbol 'saved-value)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
85 (eval (car (get symbol 'saved-value))))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
86 (t
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
87 (eval value)))))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
88
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
89 (defun custom-initialize-changed (symbol value)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
90 "Initialize SYMBOL with VALUE.
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
91 Like `custom-initialize-reset', but only use the `:set' function if the
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
92 not using the factory setting. Otherwise, use the `set-default'."
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
93 (cond ((default-boundp symbol)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
94 (funcall (or (get symbol 'custom-set) 'set-default)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
95 symbol
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
96 (funcall (or (get symbol 'custom-get) 'default-value)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
97 symbol)))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
98 ((get symbol 'saved-value)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
99 (funcall (or (get symbol 'custom-set) 'set-default)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
100 symbol
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
101 (eval (car (get symbol 'saved-value)))))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
102 (t
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
103 (set-default symbol (eval value)))))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
104
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
105 (defun custom-declare-variable (symbol value doc &rest args)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
106 "Like `defcustom', but SYMBOL and VALUE are evaluated as normal arguments."
17415
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
107 ;; Remember the factory setting.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
108 (put symbol 'factory-value (list value))
17415
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
109 ;; 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
110 (when (get symbol 'force-value)
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
111 ;; It no longer is.
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
112 (put symbol 'force-value nil))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
113 (when doc
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
114 (put symbol 'variable-documentation doc))
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
115 (let ((initialize 'custom-initialize-set)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
116 (requests nil))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
117 (while args
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
118 (let ((arg (car args)))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
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)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
136 (put symbol 'custom-type value))
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.
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
150 (funcall initialize symbol value))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
151 (run-hooks 'custom-define-hook)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
152 symbol)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
153
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
154 (defmacro defcustom (symbol value doc &rest args)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
155 "Declare SYMBOL as a customizable variable that defaults to VALUE.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
156 DOC is the variable documentation.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
157
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
158 Neither SYMBOL nor VALUE needs to be quoted.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
159 If SYMBOL is not already bound, initialize it to VALUE.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
160 The remaining arguments should have the form
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 [KEYWORD VALUE]...
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
163
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
164 The following KEYWORD's are defined:
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
165
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
166 :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
167 The default is `sexp'.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
168 :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
169 :group VALUE should be a customization group.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
170 Add SYMBOL to that group.
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
171 :initialize VALUE should be a function used to initialize the
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
172 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
173 given in the `defcustom' call. The default is
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
174 `custom-initialize-default'
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
175 :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
176 It takes two arguments, the symbol to set and the value to
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
177 give it. The default is `set-default'.
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
178 :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
179 The function takes one argument, a symbol, and should return
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
180 the current value for that symbol. The default is
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
181 `default-value'.
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
182 :require VALUE should be a feature symbol. Each feature will be
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
183 required after initialization, of the the user have saved this
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
184 option.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
185
17442
eb87aef64274 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17415
diff changeset
186 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
187 information."
17751
01342565404e (defcustom): Get rid of eval-and-compile.
Richard M. Stallman <rms@gnu.org>
parents: 17576
diff changeset
188 `(custom-declare-variable (quote ,symbol) (quote ,value) ,doc ,@args))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
189
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
190 ;;; The `defface' Macro.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
191
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
192 (defmacro defface (face spec doc &rest args)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
193 "Declare FACE as a customizable face that defaults to SPEC.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
194 FACE does not need to be quoted.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
195
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
196 Third argument DOC is the face documentation.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
197
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
198 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
199 as specified by that function, otherwise set the face attributes
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
200 according to SPEC.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
201
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
202 The remaining arguments should have the form
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
203
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
204 [KEYWORD VALUE]...
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
205
17949
3b0f71e1661d (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 17921
diff changeset
206 The following KEYWORDs are defined:
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
207
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
208 :group VALUE should be a customization group.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
209 Add FACE to that group.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
210
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
211 SPEC should be an alist of the form ((DISPLAY ATTS)...).
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
212
17949
3b0f71e1661d (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 17921
diff changeset
213 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
214 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
215 element take effect; the other elements are ignored, on that frame.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
216
17949
3b0f71e1661d (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 17921
diff changeset
217 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
218 (ATTR VALUE ATTR VALUE...)
3b0f71e1661d (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 17921
diff changeset
219 The possible attributes are `:bold', `:italic', `:underline',
3b0f71e1661d (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 17921
diff changeset
220 `:foreground', `:background', `:stipple' and `:inverse-video'.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
221
17949
3b0f71e1661d (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 17921
diff changeset
222 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
223 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
224 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
225 following REQ are defined:
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
226
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
227 `type' (the value of `window-system')
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
228 Should be one of `x' or `tty'.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
229
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
230 `class' (the frame's color support)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
231 Should be one of `color', `grayscale', or `mono'.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
232
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
233 `background' (what color is used for the background text)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
234 Should be one of `light' or `dark'.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
235
17442
eb87aef64274 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17415
diff changeset
236 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
237 information."
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
238 `(custom-declare-face (quote ,face) ,spec ,doc ,@args))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
239
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
240 ;;; The `defgroup' Macro.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
241
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
242 (defun custom-declare-group (symbol members doc &rest args)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
243 "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
244 (while members
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
245 (apply 'custom-add-to-group symbol (car members))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
246 (setq members (cdr members)))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
247 (put symbol 'custom-group (nconc members (get symbol 'custom-group)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
248 (when doc
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
249 (put symbol 'group-documentation doc))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
250 (while args
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
251 (let ((arg (car args)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
252 (setq args (cdr args))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
253 (unless (symbolp arg)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
254 (error "Junk in args %S" args))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
255 (let ((keyword arg)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
256 (value (car args)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
257 (unless args
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
258 (error "Keyword %s is missing an argument" keyword))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
259 (setq args (cdr args))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
260 (cond ((eq keyword :prefix)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
261 (put symbol 'custom-prefix value))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
262 (t
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
263 (custom-handle-keyword symbol keyword value
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
264 'custom-group))))))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
265 (run-hooks 'custom-define-hook)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
266 symbol)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
267
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
268 (defmacro defgroup (symbol members doc &rest args)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
269 "Declare SYMBOL as a customization group containing MEMBERS.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
270 SYMBOL does not need to be quoted.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
271
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
272 Third arg DOC is the group documentation.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
273
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
274 MEMBERS should be an alist of the form ((NAME WIDGET)...) where
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
275 NAME is a symbol and WIDGET is a widget is a widget for editing that
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
276 symbol. Useful widgets are `custom-variable' for editing variables,
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
277 `custom-face' for edit faces, and `custom-group' for editing groups.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
278
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
279 The remaining arguments should have the form
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
280
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
281 [KEYWORD VALUE]...
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
282
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
283 The following KEYWORD's are defined:
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
284
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
285 :group VALUE should be a customization group.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
286 Add SYMBOL to that group.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
287
17442
eb87aef64274 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17415
diff changeset
288 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
289 information."
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
290 `(custom-declare-group (quote ,symbol) ,members ,doc ,@args))
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 (defun custom-add-to-group (group option widget)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
293 "To existing GROUP add a new OPTION of type WIDGET.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
294 If there already is an entry for that option, overwrite it."
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
295 (let* ((members (get group 'custom-group))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
296 (old (assq option members)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
297 (if old
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
298 (setcar (cdr old) widget)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
299 (put group 'custom-group (nconc members (list (list option widget)))))))
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 ;;; Properties.
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 (defun custom-handle-all-keywords (symbol args type)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
304 "For customization option SYMBOL, handle keyword arguments ARGS.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
305 Third argument TYPE is the custom option type."
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
306 (while args
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
307 (let ((arg (car args)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
308 (setq args (cdr args))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
309 (unless (symbolp arg)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
310 (error "Junk in args %S" args))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
311 (let ((keyword arg)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
312 (value (car args)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
313 (unless args
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
314 (error "Keyword %s is missing an argument" keyword))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
315 (setq args (cdr args))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
316 (custom-handle-keyword symbol keyword value type)))))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
317
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
318 (defun custom-handle-keyword (symbol keyword value type)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
319 "For customization option SYMBOL, handle KEYWORD with VALUE.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
320 Fourth argument TYPE is the custom option type."
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
321 (cond ((eq keyword :group)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
322 (custom-add-to-group value symbol type))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
323 ((eq keyword :link)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
324 (custom-add-link symbol value))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
325 ((eq keyword :load)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
326 (custom-add-load symbol value))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
327 ((eq keyword :tag)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
328 (put symbol 'custom-tag value))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
329 (t
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
330 (error "Unknown keyword %s" symbol))))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
331
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
332 (defun custom-add-option (symbol option)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
333 "To the variable SYMBOL add OPTION.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
335 If SYMBOL is a hook variable, OPTION should be a hook member.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
336 For other types variables, the effect is undefined."
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
337 (let ((options (get symbol 'custom-options)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
338 (unless (member option options)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
339 (put symbol 'custom-options (cons option options)))))
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-add-link (symbol widget)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
342 "To the custom option SYMBOL add the link WIDGET."
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
343 (let ((links (get symbol 'custom-links)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
344 (unless (member widget links)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
345 (put symbol 'custom-links (cons widget links)))))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
346
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
347 (defun custom-add-load (symbol load)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
348 "To the custom option SYMBOL add the dependency LOAD.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
349 LOAD should be either a library file name, or a feature name."
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
350 (let ((loads (get symbol 'custom-loads)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
351 (unless (member load loads)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
352 (put symbol 'custom-loads (cons load loads)))))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
353
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
354 ;;; Initializing.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
355
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
356 (defun custom-set-variables (&rest args)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
357 "Initialize variables according to user preferences.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
358
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
359 The arguments should be a list where each entry has the form:
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
360
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
361 (SYMBOL VALUE [NOW])
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
362
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
363 The unevaluated VALUE is stored as the saved value for SYMBOL.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
364 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
365 the default value for the SYMBOL."
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
366 (while args
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
367 (let ((entry (car args)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
368 (if (listp entry)
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
369 (let* ((symbol (nth 0 entry))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
370 (value (nth 1 entry))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
371 (now (nth 2 entry))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
372 (requests (nth 3 entry))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
373 (set (or (get symbol 'custom-set) 'set-default)))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
374 (put symbol 'saved-value (list value))
17415
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
375 (cond (now
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
376 ;; Rogue variable, set it now.
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
377 (put symbol 'force-value t)
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
378 (funcall set symbol (eval value)))
17415
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
379 ((default-boundp symbol)
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
380 ;; Something already set this, overwrite it.
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
381 (funcall set symbol (eval value))))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
382 (when requests
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
383 (put symbol 'custom-requests requests)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
384 (mapcar 'require requests))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
385 (setq args (cdr args)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
386 ;; Old format, a plist of SYMBOL VALUE pairs.
17415
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
387 (message "Warning: old format `custom-set-variables'")
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
388 (ding)
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
389 (sit-for 2)
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
390 (let ((symbol (nth 0 args))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
391 (value (nth 1 args)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
392 (put symbol 'saved-value (list value)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
393 (setq args (cdr (cdr args)))))))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
394
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
395 ;;; The End.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
396
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
397 (provide 'custom)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
398
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
399 ;; custom.el ends here