Mercurial > emacs
annotate lisp/faces.el @ 2813:89b1121e2d43
* timer.c: Fix mispellings of get_date function's name.
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Sat, 15 May 1993 23:05:46 +0000 |
parents | 9e8635dafd40 |
children | 9c22af6d7885 |
rev | line source |
---|---|
2456 | 1 ;;; faces.el --- Lisp interface to the c "face" structure |
2 | |
3 ;; Copyright (C) 1992, 1993 Free Software Foundation, Inc. | |
4 | |
5 ;; This file is part of GNU Emacs. | |
6 | |
7 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
8 ;; it under the terms of the GNU General Public License as published by | |
9 ;; the Free Software Foundation; either version 2, or (at your option) | |
10 ;; any later version. | |
11 | |
12 ;; GNU Emacs is distributed in the hope that it will be useful, | |
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 ;; GNU General Public License for more details. | |
16 | |
17 ;; You should have received a copy of the GNU General Public License | |
18 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
19 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
20 | |
21 ;;; Commentary: | |
22 | |
23 ;; Mostly derived from Lucid. | |
24 | |
25 ;;; Code: | |
26 | |
2744
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
27 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
28 ;;;; Functions for manipulating face vectors. |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
29 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
30 ;;; A face vector is a vector of the form: |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
31 ;;; [face ID FONT FOREGROUND BACKGROUND BACKGROUND-PIXMAP UNDERLINE] |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
32 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
33 ;;; Type checkers. |
2456 | 34 (defsubst internal-facep (x) |
35 (and (vectorp x) (= (length x) 8) (eq (aref x 0) 'face))) | |
36 | |
37 (defmacro internal-check-face (face) | |
38 (` (while (not (internal-facep (, face))) | |
39 (setq (, face) (signal 'wrong-type-argument (list 'internal-facep (, face))))))) | |
40 | |
2744
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
41 ;;; Accessors. |
2456 | 42 (defsubst face-name (face) |
43 "Return the name of face FACE." | |
44 (aref (internal-get-face face) 1)) | |
45 | |
46 (defsubst face-id (face) | |
47 "Return the internal ID number of face FACE." | |
48 (aref (internal-get-face face) 2)) | |
49 | |
50 (defsubst face-font (face &optional frame) | |
51 "Return the font name of face FACE, or nil if it is unspecified. | |
52 If the optional argument FRAME is given, report on face FACE in that frame. | |
53 Otherwise report on the defaults for face FACE (for new frames)." | |
54 (aref (internal-get-face face frame) 3)) | |
55 | |
56 (defsubst face-foreground (face &optional frame) | |
57 "Return the foreground color name of face FACE, or nil if unspecified. | |
58 If the optional argument FRAME is given, report on face FACE in that frame. | |
59 Otherwise report on the defaults for face FACE (for new frames)." | |
60 (aref (internal-get-face face frame) 4)) | |
61 | |
62 (defsubst face-background (face &optional frame) | |
63 "Return the background color name of face FACE, or nil if unspecified. | |
64 If the optional argument FRAME is given, report on face FACE in that frame. | |
65 Otherwise report on the defaults for face FACE (for new frames)." | |
66 (aref (internal-get-face face frame) 5)) | |
67 | |
68 (defsubst face-background-pixmap (face &optional frame) | |
69 "Return the background pixmap name of face FACE, or nil if unspecified. | |
70 If the optional argument FRAME is given, report on face FACE in that frame. | |
71 Otherwise report on the defaults for face FACE (for new frames)." | |
72 (aref (internal-get-face face frame) 6)) | |
73 | |
74 (defsubst face-underline-p (face &optional frame) | |
75 "Return t if face FACE is underlined. | |
76 If the optional argument FRAME is given, report on face FACE in that frame. | |
77 Otherwise report on the defaults for face FACE (for new frames)." | |
78 (aref (internal-get-face face frame) 7)) | |
79 | |
2744
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
80 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
81 ;;; Mutators. |
2456 | 82 |
83 (defsubst set-face-font (face font &optional frame) | |
84 "Change the font of face FACE to FONT (a string). | |
85 If the optional FRAME argument is provided, change only | |
86 in that frame; otherwise change each frame." | |
87 (interactive (internal-face-interactive "font")) | |
2715
9caee9338229
* faces.el: Call internal-set-face-1, not internat-set-face-1.
Jim Blandy <jimb@redhat.com>
parents:
2714
diff
changeset
|
88 (internal-set-face-1 face 'font font 3 frame)) |
2456 | 89 |
90 (defsubst set-face-foreground (face color &optional frame) | |
91 "Change the foreground color of face FACE to COLOR (a string). | |
92 If the optional FRAME argument is provided, change only | |
93 in that frame; otherwise change each frame." | |
94 (interactive (internal-face-interactive "foreground")) | |
2715
9caee9338229
* faces.el: Call internal-set-face-1, not internat-set-face-1.
Jim Blandy <jimb@redhat.com>
parents:
2714
diff
changeset
|
95 (internal-set-face-1 face 'foreground color 4 frame)) |
2456 | 96 |
97 (defsubst set-face-background (face color &optional frame) | |
98 "Change the background color of face FACE to COLOR (a string). | |
99 If the optional FRAME argument is provided, change only | |
100 in that frame; otherwise change each frame." | |
101 (interactive (internal-face-interactive "background")) | |
2715
9caee9338229
* faces.el: Call internal-set-face-1, not internat-set-face-1.
Jim Blandy <jimb@redhat.com>
parents:
2714
diff
changeset
|
102 (internal-set-face-1 face 'background color 5 frame)) |
2456 | 103 |
104 (defsubst set-face-background-pixmap (face name &optional frame) | |
105 "Change the background pixmap of face FACE to PIXMAP. | |
106 PIXMAP should be a string, the name of a file of pixmap data. | |
107 The directories listed in the `x-bitmap-file-path' variable are searched. | |
108 | |
109 Alternatively, PIXMAP may be a list of the form (WIDTH HEIGHT DATA) | |
110 where WIDTH and HEIGHT are the size in pixels, | |
111 and DATA is a string, containing the raw bits of the bitmap. | |
112 | |
113 If the optional FRAME argument is provided, change only | |
114 in that frame; otherwise change each frame." | |
115 (interactive (internal-face-interactive "background-pixmap")) | |
2715
9caee9338229
* faces.el: Call internal-set-face-1, not internat-set-face-1.
Jim Blandy <jimb@redhat.com>
parents:
2714
diff
changeset
|
116 (internal-set-face-1 face 'background-pixmap name 6 frame)) |
2456 | 117 |
118 (defsubst set-face-underline-p (face underline-p &optional frame) | |
119 "Specify whether face FACE is underlined. (Yes if UNDERLINE-P is non-nil.) | |
120 If the optional FRAME argument is provided, change only | |
121 in that frame; otherwise change each frame." | |
122 (interactive (internal-face-interactive "underline-p" "underlined")) | |
2715
9caee9338229
* faces.el: Call internal-set-face-1, not internat-set-face-1.
Jim Blandy <jimb@redhat.com>
parents:
2714
diff
changeset
|
123 (internal-set-face-1 face 'underline underline-p 7 frame)) |
2456 | 124 |
2744
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
125 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
126 ;;;; Associating face names (symbols) with their face vectors. |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
127 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
128 (defvar global-face-data nil "do not use this") |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
129 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
130 (defun face-list () |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
131 "Returns a list of all defined face names." |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
132 (mapcar 'car global-face-data)) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
133 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
134 (defun internal-find-face (name &optional frame) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
135 "Retrieve the face named NAME. Return nil if there is no such face. |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
136 If the optional argument FRAME is given, this gets the face NAME for |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
137 that frame; otherwise, it uses the selected frame. |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
138 If FRAME is the symbol t, then the global, non-frame face is returned. |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
139 If NAME is already a face, it is simply returned." |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
140 (if (and (eq frame t) (not (symbolp name))) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
141 (setq name (face-name name))) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
142 (if (symbolp name) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
143 (cdr (assq name |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
144 (if (eq frame t) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
145 global-face-data |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
146 (frame-face-alist (or frame (selected-frame)))))) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
147 (internal-check-face name) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
148 name)) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
149 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
150 (defun internal-get-face (name &optional frame) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
151 "Retrieve the face named NAME; error if there is none. |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
152 If the optional argument FRAME is given, this gets the face NAME for |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
153 that frame; otherwise, it uses the selected frame. |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
154 If FRAME is the symbol t, then the global, non-frame face is returned. |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
155 If NAME is already a face, it is simply returned." |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
156 (or (internal-find-face name frame) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
157 (internal-check-face name))) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
158 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
159 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
160 (defun internal-set-face-1 (face name value index frame) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
161 (let ((inhibit-quit t)) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
162 (if (null frame) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
163 (let ((frames (frame-list))) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
164 (while frames |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
165 (internal-set-face-1 (face-name face) name value index (car frames)) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
166 (setq frames (cdr frames))) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
167 (aset (internal-get-face (if (symbolp face) face (face-name face)) t) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
168 index value) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
169 value) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
170 (or (eq frame t) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
171 (set-face-attribute-internal (face-id face) name value frame)) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
172 (aset (internal-get-face face frame) index value)))) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
173 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
174 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
175 (defun read-face-name (prompt) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
176 (let (face) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
177 (while (= (length face) 0) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
178 (setq face (completing-read prompt |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
179 (mapcar '(lambda (x) (list (symbol-name x))) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
180 (face-list)) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
181 nil t))) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
182 (intern face))) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
183 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
184 (defun internal-face-interactive (what &optional bool) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
185 (let* ((fn (intern (concat "face-" what))) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
186 (prompt (concat "Set " what " of face")) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
187 (face (read-face-name (concat prompt ": "))) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
188 (default (if (fboundp fn) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
189 (or (funcall fn face (selected-frame)) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
190 (funcall fn 'default (selected-frame))))) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
191 (value (if bool |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
192 (y-or-n-p (concat "Should face " (symbol-name face) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
193 " be " bool "? ")) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
194 (read-string (concat prompt " " (symbol-name face) " to: ") |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
195 default)))) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
196 (list face (if (equal value "") nil value)))) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
197 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
198 |
2456 | 199 |
200 (defun make-face (name) | |
201 "Define a new FACE on all frames. | |
202 You can modify the font, color, etc of this face with the set-face- functions. | |
203 If the face already exists, it is unmodified." | |
2800
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
204 (interactive "sMake face: ") |
2456 | 205 (or (internal-find-face name) |
206 (let ((face (make-vector 8 nil))) | |
207 (aset face 0 'face) | |
208 (aset face 1 name) | |
209 (let* ((frames (frame-list)) | |
210 (inhibit-quit t) | |
211 (id (internal-next-face-id))) | |
212 (make-face-internal id) | |
213 (aset face 2 id) | |
214 (while frames | |
215 (set-frame-face-alist (car frames) | |
216 (cons (cons name (copy-sequence face)) | |
217 (frame-face-alist (car frames)))) | |
218 (setq frames (cdr frames))) | |
219 (setq global-face-data (cons (cons name face) global-face-data))) | |
220 ;; when making a face after frames already exist | |
221 (if (eq window-system 'x) | |
222 (make-face-x-resource-internal face)) | |
223 face))) | |
224 | |
225 ;; Fill in a face by default based on X resources, for all existing frames. | |
226 ;; This has to be done when a new face is made. | |
227 (defun make-face-x-resource-internal (face &optional frame set-anyway) | |
228 (cond ((null frame) | |
229 (let ((frames (frame-list))) | |
230 (while frames | |
231 (make-face-x-resource-internal (face-name face) | |
232 (car frames) set-anyway) | |
233 (setq frames (cdr frames))))) | |
234 (t | |
235 (setq face (internal-get-face (face-name face) frame)) | |
236 ;; | |
237 ;; These are things like "attributeForeground" instead of simply | |
238 ;; "foreground" because people tend to do things like "*foreground", | |
239 ;; which would cause all faces to be fully qualified, making faces | |
240 ;; inherit attributes in a non-useful way. So we've made them slightly | |
241 ;; less obvious to specify in order to make them work correctly in | |
242 ;; more random environments. | |
243 ;; | |
244 ;; I think these should be called "face.faceForeground" instead of | |
245 ;; "face.attributeForeground", but they're the way they are for | |
246 ;; hysterical reasons. | |
247 ;; | |
248 (let* ((name (symbol-name (face-name face))) | |
249 (fn (or (x-get-resource (concat name ".attributeFont") | |
250 "Face.AttributeFont") | |
251 (and set-anyway (face-font face)))) | |
252 (fg (or (x-get-resource (concat name ".attributeForeground") | |
253 "Face.AttributeForeground") | |
254 (and set-anyway (face-foreground face)))) | |
255 (bg (or (x-get-resource (concat name ".attributeBackground") | |
256 "Face.AttributeBackground") | |
257 (and set-anyway (face-background face)))) | |
258 ;; (bgp (or (x-get-resource (concat name ".attributeBackgroundPixmap") | |
259 ;; "Face.AttributeBackgroundPixmap") | |
260 ;; (and set-anyway (face-background-pixmap face)))) | |
261 (ulp (or (x-get-resource (concat name ".attributeUnderline") | |
262 "Face.AttributeUnderline") | |
263 (and set-anyway (face-underline-p face)))) | |
264 ) | |
265 (if fn | |
266 (condition-case () | |
267 (set-face-font face fn frame) | |
268 (error (message "font `%s' not found for face `%s'" fn name)))) | |
269 (if fg | |
270 (condition-case () | |
271 (set-face-foreground face fg frame) | |
272 (error (message "color `%s' not allocated for face `%s'" fg name)))) | |
273 (if bg | |
274 (condition-case () | |
275 (set-face-background face bg frame) | |
276 (error (message "color `%s' not allocated for face `%s'" bg name)))) | |
277 ;; (if bgp | |
278 ;; (condition-case () | |
279 ;; (set-face-background-pixmap face bgp frame) | |
280 ;; (error (message "pixmap `%s' not found for face `%s'" bgp name)))) | |
281 (if (or ulp set-anyway) | |
282 (set-face-underline-p face ulp frame)) | |
283 ))) | |
284 face) | |
285 | |
286 (defun copy-face (old-face new-name &optional frame) | |
287 "Define a face just like OLD-FACE, with name NEW-NAME. | |
288 If NEW-NAME already exists as a face, it is modified to be like OLD-FACE. | |
289 If the optional argument FRAME is given, this applies only to that frame. | |
290 Otherwise it applies to each frame separately." | |
291 (setq old-face (internal-get-face old-face frame)) | |
292 (let* ((inhibit-quit t) | |
293 (new-face (or (internal-find-face new-name frame) | |
294 (make-face new-name)))) | |
295 (if (null frame) | |
296 (let ((frames (frame-list))) | |
297 (while frames | |
298 (copy-face old-face new-name (car frames)) | |
299 (setq frames (cdr frames))) | |
300 (copy-face old-face new-name t)) | |
301 (set-face-font new-face (face-font old-face frame) frame) | |
302 (set-face-foreground new-face (face-foreground old-face frame) frame) | |
303 (set-face-background new-face (face-background old-face frame) frame) | |
2800
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
304 ;;; (set-face-background-pixmap |
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
305 ;;; new-face (face-background-pixmap old-face frame) frame) |
2456 | 306 (set-face-underline-p new-face (face-underline-p old-face frame) |
307 frame)) | |
308 new-face)) | |
309 | |
310 (defun face-equal (face1 face2 &optional frame) | |
311 "True if the faces FACE1 and FACE2 display in the the same way." | |
312 (setq face1 (internal-get-face face1 frame) | |
313 face2 (internal-get-face face2 frame)) | |
314 (and (equal (face-foreground face1 frame) (face-foreground face2 frame)) | |
315 (equal (face-background face1 frame) (face-background face2 frame)) | |
316 (equal (face-font face1 frame) (face-font face2 frame)) | |
317 (equal (face-background-pixmap face1 frame) | |
318 (face-background-pixmap face2 frame)))) | |
319 | |
320 (defun face-differs-from-default-p (face &optional frame) | |
321 "True if face FACE displays differently from the default face, on FRAME. | |
322 A face is considered to be ``the same'' as the default face if it is | |
323 actually specified in the same way (equivalent fonts, etc) or if it is | |
324 fully unspecified, and thus inherits the attributes of any face it | |
325 is displayed on top of." | |
326 (let ((default (internal-get-face 'default frame))) | |
327 (setq face (internal-get-face face frame)) | |
328 (not (and (or (equal (face-foreground default frame) | |
329 (face-foreground face frame)) | |
330 (null (face-foreground face frame))) | |
331 (or (equal (face-background default frame) | |
332 (face-background face frame)) | |
333 (null (face-background face frame))) | |
334 (or (equal (face-font default frame) (face-font face frame)) | |
335 (null (face-font face frame))) | |
2800
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
336 ;;; (or (equal (face-background-pixmap default frame) |
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
337 ;;; (face-background-pixmap face frame)) |
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
338 ;;; (null (face-background-pixmap face frame))) |
2456 | 339 (equal (face-underline-p default frame) |
340 (face-underline-p face frame)) | |
341 )))) | |
342 | |
343 | |
344 (defun invert-face (face &optional frame) | |
345 "Swap the foreground and background colors of face FACE. | |
346 If the face doesn't specify both foreground and background, then | |
2800
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
347 set its foreground and background to the default background and foreground." |
2456 | 348 (interactive (list (read-face-name "Invert face: "))) |
349 (setq face (internal-get-face face frame)) | |
350 (let ((fg (face-foreground face frame)) | |
351 (bg (face-background face frame))) | |
352 (if (or fg bg) | |
353 (progn | |
354 (set-face-foreground face bg frame) | |
355 (set-face-background face fg frame)) | |
2800
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
356 (set-face-foreground face (or (face-background 'default frame) |
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
357 (cdr (assq 'background-color (frame-parameters frame)))) |
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
358 frame) |
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
359 (set-face-background face (or (face-foreground 'default frame) |
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
360 (cdr (assq 'foreground-color (frame-parameters frame)))) |
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
361 frame))) |
2456 | 362 face) |
363 | |
364 | |
365 (defun internal-try-face-font (face font &optional frame) | |
366 "Like set-face-font, but returns nil on failure instead of an error." | |
367 (condition-case () | |
368 (set-face-font face font frame) | |
369 (error nil))) | |
370 | |
371 ;; Manipulating font names. | |
372 | |
373 (defconst x-font-regexp nil) | |
374 (defconst x-font-regexp-head nil) | |
375 (defconst x-font-regexp-weight nil) | |
376 (defconst x-font-regexp-slant nil) | |
377 | |
378 ;;; Regexps matching font names in "Host Portable Character Representation." | |
379 ;;; | |
380 (let ((- "[-?]") | |
381 (foundry "[^-]+") | |
382 (family "[^-]+") | |
383 (weight "\\(bold\\|demibold\\|medium\\)") ; 1 | |
384 ; (weight\? "\\(\\*\\|bold\\|demibold\\|medium\\|\\)") ; 1 | |
385 (weight\? "\\([^-]*\\)") ; 1 | |
386 (slant "\\([ior]\\)") ; 2 | |
387 ; (slant\? "\\([ior?*]?\\)") ; 2 | |
388 (slant\? "\\([^-]?\\)") ; 2 | |
389 ; (swidth "\\(\\*\\|normal\\|semicondensed\\|\\)") ; 3 | |
390 (swidth "\\([^-]*\\)") ; 3 | |
391 ; (adstyle "\\(\\*\\|sans\\|\\)") ; 4 | |
392 (adstyle "[^-]*") ; 4 | |
393 (pixelsize "[0-9]+") | |
394 (pointsize "[0-9][0-9]+") | |
395 (resx "[0-9][0-9]+") | |
396 (resy "[0-9][0-9]+") | |
397 (spacing "[cmp?*]") | |
398 (avgwidth "[0-9]+") | |
399 (registry "[^-]+") | |
400 (encoding "[^-]+") | |
401 ) | |
402 (setq x-font-regexp | |
403 (concat "\\`\\*?[-?*]" | |
404 foundry - family - weight\? - slant\? - swidth - adstyle - | |
405 pixelsize - pointsize - resx - resy - spacing - registry - | |
406 encoding "[-?*]\\*?\\'" | |
407 )) | |
408 (setq x-font-regexp-head | |
409 (concat "\\`[-?*]" foundry - family - weight\? - slant\? | |
410 "\\([-*?]\\|\\'\\)")) | |
411 (setq x-font-regexp-slant (concat - slant -)) | |
412 (setq x-font-regexp-weight (concat - weight -)) | |
413 nil) | |
414 | |
415 (defun x-frob-font-weight (font which) | |
416 (if (or (string-match x-font-regexp font) | |
417 (string-match x-font-regexp-head font) | |
418 (string-match x-font-regexp-weight font)) | |
419 (concat (substring font 0 (match-beginning 1)) which | |
420 (substring font (match-end 1))) | |
421 nil)) | |
422 | |
423 (defun x-frob-font-slant (font which) | |
424 (cond ((or (string-match x-font-regexp font) | |
425 (string-match x-font-regexp-head font)) | |
426 (concat (substring font 0 (match-beginning 2)) which | |
427 (substring font (match-end 2)))) | |
428 ((string-match x-font-regexp-slant font) | |
429 (concat (substring font 0 (match-beginning 1)) which | |
430 (substring font (match-end 1)))) | |
431 (t nil))) | |
432 | |
433 | |
434 (defun x-make-font-bold (font) | |
435 "Given an X font specification, this attempts to make a `bold' version | |
436 of it. If it fails, it returns nil." | |
437 (x-frob-font-weight font "bold")) | |
438 | |
439 (defun x-make-font-demibold (font) | |
440 "Given an X font specification, this attempts to make a `demibold' version | |
441 of it. If it fails, it returns nil." | |
442 (x-frob-font-weight font "demibold")) | |
443 | |
444 (defun x-make-font-unbold (font) | |
445 "Given an X font specification, this attempts to make a non-bold version | |
446 of it. If it fails, it returns nil." | |
447 (x-frob-font-weight font "medium")) | |
448 | |
449 (defun x-make-font-italic (font) | |
450 "Given an X font specification, this attempts to make an `italic' version | |
451 of it. If it fails, it returns nil." | |
452 (x-frob-font-slant font "i")) | |
453 | |
454 (defun x-make-font-oblique (font) ; you say tomayto... | |
455 "Given an X font specification, this attempts to make an `italic' version | |
456 of it. If it fails, it returns nil." | |
457 (x-frob-font-slant font "o")) | |
458 | |
459 (defun x-make-font-unitalic (font) | |
460 "Given an X font specification, this attempts to make a non-italic version | |
461 of it. If it fails, it returns nil." | |
462 (x-frob-font-slant font "r")) | |
463 | |
464 | |
465 ;;; non-X-specific interface | |
466 | |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
467 (defun make-face-bold (face &optional frame noerror) |
2456 | 468 "Make the font of the given face be bold, if possible. |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
469 If NOERROR is non-nil, return nil on failure." |
2456 | 470 (interactive (list (read-face-name "Make which face bold: "))) |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
471 (let ((ofont (face-font face frame)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
472 font f2) |
2456 | 473 (if (null frame) |
474 (let ((frames (frame-list))) | |
475 (while frames | |
476 (make-face-bold face (car frames)) | |
477 (setq frames (cdr frames)))) | |
478 (setq face (internal-get-face face frame)) | |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
479 (setq font (or (face-font face frame) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
480 (face-font face t) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
481 (face-font 'default frame) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
482 (cdr (assq 'font (frame-parameters frame))))) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
483 (or (and (setq f2 (x-make-font-bold font)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
484 (internal-try-face-font face f2)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
485 (and (setq f2 (x-make-font-demibold font)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
486 (internal-try-face-font face f2)))) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
487 (or (not (equal ofont (face-font face))) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
488 (and (not noerror) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
489 (error "No %s version of %S" face ofont))))) |
2456 | 490 |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
491 (defun make-face-italic (face &optional frame noerror) |
2456 | 492 "Make the font of the given face be italic, if possible. |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
493 If NOERROR is non-nil, return nil on failure." |
2456 | 494 (interactive (list (read-face-name "Make which face italic: "))) |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
495 (let ((ofont (face-font face frame)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
496 font f2) |
2456 | 497 (if (null frame) |
498 (let ((frames (frame-list))) | |
499 (while frames | |
500 (make-face-italic face (car frames)) | |
501 (setq frames (cdr frames)))) | |
502 (setq face (internal-get-face face frame)) | |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
503 (setq font (or (face-font face frame) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
504 (face-font face t) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
505 (face-font 'default frame) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
506 (cdr (assq 'font (frame-parameters frame))))) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
507 (or (and (setq f2 (x-make-font-italic font)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
508 (internal-try-face-font face f2)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
509 (and (setq f2 (x-make-font-oblique font)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
510 (internal-try-face-font face f2)))) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
511 (or (not (equal ofont (face-font face))) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
512 (and (not noerror) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
513 (error "No %s version of %S" face ofont))))) |
2456 | 514 |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
515 (defun make-face-bold-italic (face &optional frame noerror) |
2456 | 516 "Make the font of the given face be bold and italic, if possible. |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
517 If NOERROR is non-nil, return nil on failure." |
2456 | 518 (interactive (list (read-face-name "Make which face bold-italic: "))) |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
519 (let ((ofont (face-font face frame)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
520 font f2 f3) |
2456 | 521 (if (null frame) |
522 (let ((frames (frame-list))) | |
523 (while frames | |
524 (make-face-bold-italic face (car frames)) | |
525 (setq frames (cdr frames)))) | |
526 (setq face (internal-get-face face frame)) | |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
527 (setq font (or (face-font face frame) |
2456 | 528 (face-font face t) |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
529 (face-font 'default frame) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
530 (cdr (assq 'font (frame-parameters frame))))) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
531 (or (and (setq f2 (x-make-font-italic font)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
532 (not (equal font f2)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
533 (setq f3 (x-make-font-bold f2)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
534 (not (equal f2 f3)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
535 (internal-try-face-font face f3)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
536 (and (setq f2 (x-make-font-oblique font)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
537 (not (equal font f2)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
538 (setq f3 (x-make-font-bold f2)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
539 (not (equal f2 f3)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
540 (internal-try-face-font face f3)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
541 (and (setq f2 (x-make-font-italic font)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
542 (not (equal font f2)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
543 (setq f3 (x-make-font-demibold f2)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
544 (not (equal f2 f3)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
545 (internal-try-face-font face f3)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
546 (and (setq f2 (x-make-font-oblique font)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
547 (not (equal font f2)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
548 (setq f3 (x-make-font-demibold f2)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
549 (not (equal f2 f3)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
550 (internal-try-face-font face f3)))) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
551 (or (not (equal ofont (face-font face))) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
552 (and (not noerror) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
553 (error "No %s version of %S" face ofont))))) |
2456 | 554 |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
555 (defun make-face-unbold (face &optional frame noerror) |
2456 | 556 "Make the font of the given face be non-bold, if possible. |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
557 If NOERROR is non-nil, return nil on failure." |
2456 | 558 (interactive (list (read-face-name "Make which face non-bold: "))) |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
559 (let ((ofont (face-font face frame)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
560 font font1) |
2456 | 561 (if (null frame) |
562 (let ((frames (frame-list))) | |
563 (while frames | |
564 (make-face-unbold face (car frames)) | |
565 (setq frames (cdr frames)))) | |
566 (setq face (internal-get-face face frame)) | |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
567 (setq font1 (or (face-font face frame) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
568 (face-font face t) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
569 (face-font 'default frame) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
570 (cdr (assq 'font (frame-parameters frame))))) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
571 (setq font (x-make-font-unbold font1)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
572 (if font (internal-try-face-font face font))) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
573 (or (not (equal ofont (face-font face))) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
574 (and (not noerror) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
575 (error "No %s version of %S" face ofont))))) |
2456 | 576 |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
577 (defun make-face-unitalic (face &optional frame noerror) |
2456 | 578 "Make the font of the given face be non-italic, if possible. |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
579 If NOERROR is non-nil, return nil on failure." |
2456 | 580 (interactive (list (read-face-name "Make which face non-italic: "))) |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
581 (let ((ofont (face-font face frame)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
582 font font1) |
2456 | 583 (if (null frame) |
584 (let ((frames (frame-list))) | |
585 (while frames | |
586 (make-face-unitalic face (car frames)) | |
587 (setq frames (cdr frames)))) | |
588 (setq face (internal-get-face face frame)) | |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
589 (setq font1 (or (face-font face frame) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
590 (face-font face t) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
591 (face-font 'default frame) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
592 (cdr (assq 'font (frame-parameters frame))))) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
593 (setq font (x-make-font-unitalic font1)) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
594 (if font (internal-try-face-font face font))) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
595 (or (not (equal ofont (face-font face))) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
596 (and (not noerror) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
597 (error "No %s version of %S" face ofont))))) |
2456 | 598 |
599 ;;; Make the builtin faces; the C code knows these as faces 0, 1, and 2, | |
600 ;;; respectively, so they must be the first three faces made. | |
601 | |
2764
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
602 (defun face-initialize () |
2456 | 603 (make-face 'default) |
2800
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
604 ;;; (make-face 'modeline) |
2456 | 605 (make-face 'highlight) |
606 ;; | |
607 ;; These aren't really special in any way, but they're nice to have around. | |
608 ;; The X-specific code is clever at them. | |
609 ;; | |
610 (make-face 'bold) | |
611 (make-face 'italic) | |
612 (make-face 'bold-italic) | |
2807
9e8635dafd40
Rename `primary-selection' to `region'.
Richard M. Stallman <rms@gnu.org>
parents:
2800
diff
changeset
|
613 (make-face 'region) |
2764
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
614 (make-face 'secondary-selection) |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
615 |
2807
9e8635dafd40
Rename `primary-selection' to `region'.
Richard M. Stallman <rms@gnu.org>
parents:
2800
diff
changeset
|
616 (setq region-face (face-id 'region)) |
2800
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
617 |
2764
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
618 ;; Set up the faces of all existing X Window frames. |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
619 (let ((frames (frame-list))) |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
620 (while frames |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
621 (if (eq (framep (car frames)) 'x) |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
622 (x-initialize-frame-faces (car frames))) |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
623 (setq frames (cdr frames))))) |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
624 |
2456 | 625 |
626 ;;; This really belongs in setting a frame's own font. | |
627 ;;; ;; | |
628 ;;; ;; No font specified in the resource database; try to cope. | |
629 ;;; ;; | |
630 ;;; (internal-try-face-font default "-*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-*" | |
631 ;;; frame) | |
632 ;;; (internal-try-face-font default "-*-courier-*-r-*-*-*-120-*-*-*-*-iso8859-*" | |
633 ;;; frame) | |
634 ;;; (internal-try-face-font default "-*-*-medium-r-*-*-*-120-*-*-m-*-iso8859-*" frame) | |
635 ;;; (internal-try-face-font default "-*-*-medium-r-*-*-*-120-*-*-c-*-iso8859-*" frame) | |
636 ;;; (internal-try-face-font default "-*-*-*-r-*-*-*-120-*-*-m-*-iso8859-*" frame) | |
637 ;;; (internal-try-face-font default "-*-*-*-r-*-*-*-120-*-*-c-*-iso8859-*" frame) | |
638 ;;; (internal-try-face-font default "-*-*-*-r-*-*-*-120-*-*-*-*-iso8859-*" frame) | |
639 | |
640 | |
641 ;;; This is called from make-screen-initial-faces to make sure that the | |
642 ;;; "default" and "modeline" faces for this screen have enough attributes | |
643 ;;; specified for emacs to be able to display anything on it. This had | |
644 ;;; better not signal an error. | |
645 ;;; | |
646 (defun x-initialize-frame-faces (frame) | |
647 (or (face-differs-from-default-p 'bold frame) | |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
648 (make-face-bold 'bold frame t) |
2456 | 649 ;; if default font is bold, then make the `bold' face be unbold. |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
650 (make-face-unbold 'bold frame t) |
2456 | 651 ;; otherwise the luser specified one of the bogus font names |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
652 (internal-x-complain-about-font 'bold frame) |
2456 | 653 ) |
654 | |
655 (or (face-differs-from-default-p 'italic frame) | |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
656 (make-face-italic 'italic frame t) |
2456 | 657 (progn |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
658 (make-face-bold 'italic frame t) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
659 (internal-x-complain-about-font 'italic frame)) |
2456 | 660 ) |
661 | |
662 (or (face-differs-from-default-p 'bold-italic frame) | |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
663 (make-face-bold-italic 'bold-italic frame t) |
2456 | 664 ;; if we couldn't get a bold-italic version, try just bold. |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
665 (make-face-bold 'bold-italic frame t) |
2456 | 666 ;; if we couldn't get bold or bold-italic, then that's probably because |
667 ;; the default font is bold, so make the `bold-italic' face be unbold. | |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
668 (and (make-face-unbold 'bold-italic frame t) |
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
669 (make-face-italic 'bold-italic frame t)) |
2456 | 670 ;; if that didn't work, try italic (can this ever happen? what the hell.) |
671 (progn | |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
672 (make-face-italic 'bold-italic frame t) |
2456 | 673 ;; then bitch and moan. |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
674 (internal-x-complain-about-font 'bold-italic frame)) |
2456 | 675 ) |
676 | |
677 (or (face-differs-from-default-p 'highlight frame) | |
678 (condition-case () | |
2800
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
679 (condition-case () |
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
680 (set-face-background 'highlight "darkseagreen2" frame) |
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
681 (error (set-face-background 'highlight "green" frame))) |
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
682 ;;; (set-face-background-pixmap 'highlight "gray1" frame) |
2456 | 683 (error (invert-face 'highlight frame)))) |
684 | |
2807
9e8635dafd40
Rename `primary-selection' to `region'.
Richard M. Stallman <rms@gnu.org>
parents:
2800
diff
changeset
|
685 (or (face-differs-from-default-p 'region frame) |
2456 | 686 (condition-case () |
2807
9e8635dafd40
Rename `primary-selection' to `region'.
Richard M. Stallman <rms@gnu.org>
parents:
2800
diff
changeset
|
687 (set-face-background 'region "gray" frame) |
9e8635dafd40
Rename `primary-selection' to `region'.
Richard M. Stallman <rms@gnu.org>
parents:
2800
diff
changeset
|
688 (error (invert-face 'region frame)))) |
2456 | 689 |
690 (or (face-differs-from-default-p 'secondary-selection frame) | |
691 (condition-case () | |
2800
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
692 (condition-case () |
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
693 ;; some older X servers don't have this one. |
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
694 (set-face-background 'secondary-selection "paleturquoise" |
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
695 frame) |
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
696 (error |
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
697 (set-face-background 'secondary-selection "green" frame))) |
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
698 ;;; (set-face-background-pixmap 'secondary-selection "gray1" frame) |
2456 | 699 (error (invert-face 'secondary-selection frame)))) |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
700 ) |
2456 | 701 |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
702 (defun internal-x-complain-about-font (face frame) |
2800
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
703 ;;; It's annoying to bother the user about this, |
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
704 ;;; since it happens under normal circumstances. |
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
705 ;;; (message "No %s version of %S" |
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
706 ;;; face |
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
707 ;;; (or (face-font face frame) |
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
708 ;;; (face-font face t) |
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
709 ;;; (face-font 'default frame) |
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
710 ;;; (cdr (assq 'font (frame-parameters frame))))) |
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
711 ;;; (sit-for 1) |
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
712 ) |
2456 | 713 |
714 ;; Like x-create-frame but also set up the faces. | |
715 | |
716 (defun x-create-frame-with-faces (&optional parameters) | |
2764
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
717 (if (null global-face-data) |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
718 (x-create-frame parameters) |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
719 (let* ((frame (x-create-frame parameters)) |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
720 (faces (copy-alist global-face-data)) |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
721 (rest faces) |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
722 default modeline) |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
723 (set-frame-face-alist frame faces) |
2456 | 724 |
2764
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
725 ;; Copy the vectors that represent the faces. |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
726 ;; Also fill them in from X resources. |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
727 (while rest |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
728 (setcdr (car rest) (copy-sequence (cdr (car rest)))) |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
729 (make-face-x-resource-internal (cdr (car rest)) frame t) |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
730 (setq rest (cdr rest))) |
2456 | 731 |
2764
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
732 (setq default (internal-get-face 'default frame) |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
733 modeline (internal-get-face 'modeline frame)) |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
734 |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
735 (x-initialize-frame-faces frame) |
2456 | 736 |
2764
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
737 ;;; ;; Make sure the modeline face is fully qualified. |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
738 ;;; (if (and (not (face-font modeline frame)) (face-font default frame)) |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
739 ;;; (set-face-font modeline (face-font default frame) frame)) |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
740 ;;; (if (and (not (face-background modeline frame)) |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
741 ;;; (face-background default frame)) |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
742 ;;; (set-face-background modeline (face-background default frame) frame)) |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
743 ;;; (if (and (not (face-foreground modeline frame)) |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
744 ;;; (face-foreground default frame)) |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
745 ;;; (set-face-foreground modeline (face-foreground default frame) frame)) |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
746 frame))) |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
747 |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
748 ;; If we are already using x-window frames, initialize faces for them. |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
749 (if (eq (framep (selected-frame)) 'x) |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
750 (face-initialize)) |
2456 | 751 |
2715
9caee9338229
* faces.el: Call internal-set-face-1, not internat-set-face-1.
Jim Blandy <jimb@redhat.com>
parents:
2714
diff
changeset
|
752 (provide 'faces) |
9caee9338229
* faces.el: Call internal-set-face-1, not internat-set-face-1.
Jim Blandy <jimb@redhat.com>
parents:
2714
diff
changeset
|
753 |
2456 | 754 ;;; faces.el ends here |