annotate lisp/custom/custom.el @ 24:4103f0995bd7 r19-15b95

Import from CVS: tag r19-15b95
author cvs
date Mon, 13 Aug 2007 08:51:03 +0200
parents 8fc7fe29b841
children 441bb1e64a06
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
1 ;;; custom.el -- Tools for declaring and initializing options.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
2 ;;
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
3 ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc.
18
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
4 ;;
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
6 ;; Keywords: help, faces
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
7 ;; Version: 1.44
18
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
8 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
9
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
10 ;;; Commentary:
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
11 ;;
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
12 ;; If you want to use this code, please visit the URL above.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
13 ;;
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
14 ;; This file only contain the code needed to declare and initialize
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
15 ;; user options. The code to customize options is autoloaded from
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
16 ;; `custom-edit.el'.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
17
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
18 ;;; Code:
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
19
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
20 (require 'widget)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
21
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
22 (define-widget-keywords :prefix :tag :load :link :options :type :group)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
23
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
24 ;; These autoloads should be deleted when the file is added to Emacs
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
25
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
26 (unless (fboundp 'load-gc)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
27 (autoload 'customize "custom-edit" nil t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
28 (autoload 'customize-variable "custom-edit" nil t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
29 (autoload 'customize-face "custom-edit" nil t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
30 (autoload 'customize-apropos "custom-edit" nil t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
31 (autoload 'customize-customized "custom-edit" nil t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
32 (autoload 'custom-buffer-create "custom-edit")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
33 (autoload 'custom-menu-update "custom-edit")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
34 (autoload 'custom-make-dependencies "custom-edit"))
18
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
35
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
36 ;;; Compatibility.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
37
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
38 (unless (fboundp 'frame-property)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
39 ;; XEmacs function missing in Emacs 19.34.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
40 (defun frame-property (frame property &optional default)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
41 "Return FRAME's value for property PROPERTY."
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
42 (or (cdr (assq property (frame-parameters frame)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
43 default)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
44
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
45 (defun custom-background-mode ()
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
46 "Kludge to detect background mode."
18
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
47 (let* ((bg-resource
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
48 (condition-case ()
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
49 (x-get-resource ".backgroundMode" "BackgroundMode" 'string)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
50 (error nil)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
51 color
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
52 (mode (cond (bg-resource
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
53 (intern (downcase bg-resource)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
54 ((and (setq color (condition-case ()
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
55 (or (frame-property
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
56 (selected-frame)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
57 'background-color)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
58 (color-instance-name
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
59 (specifier-instance
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
60 (face-background 'default))))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
61 (error nil)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
62 (< (apply '+ (x-color-values color))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
63 (/ (apply '+ (x-color-values "white"))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
64 3)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
65 'dark)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
66 (t 'light))))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
67 (modify-frame-parameters (selected-frame)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
68 (list (cons 'background-mode mode)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
69 mode))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
70
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
71 ;; XEmacs and Emacs have different definitions of `facep'.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
72 ;; The Emacs definition is the useful one, so emulate that.
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
73 (if (fboundp 'facep)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
74 (defalias 'custom-facep 'facep)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
75 (defun custom-facep (face)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
76 "No faces"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
77 nil))
18
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
78
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
79 ;;; The `defcustom' Macro.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
80
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
81 (defun custom-declare-variable (symbol value doc &rest args)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
82 "Like `defcustom', but SYMBOL and VALUE are evaluated as normal arguments."
18
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
83 (unless (and (default-boundp symbol)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
84 (not (get symbol 'saved-value)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
85 (set-default symbol (if (get symbol 'saved-value)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
86 (eval (car (get symbol 'saved-value)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
87 (eval value))))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
88 (put symbol 'factory-value (list value))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
89 (when doc
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
90 (put symbol 'variable-documentation doc))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
91 (while args
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
92 (let ((arg (car args)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
93 (setq args (cdr args))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
94 (unless (symbolp arg)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
95 (error "Junk in args %S" args))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
96 (let ((keyword arg)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
97 (value (car args)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
98 (unless args
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
99 (error "Keyword %s is missing an argument" keyword))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
100 (setq args (cdr args))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
101 (cond ((eq keyword :type)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
102 (put symbol 'custom-type value))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
103 ((eq keyword :options)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
104 (if (get symbol 'custom-options)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
105 ;; Slow safe code to avoid duplicates.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
106 (mapcar (lambda (option)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
107 (custom-add-option symbol option))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
108 value)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
109 ;; Fast code for the common case.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
110 (put symbol 'custom-options (copy-list value))))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
111 (t
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
112 (custom-handle-keyword symbol keyword value
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
113 'custom-variable))))))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
114 (run-hooks 'custom-define-hook)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
115 symbol)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
116
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
117 (defmacro defcustom (symbol value doc &rest args)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
118 "Declare SYMBOL as a customizable variable that defaults to VALUE.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
119 DOC is the variable documentation.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
120
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
121 Neither SYMBOL nor VALUE needs to be quoted.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
122 If SYMBOL is not already bound, initialize it to VALUE.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
123 The remaining arguments should have the form
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
124
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
125 [KEYWORD VALUE]...
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
126
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
127 The following KEYWORD's are defined:
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
128
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
129 :type VALUE should be a widget type.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
130 :options VALUE should be a list of valid members of the widget type.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
131 :group VALUE should be a customization group.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
132 Add SYMBOL to that group.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
133
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
134 Read the section about customization in the emacs lisp manual for more
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
135 information."
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
136 `(eval-and-compile
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
137 (custom-declare-variable (quote ,symbol) (quote ,value) ,doc ,@args)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
138
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
139 ;;; The `defface' Macro.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
140
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
141
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
142 ;(defun get-face-documentation (face)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
143 ; "Get the documentation string for FACE."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
144 ; (get face 'face-documentation))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
145
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
146 ;(defun set-face-documentation (face string)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
147 ; "Set the documentation string for FACE to STRING."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
148 ; (put face 'face-documentation string))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
149
18
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
150 (defun custom-declare-face (face spec doc &rest args)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
151 "Like `defface', but FACE is evaluated as a normal argument."
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
152 (put face 'factory-face spec)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
153 (when (fboundp 'facep)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
154 (unless (and (custom-facep face)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
155 (not (get face 'saved-face)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
156 ;; If the user has already created the face, respect that.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
157 (let ((value (or (get face 'saved-face) spec)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
158 (custom-face-display-set face value))))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
159 (when (and doc (null (get-face-documentation face)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
160 (set-face-documentation face doc))
18
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
161 (custom-handle-all-keywords face args 'custom-face)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
162 (run-hooks 'custom-define-hook)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
163 face)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
164
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
165 (defmacro defface (face spec doc &rest args)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
166 "Declare FACE as a customizable face that defaults to SPEC.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
167 FACE does not need to be quoted.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
168
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
169 Third argument DOC is the face documentation.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
170
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
171 If FACE has been set with `custom-set-face', set the face attributes
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
172 as specified by that function, otherwise set the face attributes
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
173 according to SPEC.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
174
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
175 The remaining arguments should have the form
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
176
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
177 [KEYWORD VALUE]...
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
178
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
179 The following KEYWORD's are defined:
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
180
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
181 :group VALUE should be a customization group.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
182 Add FACE to that group.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
183
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
184 SPEC should be an alist of the form ((DISPLAY ATTS)...).
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
185
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
186 ATTS is a list of face attributes and their values. The possible
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
187 attributes are defined in the variable `custom-face-attributes'.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
188 Alternatively, ATTS can be a face in which case the attributes of that
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
189 face is used.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
190
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
191 The ATTS of the first entry in SPEC where the DISPLAY matches the
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
192 frame should take effect in that frame. DISPLAY can either be the
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
193 symbol `t', which will match all frames, or an alist of the form
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
194 \((REQ ITEM...)...)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
195
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
196 For the DISPLAY to match a FRAME, the REQ property of the frame must
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
197 match one of the ITEM. The following REQ are defined:
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
198
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
199 `type' (the value of (window-system))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
200 Should be one of `x' or `tty'.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
201
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
202 `class' (the frame's color support)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
203 Should be one of `color', `grayscale', or `mono'.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
204
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
205 `background' (what color is used for the background text)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
206 Should be one of `light' or `dark'.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
207
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
208 Read the section about customization in the emacs lisp manual for more
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
209 information."
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
210 `(custom-declare-face (quote ,face) ,spec ,doc ,@args))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
211
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
212 ;;; The `defgroup' Macro.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
213
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
214 (defun custom-declare-group (symbol members doc &rest args)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
215 "Like `defgroup', but SYMBOL is evaluated as a normal argument."
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
216 (put symbol 'custom-group (nconc members (get symbol 'custom-group)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
217 (when doc
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
218 (put symbol 'group-documentation doc))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
219 (while args
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
220 (let ((arg (car args)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
221 (setq args (cdr args))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
222 (unless (symbolp arg)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
223 (error "Junk in args %S" args))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
224 (let ((keyword arg)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
225 (value (car args)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
226 (unless args
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
227 (error "Keyword %s is missing an argument" keyword))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
228 (setq args (cdr args))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
229 (cond ((eq keyword :prefix)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
230 (put symbol 'custom-prefix value))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
231 (t
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
232 (custom-handle-keyword symbol keyword value
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
233 'custom-group))))))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
234 (run-hooks 'custom-define-hook)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
235 symbol)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
236
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
237 (defmacro defgroup (symbol members doc &rest args)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
238 "Declare SYMBOL as a customization group containing MEMBERS.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
239 SYMBOL does not need to be quoted.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
240
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
241 Third arg DOC is the group documentation.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
242
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
243 MEMBERS should be an alist of the form ((NAME WIDGET)...) where
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
244 NAME is a symbol and WIDGET is a widget is a widget for editing that
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
245 symbol. Useful widgets are `custom-variable' for editing variables,
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
246 `custom-face' for edit faces, and `custom-group' for editing groups.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
247
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
248 The remaining arguments should have the form
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
249
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
250 [KEYWORD VALUE]...
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
251
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
252 The following KEYWORD's are defined:
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
253
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
254 :group VALUE should be a customization group.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
255 Add SYMBOL to that group.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
256
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
257 Read the section about customization in the emacs lisp manual for more
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
258 information."
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
259 `(custom-declare-group (quote ,symbol) ,members ,doc ,@args))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
260
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
261 (defun custom-add-to-group (group option widget)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
262 "To existing GROUP add a new OPTION of type WIDGET,
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
263 If there already is an entry for that option, overwrite it."
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
264 (let* ((members (get group 'custom-group))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
265 (old (assq option members)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
266 (if old
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
267 (setcar (cdr old) widget)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
268 (put group 'custom-group (nconc members (list (list option widget)))))))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
269
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
270 ;;; Properties.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
271
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
272 (defun custom-handle-all-keywords (symbol args type)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
273 "For customization option SYMBOL, handle keyword arguments ARGS.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
274 Third argument TYPE is the custom option type."
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
275 (while args
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
276 (let ((arg (car args)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
277 (setq args (cdr args))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
278 (unless (symbolp arg)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
279 (error "Junk in args %S" args))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
280 (let ((keyword arg)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
281 (value (car args)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
282 (unless args
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
283 (error "Keyword %s is missing an argument" keyword))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
284 (setq args (cdr args))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
285 (custom-handle-keyword symbol keyword value type)))))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
286
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
287 (defun custom-handle-keyword (symbol keyword value type)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
288 "For customization option SYMBOL, handle KEYWORD with VALUE.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
289 Fourth argument TYPE is the custom option type."
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
290 (cond ((eq keyword :group)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
291 (custom-add-to-group value symbol type))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
292 ((eq keyword :link)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
293 (custom-add-link symbol value))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
294 ((eq keyword :load)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
295 (custom-add-load symbol value))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
296 ((eq keyword :tag)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
297 (put symbol 'custom-tag value))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
298 (t
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
299 (error "Unknown keyword %s" symbol))))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
300
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
301 (defun custom-add-option (symbol option)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
302 "To the variable SYMBOL add OPTION.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
303
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
304 If SYMBOL is a hook variable, OPTION should be a hook member.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
305 For other types variables, the effect is undefined."
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
306 (let ((options (get symbol 'custom-options)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
307 (unless (member option options)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
308 (put symbol 'custom-options (cons option options)))))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
309
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
310 (defun custom-add-link (symbol widget)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
311 "To the custom option SYMBOL add the link WIDGET."
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
312 (let ((links (get symbol 'custom-links)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
313 (unless (member widget links)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
314 (put symbol 'custom-links (cons widget links)))))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
315
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
316 (defun custom-add-load (symbol load)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
317 "To the custom option SYMBOL add the dependency LOAD.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
318 LOAD should be either a library file name, or a feature name."
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
319 (let ((loads (get symbol 'custom-loads)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
320 (unless (member load loads)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
321 (put symbol 'custom-loads (cons load loads)))))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
322
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
323 ;;; Face Utilities.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
324
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
325 (and (fboundp 'make-face)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
326 (make-face 'custom-face-empty))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
327
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
328 (defun custom-face-display-set (face spec &optional frame)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
329 "Set FACE to the attributes to the first matching entry in SPEC.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
330 Iff optional FRAME is non-nil, set it for that frame only.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
331 See `defface' for information about SPEC."
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
332 (when (fboundp 'copy-face)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
333 (copy-face 'custom-face-empty face frame)
18
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
334 (while spec
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
335 (let* ((entry (car spec))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
336 (display (nth 0 entry))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
337 (atts (nth 1 entry)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
338 (setq spec (cdr spec))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
339 (when (custom-display-match-frame display frame)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
340 (apply 'custom-face-attribites-set face frame atts)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
341 (setq spec nil))))))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
342
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
343 (defcustom custom-background-mode nil
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
344 "The brightness of the background.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
345 Set this to the symbol dark if your background color is dark, light if
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
346 your background is light, or nil (default) if you want Emacs to
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
347 examine the brightness for you."
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
348 :group 'customize
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
349 :type '(choice (choice-item dark)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
350 (choice-item light)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
351 (choice-item :tag "default" nil)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
352
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
353 (defun custom-display-match-frame (display frame)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
354 "Non-nil iff DISPLAY matches FRAME.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
355 If FRAME is nil, the current FRAME is used."
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
356 ;; This is a kludge to get started, we really should use specifiers!
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
357 (unless frame
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
358 (setq frame (selected-frame)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
359 (if (eq display t)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
360 t
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
361 (let ((match t))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
362 (while (and display match)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
363 (let* ((entry (car display))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
364 (req (car entry))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
365 (options (cdr entry)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
366 (setq display (cdr display))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
367 (cond ((eq req 'type)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
368 (let ((type (if (fboundp 'device-type)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
369 (device-type (frame-device frame))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
370 window-system)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
371 (setq match (memq type options))))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
372 ((eq req 'class)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
373 (let ((class (if (fboundp 'device-class)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
374 (device-class (frame-device frame))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
375 (frame-property frame 'display-type))))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
376 (setq match (memq class options))))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
377 ((eq req 'background)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
378 (let ((background (or custom-background-mode
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
379 (frame-property frame 'background-mode)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
380 (custom-background-mode))))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
381 (setq match (memq background options))))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
382 (t
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
383 (error "Unknown req `%S' with options `%S'" req options)))))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
384 match)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
385
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
386 (defconst custom-face-attributes
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
387 '((:bold (toggle :format "Bold: %[%v%]\n") custom-set-face-bold)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
388 (:italic (toggle :format "Italic: %[%v%]\n") custom-set-face-italic)
18
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
389 (:underline
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
390 (toggle :format "Underline: %[%v%]\n") set-face-underline-p)
18
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
391 (:foreground (color :tag "Foreground") set-face-foreground)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
392 (:background (color :tag "Background") set-face-background)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
393 (:stipple (editable-field :format "Stipple: %v") set-face-stipple))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
394 "Alist of face attributes.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
395
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
396 The elements are of the form (KEY TYPE SET) where KEY is a symbol
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
397 identifying the attribute, TYPE is a widget type for editing the
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
398 attibute, SET is a function for setting the attribute value.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
399
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
400 The SET function should take three arguments, the face to modify, the
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
401 value of the attribute, and optionally the frame where the face should
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
402 be changed.")
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
403
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
404 (defun custom-face-attribites-set (face frame &rest atts)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
405 "For FACE on FRAME set the attributes [KEYWORD VALUE]....
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
406 Each keyword should be listed in `custom-face-attributes'.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
407
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
408 If FRAME is nil, set the default face."
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
409 (while atts
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
410 (let* ((name (nth 0 atts))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
411 (value (nth 1 atts))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
412 (fun (nth 2 (assq name custom-face-attributes))))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
413 (setq atts (cdr (cdr atts)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
414 (condition-case nil
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
415 (funcall fun face value frame)
18
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
416 (error nil)))))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
417
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
418 (defun custom-set-face-bold (face value &optional frame)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
419 "Set the bold property of FACE to VALUE."
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
420 (if value
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
421 (make-face-bold face frame)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
422 (make-face-unbold face frame)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
423
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
424 (defun custom-set-face-italic (face value &optional frame)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
425 "Set the italic property of FACE to VALUE."
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
426 (if value
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
427 (make-face-italic face frame)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
428 (make-face-unitalic face frame)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
429
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
430 (defun custom-initialize-faces (&optional frame)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
431 "Initialize all custom faces for FRAME.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
432 If FRAME is nil or omitted, initialize them for all frames."
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
433 (mapatoms (lambda (symbol)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
434 (let ((spec (or (get symbol 'saved-face)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
435 (get symbol 'factory-face))))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
436 (when spec
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
437 (custom-face-display-set symbol spec frame))))))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
438
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
439 ;;; Initializing.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
440
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
441 (defun custom-set-variables (&rest args)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
442 "Initialize variables according to user preferences.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
443
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
444 The arguments should be a list where each entry has the form:
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
445
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
446 (SYMBOL VALUE [NOW])
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
447
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
448 The unevaluated VALUE is stored as the saved value for SYMBOL.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
449 If NOW is present and non-nil, VALUE is also evaluated and bound as
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
450 the default value for the SYMBOL."
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
451 (while args
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
452 (let ((entry (car args)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
453 (if (listp entry)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
454 (let ((symbol (nth 0 entry))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
455 (value (nth 1 entry))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
456 (now (nth 2 entry)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
457 (put symbol 'saved-value (list value))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
458 (when now
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
459 (put symbol 'force-value t)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
460 (set-default symbol (eval value)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
461 (setq args (cdr args)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
462 ;; Old format, a plist of SYMBOL VALUE pairs.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
463 (let ((symbol (nth 0 args))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
464 (value (nth 1 args)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
465 (put symbol 'saved-value (list value)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
466 (setq args (cdr (cdr args)))))))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
467
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
468 (defun custom-set-faces (&rest args)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
469 "Initialize faces according to user preferences.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
470 The arguments should be a list where each entry has the form:
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
471
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
472 (FACE SPEC [NOW])
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
473
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
474 SPEC will be stored as the saved value for FACE. If NOW is present
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
475 and non-nil, FACE will also be created according to SPEC.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
476
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
477 See `defface' for the format of SPEC."
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
478 (while args
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
479 (let ((entry (car args)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
480 (if (listp entry)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
481 (let ((face (nth 0 entry))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
482 (spec (nth 1 entry))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
483 (now (nth 2 entry)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
484 (put face 'saved-face spec)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
485 (when now
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
486 (put face 'force-face t)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
487 (custom-face-display-set face spec))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
488 (setq args (cdr args)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
489 ;; Old format, a plist of FACE SPEC pairs.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
490 (let ((face (nth 0 args))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
491 (spec (nth 1 args)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
492 (put face 'saved-face spec))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
493 (setq args (cdr (cdr args)))))))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
494
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
495 ;;; Meta Customization
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
496
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
497 (defgroup emacs nil
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
498 "Customization of the One True Editor."
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
499 :link '(custom-manual "(emacs)Top"))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
500
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
501 (defgroup customize '((widgets custom-group))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
502 "Customization of the Customization support."
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
503 :link '(custom-manual "(custom)Top")
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
504 :link '(url-link :tag "Development Page"
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
505 "http://www.dina.kvl.dk/~abraham/custom/")
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
506 :prefix "custom-"
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
507 :group 'emacs)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
508
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
509 (defcustom custom-define-hook nil
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
510 "Hook called after defining each customize option."
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
511 :group 'customize
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
512 :type 'hook)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
513
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
514 ;;; Menu support
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
515
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
516 (defconst custom-help-menu '("Customize"
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
517 ["Update menu..." custom-menu-update t]
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
518 ["Group..." customize t]
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
519 ["Variable..." customize-variable t]
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
520 ["Face..." customize-face t]
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
521 ["Saved..." customize-customized t]
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
522 ["Apropos..." customize-apropos t])
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
523 "Customize menu")
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
524
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
525 ;(defun custom-menu-reset ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
526 ; "Reset customize menu."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
527 ; (remove-hook 'custom-define-hook 'custom-menu-reset)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
528 ; (define-key global-map [menu-bar help-menu customize-menu]
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
529 ; (cons (car custom-help-menu)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
530 ; (easy-menu-create-keymaps (car custom-help-menu)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
531 ; (cdr custom-help-menu)))))
18
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
532
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
533 ;;; The End.
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
534
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
535 (provide 'custom)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
536
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
537 (when (and (not (fboundp 'load-gc))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
538 (string-match "XEmacs" emacs-version))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
539 ;; Overwrite definitions for XEmacs.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
540 (load-library "custom-xmas"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
541
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
542 (unless (fboundp 'load-gc)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
543 (custom-menu-reset))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
544
18
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents:
diff changeset
545 ;; custom.el ends here