comparison lisp/cus-face.el @ 3027:7efd3a9bbcfb

[xemacs-hg @ 2005-10-25 11:28:23 by ben] support :inherit in cus-face and face cus-face.el, faces.el: Provide a basic implementation of the `inherit' property for faces and the :inherit property in custom. Use the new `specifier-instantiator' function. Update the documentation for various places in faces.el. 'foo -> `foo'.
author ben
date Tue, 25 Oct 2005 11:28:24 +0000
parents 943eaba38521
children 1c2a46ea1f78
comparison
equal deleted inserted replaced
3026:beef0f850624 3027:7efd3a9bbcfb
6 ;; Maintainer: Hrvoje Niksic <hniksic@xemacs.org> 6 ;; Maintainer: Hrvoje Niksic <hniksic@xemacs.org>
7 ;; Keywords: help, faces 7 ;; Keywords: help, faces
8 ;; Version: 1.9960-x 8 ;; Version: 1.9960-x
9 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/ 9 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/
10 10
11 ;;; Synched with: Not synched.
12
11 ;;; Commentary: 13 ;;; Commentary:
12 ;; 14 ;;
13 ;; See `custom.el'. 15 ;; See `custom.el'.
14
15 ;; This file should probably be dissolved, and code moved to faces.el,
16 ;; like Stallman did.
17 16
18 ;;; Code: 17 ;;; Code:
19 18
20 ;; it is now safe to put the `provide' anywhere. if an error occurs while 19 ;; it is now safe to put the `provide' anywhere. if an error occurs while
21 ;; loading, all provides (and fsets) will be undone. put it first to 20 ;; loading, all provides (and fsets) will be undone. put it first to
100 Control whether the text should be strikethru.") 99 Control whether the text should be strikethru.")
101 set-face-strikethru-p face-strikethru-p) 100 set-face-strikethru-p face-strikethru-p)
102 (:inverse-video (toggle :format "%[Inverse Video%]: %v\n" 101 (:inverse-video (toggle :format "%[Inverse Video%]: %v\n"
103 :help-echo "\ 102 :help-echo "\
104 Control whether the text should be inverted. Works only on TTY-s") 103 Control whether the text should be inverted. Works only on TTY-s")
105 set-face-reverse-p face-reverse-p)) 104 set-face-reverse-p face-reverse-p)
105 (:inherit
106 (repeat :tag "Inherit"
107 :help-echo "List of faces to inherit attributes from."
108 (face :Tag "Face" default))
109 ;; FSF 21.3
110 ; ;; filter to make value suitable for customize
111 ; (lambda (real-value)
112 ; (cond ((or (null real-value) (eq real-value 'unspecified))
113 ; nil)
114 ; ((symbolp real-value)
115 ; (list real-value))
116 ; (t
117 ; real-value)))
118 ; ;; filter to make customized-value suitable for storing
119 ; (lambda (cus-value)
120 ; (if (and (consp cus-value) (null (cdr cus-value)))
121 ; (car cus-value)
122 ; cus-value))
123 custom-set-face-inherit custom-face-inherit))
106 "Alist of face attributes. 124 "Alist of face attributes.
107 125
108 The elements are lists of the form (KEY TYPE SET GET) where: 126 The elements are lists of the form (KEY TYPE SET GET) where:
109 KEY is a symbol identifying the attribute. 127 KEY is a symbol identifying the attribute.
110 TYPE is a widget type for editing the attribute. 128 TYPE is a widget type for editing the attribute.
197 (fontobj (font-create-object font))) 215 (fontobj (font-create-object font)))
198 (font-italic-p fontobj))) 216 (font-italic-p fontobj)))
199 217
200 (defun custom-face-background-pixmap (face &rest args) 218 (defun custom-face-background-pixmap (face &rest args)
201 "Return the name of the background pixmap file used for FACE." 219 "Return the name of the background pixmap file used for FACE."
202 (let ((image (apply 'specifier-instance 220 (let ((image (apply 'specifier-instance
203 (face-background-pixmap face) args))) 221 (face-background-pixmap face) args)))
204 (and image 222 (and image
205 (image-instance-file-name image)))) 223 (image-instance-file-name image))))
224
225 (defun custom-set-face-inherit (face value &optional frame tags)
226 "Set FACE to inherit its properties from another face."
227 (if (listp value) (setq value (car value))) ;; #### Temporary hack!
228 (if (find-face value)
229 (set-face-parent face value frame tags)))
230
231 (defun custom-face-inherit (face &rest args)
232 "Return the value (instance) of the `inherit' property for FACE."
233 ;; #### Major, temporary hack!
234 (let ((spec (apply 'specifier-instantiator
235 (face-font face) args)))
236 (and spec (vector spec) (aref spec 0))))
206 237
207 ;; This consistently fails to dtrt 238 ;; This consistently fails to dtrt
208 ;;(defun custom-set-face-font-size (face size &optional locale tags) 239 ;;(defun custom-set-face-font-size (face size &optional locale tags)
209 ;; "Set the font of FACE to SIZE." 240 ;; "Set the font of FACE to SIZE."
210 ;; ;; #### should this call have tags in it? 241 ;; ;; #### should this call have tags in it?