annotate lisp/custom/cus-face.el @ 201:eb5470882647 r20-3b27

Import from CVS: tag r20-3b27
author cvs
date Mon, 13 Aug 2007 10:01:22 +0200
parents 169c0442b401
children e45d5e7c476e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
1 ;;; cus-face.el -- Support for Custom faces.
28
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>
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
6 ;; Maintainer: Hrvoje Niksic <hniksic@srce.hr>
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
7 ;; Keywords: help, faces
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
8 ;; Version: 1.9960-x
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
9 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
10
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
11 ;;; Commentary:
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
12 ;;
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
13 ;; See `custom.el'.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
14
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
15 ;; This file should probably be dissolved, and code moved to faces.el,
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
16 ;; like Stallman did.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
17
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
18 ;;; Code:
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
19
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
20 (require 'custom)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
21
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
22 ;; To elude the warnings for font functions.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
23 (eval-when-compile
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
24 (require 'font))
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
25
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
26 ;;; Declaring a face.
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
27
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
28 ;;;###autoload
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
29 (defun custom-declare-face (face spec doc &rest args)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
30 "Like `defface', but FACE is evaluated as a normal argument."
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
31 ;; (when (fboundp 'load-gc)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
32 ;; (error "Attempt to declare a face during dump"))
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
33 (unless (get face 'face-defface-spec)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
34 (put face 'face-defface-spec spec)
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
35 (unless (find-face face)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
36 ;; If the user has already created the face, respect that.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
37 (let ((value (or (get face 'saved-face) spec))
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
38 (frames (relevant-custom-frames))
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
39 frame)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
40 ;; Create global face.
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 199
diff changeset
41 (make-empty-face face)
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
42 (face-display-set face value)
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
43 ;; Create frame local faces
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
44 (while frames
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
45 (setq frame (car frames)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
46 frames (cdr frames))
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 199
diff changeset
47 (face-display-set face value frame))
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 199
diff changeset
48 (init-face-from-resources face)))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
49 (when (and doc (null (face-doc-string face)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
50 (set-face-doc-string face doc))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
51 (custom-handle-all-keywords face args 'custom-face)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
52 (run-hooks 'custom-define-hook))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
53 face)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
54
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
55 ;;; Font Attributes.
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
56
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
57 (defconst custom-face-attributes
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 161
diff changeset
58 '((:bold (boolean :tag "Bold"
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 161
diff changeset
59 :help-echo "Control whether a bold font should be used.")
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
60 custom-set-face-bold custom-face-bold)
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 161
diff changeset
61 (:italic (boolean :tag "Italic"
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 161
diff changeset
62 :help-echo "\
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
63 Control whether an italic font should be used.")
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
64 custom-set-face-italic custom-face-italic)
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 161
diff changeset
65 (:underline (boolean :tag "Underline"
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 161
diff changeset
66 :help-echo "\
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
67 Control whether the text should be underlined.")
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
68 set-face-underline-p face-underline-p)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
69 (:foreground (color :tag "Foreground"
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
70 :value ""
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
71 :help-echo "Set foreground color.")
199
169c0442b401 Import from CVS: tag r20-3b26
cvs
parents: 197
diff changeset
72 set-face-foreground face-foreground-name)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
73 (:background (color :tag "Background"
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
74 :value ""
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
75 :help-echo "Set background color.")
199
169c0442b401 Import from CVS: tag r20-3b26
cvs
parents: 197
diff changeset
76 set-face-background face-background-name)
169c0442b401 Import from CVS: tag r20-3b26
cvs
parents: 197
diff changeset
77 ;; (:inverse-video (boolean :tag "Inverse"
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
78 ;; :help-echo "\
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
79 ;;Control whether the text should be inverted.")
199
169c0442b401 Import from CVS: tag r20-3b26
cvs
parents: 197
diff changeset
80 ;; custom-inverse-face custom-face-inverse)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
81 (:stipple (editable-field :format "Stipple: %v"
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
82 :help-echo "Name of background bitmap file.")
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
83 set-face-background-pixmap custom-face-stipple)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
84 (:family (editable-field :format "Font Family: %v"
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
85 :help-echo "\
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
86 Name of font family to use (e.g. times).")
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
87 custom-set-face-font-family custom-face-font-family)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
88 (:size (editable-field :format "Size: %v"
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
89 :help-echo "\
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
90 Text size (e.g. 9pt or 2mm).")
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
91 custom-set-face-font-size custom-face-font-size)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
92 (:strikethru (toggle :format "%[Strikethru%]: %v\n"
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
93 :help-echo "\
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
94 Control whether the text should be strikethru.")
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
95 set-face-strikethru-p face-strikethru-p))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
96 "Alist of face attributes.
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
97
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
98 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
99 identifying the attribute, TYPE is a widget type for editing the
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
100 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
101
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
102 The SET function should take three arguments, the face to modify, the
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
103 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
104 be changed.
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
105
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
106 The GET function should take two arguments, the face to examine, and
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
107 optonally the frame where the face should be examined.")
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
108
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
109 (defun face-custom-attributes-set (face frame &rest atts)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
110 "For FACE on FRAME set the attributes [KEYWORD VALUE]....
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
111 Each keyword should be listed in `custom-face-attributes'.
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
112
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
113 If FRAME is nil, set the default face."
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
114 (while atts
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
115 (let* ((name (nth 0 atts))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
116 (value (nth 1 atts))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
117 (fun (nth 2 (assq name custom-face-attributes))))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
118 (setq atts (cdr (cdr atts)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
119 (condition-case nil
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
120 (funcall fun face value frame)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
121 (error nil)))))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
122
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
123 (defun face-custom-attributes-get (face frame)
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
124 "For FACE on FRAME get the attributes [KEYWORD VALUE]....
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
125 Each keyword should be listed in `custom-face-attributes'.
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
126
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
127 If FRAME is nil, use the default face."
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
128 (condition-case nil
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
129 ;; Attempt to get `font.el' from w3.
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
130 (require 'font)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
131 (error nil))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
132 (let ((atts custom-face-attributes)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
133 att result get)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
134 (while atts
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
135 (setq att (car atts)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
136 atts (cdr atts)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
137 get (nth 3 att))
161
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 157
diff changeset
138 (condition-case nil
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 157
diff changeset
139 ;; This may fail if w3 doesn't exists.
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
140 (when get
161
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 157
diff changeset
141 (let ((answer (funcall get face frame)))
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 157
diff changeset
142 (unless (equal answer (funcall get 'default frame))
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 157
diff changeset
143 (when (widget-apply (nth 1 att) :match answer)
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 157
diff changeset
144 (setq result (cons (nth 0 att) (cons answer result)))))))
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 157
diff changeset
145 (error nil)))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
146 result))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
147
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
148 (defun custom-set-face-bold (face value &optional frame)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
149 "Set the bold property of FACE to VALUE."
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
150 (if value
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
151 (make-face-bold face frame)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
152 (make-face-unbold face frame)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
153
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
154 ;; Really, we should get rid of these font.el dependencies... They
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
155 ;; are still presenting a problem with dumping the faces (font.el is
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
156 ;; too bloated for us to dump). I am thinking about hacking up
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
157 ;; font-like functionality myself for the sake of this file. It will
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
158 ;; probably be to-the-point and more efficient.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
159
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
160 (defun custom-face-bold (face &rest args)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
161 "Return non-nil if the font of FACE is bold."
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
162 (let* ((font (apply 'face-font-name face args))
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
163 ;; Gag
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
164 (fontobj (font-create-object font)))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
165 (font-bold-p fontobj)))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
166
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
167 (defun custom-set-face-italic (face value &optional frame)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
168 "Set the italic property of FACE to VALUE."
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
169 (if value
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
170 (make-face-italic face frame)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
171 (make-face-unitalic face frame)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
172
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
173 (defun custom-face-italic (face &rest args)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
174 "Return non-nil if the font of FACE is italic."
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
175 (let* ((font (apply 'face-font-name face args))
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
176 ;; Gag
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
177 (fontobj (font-create-object font)))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
178 (font-italic-p fontobj)))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
179
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
180 (defun custom-face-stipple (face &rest args)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
181 "Return the name of the stipple file used for FACE."
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
182 (let ((image (apply 'specifier-instance
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
183 (face-background-pixmap face) args)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
184 (and image
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
185 (image-instance-file-name image))))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
186
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
187 (defun custom-set-face-font-size (face size &rest args)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
188 "Set the font of FACE to SIZE"
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
189 (let* ((font (apply 'face-font-name face args))
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
190 ;; Gag
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
191 (fontobj (font-create-object font)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
192 (set-font-size fontobj size)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
193 (apply 'font-set-face-font face fontobj args)))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
194
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
195 (defun custom-face-font-size (face &rest args)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
196 "Return the size of the font of FACE as a string."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
197 (let* ((font (apply 'face-font-name face args))
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
198 ;; Gag
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
199 (fontobj (font-create-object font)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
200 (format "%s" (font-size fontobj))))
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
201
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
202 (defun custom-set-face-font-family (face family &rest args)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
203 "Set the font of FACE to FAMILY."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
204 (let* ((font (apply 'face-font-name face args))
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
205 ;; Gag
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
206 (fontobj (font-create-object font)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
207 (set-font-family fontobj family)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
208 (apply 'font-set-face-font face fontobj args)))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
209
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
210 (defun custom-face-font-family (face &rest args)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
211 "Return the name of the font family of FACE."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
212 (let* ((font (apply 'face-font-name face args))
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
213 ;; Gag
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
214 (fontobj (font-create-object font)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
215 (font-family fontobj)))
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
216
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
217 ;;(defun custom-reverse-face (face value &optional frame)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
218 ;; "Swap the foreground and background colors of face FACE.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
219 ;;If the colors are not specified in the face, use the default colors."
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
220 ;; (interactive (list (read-face-name "Reverse face: ")))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
221 ;; (when value
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
222 ;; (if (eq (frame-type) 'tty)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
223 ;; (set-face-reverse-p face value frame)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
224 ;; (let ((fg (face-foreground-instance face frame))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
225 ;; (bg (face-background-instance face frame)))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
226 ;; (set-face-foreground face bg frame)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
227 ;; (set-face-background face fg frame)))))
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
228
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
229 ;;(defun custom-face-reverse (face &optional frame)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
230 ;; "Returns non-nil if the face is reverse."
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
231 ;; (if (eq (frame-type) 'tty)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
232 ;; (face-reverse-p face frame)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
233 ;; ;;; ### Implement me
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
234 ;; ))
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
235
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
236 ;;; Initializing.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
237
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
238 ;;;###autoload
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
239 (defun custom-set-faces (&rest args)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
240 "Initialize faces according to user preferences.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
241 The arguments should be a list where each entry has the form:
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
242
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
243 (FACE SPEC [NOW])
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
244
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
245 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
246 and non-nil, FACE will also be created according to SPEC.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
247
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
248 See `defface' for the format of SPEC."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
249 (while args
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
250 (let ((entry (car args)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
251 (if (listp entry)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
252 (let ((face (nth 0 entry))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
253 (spec (nth 1 entry))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
254 (now (nth 2 entry)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
255 (put face 'saved-face spec)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
256 (when now
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
257 (put face 'force-face t))
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
258 (when (or now (find-face face))
199
169c0442b401 Import from CVS: tag r20-3b26
cvs
parents: 197
diff changeset
259 (unless (find-face face)
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 199
diff changeset
260 (make-empty-face face))
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
261 (face-spec-set face spec))
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
262 (setq args (cdr args)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
263 ;; Old format, a plist of FACE SPEC pairs.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
264 (let ((face (nth 0 args))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
265 (spec (nth 1 args)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
266 (put face 'saved-face spec))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
267 (setq args (cdr (cdr args)))))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
268
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
269 ;;; The End.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
270
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
271 (provide 'cus-face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
272
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
273 ;; cus-face.el ends here