annotate lisp/faces.el @ 3925:f286657c098e

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