annotate lisp/custom/cus-face.el @ 193:f53b5ca2e663 r20-3b23

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