Mercurial > emacs
comparison lisp/cus-face.el @ 25684:e3ed0e86532c
(custom-face-attributes): Simplify :underline, :overline,
:inverse-video cases. Fix up :box case (probably needs more work).
Change from Didier Verna:
(custom-set-faces): The arguments can now have a custom comment as
fourth argument.
author | Dave Love <fx@gnu.org> |
---|---|
date | Mon, 13 Sep 1999 13:09:30 +0000 |
parents | 1553432b90d5 |
children | 3251a6750150 |
comparison
equal
deleted
inserted
replaced
25683:d1179efb4e87 | 25684:e3ed0e86532c |
---|---|
1 ;;; cus-face.el -- customization support for faces. | 1 ;;; cus-face.el -- customization support for faces. |
2 ;; | 2 ;; |
3 ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc. |
4 ;; | 4 ;; |
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk> | 5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk> |
6 ;; Keywords: help, faces | 6 ;; Keywords: help, faces |
7 ;; Version: Emacs | 7 ;; Version: Emacs |
8 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/ | 8 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/ (probably obsolete) |
9 | 9 |
10 ;; This file is part of GNU Emacs. | 10 ;; This file is part of GNU Emacs. |
11 | 11 |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | 12 ;; GNU Emacs is free software; you can redistribute it and/or modify |
13 ;; it under the terms of the GNU General Public License as published by | 13 ;; it under the terms of the GNU General Public License as published by |
166 (cond ((eq value 'off) (setq value nil)) | 166 (cond ((eq value 'off) (setq value nil)) |
167 ((null value) (setq value 'unspecified))) | 167 ((null value) (setq value 'unspecified))) |
168 (set-face-attribute face frame :underline value)) | 168 (set-face-attribute face frame :underline value)) |
169 (lambda (face &optional frame) | 169 (lambda (face &optional frame) |
170 (let ((underline (face-attribute face :underline frame))) | 170 (let ((underline (face-attribute face :underline frame))) |
171 (cond ((eq underline 'unspecified) (setq underline nil)) | 171 (cond ((eq underline 'unspecified) nil) |
172 ((null underline) (setq underline 'off))) | 172 ((null underline) 'off))))) |
173 underline))) | |
174 | 173 |
175 (:overline | 174 (:overline |
176 (choice :tag "Overline" | 175 (choice :tag "Overline" |
177 :help-echo "Control text overlining." | 176 :help-echo "Control text overlining." |
178 (const :tag "*" nil) | 177 (const :tag "*" nil) |
183 (cond ((eq value 'off) (setq value nil)) | 182 (cond ((eq value 'off) (setq value nil)) |
184 ((null value) (setq value 'unspecified))) | 183 ((null value) (setq value 'unspecified))) |
185 (set-face-attribute face frame :overline value)) | 184 (set-face-attribute face frame :overline value)) |
186 (lambda (face &optional frame) | 185 (lambda (face &optional frame) |
187 (let ((overline (face-attribute face :overline frame))) | 186 (let ((overline (face-attribute face :overline frame))) |
188 (cond ((eq overline 'unspecified) (setq overline nil)) | 187 (cond ((eq overline 'unspecified) nil) |
189 ((null overline) (setq overline 'off))) | 188 ((null overline) 'off))))) |
190 overline))) | |
191 | 189 |
192 (:strike-through | 190 (:strike-through |
193 (choice :tag "Strike-through" | 191 (choice :tag "Strike-through" |
194 :help-echo "Control text strike-through." | 192 :help-echo "Control text strike-through." |
195 (const :tag "*" nil) | 193 (const :tag "*" nil) |
205 (cond ((eq value 'unspecified) (setq value nil)) | 203 (cond ((eq value 'unspecified) (setq value nil)) |
206 ((null value) (setq value 'off))) | 204 ((null value) (setq value 'off))) |
207 value))) | 205 value))) |
208 | 206 |
209 (:box | 207 (:box |
208 ;; Fixme: this can probably be done better. | |
210 (choice :tag "Box around text" | 209 (choice :tag "Box around text" |
211 :help-echo "Control box around text." | 210 :help-echo "Control box around text." |
212 (const :tag "*" nil) | 211 (const :tag "*" t) |
213 (const :tag "Off" off) | 212 (const :tag "Off" nil) |
214 (list :tag "Box" | 213 (list :tag "Box" |
215 :value (1 "black" nil) | 214 :value (:line-width 2 :color "grey75" |
215 :style released-button) | |
216 (const :format "" :value :line-width) | |
216 (integer :tag "Width") | 217 (integer :tag "Width") |
217 (color :tag "Color") | 218 (const :format "" :value :color) |
218 (choice :tag "Shadows" | 219 (choice :tag "Color" (const :tag "*" nil) color) |
219 (const :tag "None" nil) | 220 (const :format "" :value :style) |
220 (const :tag "Raised" raised) | 221 (choice :tag "Style" |
221 (const :tag "Sunken" sunken)))) | 222 (const :tag "Raised" released-button) |
222 (lambda (face value &optional frame) | 223 (const :tag "Sunken" pressed-button) |
223 (cond ((consp value) | 224 (const :tag "None" nil)))) |
224 (let ((width (nth 0 value)) | 225 (lambda (face value &optional frame) |
225 (color (nth 1 value)) | |
226 (shadow (nth 2 value))) | |
227 (setq value (list :width width :color color :shadow shadow)))) | |
228 ((eq value 'off) | |
229 (setq value nil)) | |
230 ((null value) | |
231 (setq value 'unspecified))) | |
232 (set-face-attribute face frame :box value)) | 226 (set-face-attribute face frame :box value)) |
233 (lambda (face &optional frame) | 227 (lambda (face &optional frame) |
234 (let ((value (face-attribute face :box frame))) | 228 (let ((value (face-attribute face :box frame))) |
235 (cond ((consp value) | 229 (if (consp value) |
236 (let ((width (plist-get value :width)) | 230 (list :line-width (or (plist-get value :line-width) 1) |
237 (color (plist-get value :color)) | 231 :color (plist-get value :color) |
238 (shadow (plist-get value :shadow))) | 232 :style (plist-get value :style)) |
239 (setq value (list width color shadow)))) | 233 value)))) |
240 ((eq value 'unspecified) | |
241 (setq value nil)) | |
242 ((null value) | |
243 (setq value 'off))) | |
244 value))) | |
245 | 234 |
246 (:inverse-video | 235 (:inverse-video |
247 (choice :tag "Inverse-video" | 236 (choice :tag "Inverse-video" |
248 :help-echo "Control whether text should be in inverse-video." | 237 :help-echo "Control whether text should be in inverse-video." |
249 (const :tag "*" nil) | 238 (const :tag "*" nil) |
253 (cond ((eq value 'off) (setq value nil)) | 242 (cond ((eq value 'off) (setq value nil)) |
254 ((null value) (setq value 'unspecified))) | 243 ((null value) (setq value 'unspecified))) |
255 (set-face-attribute face frame :inverse-video value)) | 244 (set-face-attribute face frame :inverse-video value)) |
256 (lambda (face &optional frame) | 245 (lambda (face &optional frame) |
257 (let ((value (face-attribute face :inverse-video frame))) | 246 (let ((value (face-attribute face :inverse-video frame))) |
258 (cond ((eq value 'unspecified) (setq value nil)) | 247 (cond ((eq value 'unspecified) |
259 ((null value) (setq value 'off))) | 248 nil) |
260 value))) | 249 ((null value)'off))))) |
261 | 250 |
262 (:foreground | 251 (:foreground |
263 (choice :tag "Foreground" | 252 (choice :tag "Foreground" |
264 :help-echo "Set foreground color." | 253 :help-echo "Set foreground color." |
265 (const :tag "*" nil) | 254 (const :tag "*" nil) |
328 ;;;###autoload | 317 ;;;###autoload |
329 (defun custom-set-faces (&rest args) | 318 (defun custom-set-faces (&rest args) |
330 "Initialize faces according to user preferences. | 319 "Initialize faces according to user preferences. |
331 The arguments should be a list where each entry has the form: | 320 The arguments should be a list where each entry has the form: |
332 | 321 |
333 (FACE SPEC [NOW]) | 322 (FACE SPEC [NOW [COMMENT]]) |
334 | 323 |
335 SPEC is stored as the saved value for FACE. | 324 SPEC is stored as the saved value for FACE. |
336 If NOW is present and non-nil, FACE is created now, according to SPEC. | 325 If NOW is present and non-nil, FACE is created now, according to SPEC. |
326 COMMENT is a string comment about FACE. | |
337 | 327 |
338 See `defface' for the format of SPEC." | 328 See `defface' for the format of SPEC." |
339 (while args | 329 (while args |
340 (let ((entry (car args))) | 330 (let ((entry (car args))) |
341 (if (listp entry) | 331 (if (listp entry) |
342 (let ((face (nth 0 entry)) | 332 (let ((face (nth 0 entry)) |
343 (spec (nth 1 entry)) | 333 (spec (nth 1 entry)) |
344 (now (nth 2 entry))) | 334 (now (nth 2 entry)) |
335 (comment (nth 3 entry))) | |
345 (put face 'saved-face spec) | 336 (put face 'saved-face spec) |
337 (put face 'saved-face-comment comment) | |
346 (when now | 338 (when now |
347 (put face 'force-face t)) | 339 (put face 'force-face t)) |
348 (when (or now (facep face)) | 340 (when (or now (facep face)) |
341 (put face 'face-comment comment) | |
349 (make-empty-face face) | 342 (make-empty-face face) |
350 (face-spec-set face spec)) | 343 (face-spec-set face spec)) |
351 (setq args (cdr args))) | 344 (setq args (cdr args))) |
352 ;; Old format, a plist of FACE SPEC pairs. | 345 ;; Old format, a plist of FACE SPEC pairs. |
353 (let ((face (nth 0 args)) | 346 (let ((face (nth 0 args)) |
357 | 350 |
358 ;;; The End. | 351 ;;; The End. |
359 | 352 |
360 (provide 'cus-face) | 353 (provide 'cus-face) |
361 | 354 |
362 ;; cus-face.el ends here | 355 ;;; cus-face.el ends here |