annotate lisp/custom/custom.el @ 102:a145efe76779 r20-1b3

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