annotate lisp/custom/cus-face.el @ 199:169c0442b401 r20-3b26

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