28
|
1 ;;; cus-face.el -- XEmacs specific custom support.
|
|
2 ;;
|
|
3 ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc.
|
|
4 ;;
|
|
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
|
|
6 ;; Keywords: help, faces
|
118
|
7 ;; Version: 1.69
|
28
|
8 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/
|
|
9
|
|
10 ;;; Commentary:
|
|
11 ;;
|
|
12 ;; See `custom.el'.
|
|
13
|
|
14 ;;; Code:
|
|
15
|
|
16 (require 'custom)
|
|
17
|
30
|
18 (eval-and-compile (require 'cl))
|
|
19
|
28
|
20 ;;; Compatibility.
|
|
21
|
118
|
22 (if (string-match "XEmacs" emacs-version)
|
|
23 (defun custom-face-background (face &optional frame)
|
|
24 ;; Specifiers suck!
|
|
25 "Return the background color name of face FACE, or nil if unspecified."
|
|
26 (color-instance-name (specifier-instance (face-background face) frame)))
|
|
27 (defalias 'custom-face-background 'face-background))
|
|
28
|
|
29 (if (string-match "XEmacs" emacs-version)
|
|
30 (defun custom-face-foreground (face &optional frame)
|
|
31 ;; Specifiers suck!
|
|
32 "Return the background color name of face FACE, or nil if unspecified."
|
|
33 (color-instance-name (specifier-instance (face-foreground face) frame)))
|
|
34 (defalias 'custom-face-foreground 'face-foreground))
|
|
35
|
30
|
36 (eval-and-compile
|
|
37 (unless (fboundp 'frame-property)
|
|
38 ;; XEmacs function missing in Emacs 19.34.
|
|
39 (defun frame-property (frame property &optional default)
|
|
40 "Return FRAME's value for property PROPERTY."
|
|
41 (or (cdr (assq property (frame-parameters frame)))
|
|
42 default)))
|
|
43
|
|
44 (unless (fboundp 'face-doc-string)
|
|
45 ;; XEmacs function missing in Emacs.
|
|
46 (defun face-doc-string (face)
|
|
47 "Get the documentation string for FACE."
|
|
48 (get face 'face-doc-string)))
|
|
49
|
|
50 (unless (fboundp 'set-face-doc-string)
|
|
51 ;; XEmacs function missing in Emacs.
|
|
52 (defun set-face-doc-string (face string)
|
|
53 "Set the documentation string for FACE to STRING."
|
118
|
54 (put face 'face-doc-string string)))
|
|
55
|
|
56 (when (and (not (fboundp 'set-face-stipple))
|
|
57 (fboundp 'set-face-background-pixmap))
|
|
58 ;; Emacs function missing in XEmacs 19.15.
|
|
59 (defun set-face-stipple (face pixmap &optional frame)
|
|
60 ;; Written by Kyle Jones.
|
|
61 "Change the stipple pixmap of face FACE to PIXMAP.
|
|
62 PIXMAP should be a string, the name of a file of pixmap data.
|
|
63 The directories listed in the `x-bitmap-file-path' variable are searched.
|
|
64
|
|
65 Alternatively, PIXMAP may be a list of the form (WIDTH HEIGHT DATA)
|
|
66 where WIDTH and HEIGHT are the size in pixels,
|
|
67 and DATA is a string, containing the raw bits of the bitmap.
|
|
68
|
|
69 If the optional FRAME argument is provided, change only
|
|
70 in that frame; otherwise change each frame."
|
|
71 (while (not (find-face face))
|
|
72 (setq face (signal 'wrong-type-argument (list 'facep face))))
|
|
73 (while (cond ((stringp pixmap)
|
|
74 (unless (file-readable-p pixmap)
|
|
75 (setq pixmap (vector 'xbm ':file pixmap)))
|
|
76 nil)
|
|
77 ((and (consp pixmap) (= (length pixmap) 3))
|
|
78 (setq pixmap (vector 'xbm ':data pixmap))
|
|
79 nil)
|
|
80 (t t))
|
|
81 (setq pixmap (signal 'wrong-type-argument
|
|
82 (list 'stipple-pixmap-p pixmap))))
|
|
83 (while (and frame (not (framep frame)))
|
|
84 (setq frame (signal 'wrong-type-argument (list 'framep frame))))
|
|
85 (set-face-background-pixmap face pixmap frame))))
|
28
|
86
|
|
87 (unless (fboundp 'x-color-values)
|
|
88 ;; Emacs function missing in XEmacs 19.14.
|
|
89 (defun x-color-values (color &optional frame)
|
|
90 "Return a description of the color named COLOR on frame FRAME.
|
|
91 The value is a list of integer RGB values--(RED GREEN BLUE).
|
|
92 These values appear to range from 0 to 65280 or 65535, depending
|
|
93 on the system; white is (65280 65280 65280) or (65535 65535 65535).
|
|
94 If FRAME is omitted or nil, use the selected frame."
|
|
95 (color-instance-rgb-components (make-color-instance color))))
|
|
96
|
|
97 ;; XEmacs and Emacs have different definitions of `facep'.
|
|
98 ;; The Emacs definition is the useful one, so emulate that.
|
|
99 (cond ((not (fboundp 'facep))
|
|
100 (defun custom-facep (face)
|
|
101 "No faces"
|
|
102 nil))
|
|
103 ((string-match "XEmacs" emacs-version)
|
|
104 (defalias 'custom-facep 'find-face))
|
|
105 (t
|
|
106 (defalias 'custom-facep 'facep)))
|
|
107
|
|
108 (unless (fboundp 'make-empty-face)
|
|
109 ;; This should be moved to `faces.el'.
|
|
110 (if (string-match "XEmacs" emacs-version)
|
30
|
111 ;; Give up for old XEmacs pre 19.15/20.1.
|
28
|
112 (defalias 'make-empty-face 'make-face)
|
30
|
113 ;; Define for Emacs pre 19.35.
|
28
|
114 (defun make-empty-face (name)
|
|
115 "Define a new FACE on all frames, ignoring X resources."
|
|
116 (interactive "SMake face: ")
|
|
117 (or (internal-find-face name)
|
|
118 (let ((face (make-vector 8 nil)))
|
|
119 (aset face 0 'face)
|
|
120 (aset face 1 name)
|
|
121 (let* ((frames (frame-list))
|
|
122 (inhibit-quit t)
|
|
123 (id (internal-next-face-id)))
|
|
124 (make-face-internal id)
|
|
125 (aset face 2 id)
|
|
126 (while frames
|
|
127 (set-frame-face-alist (car frames)
|
|
128 (cons (cons name (copy-sequence face))
|
|
129 (frame-face-alist (car frames))))
|
|
130 (setq frames (cdr frames)))
|
|
131 (setq global-face-data (cons (cons name face) global-face-data)))
|
|
132 ;; add to menu
|
|
133 (if (fboundp 'facemenu-add-new-face)
|
|
134 (facemenu-add-new-face name))
|
|
135 face))
|
|
136 name)))
|
|
137
|
|
138 (defcustom initialize-face-resources t
|
|
139 "If non nil, allow X resources to initialize face properties.
|
|
140 This only affects faces declared with `defface', and only NT or X11 frames."
|
|
141 :group 'customize
|
|
142 :type 'boolean)
|
|
143
|
|
144 (cond ((fboundp 'initialize-face-resources)
|
|
145 ;; Already bound, do nothing.
|
|
146 )
|
|
147 ((fboundp 'make-face-x-resource-internal)
|
|
148 ;; Emacs or new XEmacs.
|
|
149 (defun initialize-face-resources (face &optional frame)
|
|
150 "Initialize face according to the X11 resources.
|
|
151 This might overwrite existing face properties.
|
|
152 Does nothing when the variable initialize-face-resources is nil."
|
|
153 (when initialize-face-resources
|
|
154 (make-face-x-resource-internal face frame t))))
|
|
155 (t
|
|
156 ;; Too hard to do right on XEmacs.
|
|
157 (defalias 'initialize-face-resources 'ignore)))
|
|
158
|
36
|
159 ;;(if (string-match "XEmacs" emacs-version)
|
|
160 ;; ;; Xemacs.
|
|
161 ;; (defun custom-invert-face (face &optional frame)
|
|
162 ;; "Swap the foreground and background colors of face FACE.
|
|
163 ;;If the colors are not specified in the face, use the default colors."
|
|
164 ;; (interactive (list (read-face-name "Reverse face: ")))
|
|
165 ;; (let ((fg (color-name (face-foreground face frame) frame))
|
|
166 ;; (bg (color-name (face-background face frame) frame)))
|
|
167 ;; (set-face-foreground face bg frame)
|
|
168 ;; (set-face-background face fg frame)))
|
|
169 ;; ;; Emacs.
|
|
170 ;; (defun custom-invert-face (face &optional frame)
|
|
171 ;; "Swap the foreground and background colors of face FACE.
|
|
172 ;;If the colors are not specified in the face, use the default colors."
|
|
173 ;; (interactive (list (read-face-name "Reverse face: ")))
|
|
174 ;; (let ((fg (or (face-foreground face frame)
|
|
175 ;; (face-foreground 'default frame)
|
|
176 ;; (frame-property (or frame (selected-frame))
|
|
177 ;; 'foreground-color)
|
|
178 ;; "black"))
|
|
179 ;; (bg (or (face-background face frame)
|
|
180 ;; (face-background 'default frame)
|
|
181 ;; (frame-property (or frame (selected-frame))
|
|
182 ;; 'background-color)
|
|
183 ;; "white")))
|
|
184 ;; (set-face-foreground face bg frame)
|
|
185 ;; (set-face-background face fg frame))))
|
28
|
186
|
|
187 (defcustom custom-background-mode nil
|
|
188 "The brightness of the background.
|
|
189 Set this to the symbol dark if your background color is dark, light if
|
|
190 your background is light, or nil (default) if you want Emacs to
|
|
191 examine the brightness for you."
|
|
192 :group 'customize
|
|
193 :type '(choice (choice-item dark)
|
|
194 (choice-item light)
|
|
195 (choice-item :tag "default" nil)))
|
|
196
|
|
197 (defun custom-background-mode (frame)
|
|
198 "Kludge to detect background mode for FRAME."
|
|
199 (let* ((bg-resource
|
|
200 (condition-case ()
|
|
201 (x-get-resource ".backgroundMode" "BackgroundMode" 'string)
|
|
202 (error nil)))
|
|
203 color
|
|
204 (mode (cond (bg-resource
|
|
205 (intern (downcase bg-resource)))
|
|
206 ((and (setq color (condition-case ()
|
|
207 (or (frame-property
|
|
208 frame
|
|
209 'background-color)
|
118
|
210 (custom-face-background
|
|
211 'default))
|
28
|
212 (error nil)))
|
|
213 (or (string-match "XEmacs" emacs-version)
|
|
214 window-system)
|
|
215 (< (apply '+ (x-color-values color))
|
|
216 (/ (apply '+ (x-color-values "white"))
|
|
217 3)))
|
|
218 'dark)
|
|
219 (t 'light))))
|
|
220 (modify-frame-parameters frame (list (cons 'background-mode mode)))
|
|
221 mode))
|
|
222
|
30
|
223 (eval-and-compile
|
|
224 (if (string-match "XEmacs" emacs-version)
|
|
225 ;; XEmacs.
|
|
226 (defun custom-extract-frame-properties (frame)
|
|
227 "Return a plist with the frame properties of FRAME used by custom."
|
|
228 (list 'type (device-type (frame-device frame))
|
|
229 'class (device-class (frame-device frame))
|
|
230 'background (or custom-background-mode
|
|
231 (frame-property frame
|
|
232 'background-mode)
|
|
233 (custom-background-mode frame))))
|
|
234 ;; Emacs.
|
|
235 (defun custom-extract-frame-properties (frame)
|
|
236 "Return a plist with the frame properties of FRAME used by custom."
|
|
237 (list 'type window-system
|
|
238 'class (frame-property frame 'display-type)
|
|
239 'background (or custom-background-mode
|
|
240 (frame-property frame 'background-mode)
|
|
241 (custom-background-mode frame))))))
|
|
242
|
|
243 ;;; Declaring a face.
|
|
244
|
|
245 ;;;###autoload
|
|
246 (defun custom-declare-face (face spec doc &rest args)
|
|
247 "Like `defface', but FACE is evaluated as a normal argument."
|
|
248 (when (fboundp 'load-gc)
|
|
249 ;; This should be allowed, somehow.
|
|
250 (error "Attempt to declare a face during dump"))
|
|
251 (unless (get face 'factory-face)
|
|
252 (put face 'factory-face spec)
|
|
253 (when (fboundp 'facep)
|
32
|
254 (unless (custom-facep face)
|
30
|
255 ;; If the user has already created the face, respect that.
|
|
256 (let ((value (or (get face 'saved-face) spec))
|
|
257 (frames (custom-relevant-frames))
|
|
258 frame)
|
|
259 ;; Create global face.
|
|
260 (make-empty-face face)
|
|
261 (custom-face-display-set face value)
|
|
262 ;; Create frame local faces
|
|
263 (while frames
|
|
264 (setq frame (car frames)
|
|
265 frames (cdr frames))
|
|
266 (custom-face-display-set face value frame))
|
|
267 (initialize-face-resources face))))
|
|
268 (when (and doc (null (face-doc-string face)))
|
|
269 (set-face-doc-string face doc))
|
|
270 (custom-handle-all-keywords face args 'custom-face)
|
|
271 (run-hooks 'custom-define-hook))
|
|
272 face)
|
|
273
|
|
274 ;;; Font Attributes.
|
|
275
|
|
276 (defconst custom-face-attributes
|
|
277 '((:bold (toggle :format "Bold: %[%v%]\n"
|
|
278 :help-echo "Control whether a bold font should be used.")
|
|
279 custom-set-face-bold)
|
|
280 (:italic (toggle :format "Italic: %[%v%]\n"
|
|
281 :help-echo "\
|
|
282 Control whether an italic font should be used.")
|
|
283 custom-set-face-italic)
|
|
284 (:underline (toggle :format "Underline: %[%v%]\n"
|
|
285 :help-echo "\
|
|
286 Control whether the text should be underlined.")
|
118
|
287 set-face-underline-p
|
|
288 face-underline-p)
|
30
|
289 (:foreground (color :tag "Foreground"
|
32
|
290 :value "black"
|
30
|
291 :help-echo "Set foreground color.")
|
118
|
292 set-face-foreground
|
|
293 custom-face-foreground)
|
30
|
294 (:background (color :tag "Background"
|
32
|
295 :value "white"
|
30
|
296 :help-echo "Set background color.")
|
118
|
297 set-face-background
|
|
298 custom-face-background)
|
36
|
299 ;; (:invert (const :format "Invert Face\n"
|
|
300 ;; :sibling-args (:help-echo "
|
|
301 ;;Reverse the foreground and background color.
|
|
302 ;;If you haven't specified them for the face, the default colors will be used.")
|
|
303 ;; t)
|
|
304 ;; (lambda (face value &optional frame)
|
|
305 ;; ;; We don't use VALUE.
|
|
306 ;; (custom-invert-face face frame)))
|
30
|
307 (:stipple (editable-field :format "Stipple: %v"
|
|
308 :help-echo "Name of background bitmap file.")
|
|
309 set-face-stipple))
|
|
310 "Alist of face attributes.
|
|
311
|
118
|
312 The elements are of the form (KEY TYPE SET GET) where KEY is a symbol
|
30
|
313 identifying the attribute, TYPE is a widget type for editing the
|
118
|
314 attibute, SET is a function for setting the attribute value, and GET is a function for getiing the attribute value.
|
30
|
315
|
|
316 The SET function should take three arguments, the face to modify, the
|
|
317 value of the attribute, and optionally the frame where the face should
|
118
|
318 be changed.
|
|
319
|
|
320 The GET function should take two arguments, the face to examine, and
|
|
321 optonally the frame where the face should be examined.")
|
30
|
322
|
|
323 (defun custom-face-attributes-set (face frame &rest atts)
|
|
324 "For FACE on FRAME set the attributes [KEYWORD VALUE]....
|
|
325 Each keyword should be listed in `custom-face-attributes'.
|
|
326
|
|
327 If FRAME is nil, set the default face."
|
|
328 (while atts
|
|
329 (let* ((name (nth 0 atts))
|
|
330 (value (nth 1 atts))
|
|
331 (fun (nth 2 (assq name custom-face-attributes))))
|
|
332 (setq atts (cdr (cdr atts)))
|
|
333 (condition-case nil
|
|
334 (funcall fun face value frame)
|
|
335 (error nil)))))
|
|
336
|
118
|
337 (defun custom-face-attributes-get (face frame)
|
|
338 "For FACE on FRAME get the attributes [KEYWORD VALUE]....
|
|
339 Each keyword should be listed in `custom-face-attributes'.
|
|
340
|
|
341 If FRAME is nil, use the default face."
|
|
342 (let ((atts custom-face-attributes)
|
|
343 att result get)
|
|
344 (while atts
|
|
345 (setq att (car atts)
|
|
346 atts (cdr atts)
|
|
347 get (nth 3 att))
|
|
348 (when get
|
|
349 (let ((answer (funcall get face frame)))
|
|
350 (unless (equal answer (funcall get 'default frame))
|
|
351 (when (widget-apply (nth 1 att) :match answer)
|
|
352 (setq result (cons (nth 0 att) (cons answer result))))))))
|
|
353 result))
|
|
354
|
30
|
355 (defun custom-set-face-bold (face value &optional frame)
|
|
356 "Set the bold property of FACE to VALUE."
|
|
357 (if value
|
|
358 (make-face-bold face frame)
|
|
359 (make-face-unbold face frame)))
|
|
360
|
|
361 (defun custom-set-face-italic (face value &optional frame)
|
|
362 "Set the italic property of FACE to VALUE."
|
|
363 (if value
|
|
364 (make-face-italic face frame)
|
|
365 (make-face-unitalic face frame)))
|
|
366
|
|
367 (when (string-match "XEmacs" emacs-version)
|
|
368 ;; Support for special XEmacs font attributes.
|
|
369 (autoload 'font-create-object "font" nil)
|
|
370
|
|
371 (unless (fboundp 'face-font-name)
|
|
372 (defun face-font-name (face &rest args)
|
|
373 (apply 'face-font face args)))
|
|
374
|
|
375 (defun custom-set-face-font-size (face size &rest args)
|
|
376 "Set the font of FACE to SIZE"
|
|
377 (let* ((font (apply 'face-font-name face args))
|
|
378 (fontobj (font-create-object font)))
|
|
379 (set-font-size fontobj size)
|
32
|
380 (apply 'font-set-face-font face fontobj args)))
|
30
|
381
|
|
382 (defun custom-set-face-font-family (face family &rest args)
|
|
383 "Set the font of FACE to FAMILY"
|
|
384 (let* ((font (apply 'face-font-name face args))
|
|
385 (fontobj (font-create-object font)))
|
|
386 (set-font-family fontobj family)
|
32
|
387 (apply 'font-set-face-font face fontobj args)))
|
30
|
388
|
|
389 (nconc custom-face-attributes
|
|
390 '((:family (editable-field :format "Font Family: %v"
|
|
391 :help-echo "\
|
|
392 Name of font family to use (e.g. times).")
|
|
393 custom-set-face-font-family)
|
|
394 (:size (editable-field :format "Size: %v"
|
|
395 :help-echo "\
|
|
396 Text size (e.g. 9pt or 2mm).")
|
|
397 custom-set-face-font-size))))
|
|
398
|
|
399 ;;; Frames.
|
|
400
|
|
401 (defun custom-face-display-set (face spec &optional frame)
|
|
402 "Set FACE to the attributes to the first matching entry in SPEC.
|
|
403 Iff optional FRAME is non-nil, set it for that frame only.
|
|
404 See `defface' for information about SPEC."
|
|
405 (when (fboundp 'make-face)
|
|
406 (while spec
|
|
407 (let* ((entry (car spec))
|
|
408 (display (nth 0 entry))
|
|
409 (atts (nth 1 entry)))
|
|
410 (setq spec (cdr spec))
|
|
411 (when (custom-display-match-frame display frame)
|
|
412 ;; Avoid creating frame local duplicates of the global face.
|
|
413 (unless (and frame (eq display (get face 'custom-face-display)))
|
|
414 (apply 'custom-face-attributes-set face frame atts))
|
|
415 (unless frame
|
|
416 (put face 'custom-face-display display))
|
|
417 (setq spec nil))))))
|
|
418
|
28
|
419 (defvar custom-default-frame-properties nil
|
|
420 "The frame properties used for the global faces.
|
|
421 Frames who doesn't match these propertiess should have frame local faces.
|
|
422 The value should be nil, if uninitialized, or a plist otherwise.
|
|
423 See `defface' for a list of valid keys and values for the plist.")
|
|
424
|
|
425 (defun custom-get-frame-properties (&optional frame)
|
|
426 "Return a plist with the frame properties of FRAME used by custom.
|
|
427 If FRAME is nil, return the default frame properties."
|
|
428 (cond (frame
|
|
429 ;; Try to get from cache.
|
|
430 (let ((cache (frame-property frame 'custom-properties)))
|
|
431 (unless cache
|
|
432 ;; Oh well, get it then.
|
|
433 (setq cache (custom-extract-frame-properties frame))
|
|
434 ;; and cache it...
|
|
435 (modify-frame-parameters frame
|
|
436 (list (cons 'custom-properties cache))))
|
|
437 cache))
|
|
438 (custom-default-frame-properties)
|
|
439 (t
|
|
440 (setq custom-default-frame-properties
|
|
441 (custom-extract-frame-properties (selected-frame))))))
|
|
442
|
|
443 (defun custom-display-match-frame (display frame)
|
|
444 "Non-nil iff DISPLAY matches FRAME.
|
|
445 If FRAME is nil, the current FRAME is used."
|
|
446 ;; This is a kludge to get started, we really should use specifiers!
|
|
447 (if (eq display t)
|
|
448 t
|
|
449 (let* ((props (custom-get-frame-properties frame))
|
|
450 (type (plist-get props 'type))
|
|
451 (class (plist-get props 'class))
|
|
452 (background (plist-get props 'background))
|
|
453 (match t)
|
|
454 (entries display)
|
|
455 entry req options)
|
|
456 (while (and entries match)
|
|
457 (setq entry (car entries)
|
|
458 entries (cdr entries)
|
|
459 req (car entry)
|
|
460 options (cdr entry)
|
|
461 match (cond ((eq req 'type)
|
|
462 (memq type options))
|
|
463 ((eq req 'class)
|
|
464 (memq class options))
|
|
465 ((eq req 'background)
|
|
466 (memq background options))
|
|
467 (t
|
|
468 (error "Unknown req `%S' with options `%S'"
|
|
469 req options)))))
|
|
470 match)))
|
|
471
|
|
472 (defun custom-relevant-frames ()
|
|
473 "List of frames whose custom properties differ from the default."
|
30
|
474 (let ((relevant nil)
|
|
475 (default (custom-get-frame-properties))
|
|
476 (frames (frame-list))
|
|
477 frame)
|
|
478 (while frames
|
|
479 (setq frame (car frames)
|
|
480 frames (cdr frames))
|
|
481 (unless (equal default (custom-get-frame-properties frame))
|
|
482 (push frame relevant)))
|
|
483 relevant))
|
28
|
484
|
|
485 (defun custom-initialize-faces (&optional frame)
|
|
486 "Initialize all custom faces for FRAME.
|
|
487 If FRAME is nil or omitted, initialize them for all frames."
|
|
488 (mapcar (lambda (symbol)
|
|
489 (let ((spec (or (get symbol 'saved-face)
|
|
490 (get symbol 'factory-face))))
|
|
491 (when spec
|
|
492 (custom-face-display-set symbol spec frame)
|
|
493 (initialize-face-resources symbol frame))))
|
|
494 (face-list)))
|
|
495
|
|
496 (defun custom-initialize-frame (&optional frame)
|
|
497 "Initialize local faces for FRAME if necessary.
|
118
|
498 If FRAME is missing or nil, the first member of (frame-list) is used."
|
28
|
499 (unless frame
|
|
500 (setq frame (car (frame-list))))
|
|
501 (unless (equal (custom-get-frame-properties)
|
|
502 (custom-get-frame-properties frame))
|
30
|
503 (custom-initialize-faces frame)))
|
28
|
504
|
|
505 ;; Enable. This should go away when bundled with Emacs.
|
30
|
506 (unless (string-match "XEmacs" emacs-version)
|
|
507 (add-hook 'after-make-frame-hook 'custom-initialize-frame))
|
28
|
508
|
|
509 ;;; Initializing.
|
|
510
|
|
511 (and (fboundp 'make-face)
|
|
512 (make-face 'custom-face-empty))
|
|
513
|
|
514 ;;;###autoload
|
|
515 (defun custom-set-faces (&rest args)
|
|
516 "Initialize faces according to user preferences.
|
|
517 The arguments should be a list where each entry has the form:
|
|
518
|
|
519 (FACE SPEC [NOW])
|
|
520
|
|
521 SPEC will be stored as the saved value for FACE. If NOW is present
|
|
522 and non-nil, FACE will also be created according to SPEC.
|
|
523
|
|
524 See `defface' for the format of SPEC."
|
|
525 (while args
|
|
526 (let ((entry (car args)))
|
|
527 (if (listp entry)
|
|
528 (let ((face (nth 0 entry))
|
|
529 (spec (nth 1 entry))
|
|
530 (now (nth 2 entry)))
|
|
531 (put face 'saved-face spec)
|
|
532 (when now
|
32
|
533 (put face 'force-face t))
|
|
534 (when (or now (custom-facep face))
|
28
|
535 (when (fboundp 'copy-face)
|
|
536 (copy-face 'custom-face-empty face))
|
|
537 (custom-face-display-set face spec))
|
|
538 (setq args (cdr args)))
|
|
539 ;; Old format, a plist of FACE SPEC pairs.
|
|
540 (let ((face (nth 0 args))
|
|
541 (spec (nth 1 args)))
|
|
542 (put face 'saved-face spec))
|
|
543 (setq args (cdr (cdr args)))))))
|
|
544
|
|
545 ;;; The End.
|
|
546
|
|
547 (provide 'cus-face)
|
|
548
|
|
549 ;; cus-face.el ends here
|