annotate lisp/cus-face.el @ 398:74fd4e045ea6 r21-2-29

Import from CVS: tag r21-2-29
author cvs
date Mon, 13 Aug 2007 11:13:30 +0200
parents d883f39b8495
children 697ef44129c6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1 ;;; cus-face.el -- Support for Custom faces.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2 ;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3 ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
4 ;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
6 ;; Maintainer: Hrvoje Niksic <hniksic@xemacs.org>
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
7 ;; Keywords: help, faces
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
8 ;; Version: 1.9960-x
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
9 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
10
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
11 ;;; Commentary:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
12 ;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
13 ;; See `custom.el'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
14
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
15 ;; This file should probably be dissolved, and code moved to faces.el,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
16 ;; like Stallman did.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
17
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
18 ;;; Code:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
19
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
20 (require 'custom)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
21
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
22 ;; To elude the warnings for font functions.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
23 (eval-when-compile
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
24 (require 'font))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
25
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
26 ;;; Declaring a face.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
27
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
28 ;;;###autoload
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
29 (defun custom-declare-face (face spec doc &rest args)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
30 "Like `defface', but FACE is evaluated as a normal argument."
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 235
diff changeset
31 ;; (when (fboundp 'pureload)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
32 ;; (error "Attempt to declare a face during dump"))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
33 ;; #### should we possibly reset force-face here?
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
34 (unless (get face 'face-defface-spec)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
35 (put face 'face-defface-spec spec)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
36 (unless (find-face face)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
37 ;; If the user has already created the face, respect that.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
38 (let ((value (or (get face 'saved-face) spec))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
39 (frames (relevant-custom-frames))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
40 frame)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
41 ;; Create global face.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
42 (make-empty-face face)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
43 (face-display-set face value nil '(custom))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
44 ;; Create frame local faces
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
45 (while frames
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
46 (setq frame (car frames)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
47 frames (cdr frames))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
48 (face-display-set face value frame '(custom)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
49 (init-face-from-resources face)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
50 (when (and doc (null (face-doc-string face)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
51 (set-face-doc-string face doc))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
52 (custom-handle-all-keywords face args 'custom-face)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
53 (run-hooks 'custom-define-hook))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
54 face)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
55
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
56 ;;; Font Attributes.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
57
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
58 (defconst custom-face-attributes
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 267
diff changeset
59 '((:foreground (color :tag "Foreground"
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
60 :value ""
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
61 :help-echo "Set foreground color.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
62 set-face-foreground face-foreground-name)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
63 (:background (color :tag "Background"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
64 :value ""
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
65 :help-echo "Set background color.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
66 set-face-background face-background-name)
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 267
diff changeset
67 (:size (editable-field :format "Size: %v"
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 267
diff changeset
68 :help-echo "\
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 267
diff changeset
69 Text size (e.g. 9pt or 2mm).")
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 267
diff changeset
70 custom-set-face-font-size custom-face-font-size)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
71 (:family (editable-field :format "Font Family: %v"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
72 :help-echo "\
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
73 Name of font family to use (e.g. times).")
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
74 custom-set-face-font-family custom-face-font-family)
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
75 (:background-pixmap (editable-field :format "Background pixmap: %v"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
76 :help-echo "\
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
77 Name of background pixmap file.")
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
78 set-face-background-pixmap custom-face-background-pixmap)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
79 (:dim (toggle :format "%[Dim%]: %v\n"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
80 :help-echo "Control whether the text should be dimmed.")
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
81 set-face-dim-p face-dim-p)
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 267
diff changeset
82 (:bold (toggle :format "%[Bold%]: %v\n"
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 267
diff changeset
83 :help-echo "Control whether a bold font should be used.")
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 267
diff changeset
84 custom-set-face-bold custom-face-bold)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 267
diff changeset
85 (:italic (toggle :format "%[Italic%]: %v\n"
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 267
diff changeset
86 :help-echo "\
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 267
diff changeset
87 Control whether an italic font should be used.")
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 267
diff changeset
88 custom-set-face-italic custom-face-italic)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 267
diff changeset
89 (:underline (toggle :format "%[Underline%]: %v\n"
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 267
diff changeset
90 :help-echo "\
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 267
diff changeset
91 Control whether the text should be underlined.")
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 267
diff changeset
92 set-face-underline-p face-underline-p)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
93 (:strikethru (toggle :format "%[Strikethru%]: %v\n"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
94 :help-echo "\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
95 Control whether the text should be strikethru.")
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 267
diff changeset
96 set-face-strikethru-p face-strikethru-p)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 267
diff changeset
97 (:inverse-video (toggle :format "%[Inverse Video%]: %v\n"
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 267
diff changeset
98 :help-echo "\
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 267
diff changeset
99 Control whether the text should be inverted. Works only on TTY-s")
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 267
diff changeset
100 set-face-reverse-p face-reverse-p))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
101 "Alist of face attributes.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
102
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
103 The elements are of the form (KEY TYPE SET GET) where KEY is a symbol
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
104 identifying the attribute, TYPE is a widget type for editing the
371
cc15677e0335 Import from CVS: tag r21-2b1
cvs
parents: 367
diff changeset
105 attibute, SET is a function for setting the attribute value, and GET is a function for getiing the attribute value.
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
106
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
107 The SET function should take three arguments, the face to modify, the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
108 value of the attribute, and optionally the frame where the face should
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
109 be changed.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
110
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
111 The GET function should take two arguments, the face to examine, and
371
cc15677e0335 Import from CVS: tag r21-2b1
cvs
parents: 367
diff changeset
112 optonally the frame where the face should be examined.")
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
113
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
114 (defun face-custom-attributes-set (face frame tags &rest atts)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
115 "For FACE on FRAME set the attributes [KEYWORD VALUE]....
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
116 Each keyword should be listed in `custom-face-attributes'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
117
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
118 If FRAME is nil, set the default face."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
119 (while atts
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
120 (let* ((name (nth 0 atts))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
121 (value (nth 1 atts))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
122 (fun (nth 2 (assq name custom-face-attributes))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
123 (setq atts (cdr (cdr atts)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
124 (condition-case nil
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
125 (funcall fun face value frame tags)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
126 (error nil)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
127
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
128 (defun face-custom-attributes-get (face frame)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
129 "For FACE on FRAME get the attributes [KEYWORD VALUE]....
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
130 Each keyword should be listed in `custom-face-attributes'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
131
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
132 If FRAME is nil, use the default face."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
133 (condition-case nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
134 ;; Attempt to get `font.el' from w3.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
135 (require 'font)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
136 (error nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
137 (let ((atts custom-face-attributes)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
138 att result get)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
139 (while atts
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
140 (setq att (car atts)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
141 atts (cdr atts)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
142 get (nth 3 att))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
143 (condition-case nil
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 213
diff changeset
144 ;; This may fail if w3 doesn't exist.
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
145 (when get
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
146 (let ((answer (funcall get face frame)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
147 (unless (equal answer (funcall get 'default frame))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
148 (when (widget-apply (nth 1 att) :match answer)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
149 (setq result (cons (nth 0 att) (cons answer result)))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
150 (error nil)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
151 result))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
152
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
153 (defsubst custom-face-get-spec (symbol)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
154 (or (get symbol 'customized-face)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
155 (get symbol 'saved-face)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
156 (get symbol 'face-defface-spec)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
157 ;; Attempt to construct it.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
158 (list (list t (face-custom-attributes-get
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
159 symbol (selected-frame))))))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
160
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
161 (defun custom-set-face-bold (face value &optional frame tags)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
162 "Set the bold property of FACE to VALUE."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
163 (if value
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
164 (make-face-bold face frame tags)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
165 (make-face-unbold face frame tags)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
166
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
167 ;; Really, we should get rid of these font.el dependencies... They
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
168 ;; are still presenting a problem with dumping the faces (font.el is
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
169 ;; too bloated for us to dump). I am thinking about hacking up
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
170 ;; font-like functionality myself for the sake of this file. It will
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
171 ;; probably be to-the-point and more efficient.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
172
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
173 (defun custom-face-bold (face &rest args)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
174 "Return non-nil if the font of FACE is bold."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
175 (let* ((font (apply 'face-font-name face args))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
176 ;; Gag
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
177 (fontobj (font-create-object font)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
178 (font-bold-p fontobj)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
179
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
180 (defun custom-set-face-italic (face value &optional frame tags)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
181 "Set the italic property of FACE to VALUE."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
182 (if value
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
183 (make-face-italic face frame tags)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
184 (make-face-unitalic face frame tags)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
185
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
186 (defun custom-face-italic (face &rest args)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
187 "Return non-nil if the font of FACE is italic."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
188 (let* ((font (apply 'face-font-name face args))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
189 ;; Gag
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
190 (fontobj (font-create-object font)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
191 (font-italic-p fontobj)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
192
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
193 (defun custom-face-background-pixmap (face &rest args)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
194 "Return the name of the background pixmap file used for FACE."
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
195 (let ((image (apply 'specifier-instance
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
196 (face-background-pixmap face) args)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
197 (and image
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
198 (image-instance-file-name image))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
199
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
200 (defun custom-set-face-font-size (face size &optional locale tags)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
201 "Set the font of FACE to SIZE"
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
202 (let* ((font (apply 'face-font-name face locale))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
203 ;; Gag
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
204 (fontobj (font-create-object font)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
205 (set-font-size fontobj size)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
206 (apply 'font-set-face-font face fontobj locale tags)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
207
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
208 (defun custom-face-font-size (face &rest args)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
209 "Return the size of the font of FACE as a string."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
210 (let* ((font (apply 'face-font-name face args))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
211 ;; Gag
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
212 (fontobj (font-create-object font)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
213 (format "%s" (font-size fontobj))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
214
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
215 (defun custom-set-face-font-family (face family &optional locale tags)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
216 "Set the font of FACE to FAMILY."
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
217 (let* ((font (apply 'face-font-name face locale))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
218 ;; Gag
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
219 (fontobj (font-create-object font)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
220 (set-font-family fontobj family)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
221 (apply 'font-set-face-font face fontobj locale tags)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
222
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
223 (defun custom-face-font-family (face &rest args)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
224 "Return the name of the font family of FACE."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
225 (let* ((font (apply 'face-font-name face args))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
226 ;; Gag
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
227 (fontobj (font-create-object font)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
228 (font-family fontobj)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
229
377
d883f39b8495 Import from CVS: tag r21-2b4
cvs
parents: 373
diff changeset
230 ;;;###autoload
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
231 (defun custom-set-face-update-spec (face display plist)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
232 "Customize the FACE for display types matching DISPLAY, merging
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
233 in the new items from PLIST"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
234 (let ((spec (face-spec-update-all-matching (custom-face-get-spec face)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
235 display plist)))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
236 (put face 'customized-face spec)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
237 (face-spec-set face spec nil '(custom))))
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
238
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
239 ;;; Initializing.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
240
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
241 ;;;###autoload
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
242 (defun custom-set-faces (&rest args)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
243 "Initialize faces according to user preferences.
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
244 This asociates the setting with the USER theme.
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
245 The arguments should be a list where each entry has the form:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
246
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
247 (FACE SPEC [NOW [COMMENT]])
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
248
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
249 SPEC will be stored as the saved value for FACE. If NOW is present
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
250 and non-nil, FACE will also be created according to SPEC.
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
251 COMMENT is a string comment about FACE.
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
252
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
253 See `defface' for the format of SPEC."
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
254 (apply #'custom-theme-set-faces 'user args))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
255
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
256 ;;;###autoload
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
257 (defun custom-theme-set-faces (theme &rest args)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
258 "Initialize faces according to settings specified by args.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
259 Records the settings as belonging to THEME.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
260
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
261 See `custom-set-faces' for a description of the arguments ARGS."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
262 (custom-check-theme theme)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
263 (let ((immediate (get theme 'theme-immediate)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
264 (while args
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
265 (let ((entry (car args)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
266 (if (listp entry)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
267 (let ((face (nth 0 entry))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
268 (spec (nth 1 entry))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
269 (now (nth 2 entry))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
270 (comment (nth 3 entry)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
271 (put face 'saved-face spec)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
272 (custom-push-theme 'theme-face face theme 'set spec)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
273 (put face 'saved-face-comment comment)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
274 (when (or now immediate)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
275 (put face 'force-face (if now 'rogue 'immediate)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
276 (when (or now immediate (find-face face))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
277 (put face 'face-comment comment)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
278 (unless (find-face face)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
279 (make-empty-face face))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
280 (face-spec-set face spec nil '(custom)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
281 (setq args (cdr args)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
282 ;; Old format, a plist of FACE SPEC pairs.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
283 (let ((face (nth 0 args))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
284 (spec (nth 1 args)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
285 (put face 'saved-face spec)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
286 (custom-push-theme 'theme-face face theme 'set spec))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
287 (setq args (cdr (cdr args))))))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
288
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
289 ;;;###autoload
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
290 (defun custom-theme-face-value (face theme)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
291 "Return spec of FACE in THEME if the THEME modifies the
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
292 FACE. Nil otherwise."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
293 (car-safe (custom-theme-value theme (get face 'theme-face))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
294
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
295 (defun custom-theme-reset-internal-face (face to-theme)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
296 (let ((spec (custom-theme-face-value face to-theme))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
297 was-in-theme)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
298 (setq was-in-theme spec)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
299 (setq spec (or spec (get face 'standard-value)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
300 (when spec
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
301 (put face 'save-face was-in-theme)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
302 (when (or (get face 'force-face) (find-face face))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
303 (unless (find-face face)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
304 (make-empty-face face))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
305 (face-spec-set face spec)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
306 spec))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
307
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
308 ;;;###autoload
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
309 (defun custom-theme-reset-faces (theme &rest args)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
310 (custom-check-theme theme)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
311 "Reset the value of the face to values previously defined.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
312 Assosiate this setting with THEME.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
313
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
314 ARGS is a list of lists of the form
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
315
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
316 (face to-theme)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
317
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
318 This means reset face to its value in to-theme."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
319 (mapc #'(lambda (arg)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
320 (apply #'custom-theme-reset-internal-face arg)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
321 (custom-push-theme (car arg) 'theme-face theme 'reset (cadr arg)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
322 args))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
323
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
324 ;;;###autoload
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
325 (defun custom-reset-faces (&rest args)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
326 "Reset the value of the face to values previously defined.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
327 Assosiate this setting with the 'user' theme.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
328
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
329 ARGS is defined as for `custom-theme-reset-faces'"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
330 (apply #'custom-theme-reset-faces 'user args))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 377
diff changeset
331
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
332
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
333 ;;; The End.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
334
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
335 (provide 'cus-face)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
336
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
337 ;; cus-face.el ends here