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