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