comparison lisp/cus-face.el @ 39607:dc8769075676

(custom-face-attributes): Make sure each attribute has a valid default value. Remove hacks that mapped `nil' to `off' and used nil to mean `unspecified'. Remove `unspecified' choices from all attributes (unspecified is handled by the parent checklist).
author Miles Bader <miles@gnu.org>
date Fri, 05 Oct 2001 13:04:26 +0000
parents b174db545cfd
children b1d6fcf67b85
comparison
equal deleted inserted replaced
39606:1b4259bc2f74 39607:dc8769075676
60 (run-hooks 'custom-define-hook)) 60 (run-hooks 'custom-define-hook))
61 face) 61 face)
62 62
63 ;;; Face attributes. 63 ;;; Face attributes.
64 64
65 ;; Below, nil is used in widget specifications for `unspecified' face
66 ;; attributes and `off' is used instead of nil attribute values. The
67 ;; reason for this is that nil corresponds to the result you get when
68 ;; looking up an attribute in a defface spec that isn't contained in
69 ;; the spec.
70
71 (defconst custom-face-attributes 65 (defconst custom-face-attributes
72 '((:family 66 '((:family
73 (choice :tag "Font family" 67 (string :tag "Font Family"
74 :help-echo "Font family or fontset alias name." 68 :help-echo "Font family or fontset alias name."))
75 (const :tag "*" nil)
76 (string :tag "Family")))
77 69
78 (:width 70 (:width
79 (choice :tag "Width" 71 (choice :tag "Width"
80 :help-echo "Font width." 72 :help-echo "Font width."
81 (const :tag "*" nil) 73 :value normal ; default
82 (const :tag "compressed" condensed) 74 (const :tag "compressed" condensed)
83 (const :tag "condensed" condensed) 75 (const :tag "condensed" condensed)
84 (const :tag "demiexpanded" semi-expanded) 76 (const :tag "demiexpanded" semi-expanded)
85 (const :tag "expanded" expanded) 77 (const :tag "expanded" expanded)
86 (const :tag "extracondensed" extra-condensed) 78 (const :tag "extracondensed" extra-condensed)
96 (const :tag "wide" extra-expanded))) 88 (const :tag "wide" extra-expanded)))
97 89
98 (:height 90 (:height
99 (choice :tag "Height" 91 (choice :tag "Height"
100 :help-echo "Face's font height." 92 :help-echo "Face's font height."
101 (const :tag "*" nil) 93 :value 1.0 ; default
102 (integer :tag "Height in 1/10 pt") 94 (integer :tag "Height in 1/10 pt")
103 (number :tag "Scale" 1.0))) 95 (number :tag "Scale" 1.0)))
104 96
105 (:weight 97 (:weight
106 (choice :tag "Weight" 98 (choice :tag "Weight"
107 :help-echo "Font weight." 99 :help-echo "Font weight."
108 (const :tag "*" nil) 100 :value normal ; default
109 (const :tag "black" ultra_bold) 101 (const :tag "black" ultra_bold)
110 (const :tag "bold" bold) 102 (const :tag "bold" bold)
111 (const :tag "book" semi-light) 103 (const :tag "book" semi-light)
112 (const :tag "demibold" semi-bold) 104 (const :tag "demibold" semi-bold)
113 (const :tag "extralight" extra-light) 105 (const :tag "extralight" extra-light)
123 (const :tag "ultrabold" ultra-bold))) 115 (const :tag "ultrabold" ultra-bold)))
124 116
125 (:slant 117 (:slant
126 (choice :tag "Slant" 118 (choice :tag "Slant"
127 :help-echo "Font slant." 119 :help-echo "Font slant."
128 (const :tag "*" nil) 120 :value normal ; default
129 (const :tag "italic" italic) 121 (const :tag "italic" italic)
130 (const :tag "oblique" oblique) 122 (const :tag "oblique" oblique)
131 (const :tag "normal" normal))) 123 (const :tag "normal" normal)))
132 124
133 (:underline 125 (:underline
134 (choice :tag "Underline" 126 (choice :tag "Underline"
135 :help-echo "Control text underlining." 127 :help-echo "Control text underlining."
136 (const :tag "*" nil) 128 (const :tag "Off" nil)
137 (const :tag "On" t) 129 (const :tag "On" t)
138 (const :tag "Off" off)
139 (color :tag "Colored"))) 130 (color :tag "Colored")))
140 131
141 (:overline 132 (:overline
142 (choice :tag "Overline" 133 (choice :tag "Overline"
143 :help-echo "Control text overlining." 134 :help-echo "Control text overlining."
144 (const :tag "*" nil) 135 (const :tag "Off" nil)
145 (const :tag "On" t) 136 (const :tag "On" t)
146 (const :tag "Off" off)
147 (color :tag "Colored"))) 137 (color :tag "Colored")))
148 138
149 (:strike-through 139 (:strike-through
150 (choice :tag "Strike-through" 140 (choice :tag "Strike-through"
151 :help-echo "Control text strike-through." 141 :help-echo "Control text strike-through."
152 (const :tag "*" nil) 142 (const :tag "Off" nil)
153 (const :tag "On" t) 143 (const :tag "On" t)
154 (const :tag "Off" off)
155 (color :tag "Colored"))) 144 (color :tag "Colored")))
156 145
157 (:box 146 (:box
158 ;; Fixme: this can probably be done better. 147 ;; Fixme: this can probably be done better.
159 (choice :tag "Box around text" 148 (choice :tag "Box around text"
160 :help-echo "Control box around text." 149 :help-echo "Control box around text."
161 (const :tag "*" nil) 150 (const :tag "Off" nil)
162 (const :tag "Off" off)
163 (list :tag "Box" 151 (list :tag "Box"
164 :value (:line-width 2 :color "grey75" :style released-button) 152 :value (:line-width 2 :color "grey75" :style released-button)
165 (const :format "" :value :line-width) 153 (const :format "" :value :line-width)
166 (integer :tag "Width") 154 (integer :tag "Width")
167 (const :format "" :value :color) 155 (const :format "" :value :color)
171 (const :tag "Raised" released-button) 159 (const :tag "Raised" released-button)
172 (const :tag "Sunken" pressed-button) 160 (const :tag "Sunken" pressed-button)
173 (const :tag "None" nil)))) 161 (const :tag "None" nil))))
174 ;; filter to make value suitable for customize 162 ;; filter to make value suitable for customize
175 (lambda (real-value) 163 (lambda (real-value)
176 (if (null real-value) 164 (and real-value
177 'off 165 (let ((lwidth
178 (let ((lwidth 166 (or (and (consp real-value)
179 (or (and (consp real-value) (plist-get real-value :line-width)) 167 (plist-get real-value :line-width))
180 (and (integerp real-value) real-value) 168 (and (integerp real-value) real-value)
181 1)) 169 1))
182 (color 170 (color
183 (or (and (consp real-value) (plist-get real-value :color)) 171 (or (and (consp real-value) (plist-get real-value :color))
184 (and (stringp real-value) real-value) 172 (and (stringp real-value) real-value)
185 nil)) 173 nil))
186 (style 174 (style
187 (and (consp real-value) (plist-get real-value :style)))) 175 (and (consp real-value) (plist-get real-value :style))))
188 (list :line-width lwidth :color color :style style)))) 176 (list :line-width lwidth :color color :style style))))
189 ;; filter to make customized-value suitable for storing 177 ;; filter to make customized-value suitable for storing
190 (lambda (cus-value) 178 (lambda (cus-value)
191 (cond ((null cus-value) 179 (and cus-value
192 'unspecified) 180 (let ((lwidth (plist-get cus-value :line-width))
193 ((eq cus-value 'off) 181 (color (plist-get cus-value :color))
194 nil) 182 (style (plist-get cus-value :style)))
195 (t 183 (cond ((and (null color) (null style))
196 (let ((lwidth (plist-get cus-value :line-width)) 184 lwidth)
197 (color (plist-get cus-value :color)) 185 ((and (null lwidth) (null style))
198 (style (plist-get cus-value :style))) 186 ;; actually can't happen, because LWIDTH is always an int
199 (cond ((and (null color) (null style)) 187 color)
200 lwidth) 188 (t
201 ((and (null lwidth) (null style)) 189 ;; Keep as a plist, but remove null entries
202 ;; actually can't happen, because LWIDTH is always an int 190 (nconc (and lwidth `(:line-width ,lwidth))
203 color) 191 (and color `(:color ,color))
204 (t 192 (and style `(:style ,style)))))))))
205 ;; Keep as a plist, but remove null entries
206 (nconc (and lwidth `(:line-width ,lwidth))
207 (and color `(:color ,color))
208 (and style `(:style ,style))))))))))
209 193
210 (:inverse-video 194 (:inverse-video
211 (choice :tag "Inverse-video" 195 (choice :tag "Inverse-video"
212 :help-echo "Control whether text should be in inverse-video." 196 :help-echo "Control whether text should be in inverse-video."
213 (const :tag "*" nil) 197 (const :tag "Off" nil)
214 (const :tag "On" t) 198 (const :tag "On" t)))
215 (const :tag "Off" off)))
216 199
217 (:foreground 200 (:foreground
218 (choice :tag "Foreground" 201 (color :tag "Foreground"
219 :help-echo "Set foreground color." 202 :help-echo "Set foreground color."))
220 (const :tag "*" nil)
221 (color :tag "Color")))
222 203
223 (:background 204 (:background
224 (choice :tag "Background" 205 (color :tag "Background"
225 :help-echo "Set background color." 206 :help-echo "Set background color."))
226 (const :tag "*" nil)
227 (color :tag "Color")))
228 207
229 (:stipple 208 (:stipple
230 (choice :tag "Stipple" 209 (choice :tag "Stipple"
231 :help-echo "Background bit-mask" 210 :help-echo "Background bit-mask"
232 (const :tag "*" nil) 211 (const :tag "None" nil)
233 (const :tag "None" off)
234 (file :tag "File" 212 (file :tag "File"
235 :help-echo "Name of bitmap file." 213 :help-echo "Name of bitmap file."
236 :must-match t))) 214 :must-match t)))
237 215
238 (:inherit 216 (:inherit