annotate lisp/custom/cus-face.el @ 173:8eaf7971accc r20-3b13

Import from CVS: tag r20-3b13
author cvs
date Mon, 13 Aug 2007 09:49:09 +0200
parents 85ec50267440
children 9ad43877534d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
1 ;;; cus-face.el -- XEmacs specific custom support.
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>
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
6 ;; Keywords: help, faces
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 167
diff changeset
7 ;; Version: 1.9951
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
8 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
9
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
10 ;;; Commentary:
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
11 ;;
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
12 ;; See `custom.el'.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
13
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
14 ;;; Code:
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
15
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
16 (require 'custom)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
17
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
18 (eval-when-compile (require 'cl))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
19
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
20 ;;; Compatibility.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
21
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
22 (if (string-match "XEmacs" emacs-version)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
23 (defun custom-face-background (face &optional frame)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
24 ;; Specifiers suck!
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
25 "Return the background color name of face FACE, or nil if unspecified."
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
26 (color-instance-name (specifier-instance (face-background face) frame)))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
27 (defalias 'custom-face-background 'face-background))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
28
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
29 (if (string-match "XEmacs" emacs-version)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
30 (defun custom-face-foreground (face &optional frame)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
31 ;; Specifiers suck!
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
32 "Return the background color name of face FACE, or nil if unspecified."
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
33 (color-instance-name (specifier-instance (face-foreground face) frame)))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
34 (defalias 'custom-face-foreground 'face-foreground))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
35
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
36 (defalias 'custom-face-font-name (if (string-match "XEmacs" emacs-version)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
37 'face-font-name
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
38 'face-font))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
39
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
40 (eval-and-compile
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
41 (cond ((fboundp 'frame-property)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
42 ;; XEmacs.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
43 (defalias 'custom-frame-parameter 'frame-property))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
44 ((fboundp 'frame-parameter)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
45 ;; Emacs 19.35.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
46 (defalias 'custom-frame-parameter 'frame-parameter))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
47 (t
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
48 ;; Old emacsen.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
49 (defun custom-frame-parameter (frame property &optional default)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
50 "Return FRAME's value for property PROPERTY."
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
51 (or (cdr (assq property (frame-parameters frame)))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
52 default))))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
53
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
54 (unless (fboundp 'face-doc-string)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
55 ;; XEmacs function missing in Emacs.
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
56 (defun face-doc-string (face)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
57 "Get the documentation string for FACE."
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 120
diff changeset
58 (get face 'face-documentation)))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
59
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
60 (unless (fboundp 'set-face-doc-string)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
61 ;; XEmacs function missing in Emacs.
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
62 (defun set-face-doc-string (face string)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
63 "Set the documentation string for FACE to STRING."
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 120
diff changeset
64 (put face 'face-documentation string))))
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
65
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
66 (unless (fboundp 'x-color-values)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
67 ;; Emacs function missing in XEmacs 19.14.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
68 (defun x-color-values (color &optional frame)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
69 "Return a description of the color named COLOR on frame FRAME.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
70 The value is a list of integer RGB values--(RED GREEN BLUE).
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
71 These values appear to range from 0 to 65280 or 65535, depending
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
72 on the system; white is (65280 65280 65280) or (65535 65535 65535).
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
73 If FRAME is omitted or nil, use the selected frame."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
74 (color-instance-rgb-components (make-color-instance color))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
75
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
76 ;; XEmacs and Emacs have different definitions of `facep'.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
77 ;; The Emacs definition is the useful one, so emulate that.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
78 (cond ((not (fboundp 'facep))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
79 (defun custom-facep (face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
80 "No faces"
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
81 nil))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
82 ((string-match "XEmacs" emacs-version)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
83 (defalias 'custom-facep 'find-face))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
84 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
85 (defalias 'custom-facep 'facep)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
86
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
87 (unless (fboundp 'make-empty-face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
88 ;; This should be moved to `faces.el'.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
89 (if (string-match "XEmacs" emacs-version)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
90 ;; Give up for old XEmacs pre 19.15/20.1.
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
91 (defalias 'make-empty-face 'make-face)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
92 ;; Define for Emacs pre 19.35.
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
93 (defun make-empty-face (name)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
94 "Define a new FACE on all frames, ignoring X resources."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
95 (interactive "SMake face: ")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
96 (or (internal-find-face name)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
97 (let ((face (make-vector 8 nil)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
98 (aset face 0 'face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
99 (aset face 1 name)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
100 (let* ((frames (frame-list))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
101 (inhibit-quit t)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
102 (id (internal-next-face-id)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
103 (make-face-internal id)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
104 (aset face 2 id)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
105 (while frames
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
106 (set-frame-face-alist (car frames)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
107 (cons (cons name (copy-sequence face))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
108 (frame-face-alist (car frames))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
109 (setq frames (cdr frames)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
110 (setq global-face-data (cons (cons name face) global-face-data)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
111 ;; add to menu
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
112 (if (fboundp 'facemenu-add-new-face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
113 (facemenu-add-new-face name))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
114 face))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
115 name)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
116
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
117 (defcustom initialize-face-resources t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
118 "If non nil, allow X resources to initialize face properties.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
119 This only affects faces declared with `defface', and only NT or X11 frames."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
120 :group 'customize
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
121 :type 'boolean)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
122
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
123 (cond ((fboundp 'initialize-face-resources)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
124 ;; Already bound, do nothing.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
125 )
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
126 ((fboundp 'make-face-x-resource-internal)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
127 ;; Emacs or new XEmacs.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
128 (defun initialize-face-resources (face &optional frame)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
129 "Initialize face according to the X11 resources.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
130 This might overwrite existing face properties.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
131 Does nothing when the variable initialize-face-resources is nil."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
132 (when initialize-face-resources
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
133 (make-face-x-resource-internal face frame t))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
134 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
135 ;; Too hard to do right on XEmacs.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
136 (defalias 'initialize-face-resources 'ignore)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
137
36
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
138 ;;(if (string-match "XEmacs" emacs-version)
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
139 ;; ;; Xemacs.
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
140 ;; (defun custom-invert-face (face &optional frame)
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
141 ;; "Swap the foreground and background colors of face FACE.
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
142 ;;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
143 ;; (interactive (list (read-face-name "Reverse face: ")))
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
144 ;; (let ((fg (color-name (face-foreground face frame) frame))
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
145 ;; (bg (color-name (face-background face frame) frame)))
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
146 ;; (set-face-foreground face bg frame)
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
147 ;; (set-face-background face fg frame)))
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
148 ;; ;; Emacs.
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
149 ;; (defun custom-invert-face (face &optional frame)
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
150 ;; "Swap the foreground and background colors of face FACE.
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
151 ;;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
152 ;; (interactive (list (read-face-name "Reverse face: ")))
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
153 ;; (let ((fg (or (face-foreground face frame)
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
154 ;; (face-foreground 'default frame)
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
155 ;; (custom-frame-parameter (or frame (selected-frame))
36
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
156 ;; 'foreground-color)
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
157 ;; "black"))
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
158 ;; (bg (or (face-background face frame)
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
159 ;; (face-background 'default frame)
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
160 ;; (custom-frame-parameter (or frame (selected-frame))
36
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
161 ;; 'background-color)
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
162 ;; "white")))
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
163 ;; (set-face-foreground face bg frame)
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
164 ;; (set-face-background face fg frame))))
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
165
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
166 (defcustom custom-background-mode nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
167 "The brightness of the background.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
168 Set this to the symbol dark if your background color is dark, light if
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
169 your background is light, or nil (default) if you want Emacs to
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
170 examine the brightness for you."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
171 :group 'customize
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
172 :type '(choice (const dark)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
173 (const light)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
174 (const :tag "default" nil)))
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
175
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
176 (defun custom-background-mode (frame)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
177 "Kludge to detect background mode for FRAME."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
178 (let* ((bg-resource
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
179 (condition-case ()
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
180 (x-get-resource ".backgroundMode" "BackgroundMode" 'string)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
181 (error nil)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
182 color
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
183 (mode (cond (bg-resource
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
184 (intern (downcase bg-resource)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
185 ((and (setq color (condition-case ()
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
186 (or (custom-frame-parameter
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
187 frame
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
188 'background-color)
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
189 (custom-face-background
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
190 'default))
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
191 (error nil)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
192 (or (string-match "XEmacs" emacs-version)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
193 window-system)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
194 (< (apply '+ (x-color-values color))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
195 (/ (apply '+ (x-color-values "white"))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
196 3)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
197 'dark)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
198 (t 'light))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
199 (modify-frame-parameters frame (list (cons 'background-mode mode)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
200 mode))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
201
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
202 (eval-and-compile
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
203 (if (string-match "XEmacs" emacs-version)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
204 ;; XEmacs.
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
205 (defun custom-extract-frame-properties (frame)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
206 "Return a plist with the frame properties of FRAME used by custom."
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
207 (list 'type (device-type (frame-device frame))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
208 'class (device-class (frame-device frame))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
209 'background (or custom-background-mode
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
210 (custom-frame-parameter frame
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
211 'background-mode)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
212 (custom-background-mode frame))))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
213 ;; Emacs.
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
214 (defun custom-extract-frame-properties (frame)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
215 "Return a plist with the frame properties of FRAME used by custom."
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
216 (list 'type window-system
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
217 'class (custom-frame-parameter frame 'display-type)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
218 'background (or custom-background-mode
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
219 (custom-frame-parameter frame 'background-mode)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
220 (custom-background-mode frame))))))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
221
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
222 ;;; Declaring a face.
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
223
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
224 ;;;###autoload
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
225 (defun custom-declare-face (face spec doc &rest args)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
226 "Like `defface', but FACE is evaluated as a normal argument."
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
227 (when (or (fboundp 'load-gc) ;XEmacs.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
228 ;; Emacs.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
229 (and (boundp purify-flag) purify-flag))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
230 ;; This should be allowed, somehow.
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
231 (error "Attempt to declare a face during dump"))
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
232 (unless (get face 'face-defface-spec)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
233 (put face 'face-defface-spec spec)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
234 (when (fboundp 'facep)
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
235 (unless (custom-facep face)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
236 ;; If the user has already created the face, respect that.
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
237 (let ((value (or (get face 'saved-face) spec))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
238 (frames (custom-relevant-frames))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
239 frame)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
240 ;; Create global face.
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
241 (make-empty-face face)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
242 (custom-face-display-set face value)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
243 ;; Create frame local faces
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
244 (while frames
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
245 (setq frame (car frames)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
246 frames (cdr frames))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
247 (custom-face-display-set face value frame))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
248 (initialize-face-resources face))))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
249 (when (and doc (null (face-doc-string face)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
250 (set-face-doc-string face doc))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
251 (custom-handle-all-keywords face args 'custom-face)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
252 (run-hooks 'custom-define-hook))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
253 face)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
254
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
255 ;;; Font Attributes.
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
256
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
257 (defconst custom-face-attributes
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 161
diff changeset
258 '((:bold (boolean :tag "Bold"
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 161
diff changeset
259 :help-echo "Control whether a bold font should be used.")
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
260 custom-set-face-bold
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
261 custom-face-bold)
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 161
diff changeset
262 (:italic (boolean :tag "Italic"
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 161
diff changeset
263 :help-echo "\
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
264 Control whether an italic font should be used.")
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
265 custom-set-face-italic
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
266 custom-face-italic)
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 161
diff changeset
267 (:underline (boolean :tag "Underline"
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 161
diff changeset
268 :help-echo "\
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
269 Control whether the text should be underlined.")
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
270 set-face-underline-p
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
271 face-underline-p)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
272 (:foreground (color :tag "Foreground"
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
273 :value "black"
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
274 :help-echo "Set foreground color.")
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
275 set-face-foreground
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
276 custom-face-foreground)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
277 (:background (color :tag "Background"
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
278 :value "white"
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
279 :help-echo "Set background color.")
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
280 set-face-background
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
281 custom-face-background)
36
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
282 ;; (:invert (const :format "Invert Face\n"
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
283 ;; :sibling-args (:help-echo "
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
284 ;;Reverse the foreground and background color.
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
285 ;;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
286 ;; t)
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
287 ;; (lambda (face value &optional frame)
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
288 ;; ;; We don't use VALUE.
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 34
diff changeset
289 ;; (custom-invert-face face frame)))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
290 (:stipple (editable-field :format "Stipple: %v"
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
291 :help-echo "Name of background bitmap file.")
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
292 set-face-stipple custom-face-stipple))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
293 "Alist of face attributes.
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
294
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
295 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
296 identifying the attribute, TYPE is a widget type for editing the
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
297 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
298
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
299 The SET function should take three arguments, the face to modify, the
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
300 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
301 be changed.
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
302
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
303 The GET function should take two arguments, the face to examine, and
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
304 optonally the frame where the face should be examined.")
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
305
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
306 (defun custom-face-attributes-set (face frame &rest atts)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
307 "For FACE on FRAME set the attributes [KEYWORD VALUE]....
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
308 Each keyword should be listed in `custom-face-attributes'.
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
309
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
310 If FRAME is nil, set the default face."
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
311 (while atts
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
312 (let* ((name (nth 0 atts))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
313 (value (nth 1 atts))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
314 (fun (nth 2 (assq name custom-face-attributes))))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
315 (setq atts (cdr (cdr atts)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
316 (condition-case nil
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
317 (funcall fun face value frame)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
318 (error nil)))))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
319
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
320 (defun custom-face-attributes-get (face frame)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
321 "For FACE on FRAME get the attributes [KEYWORD VALUE]....
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
322 Each keyword should be listed in `custom-face-attributes'.
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
323
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
324 If FRAME is nil, use the default face."
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
325 (condition-case nil
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
326 ;; Attempt to get `font.el' from w3.
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
327 (require 'font)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
328 (error nil))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
329 (let ((atts custom-face-attributes)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
330 att result get)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
331 (while atts
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
332 (setq att (car atts)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
333 atts (cdr atts)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
334 get (nth 3 att))
161
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 157
diff changeset
335 (condition-case nil
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 157
diff changeset
336 ;; This may fail if w3 doesn't exists.
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 157
diff changeset
337 (when get
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 157
diff changeset
338 (let ((answer (funcall get face frame)))
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 157
diff changeset
339 (unless (equal answer (funcall get 'default frame))
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 157
diff changeset
340 (when (widget-apply (nth 1 att) :match answer)
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 157
diff changeset
341 (setq result (cons (nth 0 att) (cons answer result)))))))
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 157
diff changeset
342 (error nil)))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
343 result))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
344
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
345 (defun custom-set-face-bold (face value &optional frame)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
346 "Set the bold property of FACE to VALUE."
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
347 (if value
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
348 (make-face-bold face frame)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
349 (make-face-unbold face frame)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
350
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
351 (defun custom-face-bold (face &rest args)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
352 "Return non-nil if the font of FACE is bold."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
353 (let* ((font (apply 'custom-face-font-name face args))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
354 (fontobj (font-create-object font)))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
355 (font-bold-p fontobj)))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
356
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
357 (defun custom-set-face-italic (face value &optional frame)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
358 "Set the italic property of FACE to VALUE."
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
359 (if value
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
360 (make-face-italic face frame)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
361 (make-face-unitalic face frame)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
362
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
363 (defun custom-face-italic (face &rest args)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
364 "Return non-nil if the font of FACE is italic."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
365 (let* ((font (apply 'custom-face-font-name face args))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
366 (fontobj (font-create-object font)))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
367 (font-italic-p fontobj)))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
368
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
369 (defun custom-face-stipple (face &rest args)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
370 "Return the name of the stipple file used for FACE."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
371 (if (string-match "XEmacs" emacs-version)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
372 (let ((image (apply 'specifier-instance
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
373 (face-background-pixmap face) args)))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
374 (when image
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
375 (image-instance-file-name image)))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
376 (apply 'face-stipple face args)))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
377
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
378 (when (string-match "XEmacs" emacs-version)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
379 ;; Support for special XEmacs font attributes.
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
380 (autoload 'font-create-object "font" nil)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
381
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
382 (defun custom-set-face-font-size (face size &rest args)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
383 "Set the font of FACE to SIZE"
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
384 (let* ((font (apply 'custom-face-font-name face args))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
385 (fontobj (font-create-object font)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
386 (set-font-size fontobj size)
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
387 (apply 'font-set-face-font face fontobj args)))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
388
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
389 (defun custom-face-font-size (face &rest args)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
390 "Return the size of the font of FACE as a string."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
391 (let* ((font (apply 'custom-face-font-name face args))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
392 (fontobj (font-create-object font)))
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 120
diff changeset
393 (format "%s" (font-size fontobj))))
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
394
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
395 (defun custom-set-face-font-family (face family &rest args)
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
396 "Set the font of FACE to FAMILY."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
397 (let* ((font (apply 'custom-face-font-name face args))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
398 (fontobj (font-create-object font)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
399 (set-font-family fontobj family)
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
400 (apply 'font-set-face-font face fontobj args)))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
401
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
402 (defun custom-face-font-family (face &rest args)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
403 "Return the name of the font family of FACE."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
404 (let* ((font (apply 'custom-face-font-name face args))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
405 (fontobj (font-create-object font)))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
406 (font-family fontobj)))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
407
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
408 (setq custom-face-attributes
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
409 (append '((:family (editable-field :format "Font Family: %v"
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
410 :help-echo "\
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
411 Name of font family to use (e.g. times).")
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
412 custom-set-face-font-family
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
413 custom-face-font-family)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
414 (:size (editable-field :format "Size: %v"
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
415 :help-echo "\
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
416 Text size (e.g. 9pt or 2mm).")
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
417 custom-set-face-font-size
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
418 custom-face-font-size)
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
419 (:strikethru (toggle :format "%[Strikethru%]: %v\n"
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
420 :help-echo "\
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
421 Control whether the text should be strikethru.")
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
422 set-face-strikethru-p
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
423 face-strikethru-p))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
424 custom-face-attributes)))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
425
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
426 ;;; Frames.
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
427
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
428 (defun face-spec-set (face spec &optional frame)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
429 "Set FACE to the attributes to the first matching entry in SPEC.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
430 Iff optional FRAME is non-nil, set it for that frame only.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
431 See `defface' for information about SPEC.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
432
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
433 Clear all existing attributes first."
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
434 (when (fboundp 'copy-face)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
435 (copy-face 'custom-face-empty face frame))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
436 (custom-face-display-set face spec frame))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
437
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
438 (defun custom-face-display-set (face spec &optional frame)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
439 "Set FACE to the attributes to the first matching entry in SPEC.
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
440 Iff optional FRAME is non-nil, set it for that frame only.
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
441 See `defface' for information about SPEC."
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
442 (when (fboundp 'make-face)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
443 (while spec
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
444 (let* ((entry (car spec))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
445 (display (nth 0 entry))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
446 (atts (nth 1 entry)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
447 (setq spec (cdr spec))
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
448 (when (face-spec-set-match-display display frame)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
449 ;; Avoid creating frame local duplicates of the global face.
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
450 (unless (and frame (eq display (get face 'custom-face-display)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
451 (apply 'custom-face-attributes-set face frame atts))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
452 (unless frame
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
453 (put face 'custom-face-display display))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
454 (setq spec nil))))))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
455
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
456 (defvar custom-default-frame-properties nil
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
457 "The frame properties used for the global faces.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
458 Frames who doesn't match these propertiess should have frame local faces.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
459 The value should be nil, if uninitialized, or a plist otherwise.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
460 See `defface' for a list of valid keys and values for the plist.")
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
461
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
462 (defun custom-get-frame-properties (&optional frame)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
463 "Return a plist with the frame properties of FRAME used by custom.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
464 If FRAME is nil, return the default frame properties."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
465 (cond (frame
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
466 ;; Try to get from cache.
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
467 (let ((cache (custom-frame-parameter frame 'custom-properties)))
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
468 (unless cache
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
469 ;; Oh well, get it then.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
470 (setq cache (custom-extract-frame-properties frame))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
471 ;; and cache it...
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
472 (modify-frame-parameters frame
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
473 (list (cons 'custom-properties cache))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
474 cache))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
475 (custom-default-frame-properties)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
476 (t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
477 (setq custom-default-frame-properties
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
478 (custom-extract-frame-properties (selected-frame))))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
479
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
480 (defun face-spec-set-match-display (display frame)
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
481 "Non-nil iff DISPLAY matches FRAME.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
482 If FRAME is nil, the current FRAME is used."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
483 ;; This is a kludge to get started, we really should use specifiers!
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
484 (if (eq display t)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
485 t
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
486 (let* ((props (custom-get-frame-properties frame))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
487 (type (plist-get props 'type))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
488 (class (plist-get props 'class))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
489 (background (plist-get props 'background))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
490 (match t)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
491 (entries display)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
492 entry req options)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
493 (while (and entries match)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
494 (setq entry (car entries)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
495 entries (cdr entries)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
496 req (car entry)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
497 options (cdr entry)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
498 match (cond ((eq req 'type)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
499 (memq type options))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
500 ((eq req 'class)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
501 (memq class options))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
502 ((eq req 'background)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
503 (memq background options))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
504 (t
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
505 (message (format "\
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
506 Warning: Unknown req `%S' with options `%S'" req options))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
507 nil))))
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
508 match)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
509
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
510 (defun custom-relevant-frames ()
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
511 "List of frames whose custom properties differ from the default."
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
512 (let ((relevant nil)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
513 (default (custom-get-frame-properties))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
514 (frames (frame-list))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
515 frame)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
516 (while frames
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
517 (setq frame (car frames)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
518 frames (cdr frames))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
519 (unless (equal default (custom-get-frame-properties frame))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
520 (push frame relevant)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
521 relevant))
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
522
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
523 (defun custom-initialize-faces (&optional frame)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
524 "Initialize all custom faces for FRAME.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
525 If FRAME is nil or omitted, initialize them for all frames."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
526 (mapcar (lambda (symbol)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
527 (let ((spec (or (get symbol 'saved-face)
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
528 (get symbol 'face-defface-spec))))
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
529 (when spec
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
530 (custom-face-display-set symbol spec frame)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
531 (initialize-face-resources symbol frame))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
532 (face-list)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
533
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 120
diff changeset
534 ;;;###autoload
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
535 (defun custom-initialize-frame (&optional frame)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
536 "Initialize local faces for FRAME if necessary.
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
537 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
538 (unless frame
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
539 (setq frame (car (frame-list))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
540 (unless (equal (custom-get-frame-properties)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
541 (custom-get-frame-properties frame))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
542 (custom-initialize-faces frame)))
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
543
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
544 ;;; Initializing.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
545
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
546 (and (fboundp 'make-face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
547 (make-face 'custom-face-empty))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
548
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
549 ;;;###autoload
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
550 (defun custom-set-faces (&rest args)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
551 "Initialize faces according to user preferences.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
552 The arguments should be a list where each entry has the form:
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
553
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
554 (FACE SPEC [NOW])
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
555
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
556 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
557 and non-nil, FACE will also be created according to SPEC.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
558
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
559 See `defface' for the format of SPEC."
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
560 (while args
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
561 (let ((entry (car args)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
562 (if (listp entry)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
563 (let ((face (nth 0 entry))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
564 (spec (nth 1 entry))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
565 (now (nth 2 entry)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
566 (put face 'saved-face spec)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
567 (when now
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
568 (put face 'force-face t))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
569 (when (or now (custom-facep face))
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
570 (face-spec-set face spec))
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
571 (setq args (cdr args)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
572 ;; Old format, a plist of FACE SPEC pairs.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
573 (let ((face (nth 0 args))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
574 (spec (nth 1 args)))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
575 (put face 'saved-face spec))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
576 (setq args (cdr (cdr args)))))))
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
577
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
578 ;;; The End.
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
579
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
580 (provide 'cus-face)
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
581
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents:
diff changeset
582 ;; cus-face.el ends here