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