annotate lisp/custom/cus-face.el @ 195:a2f645c6b9f8 r20-3b24

Import from CVS: tag r20-3b24
author cvs
date Mon, 13 Aug 2007 09:59:05 +0200
parents f53b5ca2e663
children acd284d43ca1
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
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
26 ;;;###autoload
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
27 (defcustom frame-background-mode nil
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
28 "*The brightness of the background.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
29 Set this to the symbol dark if your background color is dark, light if
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
30 your background is light, or nil (default) if you want Emacs to
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
31 examine the brightness for you."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
32 :group 'faces
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
33 :type '(choice (choice-item dark)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
34 (choice-item light)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
35 (choice-item :tag "Auto" nil)))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
36
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
37
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
38 ;; Originally, this did much more stuff, and cached the results. The
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
39 ;; trouble is that, if user changes the bg color of a frame's default
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
40 ;; face, the cache wouldn't get updated. This version should be fast
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
41 ;; enough for use without caching, I think.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
42 (defun get-frame-background-mode (frame)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
43 "Detect background mode for FRAME."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
44 (let* ((color-instance (face-background-instance 'default frame))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
45 (mode (condition-case nil
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
46 (if (< (apply '+ (color-instance-rgb-components
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
47 color-instance)) 65536)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
48 'dark
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
49 'light)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
50 ;; We'll get an error on a TTY; TTY-s are generally dark.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
51 (error 'dark))))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
52 ;(set-frame-property 'background-mode mode)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
53 mode))
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
54
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
55 ;;;###autoload
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
56 (defcustom initialize-face-resources t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
57 "If non nil, allow X resources to initialize face properties.
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
58 This only affects faces declared with `defface', and only X11 frames."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
59 :group 'faces
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
60 :type 'boolean)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
61
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
62 (defun initialize-face-resources (face &optional frame)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
63 "Initialize face according to the X11 resources.
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
64 This might overwrite existing face properties.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
65 Does nothing when the variable initialize-face-resources is nil."
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
66 (when initialize-face-resources
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
67 (make-face-x-resource-internal face frame t)))
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
68
36
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
69 ;;(if (string-match "XEmacs" emacs-version)
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
70 ;; ;; Xemacs.
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
71 ;; (defun custom-invert-face (face &optional frame)
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
72 ;; "Swap the foreground and background colors of face FACE.
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
73 ;;If the colors are not specified in the face, use the default colors."
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
74 ;; (interactive (list (read-face-name "Reverse face: ")))
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
75 ;; (let ((fg (color-name (face-foreground face frame) frame))
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
76 ;; (bg (color-name (face-background face frame) frame)))
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
77 ;; (set-face-foreground face bg frame)
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
78 ;; (set-face-background face fg frame)))
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
79 ;; ;; Emacs.
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
80 ;; (defun custom-invert-face (face &optional frame)
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
81 ;; "Swap the foreground and background colors of face FACE.
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
82 ;;If the colors are not specified in the face, use the default colors."
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
83 ;; (interactive (list (read-face-name "Reverse face: ")))
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
84 ;; (let ((fg (or (face-foreground face frame)
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
85 ;; (face-foreground 'default frame)
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
86 ;; (frame-property (or frame (selected-frame))
36
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
87 ;; 'foreground-color)
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
88 ;; "black"))
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
89 ;; (bg (or (face-background face frame)
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
90 ;; (face-background 'default frame)
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
91 ;; (frame-property (or frame (selected-frame))
36
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
92 ;; 'background-color)
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
93 ;; "white")))
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
94 ;; (set-face-foreground face bg frame)
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
95 ;; (set-face-background face fg frame))))
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
96
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
97 (defun custom-extract-frame-properties (frame)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
98 "Return a plist with the frame properties of FRAME used by custom."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
99 (list 'type (device-type (frame-device frame))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
100 'class (device-class (frame-device frame))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
101 'background (or frame-background-mode
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
102 (frame-property frame 'background-mode)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
103 (get-frame-background-mode frame))))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
104
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
105 ;;; Declaring a face.
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
106
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
107 ;;;###autoload
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
108 (defun custom-declare-face (face spec doc &rest args)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
109 "Like `defface', but FACE is evaluated as a normal argument."
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
110 (when (fboundp 'load-gc)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
111 ;; This should be allowed, using specifiers.
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
112 (error "Attempt to declare a face during dump"))
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
113 (unless (get face 'face-defface-spec)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
114 (put face 'face-defface-spec spec)
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
115 (unless (find-face face)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
116 ;; If the user has already created the face, respect that.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
117 (let ((value (or (get face 'saved-face) spec))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
118 (frames (custom-relevant-frames))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
119 frame)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
120 ;; Create global face.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
121 (make-empty-face face)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
122 (custom-face-display-set face value)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
123 ;; Create frame local faces
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
124 (while frames
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
125 (setq frame (car frames)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
126 frames (cdr frames))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
127 (custom-face-display-set face value frame))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
128 (initialize-face-resources face)))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
129 (when (and doc (null (face-doc-string face)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
130 (set-face-doc-string face doc))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
131 (custom-handle-all-keywords face args 'custom-face)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
132 (run-hooks 'custom-define-hook))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
133 face)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
134
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
135 (defun custom-face-background (face &optional frame)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
136 "Return the background color name of face FACE, or nil if unspecified."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
137 (color-instance-name (specifier-instance (face-background face) frame)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
138
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
139 (defun custom-face-foreground (face &optional frame)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
140 "Return the background color name of face FACE, or nil if unspecified."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
141 (color-instance-name (specifier-instance (face-foreground face) frame)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
142
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
143 ;;; Font Attributes.
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
144
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
145 (defconst custom-face-attributes
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 161
diff changeset
146 '((:bold (boolean :tag "Bold"
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 161
diff changeset
147 :help-echo "Control whether a bold font should be used.")
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
148 custom-set-face-bold
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
149 custom-face-bold)
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 161
diff changeset
150 (:italic (boolean :tag "Italic"
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 161
diff changeset
151 :help-echo "\
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
152 Control whether an italic font should be used.")
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
153 custom-set-face-italic
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
154 custom-face-italic)
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 161
diff changeset
155 (:underline (boolean :tag "Underline"
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 161
diff changeset
156 :help-echo "\
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
157 Control whether the text should be underlined.")
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
158 set-face-underline-p
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
159 face-underline-p)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
160 (:foreground (color :tag "Foreground"
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
161 :value ""
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
162 :help-echo "Set foreground color.")
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
163 set-face-foreground
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
164 custom-face-foreground)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
165 (:background (color :tag "Background"
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
166 :value ""
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
167 :help-echo "Set background color.")
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
168 set-face-background
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
169 custom-face-background)
36
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
170 ;; (:invert (const :format "Invert Face\n"
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
171 ;; :sibling-args (:help-echo "
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
172 ;;Reverse the foreground and background color.
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
173 ;;If you haven't specified them for the face, the default colors will be used.")
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
174 ;; t)
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
175 ;; (lambda (face value &optional frame)
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
176 ;; ;; We don't use VALUE.
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
177 ;; (custom-invert-face face frame)))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
178 (:stipple (editable-field :format "Stipple: %v"
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
179 :help-echo "Name of background bitmap file.")
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
180 set-face-stipple custom-face-stipple))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
181 "Alist of face attributes.
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
182
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
183 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
184 identifying the attribute, TYPE is a widget type for editing the
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
185 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
186
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
187 The SET function should take three arguments, the face to modify, the
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
188 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
189 be changed.
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
190
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
191 The GET function should take two arguments, the face to examine, and
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
192 optonally the frame where the face should be examined.")
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
193
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
194 (defun custom-face-attributes-set (face frame &rest atts)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
195 "For FACE on FRAME set the attributes [KEYWORD VALUE]....
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
196 Each keyword should be listed in `custom-face-attributes'.
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
197
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
198 If FRAME is nil, set the default face."
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
199 (while atts
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
200 (let* ((name (nth 0 atts))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
201 (value (nth 1 atts))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
202 (fun (nth 2 (assq name custom-face-attributes))))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
203 (setq atts (cdr (cdr atts)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
204 (condition-case nil
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
205 (funcall fun face value frame)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
206 (error nil)))))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
207
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
208 (defun custom-face-attributes-get (face frame)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
209 "For FACE on FRAME get the attributes [KEYWORD VALUE]....
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
210 Each keyword should be listed in `custom-face-attributes'.
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
211
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
212 If FRAME is nil, use the default face."
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
213 (condition-case nil
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
214 ;; Attempt to get `font.el' from w3.
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
215 (require 'font)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
216 (error nil))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
217 (let ((atts custom-face-attributes)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
218 att result get)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
219 (while atts
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
220 (setq att (car atts)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
221 atts (cdr atts)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
222 get (nth 3 att))
161
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 157
diff changeset
223 (condition-case nil
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 157
diff changeset
224 ;; This may fail if w3 doesn't exists.
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
225 (when get
161
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 157
diff changeset
226 (let ((answer (funcall get face frame)))
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 157
diff changeset
227 (unless (equal answer (funcall get 'default frame))
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 157
diff changeset
228 (when (widget-apply (nth 1 att) :match answer)
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 157
diff changeset
229 (setq result (cons (nth 0 att) (cons answer result)))))))
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 157
diff changeset
230 (error nil)))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
231 result))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
232
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
233 (defun custom-set-face-bold (face value &optional frame)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
234 "Set the bold property of FACE to VALUE."
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
235 (if value
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
236 (make-face-bold face frame)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
237 (make-face-unbold face frame)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
238
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
239 (defun custom-face-bold (face &rest args)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
240 "Return non-nil if the font of FACE is bold."
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
241 (let* ((font (apply 'face-font-name face args))
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
242 (fontobj (font-create-object font)))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
243 (font-bold-p fontobj)))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
244
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
245 (defun custom-set-face-italic (face value &optional frame)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
246 "Set the italic property of FACE to VALUE."
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
247 (if value
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
248 (make-face-italic face frame)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
249 (make-face-unitalic face frame)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
250
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
251 (defun custom-face-italic (face &rest args)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
252 "Return non-nil if the font of FACE is italic."
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
253 (let* ((font (apply 'face-font-name face args))
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
254 (fontobj (font-create-object font)))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
255 (font-italic-p fontobj)))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
256
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
257 (defun custom-face-stipple (face &rest args)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
258 "Return the name of the stipple file used for FACE."
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
259 (let ((image (apply 'specifier-instance
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
260 (face-background-pixmap face) args)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
261 (and image
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
262 (image-instance-file-name image))))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
263
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
264 (defun custom-set-face-font-size (face size &rest args)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
265 "Set the font of FACE to SIZE"
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
266 (let* ((font (apply 'face-font-name face args))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
267 (fontobj (font-create-object font)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
268 (set-font-size fontobj size)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
269 (apply 'font-set-face-font face fontobj args)))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
270
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
271 (defun custom-face-font-size (face &rest args)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
272 "Return the size of the font of FACE as a string."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
273 (let* ((font (apply 'face-font-name face args))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
274 (fontobj (font-create-object font)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
275 (format "%s" (font-size fontobj))))
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
276
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
277 (defun custom-set-face-font-family (face family &rest args)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
278 "Set the font of FACE to FAMILY."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
279 (let* ((font (apply 'face-font-name face args))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
280 (fontobj (font-create-object font)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
281 (set-font-family fontobj family)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
282 (apply 'font-set-face-font face fontobj args)))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
283
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
284 (defun custom-face-font-family (face &rest args)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
285 "Return the name of the font family of FACE."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
286 (let* ((font (apply 'face-font-name face args))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
287 (fontobj (font-create-object font)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
288 (font-family fontobj)))
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
289
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
290 (setq custom-face-attributes
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
291 (append '((:family (editable-field :format "Font Family: %v"
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
292 :help-echo "\
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
293 Name of font family to use (e.g. times).")
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
294 custom-set-face-font-family
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
295 custom-face-font-family)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
296 (:size (editable-field :format "Size: %v"
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
297 :help-echo "\
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
298 Text size (e.g. 9pt or 2mm).")
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
299 custom-set-face-font-size
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
300 custom-face-font-size)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
301 (:strikethru (toggle :format "%[Strikethru%]: %v\n"
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
302 :help-echo "\
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
303 Control whether the text should be strikethru.")
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
304 set-face-strikethru-p
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
305 face-strikethru-p))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
306 custom-face-attributes))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
307 ;;; Frames.
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
308
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
309 (defun face-spec-set (face spec &optional frame)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
310 "Set FACE to the attributes to the first matching entry in SPEC.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
311 Iff optional FRAME is non-nil, set it for that frame only.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
312 See `defface' for information about SPEC.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
313
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
314 Clear all existing attributes first."
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
315 (copy-face 'custom-face-empty face frame)
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
316 (custom-face-display-set face spec frame))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
317
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
318 (defun custom-face-display-set (face spec &optional frame)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
319 "Set FACE to the attributes to the first matching entry in SPEC.
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
320 Iff optional FRAME is non-nil, set it for that frame only.
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
321 See `defface' for information about SPEC."
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
322 (while spec
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
323 (let* ((entry (car spec))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
324 (display (nth 0 entry))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
325 (atts (nth 1 entry)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
326 (setq spec (cdr spec))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
327 (when (face-spec-set-match-display display frame)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
328 ;; Avoid creating frame local duplicates of the global face.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
329 (unless (and frame (eq display (get face 'custom-face-display)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
330 (apply 'custom-face-attributes-set face frame atts))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
331 (unless frame
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
332 (put face 'custom-face-display display))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
333 (setq spec nil)))))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
334
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
335 (defvar custom-default-frame-properties nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
336 "The frame properties used for the global faces.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
337 Frames who doesn't match these propertiess should have frame local faces.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
338 The value should be nil, if uninitialized, or a plist otherwise.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
339 See `defface' for a list of valid keys and values for the plist.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
340
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
341 (defun custom-get-frame-properties (&optional frame)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
342 "Return a plist with the frame properties of FRAME used by custom.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
343 If FRAME is nil, return the default frame properties."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
344 (cond (frame
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
345 ;; Try to get from cache.
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
346 (let ((cache (frame-property frame 'custom-properties)))
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
347 (unless cache
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
348 ;; Oh well, get it then.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
349 (setq cache (custom-extract-frame-properties frame))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
350 ;; and cache it...
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
351 (modify-frame-parameters frame
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
352 (list (cons 'custom-properties cache))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
353 cache))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
354 (custom-default-frame-properties)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
355 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
356 (setq custom-default-frame-properties
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
357 (custom-extract-frame-properties (selected-frame))))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
358
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
359 (defun face-spec-set-match-display (display frame)
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
360 "Non-nil iff DISPLAY matches FRAME.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
361 If FRAME is nil, the current FRAME is used."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
362 ;; This is a kludge to get started, we really should use specifiers!
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
363 (if (eq display t)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
364 t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
365 (let* ((props (custom-get-frame-properties frame))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
366 (type (plist-get props 'type))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
367 (class (plist-get props 'class))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
368 (background (plist-get props 'background))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
369 (match t)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
370 (entries display)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
371 entry req options)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
372 (while (and entries match)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
373 (setq entry (car entries)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
374 entries (cdr entries)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
375 req (car entry)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
376 options (cdr entry)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
377 match (cond ((eq req 'type)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
378 (memq type options))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
379 ((eq req 'class)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
380 (memq class options))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
381 ((eq req 'background)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
382 (memq background options))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
383 (t
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
384 (warn "Unknown req `%S' with options `%S'"
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
385 req options)
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
386 nil))))
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
387 match)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
388
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
389 (defun custom-relevant-frames ()
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
390 "List of frames whose custom properties differ from the default."
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
391 (let ((relevant nil)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
392 (default (custom-get-frame-properties))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
393 (frames (frame-list))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
394 frame)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
395 (while frames
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
396 (setq frame (car frames)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
397 frames (cdr frames))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
398 (unless (equal default (custom-get-frame-properties frame))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
399 (push frame relevant)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
400 relevant))
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
401
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
402 (defun custom-initialize-faces (&optional frame)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
403 "Initialize all custom faces for FRAME.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
404 If FRAME is nil or omitted, initialize them for all frames."
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
405 (mapc (lambda (symbol)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
406 (let ((spec (or (get symbol 'saved-face)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
407 (get symbol 'face-defface-spec))))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
408 (when spec
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
409 (custom-face-display-set symbol spec frame)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
410 (initialize-face-resources symbol frame))))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
411 (face-list)))
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
412
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 120
diff changeset
413 ;;;###autoload
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
414 (defun custom-initialize-frame (&optional frame)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
415 "Initialize local faces for FRAME if necessary.
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
416 If FRAME is missing or nil, the first member of (frame-list) is used."
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
417 (unless frame
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
418 (setq frame (car (frame-list))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
419 (unless (equal (custom-get-frame-properties)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
420 (custom-get-frame-properties frame))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
421 (custom-initialize-faces frame)))
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
422
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
423 ;;; Initializing.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
424
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
425 (make-face 'custom-face-empty)
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
426
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
427 ;;;###autoload
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
428 (defun custom-set-faces (&rest args)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
429 "Initialize faces according to user preferences.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
430 The arguments should be a list where each entry has the form:
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
431
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
432 (FACE SPEC [NOW])
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
433
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
434 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
435 and non-nil, FACE will also be created according to SPEC.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
436
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
437 See `defface' for the format of SPEC."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
438 (while args
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
439 (let ((entry (car args)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
440 (if (listp entry)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
441 (let ((face (nth 0 entry))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
442 (spec (nth 1 entry))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
443 (now (nth 2 entry)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
444 (put face 'saved-face spec)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
445 (when now
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
446 (put face 'force-face t))
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
447 (when (or now (find-face face))
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
448 (face-spec-set face spec))
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
449 (setq args (cdr args)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
450 ;; Old format, a plist of FACE SPEC pairs.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
451 (let ((face (nth 0 args))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
452 (spec (nth 1 args)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
453 (put face 'saved-face spec))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
454 (setq args (cdr (cdr args)))))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
455
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
456 ;;; The End.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
457
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
458 (provide 'cus-face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
459
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
460 ;; cus-face.el ends here