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