annotate lisp/faces.el @ 17173:84aa6682810b

(set-face-font): Allow specifing fontset for the arg FONT.
author Kenichi Handa <handa@m17n.org>
date Tue, 18 Mar 1997 23:16:27 +0000
parents 97232f50447f
children b251c8820860
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
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
3 ;; Copyright (C) 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
2456
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
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
18 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
19 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
20 ;; Boston, MA 02111-1307, USA.
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
21
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
22 ;;; Commentary:
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
23
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
24 ;; Mostly derived from Lucid.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
25
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
26 ;;; Code:
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
27
10107
2af74ff52cd0 At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents: 10105
diff changeset
28 (eval-when-compile
2af74ff52cd0 At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents: 10105
diff changeset
29 ;; These used to be defsubsts, now they're subrs. Avoid losing if we're
2af74ff52cd0 At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents: 10105
diff changeset
30 ;; being compiled with an old Emacs that still has defsubrs in it.
2af74ff52cd0 At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents: 10105
diff changeset
31 (put 'face-name 'byte-optimizer nil)
2af74ff52cd0 At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents: 10105
diff changeset
32 (put 'face-id 'byte-optimizer nil)
2af74ff52cd0 At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents: 10105
diff changeset
33 (put 'face-font 'byte-optimizer nil)
2af74ff52cd0 At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents: 10105
diff changeset
34 (put 'face-foreground 'byte-optimizer nil)
2af74ff52cd0 At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents: 10105
diff changeset
35 (put 'face-background 'byte-optimizer nil)
2af74ff52cd0 At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents: 10105
diff changeset
36 (put 'face-stipple 'byte-optimizer nil)
2af74ff52cd0 At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents: 10105
diff changeset
37 (put 'face-underline-p 'byte-optimizer nil)
2af74ff52cd0 At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents: 10105
diff changeset
38 (put 'set-face-font 'byte-optimizer nil)
2af74ff52cd0 At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents: 10105
diff changeset
39 (put 'set-face-foreground 'byte-optimizer nil)
2af74ff52cd0 At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents: 10105
diff changeset
40 (put 'set-face-background 'byte-optimizer nil)
11850
f9174d73e755 Put property on set-face-stipple, not set-stipple.
Karl Heuer <kwzh@gnu.org>
parents: 11464
diff changeset
41 (put 'set-face-stipple 'byte-optimizer nil)
10107
2af74ff52cd0 At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents: 10105
diff changeset
42 (put 'set-face-underline-p 'byte-optimizer nil))
2744
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
43
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
44 ;;;; 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
45
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
46 ;;; A face vector is a vector of the form:
9569
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
47 ;;; [face NAME ID FONT FOREGROUND BACKGROUND STIPPLE UNDERLINE]
2744
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
48
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
49 ;;; Type checkers.
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
50 (defsubst internal-facep (x)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
51 (and (vectorp x) (= (length x) 8) (eq (aref x 0) 'face)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
52
10584
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
53 (defun facep (x)
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
54 "Return t if X is a face name or an internal face vector."
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
55 (and (or (internal-facep x)
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
56 (and (symbolp x) (assq x global-face-data)))
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
57 t))
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
58
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
59 (defmacro internal-check-face (face)
10584
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
60 (` (or (internal-facep (, face))
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
61 (signal 'wrong-type-argument (list 'internal-facep (, face))))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
62
2744
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
63 ;;; Accessors.
10105
249d94c7e4f1 (face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents: 10022
diff changeset
64 (defun face-name (face)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
65 "Return the name of face FACE."
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
66 (aref (internal-get-face face) 1))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
67
10105
249d94c7e4f1 (face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents: 10022
diff changeset
68 (defun face-id (face)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
69 "Return the internal ID number of face FACE."
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
70 (aref (internal-get-face face) 2))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
71
10105
249d94c7e4f1 (face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents: 10022
diff changeset
72 (defun face-font (face &optional frame)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
73 "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
74 If the optional argument FRAME is given, report on face FACE in that frame.
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
75 If FRAME is t, report on the defaults for face FACE (for new frames).
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
76 The font default for a face is either nil, or a list
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
77 of the form (bold), (italic) or (bold italic).
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
78 If FRAME is omitted or nil, use the selected frame."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
79 (aref (internal-get-face face frame) 3))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
80
10105
249d94c7e4f1 (face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents: 10022
diff changeset
81 (defun face-foreground (face &optional frame)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
82 "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
83 If the optional argument FRAME is given, report on face FACE in that frame.
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
84 If FRAME is t, report on the defaults for face FACE (for new frames).
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
85 If FRAME is omitted or nil, use the selected frame."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
86 (aref (internal-get-face face frame) 4))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
87
10105
249d94c7e4f1 (face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents: 10022
diff changeset
88 (defun face-background (face &optional frame)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
89 "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
90 If the optional argument FRAME is given, report on face FACE in that frame.
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
91 If FRAME is t, report on the defaults for face FACE (for new frames).
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
92 If FRAME is omitted or nil, use the selected frame."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
93 (aref (internal-get-face face frame) 5))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
94
10105
249d94c7e4f1 (face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents: 10022
diff changeset
95 (defun face-stipple (face &optional frame)
9569
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
96 "Return the stipple pixmap name of face FACE, or nil if unspecified.
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
97 If the optional argument FRAME is given, report on face FACE in that frame.
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
98 If FRAME is t, report on the defaults for face FACE (for new frames).
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
99 If FRAME is omitted or nil, use the selected frame."
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
100 (aref (internal-get-face face frame) 6))
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
101
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
102 (defalias 'face-background-pixmap 'face-stipple)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
103
10105
249d94c7e4f1 (face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents: 10022
diff changeset
104 (defun face-underline-p (face &optional frame)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
105 "Return t if face FACE is underlined.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
106 If the optional argument FRAME is given, report on face FACE in that frame.
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
107 If FRAME is t, report on the defaults for face FACE (for new frames).
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
108 If FRAME is omitted or nil, use the selected frame."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
109 (aref (internal-get-face face frame) 7))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
110
2744
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
111
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
112 ;;; Mutators.
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
113
10105
249d94c7e4f1 (face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents: 10022
diff changeset
114 (defun set-face-font (face font &optional frame)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
115 "Change the font of face FACE to FONT (a string).
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
116 If the optional FRAME argument is provided, change only
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
117 in that frame; otherwise change each frame."
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
118 (interactive (internal-face-interactive "font"))
17173
84aa6682810b (set-face-font): Allow specifing fontset for the arg FONT.
Kenichi Handa <handa@m17n.org>
parents: 17162
diff changeset
119 (if (stringp font)
84aa6682810b (set-face-font): Allow specifing fontset for the arg FONT.
Kenichi Handa <handa@m17n.org>
parents: 17162
diff changeset
120 (setq font (or (query-fontset font)
84aa6682810b (set-face-font): Allow specifing fontset for the arg FONT.
Kenichi Handa <handa@m17n.org>
parents: 17162
diff changeset
121 (x-resolve-font-name font 'default frame))))
3130
82c29bacb6b3 * faces.el (x-resolve-font-name): If PATTERN is nil, return the
Jim Blandy <jimb@redhat.com>
parents: 3071
diff changeset
122 (internal-set-face-1 face 'font font 3 frame))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
123
10105
249d94c7e4f1 (face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents: 10022
diff changeset
124 (defun set-face-foreground (face color &optional frame)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
125 "Change the foreground color of face FACE to COLOR (a string).
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
126 If the optional FRAME argument is provided, change only
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
127 in that frame; otherwise change each frame."
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
128 (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
129 (internal-set-face-1 face 'foreground color 4 frame))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
130
12562
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
131 (defvar face-default-stipple "gray3"
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
132 "Default stipple pattern used on monochrome displays.
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
133 This stipple pattern is used on monochrome displays
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
134 instead of shades of gray for a face background color.
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
135 See `set-face-stipple' for possible values for this variable.")
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
136
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
137 (defun face-color-gray-p (color &optional frame)
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
138 "Return t if COLOR is a shade of gray (or white or black).
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
139 FRAME specifies the frame and thus the display for interpreting COLOR."
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
140 (let* ((values (x-color-values color frame))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
141 (r (nth 0 values))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
142 (g (nth 1 values))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
143 (b (nth 2 values)))
14409
11a297676bda (face-color-gray-p): Return nil if x-color-values does.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
144 (and values
11a297676bda (face-color-gray-p): Return nil if x-color-values does.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
145 (< (abs (- r g)) (/ (max 1 (abs r) (abs g)) 20))
12562
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
146 (< (abs (- g b)) (/ (max 1 (abs g) (abs b)) 20))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
147 (< (abs (- b r)) (/ (max 1 (abs b) (abs r)) 20)))))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
148
10105
249d94c7e4f1 (face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents: 10022
diff changeset
149 (defun set-face-background (face color &optional frame)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
150 "Change the background color of face FACE to COLOR (a string).
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
151 If the optional FRAME argument is provided, change only
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
152 in that frame; otherwise change each frame."
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
153 (interactive (internal-face-interactive "background"))
9665
36bdda3a1dc9 (set-face-background): Set either stipple or color,
Richard M. Stallman <rms@gnu.org>
parents: 9661
diff changeset
154 ;; For a specific frame, use gray stipple instead of gray color
36bdda3a1dc9 (set-face-background): Set either stipple or color,
Richard M. Stallman <rms@gnu.org>
parents: 9661
diff changeset
155 ;; if the display does not support a gray color.
12725
968d38f57f3a (set-face-background): Don't treat nil as a color.
Richard M. Stallman <rms@gnu.org>
parents: 12690
diff changeset
156 (if (and frame (not (eq frame t)) color
14040
187735b53d52 Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 13725
diff changeset
157 ;; Check for support for foreground, not for background!
12776
d69a2d6d1ae9 (set-face-background): When using face-color-supported-p,
Richard M. Stallman <rms@gnu.org>
parents: 12725
diff changeset
158 ;; face-color-supported-p is smart enough to know
d69a2d6d1ae9 (set-face-background): When using face-color-supported-p,
Richard M. Stallman <rms@gnu.org>
parents: 12725
diff changeset
159 ;; that grays are "supported" as background
d69a2d6d1ae9 (set-face-background): When using face-color-supported-p,
Richard M. Stallman <rms@gnu.org>
parents: 12725
diff changeset
160 ;; because we are supposed to use stipple for them!
d69a2d6d1ae9 (set-face-background): When using face-color-supported-p,
Richard M. Stallman <rms@gnu.org>
parents: 12725
diff changeset
161 (not (face-color-supported-p frame color nil)))
12562
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
162 (set-face-stipple face face-default-stipple frame)
11464
4921121fbdc0 (set-face-background): Handle FRAME = nil directly
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
163 (if (null frame)
4921121fbdc0 (set-face-background): Handle FRAME = nil directly
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
164 (let ((frames (frame-list)))
4921121fbdc0 (set-face-background): Handle FRAME = nil directly
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
165 (while frames
4921121fbdc0 (set-face-background): Handle FRAME = nil directly
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
166 (set-face-background (face-name face) color (car frames))
4921121fbdc0 (set-face-background): Handle FRAME = nil directly
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
167 (setq frames (cdr frames)))
4921121fbdc0 (set-face-background): Handle FRAME = nil directly
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
168 (set-face-background face color t)
4921121fbdc0 (set-face-background): Handle FRAME = nil directly
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
169 color)
4921121fbdc0 (set-face-background): Handle FRAME = nil directly
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
170 (internal-set-face-1 face 'background color 5 frame))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
171
12562
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
172 (defun set-face-stipple (face pixmap &optional frame)
9569
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
173 "Change the stipple pixmap of face FACE to PIXMAP.
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
174 PIXMAP should be a string, the name of a file of pixmap data.
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
175 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
176
9569
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
177 Alternatively, PIXMAP may be a list of the form (WIDTH HEIGHT DATA)
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
178 where WIDTH and HEIGHT are the size in pixels,
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
179 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
180
9569
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
181 If the optional FRAME argument is provided, change only
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
182 in that frame; otherwise change each frame."
15884
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
183 (interactive (internal-face-interactive-stipple "stipple"))
12562
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
184 (internal-set-face-1 face 'background-pixmap pixmap 6 frame))
9569
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
185
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
186 (defalias 'set-face-background-pixmap 'set-face-stipple)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
187
10105
249d94c7e4f1 (face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents: 10022
diff changeset
188 (defun set-face-underline-p (face underline-p &optional frame)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
189 "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
190 If the optional FRAME argument is provided, change only
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
191 in that frame; otherwise change each frame."
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
192 (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
193 (internal-set-face-1 face 'underline underline-p 7 frame))
9197
3fe469325a8b (modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8999
diff changeset
194
11153
984f7567a1bd Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 11152
diff changeset
195 (defun modify-face-read-string (face default name alist)
11152
eb26f12a8be6 (modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents: 10598
diff changeset
196 (let ((value
eb26f12a8be6 (modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents: 10598
diff changeset
197 (completing-read
eb26f12a8be6 (modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents: 10598
diff changeset
198 (if default
eb26f12a8be6 (modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents: 10598
diff changeset
199 (format "Set face %s %s (default %s): "
eb26f12a8be6 (modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents: 10598
diff changeset
200 face name (downcase default))
eb26f12a8be6 (modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents: 10598
diff changeset
201 (format "Set face %s %s: " face name))
eb26f12a8be6 (modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents: 10598
diff changeset
202 alist)))
eb26f12a8be6 (modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents: 10598
diff changeset
203 (cond ((equal value "none")
eb26f12a8be6 (modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents: 10598
diff changeset
204 nil)
eb26f12a8be6 (modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents: 10598
diff changeset
205 ((equal value "")
eb26f12a8be6 (modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents: 10598
diff changeset
206 default)
eb26f12a8be6 (modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents: 10598
diff changeset
207 (t value))))
eb26f12a8be6 (modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents: 10598
diff changeset
208
eb26f12a8be6 (modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents: 10598
diff changeset
209 (defun modify-face (face foreground background stipple
13725
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
210 bold-p italic-p underline-p &optional frame)
9197
3fe469325a8b (modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8999
diff changeset
211 "Change the display attributes for face FACE.
13725
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
212 If the optional FRAME argument is provided, change only
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
213 in that frame; otherwise change each frame.
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
214
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
215 FOREGROUND and BACKGROUND should be a colour name string (or list of strings to
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
216 try) or nil. STIPPLE should be a stipple pattern name string or nil.
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
217 If nil, means do not change the display attribute corresponding to that arg.
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
218
9197
3fe469325a8b (modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8999
diff changeset
219 BOLD-P, ITALIC-P, and UNDERLINE-P specify whether the face should be set bold,
13725
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
220 in italic, and underlined, respectively. If neither nil or t, means do not
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
221 change the display attribute corresponding to that arg.
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
222
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
223 If called interactively, prompts for a face name and face attributes."
9197
3fe469325a8b (modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8999
diff changeset
224 (interactive
3fe469325a8b (modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8999
diff changeset
225 (let* ((completion-ignore-case t)
13725
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
226 (face (symbol-name (read-face-name "Modify face: ")))
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
227 (colors (mapcar 'list x-colors))
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
228 (stipples (mapcar 'list (apply 'nconc
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
229 (mapcar 'directory-files
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
230 x-bitmap-file-path))))
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
231 (foreground (modify-face-read-string
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
232 face (face-foreground (intern face))
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
233 "foreground" colors))
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
234 (background (modify-face-read-string
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
235 face (face-background (intern face))
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
236 "background" colors))
15871
4904f9f8bf41 (modify-face): Handle stipple values
Richard M. Stallman <rms@gnu.org>
parents: 15510
diff changeset
237 ;; If the stipple value is a list (WIDTH HEIGHT DATA),
4904f9f8bf41 (modify-face): Handle stipple values
Richard M. Stallman <rms@gnu.org>
parents: 15510
diff changeset
238 ;; represent that as a string by printing it out.
4904f9f8bf41 (modify-face): Handle stipple values
Richard M. Stallman <rms@gnu.org>
parents: 15510
diff changeset
239 (old-stipple-string
4904f9f8bf41 (modify-face): Handle stipple values
Richard M. Stallman <rms@gnu.org>
parents: 15510
diff changeset
240 (if (stringp (face-stipple (intern face)))
4904f9f8bf41 (modify-face): Handle stipple values
Richard M. Stallman <rms@gnu.org>
parents: 15510
diff changeset
241 (face-stipple (intern face))
15884
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
242 (if (face-stipple (intern face))
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
243 (prin1-to-string (face-stipple (intern face))))))
15871
4904f9f8bf41 (modify-face): Handle stipple values
Richard M. Stallman <rms@gnu.org>
parents: 15510
diff changeset
244 (new-stipple-string
4904f9f8bf41 (modify-face): Handle stipple values
Richard M. Stallman <rms@gnu.org>
parents: 15510
diff changeset
245 (modify-face-read-string
4904f9f8bf41 (modify-face): Handle stipple values
Richard M. Stallman <rms@gnu.org>
parents: 15510
diff changeset
246 face old-stipple-string
4904f9f8bf41 (modify-face): Handle stipple values
Richard M. Stallman <rms@gnu.org>
parents: 15510
diff changeset
247 "stipple" stipples))
4904f9f8bf41 (modify-face): Handle stipple values
Richard M. Stallman <rms@gnu.org>
parents: 15510
diff changeset
248 ;; Convert the stipple value text we read
4904f9f8bf41 (modify-face): Handle stipple values
Richard M. Stallman <rms@gnu.org>
parents: 15510
diff changeset
249 ;; back to a list if it looks like one.
4904f9f8bf41 (modify-face): Handle stipple values
Richard M. Stallman <rms@gnu.org>
parents: 15510
diff changeset
250 ;; This makes the assumption that a pixmap file name
4904f9f8bf41 (modify-face): Handle stipple values
Richard M. Stallman <rms@gnu.org>
parents: 15510
diff changeset
251 ;; won't start with an open-paren.
4904f9f8bf41 (modify-face): Handle stipple values
Richard M. Stallman <rms@gnu.org>
parents: 15510
diff changeset
252 (stipple
15884
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
253 (and new-stipple-string
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
254 (if (string-match "^(" new-stipple-string)
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
255 (read new-stipple-string)
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
256 new-stipple-string)))
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
257 (bold-p (y-or-n-p (concat "Should face " face " be bold ")))
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
258 (italic-p (y-or-n-p (concat "Should face " face " be italic ")))
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
259 (underline-p (y-or-n-p (concat "Should face " face " be underlined ")))
13725
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
260 (all-frames-p (y-or-n-p (concat "Modify face " face " in all frames "))))
9197
3fe469325a8b (modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8999
diff changeset
261 (message "Face %s: %s" face
3fe469325a8b (modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8999
diff changeset
262 (mapconcat 'identity
3fe469325a8b (modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8999
diff changeset
263 (delq nil
3fe469325a8b (modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8999
diff changeset
264 (list (and foreground (concat (downcase foreground) " foreground"))
3fe469325a8b (modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8999
diff changeset
265 (and background (concat (downcase background) " background"))
15871
4904f9f8bf41 (modify-face): Handle stipple values
Richard M. Stallman <rms@gnu.org>
parents: 15510
diff changeset
266 (and stipple (concat (downcase new-stipple-string) " stipple"))
9197
3fe469325a8b (modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8999
diff changeset
267 (and bold-p "bold") (and italic-p "italic")
3fe469325a8b (modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8999
diff changeset
268 (and underline-p "underline"))) ", "))
11152
eb26f12a8be6 (modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents: 10598
diff changeset
269 (list (intern face) foreground background stipple
13725
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
270 bold-p italic-p underline-p
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
271 (if all-frames-p nil (selected-frame)))))
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
272 (condition-case nil
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
273 (face-try-color-list 'set-face-foreground face foreground frame)
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
274 (error nil))
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
275 (condition-case nil
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
276 (face-try-color-list 'set-face-background face background frame)
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
277 (error nil))
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
278 (condition-case nil
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
279 (set-face-stipple face stipple frame)
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
280 (error nil))
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
281 (cond ((eq bold-p nil) (make-face-unbold face frame t))
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
282 ((eq bold-p t) (make-face-bold face frame t)))
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
283 (cond ((eq italic-p nil) (make-face-unitalic face frame t))
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
284 ((eq italic-p t) (make-face-italic face frame t)))
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
285 (if (memq underline-p '(nil t))
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
286 (set-face-underline-p face underline-p frame))
9197
3fe469325a8b (modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8999
diff changeset
287 (and (interactive-p) (redraw-display)))
2744
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
288
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
289 ;;;; 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
290
3925
f286657c098e * faces.el (global-face-data): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 3911
diff changeset
291 (defvar global-face-data nil
f286657c098e * faces.el (global-face-data): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 3911
diff changeset
292 "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
293 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
294 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
295
2744
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
296 (defun face-list ()
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
297 "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
298 (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
299
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
300 (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
301 "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
302 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
303 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
304 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
305 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
306 (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
307 (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
308 (if (symbolp name)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
309 (cdr (assq name
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
310 (if (eq frame t)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
311 global-face-data
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
312 (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
313 (internal-check-face name)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
314 name))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
315
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
316 (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
317 "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
318 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
319 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
320 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
321 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
322 (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
323 (internal-check-face name)))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
324
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
325
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
326 (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
327 (let ((inhibit-quit t))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
328 (if (null frame)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
329 (let ((frames (frame-list)))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
330 (while frames
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
331 (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
332 (setq frames (cdr frames)))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
333 (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
334 index value)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
335 value)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
336 (or (eq frame t)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
337 (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
338 (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
339
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
340
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
341 (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
342 (let (face)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
343 (while (= (length face) 0)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
344 (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
345 (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
346 (face-list))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
347 nil t)))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
348 (intern face)))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
349
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
350 (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
351 (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
352 (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
353 (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
354 (default (if (fboundp fn)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
355 (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
356 (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
357 (value (if bool
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
358 (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
359 " be " bool "? "))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
360 (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
361 default))))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
362 (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
363
15884
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
364 (defun internal-face-interactive-stipple (what)
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
365 (let* ((fn (intern (concat "face-" what)))
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
366 (prompt (concat "Set " what " of face"))
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
367 (face (read-face-name (concat prompt ": ")))
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
368 (default (if (fboundp fn)
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
369 (or (funcall fn face (selected-frame))
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
370 (funcall fn 'default (selected-frame)))))
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
371 ;; If the stipple value is a list (WIDTH HEIGHT DATA),
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
372 ;; represent that as a string by printing it out.
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
373 (old-stipple-string
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
374 (if (stringp (face-stipple face))
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
375 (face-stipple face)
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
376 (if (null (face-stipple face))
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
377 nil
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
378 (prin1-to-string (face-stipple face)))))
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
379 (new-stipple-string
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
380 (read-string
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
381 (concat prompt " " (symbol-name face) " to: ")
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
382 old-stipple-string))
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
383 ;; Convert the stipple value text we read
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
384 ;; back to a list if it looks like one.
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
385 ;; This makes the assumption that a pixmap file name
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
386 ;; won't start with an open-paren.
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
387 (stipple
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
388 (if (string-match "^(" new-stipple-string)
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
389 (read new-stipple-string)
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
390 new-stipple-string)))
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
391 (list face (if (equal stipple "") nil stipple))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
392
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
393 (defun make-face (name)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
394 "Define a new FACE on all frames.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
395 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
396 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
397 (interactive "SMake face: ")
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
398 (or (internal-find-face name)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
399 (let ((face (make-vector 8 nil)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
400 (aset face 0 'face)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
401 (aset face 1 name)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
402 (let* ((frames (frame-list))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
403 (inhibit-quit t)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
404 (id (internal-next-face-id)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
405 (make-face-internal id)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
406 (aset face 2 id)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
407 (while frames
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
408 (set-frame-face-alist (car frames)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
409 (cons (cons name (copy-sequence face))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
410 (frame-face-alist (car frames))))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
411 (setq frames (cdr frames)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
412 (setq global-face-data (cons (cons name face) global-face-data)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
413 ;; when making a face after frames already exist
16590
a0cfcb9f8033 Use w32 instead of ms-windows for window-system symbol
Geoff Voelker <voelker@cs.washington.edu>
parents: 16199
diff changeset
414 (if (memq window-system '(x w32))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
415 (make-face-x-resource-internal face))
9622
14e1032a7ae7 (make-face): Add new face to Face menu on creation. -- Bng
Boris Goldowsky <boris@gnu.org>
parents: 9572
diff changeset
416 ;; add to menu
14e1032a7ae7 (make-face): Add new face to Face menu on creation. -- Bng
Boris Goldowsky <boris@gnu.org>
parents: 9572
diff changeset
417 (if (fboundp 'facemenu-add-new-face)
14e1032a7ae7 (make-face): Add new face to Face menu on creation. -- Bng
Boris Goldowsky <boris@gnu.org>
parents: 9572
diff changeset
418 (facemenu-add-new-face name))
8011
1bb462fc29fc (make-face): Return the face name, not the vector.
Richard M. Stallman <rms@gnu.org>
parents: 8000
diff changeset
419 face))
1bb462fc29fc (make-face): Return the face name, not the vector.
Richard M. Stallman <rms@gnu.org>
parents: 8000
diff changeset
420 name)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
421
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
422 ;; 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
423 ;; This has to be done when a new face is made.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
424 (defun make-face-x-resource-internal (face &optional frame set-anyway)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
425 (cond ((null frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
426 (let ((frames (frame-list)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
427 (while frames
16590
a0cfcb9f8033 Use w32 instead of ms-windows for window-system symbol
Geoff Voelker <voelker@cs.washington.edu>
parents: 16199
diff changeset
428 (if (memq (framep (car frames)) '(x w32))
6873
086e14489073 (make-face-x-resource-internal): Don't mess with terminal frames.
Richard M. Stallman <rms@gnu.org>
parents: 6871
diff changeset
429 (make-face-x-resource-internal (face-name face)
086e14489073 (make-face-x-resource-internal): Don't mess with terminal frames.
Richard M. Stallman <rms@gnu.org>
parents: 6871
diff changeset
430 (car frames) set-anyway))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
431 (setq frames (cdr frames)))))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
432 (t
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
433 (setq face (internal-get-face (face-name face) frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
434 ;;
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
435 ;; These are things like "attributeForeground" instead of simply
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
436 ;; "foreground" because people tend to do things like "*foreground",
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
437 ;; which would cause all faces to be fully qualified, making faces
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
438 ;; 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
439 ;; 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
440 ;; more random environments.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
441 ;;
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
442 ;; I think these should be called "face.faceForeground" instead of
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
443 ;; "face.attributeForeground", but they're the way they are for
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
444 ;; hysterical reasons.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
445 ;;
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
446 (let* ((name (symbol-name (face-name face)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
447 (fn (or (x-get-resource (concat name ".attributeFont")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
448 "Face.AttributeFont")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
449 (and set-anyway (face-font face))))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
450 (fg (or (x-get-resource (concat name ".attributeForeground")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
451 "Face.AttributeForeground")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
452 (and set-anyway (face-foreground face))))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
453 (bg (or (x-get-resource (concat name ".attributeBackground")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
454 "Face.AttributeBackground")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
455 (and set-anyway (face-background face))))
9569
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
456 (bgp (or (x-get-resource (concat name ".attributeStipple")
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
457 "Face.AttributeStipple")
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
458 (x-get-resource (concat name ".attributeBackgroundPixmap")
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
459 "Face.AttributeBackgroundPixmap")
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
460 (and set-anyway (face-stipple face))))
8149
5e27997957db (x-create-frame-with-faces): Ignore case in X resource.
Richard M. Stallman <rms@gnu.org>
parents: 8109
diff changeset
461 (ulp (let ((resource (x-get-resource
5e27997957db (x-create-frame-with-faces): Ignore case in X resource.
Richard M. Stallman <rms@gnu.org>
parents: 8109
diff changeset
462 (concat name ".attributeUnderline")
5e27997957db (x-create-frame-with-faces): Ignore case in X resource.
Richard M. Stallman <rms@gnu.org>
parents: 8109
diff changeset
463 "Face.AttributeUnderline")))
5e27997957db (x-create-frame-with-faces): Ignore case in X resource.
Richard M. Stallman <rms@gnu.org>
parents: 8109
diff changeset
464 (if resource
5e27997957db (x-create-frame-with-faces): Ignore case in X resource.
Richard M. Stallman <rms@gnu.org>
parents: 8109
diff changeset
465 (member (downcase resource) '("on" "true"))
5e27997957db (x-create-frame-with-faces): Ignore case in X resource.
Richard M. Stallman <rms@gnu.org>
parents: 8109
diff changeset
466 (and set-anyway (face-underline-p face)))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
467 )
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
468 (if fn
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
469 (condition-case ()
12460
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
470 (cond ((string= fn "italic")
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
471 (make-face-italic face))
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
472 ((string= fn "bold")
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
473 (make-face-bold face))
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
474 ((string= fn "bold-italic")
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
475 (make-face-bold-italic face))
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
476 (t
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
477 (set-face-font face fn frame)))
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
478 (error
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
479 (if (member fn '("italic" "bold" "bold-italic"))
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
480 (message "no %s version found for face `%s'" fn name)
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
481 (message "font `%s' not found for face `%s'" fn name)))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
482 (if fg
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
483 (condition-case ()
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
484 (set-face-foreground face fg frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
485 (error (message "color `%s' not allocated for face `%s'" fg name))))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
486 (if bg
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
487 (condition-case ()
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
488 (set-face-background face bg frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
489 (error (message "color `%s' not allocated for face `%s'" bg name))))
9569
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
490 (if bgp
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
491 (condition-case ()
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
492 (set-face-stipple face bgp frame)
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
493 (error (message "pixmap `%s' not found for face `%s'" bgp name))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
494 (if (or ulp set-anyway)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
495 (set-face-underline-p face ulp frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
496 )))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
497 face)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
498
5849
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
499 (defun copy-face (old-face new-face &optional frame new-frame)
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
500 "Define a face just like OLD-FACE, with name NEW-FACE.
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
501 If NEW-FACE already exists as a face, it is modified to be like OLD-FACE.
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
502 If it doesn't already exist, it is created.
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
503
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
504 If the optional argument FRAME is given as a frame,
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
505 NEW-FACE is changed on FRAME only.
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
506 If FRAME is t, the frame-independent default specification for OLD-FACE
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
507 is copied to NEW-FACE.
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
508 If FRAME is nil, copying is done for the frame-independent defaults
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
509 and for each existing frame.
4083
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
510 If the optional fourth argument NEW-FRAME is given,
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
511 copy the information from face OLD-FACE on frame FRAME
5849
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
512 to NEW-FACE on frame NEW-FRAME."
4083
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
513 (or new-frame (setq new-frame frame))
6145
843ce3f872c2 (copy-face): Don't change old-face and new-face before the frame loop.
Karl Heuer <kwzh@gnu.org>
parents: 5955
diff changeset
514 (let ((inhibit-quit t))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
515 (if (null frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
516 (let ((frames (frame-list)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
517 (while frames
5849
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
518 (copy-face old-face new-face (car frames))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
519 (setq frames (cdr frames)))
5849
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
520 (copy-face old-face new-face t))
6145
843ce3f872c2 (copy-face): Don't change old-face and new-face before the frame loop.
Karl Heuer <kwzh@gnu.org>
parents: 5955
diff changeset
521 (setq old-face (internal-get-face old-face frame))
843ce3f872c2 (copy-face): Don't change old-face and new-face before the frame loop.
Karl Heuer <kwzh@gnu.org>
parents: 5955
diff changeset
522 (setq new-face (or (internal-find-face new-face new-frame)
843ce3f872c2 (copy-face): Don't change old-face and new-face before the frame loop.
Karl Heuer <kwzh@gnu.org>
parents: 5955
diff changeset
523 (make-face new-face)))
8515
3043fef029a7 (copy-face): Ignore errors in set-face-font.
Richard M. Stallman <rms@gnu.org>
parents: 8377
diff changeset
524 (condition-case nil
3043fef029a7 (copy-face): Ignore errors in set-face-font.
Richard M. Stallman <rms@gnu.org>
parents: 8377
diff changeset
525 ;; A face that has a global symbolic font modifier such as `bold'
3043fef029a7 (copy-face): Ignore errors in set-face-font.
Richard M. Stallman <rms@gnu.org>
parents: 8377
diff changeset
526 ;; might legitimately get an error here.
3043fef029a7 (copy-face): Ignore errors in set-face-font.
Richard M. Stallman <rms@gnu.org>
parents: 8377
diff changeset
527 ;; Use the frame's default font in that case.
3043fef029a7 (copy-face): Ignore errors in set-face-font.
Richard M. Stallman <rms@gnu.org>
parents: 8377
diff changeset
528 (set-face-font new-face (face-font old-face frame) new-frame)
3043fef029a7 (copy-face): Ignore errors in set-face-font.
Richard M. Stallman <rms@gnu.org>
parents: 8377
diff changeset
529 (error
3043fef029a7 (copy-face): Ignore errors in set-face-font.
Richard M. Stallman <rms@gnu.org>
parents: 8377
diff changeset
530 (set-face-font new-face nil new-frame)))
4083
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
531 (set-face-foreground new-face (face-foreground old-face frame) new-frame)
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
532 (set-face-background new-face (face-background old-face frame) new-frame)
9569
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
533 (set-face-stipple new-face
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
534 (face-stipple old-face frame)
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
535 new-frame)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
536 (set-face-underline-p new-face (face-underline-p old-face frame)
4083
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
537 new-frame))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
538 new-face))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
539
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
540 (defun face-equal (face1 face2 &optional frame)
2906
ca9bf00d4b19 * xfaces.el (face-equal): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 2826
diff changeset
541 "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
542 (setq face1 (internal-get-face face1 frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
543 face2 (internal-get-face face2 frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
544 (and (equal (face-foreground face1 frame) (face-foreground face2 frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
545 (equal (face-background face1 frame) (face-background face2 frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
546 (equal (face-font face1 frame) (face-font face2 frame))
8000
6d0a448be1ec (face-equal): Do check the underline attribute.
Richard M. Stallman <rms@gnu.org>
parents: 7936
diff changeset
547 (eq (face-underline-p face1 frame) (face-underline-p face2 frame))
9569
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
548 (equal (face-stipple face1 frame)
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
549 (face-stipple face2 frame))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
550
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
551 (defun face-differs-from-default-p (face &optional frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
552 "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
553 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
554 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
555 fully unspecified, and thus inherits the attributes of any face it
10379
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
556 is displayed on top of.
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
557
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
558 The optional argument FRAME specifies which frame to test;
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
559 if FRAME is t, test the default for new frames.
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
560 If FRAME is nil or omitted, test the selected frame."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
561 (let ((default (internal-get-face 'default frame)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
562 (setq face (internal-get-face face frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
563 (not (and (or (equal (face-foreground default frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
564 (face-foreground face frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
565 (null (face-foreground face frame)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
566 (or (equal (face-background default frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
567 (face-background face frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
568 (null (face-background face frame)))
17160
5bf55bb553f2 When testing FACE's non-nil face-font with the default face font, use the frame's font parameter if the default face's face-font is nil.
Simon Marshall <simon@gnu.org>
parents: 16841
diff changeset
569 (or (null (face-font face frame))
5bf55bb553f2 When testing FACE's non-nil face-font with the default face font, use the frame's font parameter if the default face's face-font is nil.
Simon Marshall <simon@gnu.org>
parents: 16841
diff changeset
570 (equal (face-font face frame)
5bf55bb553f2 When testing FACE's non-nil face-font with the default face font, use the frame's font parameter if the default face's face-font is nil.
Simon Marshall <simon@gnu.org>
parents: 16841
diff changeset
571 (or (face-font default frame)
5bf55bb553f2 When testing FACE's non-nil face-font with the default face font, use the frame's font parameter if the default face's face-font is nil.
Simon Marshall <simon@gnu.org>
parents: 16841
diff changeset
572 (downcase
5bf55bb553f2 When testing FACE's non-nil face-font with the default face font, use the frame's font parameter if the default face's face-font is nil.
Simon Marshall <simon@gnu.org>
parents: 16841
diff changeset
573 (cdr (assq 'font (frame-parameters frame)))))))
9569
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
574 (or (equal (face-stipple default frame)
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
575 (face-stipple face frame))
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
576 (null (face-stipple face frame)))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
577 (equal (face-underline-p default frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
578 (face-underline-p face frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
579 ))))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
580
10379
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
581 (defun face-nontrivial-p (face &optional frame)
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
582 "True if face FACE has some non-nil attribute.
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
583 The optional argument FRAME specifies which frame to test;
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
584 if FRAME is t, test the default for new frames.
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
585 If FRAME is nil or omitted, test the selected frame."
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
586 (setq face (internal-get-face face frame))
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
587 (or (face-foreground face frame)
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
588 (face-background face frame)
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
589 (face-font face frame)
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
590 (face-stipple face frame)
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
591 (face-underline-p face frame)))
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
592
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
593
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
594 (defun invert-face (face &optional frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
595 "Swap the foreground and background colors of face FACE.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
596 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
597 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
598 (interactive (list (read-face-name "Invert face: ")))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
599 (setq face (internal-get-face face frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
600 (let ((fg (face-foreground face frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
601 (bg (face-background face frame)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
602 (if (or fg bg)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
603 (progn
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
604 (set-face-foreground face bg frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
605 (set-face-background face fg frame))
16841
5c964321c440 (invert-face): Handle inverting the default face better.
Richard M. Stallman <rms@gnu.org>
parents: 16687
diff changeset
606 (let* ((frame-bg (cdr (assq 'background-color (frame-parameters frame))))
5c964321c440 (invert-face): Handle inverting the default face better.
Richard M. Stallman <rms@gnu.org>
parents: 16687
diff changeset
607 (default-bg (or (face-background 'default frame)
5c964321c440 (invert-face): Handle inverting the default face better.
Richard M. Stallman <rms@gnu.org>
parents: 16687
diff changeset
608 frame-bg))
5c964321c440 (invert-face): Handle inverting the default face better.
Richard M. Stallman <rms@gnu.org>
parents: 16687
diff changeset
609 (frame-fg (cdr (assq 'foreground-color (frame-parameters frame))))
5c964321c440 (invert-face): Handle inverting the default face better.
Richard M. Stallman <rms@gnu.org>
parents: 16687
diff changeset
610 (default-fg (or (face-foreground 'default frame)
5c964321c440 (invert-face): Handle inverting the default face better.
Richard M. Stallman <rms@gnu.org>
parents: 16687
diff changeset
611 frame-fg)))
5c964321c440 (invert-face): Handle inverting the default face better.
Richard M. Stallman <rms@gnu.org>
parents: 16687
diff changeset
612 (set-face-foreground face default-bg frame)
5c964321c440 (invert-face): Handle inverting the default face better.
Richard M. Stallman <rms@gnu.org>
parents: 16687
diff changeset
613 (set-face-background face default-fg frame))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
614 face)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
615
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
616
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
617 (defun internal-try-face-font (face font &optional frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
618 "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
619 (condition-case ()
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
620 (set-face-font face font frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
621 (error nil)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
622
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
623 ;; Manipulating font names.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
624
16687
049c87a96dca Change defconsts to defvars.
Richard M. Stallman <rms@gnu.org>
parents: 16590
diff changeset
625 (defvar x-font-regexp nil)
049c87a96dca Change defconsts to defvars.
Richard M. Stallman <rms@gnu.org>
parents: 16590
diff changeset
626 (defvar x-font-regexp-head nil)
049c87a96dca Change defconsts to defvars.
Richard M. Stallman <rms@gnu.org>
parents: 16590
diff changeset
627 (defvar x-font-regexp-weight nil)
049c87a96dca Change defconsts to defvars.
Richard M. Stallman <rms@gnu.org>
parents: 16590
diff changeset
628 (defvar x-font-regexp-slant nil)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
629
12668
7660e82d0346 (x-font-regexp-weight-subnum, x-font-regexp-slant-subnum)
Karl Heuer <kwzh@gnu.org>
parents: 12651
diff changeset
630 (defconst x-font-regexp-weight-subnum 1)
7660e82d0346 (x-font-regexp-weight-subnum, x-font-regexp-slant-subnum)
Karl Heuer <kwzh@gnu.org>
parents: 12651
diff changeset
631 (defconst x-font-regexp-slant-subnum 2)
7660e82d0346 (x-font-regexp-weight-subnum, x-font-regexp-slant-subnum)
Karl Heuer <kwzh@gnu.org>
parents: 12651
diff changeset
632 (defconst x-font-regexp-swidth-subnum 3)
7660e82d0346 (x-font-regexp-weight-subnum, x-font-regexp-slant-subnum)
Karl Heuer <kwzh@gnu.org>
parents: 12651
diff changeset
633 (defconst x-font-regexp-adstyle-subnum 4)
7660e82d0346 (x-font-regexp-weight-subnum, x-font-regexp-slant-subnum)
Karl Heuer <kwzh@gnu.org>
parents: 12651
diff changeset
634
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
635 ;;; Regexps matching font names in "Host Portable Character Representation."
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 (let ((- "[-?]")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
638 (foundry "[^-]+")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
639 (family "[^-]+")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
640 (weight "\\(bold\\|demibold\\|medium\\)") ; 1
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
641 ; (weight\? "\\(\\*\\|bold\\|demibold\\|medium\\|\\)") ; 1
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
642 (weight\? "\\([^-]*\\)") ; 1
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
643 (slant "\\([ior]\\)") ; 2
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
644 ; (slant\? "\\([ior?*]?\\)") ; 2
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
645 (slant\? "\\([^-]?\\)") ; 2
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
646 ; (swidth "\\(\\*\\|normal\\|semicondensed\\|\\)") ; 3
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
647 (swidth "\\([^-]*\\)") ; 3
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
648 ; (adstyle "\\(\\*\\|sans\\|\\)") ; 4
12690
e2d3fa52d100 (x-font-regexp): Add \\(\\) for substring extraction.
Karl Heuer <kwzh@gnu.org>
parents: 12668
diff changeset
649 (adstyle "\\([^-]*\\)") ; 4
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
650 (pixelsize "[0-9]+")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
651 (pointsize "[0-9][0-9]+")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
652 (resx "[0-9][0-9]+")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
653 (resy "[0-9][0-9]+")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
654 (spacing "[cmp?*]")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
655 (avgwidth "[0-9]+")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
656 (registry "[^-]+")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
657 (encoding "[^-]+")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
658 )
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
659 (setq x-font-regexp
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
660 (concat "\\`\\*?[-?*]"
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
661 foundry - family - weight\? - slant\? - swidth - adstyle -
12475
eb436b0c4ab3 (x-font-regexp): Include the avgwidth.
Richard M. Stallman <rms@gnu.org>
parents: 12460
diff changeset
662 pixelsize - pointsize - resx - resy - spacing - avgwidth -
eb436b0c4ab3 (x-font-regexp): Include the avgwidth.
Richard M. Stallman <rms@gnu.org>
parents: 12460
diff changeset
663 registry - encoding "\\*?\\'"
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
664 ))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
665 (setq x-font-regexp-head
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
666 (concat "\\`[-?*]" foundry - family - weight\? - slant\?
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 (setq x-font-regexp-slant (concat - slant -))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
669 (setq x-font-regexp-weight (concat - weight -))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
670 nil)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
671
3071
68de05fb5751 * faces.el (set-face-font): Call x-resolve-font-name on the font
Jim Blandy <jimb@redhat.com>
parents: 3049
diff changeset
672 (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
673 "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
674 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
675 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
676 contains wildcards.
10170
5fc240a3e4a0 (face-initialize): Test for framep not t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 10107
diff changeset
677 Given optional arguments FACE and FRAME, return a font which is
5fc240a3e4a0 (face-initialize): Test for framep not t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 10107
diff changeset
678 also the same size as FACE on FRAME, or fail."
3233
28b2df35c33e (x-resolve-font-name): Allow symbol as FACE arg.
Richard M. Stallman <rms@gnu.org>
parents: 3182
diff changeset
679 (or (symbolp face)
28b2df35c33e (x-resolve-font-name): Allow symbol as FACE arg.
Richard M. Stallman <rms@gnu.org>
parents: 3182
diff changeset
680 (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
681 (and (eq frame t)
28b2df35c33e (x-resolve-font-name): Allow symbol as FACE arg.
Richard M. Stallman <rms@gnu.org>
parents: 3182
diff changeset
682 (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
683 (if pattern
5092
36508a7c0a3f (x-resolve-font-name): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents: 5081
diff changeset
684 ;; Note that x-list-fonts has code to handle a face with nil as its font.
16002
c8cbde1d3f11 (internal-set-face-1): When calling x-list-fonts, ask for just one match.
Richard M. Stallman <rms@gnu.org>
parents: 15884
diff changeset
685 (let ((fonts (x-list-fonts pattern face frame 1)))
3130
82c29bacb6b3 * faces.el (x-resolve-font-name): If PATTERN is nil, return the
Jim Blandy <jimb@redhat.com>
parents: 3071
diff changeset
686 (or fonts
82c29bacb6b3 * faces.el (x-resolve-font-name): If PATTERN is nil, return the
Jim Blandy <jimb@redhat.com>
parents: 3071
diff changeset
687 (if face
10584
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
688 (if (string-match "\\*" pattern)
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
689 (if (null (face-font face))
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
690 (error "No matching fonts are the same height as the frame default font")
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
691 (error "No matching fonts are the same height as face `%s'" face))
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
692 (if (null (face-font face))
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
693 (error "Height of font `%s' doesn't match the frame default font"
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
694 pattern)
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
695 (error "Height of font `%s' doesn't match face `%s'"
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
696 pattern face)))
3353
8cbd38886eef (x-resolve-font-name): Clean up error messages.
Richard M. Stallman <rms@gnu.org>
parents: 3298
diff changeset
697 (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
698 (car fonts))
82c29bacb6b3 * faces.el (x-resolve-font-name): If PATTERN is nil, return the
Jim Blandy <jimb@redhat.com>
parents: 3071
diff changeset
699 (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
700
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
701 (defun x-frob-font-weight (font which)
13704
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
702 (let ((case-fold-search t))
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
703 (cond ((string-match x-font-regexp font)
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
704 (concat (substring font 0
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
705 (match-beginning x-font-regexp-weight-subnum))
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
706 which
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
707 (substring font (match-end x-font-regexp-weight-subnum)
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
708 (match-beginning x-font-regexp-adstyle-subnum))
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
709 ;; Replace the ADD_STYLE_NAME field with *
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
710 ;; because the info in it may not be the same
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
711 ;; for related fonts.
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
712 "*"
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
713 (substring font (match-end x-font-regexp-adstyle-subnum))))
14880
b405f39b5493 (x-frob-font-slant): Properly handle a match against
Richard M. Stallman <rms@gnu.org>
parents: 14409
diff changeset
714 ((string-match x-font-regexp-head font)
b405f39b5493 (x-frob-font-slant): Properly handle a match against
Richard M. Stallman <rms@gnu.org>
parents: 14409
diff changeset
715 (concat (substring font 0 (match-beginning 1)) which
b405f39b5493 (x-frob-font-slant): Properly handle a match against
Richard M. Stallman <rms@gnu.org>
parents: 14409
diff changeset
716 (substring font (match-end 1))))
b405f39b5493 (x-frob-font-slant): Properly handle a match against
Richard M. Stallman <rms@gnu.org>
parents: 14409
diff changeset
717 ((string-match x-font-regexp-weight font)
13704
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
718 (concat (substring font 0 (match-beginning 1)) which
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
719 (substring font (match-end 1)))))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
720
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
721 (defun x-frob-font-slant (font which)
13704
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
722 (let ((case-fold-search t))
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
723 (cond ((string-match x-font-regexp font)
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
724 (concat (substring font 0
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
725 (match-beginning x-font-regexp-slant-subnum))
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
726 which
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
727 (substring font (match-end x-font-regexp-slant-subnum)
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
728 (match-beginning x-font-regexp-adstyle-subnum))
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
729 ;; Replace the ADD_STYLE_NAME field with *
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
730 ;; because the info in it may not be the same
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
731 ;; for related fonts.
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
732 "*"
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
733 (substring font (match-end x-font-regexp-adstyle-subnum))))
14880
b405f39b5493 (x-frob-font-slant): Properly handle a match against
Richard M. Stallman <rms@gnu.org>
parents: 14409
diff changeset
734 ((string-match x-font-regexp-head font)
b405f39b5493 (x-frob-font-slant): Properly handle a match against
Richard M. Stallman <rms@gnu.org>
parents: 14409
diff changeset
735 (concat (substring font 0 (match-beginning 2)) which
b405f39b5493 (x-frob-font-slant): Properly handle a match against
Richard M. Stallman <rms@gnu.org>
parents: 14409
diff changeset
736 (substring font (match-end 2))))
b405f39b5493 (x-frob-font-slant): Properly handle a match against
Richard M. Stallman <rms@gnu.org>
parents: 14409
diff changeset
737 ((string-match x-font-regexp-slant font)
13704
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
738 (concat (substring font 0 (match-beginning 1)) which
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
739 (substring font (match-end 1)))))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
740
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
741 (defun x-make-font-bold (font)
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
742 "Given an X font specification, make a bold version of it.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
743 If that can't be done, return nil."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
744 (x-frob-font-weight font "bold"))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
745
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
746 (defun x-make-font-demibold (font)
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
747 "Given an X font specification, make a demibold version of it.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
748 If that can't be done, return nil."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
749 (x-frob-font-weight font "demibold"))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
750
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
751 (defun x-make-font-unbold (font)
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
752 "Given an X font specification, make a non-bold version of it.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
753 If that can't be done, return nil."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
754 (x-frob-font-weight font "medium"))
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 (defun x-make-font-italic (font)
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
757 "Given an X font specification, make an italic version of it.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
758 If that can't be done, return nil."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
759 (x-frob-font-slant font "i"))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
760
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
761 (defun x-make-font-oblique (font) ; you say tomayto...
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
762 "Given an X font specification, make an oblique version of it.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
763 If that can't be done, return nil."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
764 (x-frob-font-slant font "o"))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
765
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
766 (defun x-make-font-unitalic (font)
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
767 "Given an X font specification, make a non-italic version of it.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
768 If that can't be done, return nil."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
769 (x-frob-font-slant font "r"))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
770
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
771 ;;; non-X-specific interface
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
772
2714
bfe999b19082 * faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents: 2456
diff changeset
773 (defun make-face-bold (face &optional frame noerror)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
774 "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
775 If NOERROR is non-nil, return nil on failure."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
776 (interactive (list (read-face-name "Make which face bold: ")))
5199
b8b8063551e1 (make-face-unitalic, make-face-unbold, make-face-bold)
Richard M. Stallman <rms@gnu.org>
parents: 5092
diff changeset
777 (if (and (eq frame t) (listp (face-font face t)))
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
778 (set-face-font face (if (memq 'italic (face-font face t))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
779 '(bold italic) '(bold))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
780 t)
12651
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
781 (let (font)
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
782 (if (null frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
783 (let ((frames (frame-list)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
784 ;; Make this face bold in global-face-data.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
785 (make-face-bold face t noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
786 ;; Make this face bold in each frame.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
787 (while frames
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
788 (make-face-bold face (car frames) noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
789 (setq frames (cdr frames))))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
790 (setq face (internal-get-face face frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
791 (setq font (or (face-font face frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
792 (face-font face t)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
793 (if (listp font)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
794 (setq font nil))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
795 (setq font (or font
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
796 (face-font 'default frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
797 (cdr (assq 'font (frame-parameters frame)))))
12651
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
798 (or (and font (make-face-bold-internal face frame font))
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
799 ;; We failed to find a bold version of the font.
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
800 noerror
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
801 (error "No bold version of %S" font))))))
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
802
8109
9bc00e1f0f3e (make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents: 8107
diff changeset
803 (defun make-face-bold-internal (face frame font)
9bc00e1f0f3e (make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents: 8107
diff changeset
804 (let (f2)
9bc00e1f0f3e (make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents: 8107
diff changeset
805 (or (and (setq f2 (x-make-font-bold font))
9bc00e1f0f3e (make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents: 8107
diff changeset
806 (internal-try-face-font face f2 frame))
9bc00e1f0f3e (make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents: 8107
diff changeset
807 (and (setq f2 (x-make-font-demibold font))
9bc00e1f0f3e (make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents: 8107
diff changeset
808 (internal-try-face-font face f2 frame)))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
809
2714
bfe999b19082 * faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents: 2456
diff changeset
810 (defun make-face-italic (face &optional frame noerror)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
811 "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
812 If NOERROR is non-nil, return nil on failure."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
813 (interactive (list (read-face-name "Make which face italic: ")))
5199
b8b8063551e1 (make-face-unitalic, make-face-unbold, make-face-bold)
Richard M. Stallman <rms@gnu.org>
parents: 5092
diff changeset
814 (if (and (eq frame t) (listp (face-font face t)))
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
815 (set-face-font face (if (memq 'bold (face-font face t))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
816 '(bold italic) '(italic))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
817 t)
12651
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
818 (let (font)
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
819 (if (null frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
820 (let ((frames (frame-list)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
821 ;; Make this face italic in global-face-data.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
822 (make-face-italic face t noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
823 ;; Make this face italic in each frame.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
824 (while frames
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
825 (make-face-italic face (car frames) noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
826 (setq frames (cdr frames))))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
827 (setq face (internal-get-face face frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
828 (setq font (or (face-font face frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
829 (face-font face t)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
830 (if (listp font)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
831 (setq font nil))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
832 (setq font (or font
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
833 (face-font 'default frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
834 (cdr (assq 'font (frame-parameters frame)))))
12651
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
835 (or (and font (make-face-italic-internal face frame font))
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
836 ;; We failed to find an italic version of the font.
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
837 noerror
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
838 (error "No italic version of %S" font))))))
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
839
8109
9bc00e1f0f3e (make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents: 8107
diff changeset
840 (defun make-face-italic-internal (face frame font)
9bc00e1f0f3e (make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents: 8107
diff changeset
841 (let (f2)
9bc00e1f0f3e (make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents: 8107
diff changeset
842 (or (and (setq f2 (x-make-font-italic font))
9bc00e1f0f3e (make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents: 8107
diff changeset
843 (internal-try-face-font face f2 frame))
9bc00e1f0f3e (make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents: 8107
diff changeset
844 (and (setq f2 (x-make-font-oblique font))
9bc00e1f0f3e (make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents: 8107
diff changeset
845 (internal-try-face-font face f2 frame)))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
846
2714
bfe999b19082 * faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents: 2456
diff changeset
847 (defun make-face-bold-italic (face &optional frame noerror)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
848 "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
849 If NOERROR is non-nil, return nil on failure."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
850 (interactive (list (read-face-name "Make which face bold-italic: ")))
5199
b8b8063551e1 (make-face-unitalic, make-face-unbold, make-face-bold)
Richard M. Stallman <rms@gnu.org>
parents: 5092
diff changeset
851 (if (and (eq frame t) (listp (face-font face t)))
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
852 (set-face-font face '(bold italic) t)
12651
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
853 (let (font)
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
854 (if (null frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
855 (let ((frames (frame-list)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
856 ;; Make this face bold-italic in global-face-data.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
857 (make-face-bold-italic face t noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
858 ;; Make this face bold in each frame.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
859 (while frames
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
860 (make-face-bold-italic face (car frames) noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
861 (setq frames (cdr frames))))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
862 (setq face (internal-get-face face frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
863 (setq font (or (face-font face frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
864 (face-font face t)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
865 (if (listp font)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
866 (setq font nil))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
867 (setq font (or font
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
868 (face-font 'default frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
869 (cdr (assq 'font (frame-parameters frame)))))
12651
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
870 (or (and font (make-face-bold-italic-internal face frame font))
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
871 ;; We failed to find a bold italic version.
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
872 noerror
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
873 (error "No bold italic version of %S" font))))))
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
874
8109
9bc00e1f0f3e (make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents: 8107
diff changeset
875 (defun make-face-bold-italic-internal (face frame font)
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
876 (let (f2 f3)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
877 (or (and (setq f2 (x-make-font-italic font))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
878 (not (equal font f2))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
879 (setq f3 (x-make-font-bold f2))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
880 (not (equal f2 f3))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
881 (internal-try-face-font face f3 frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
882 (and (setq f2 (x-make-font-oblique font))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
883 (not (equal font f2))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
884 (setq f3 (x-make-font-bold f2))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
885 (not (equal f2 f3))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
886 (internal-try-face-font face f3 frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
887 (and (setq f2 (x-make-font-italic font))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
888 (not (equal font f2))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
889 (setq f3 (x-make-font-demibold f2))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
890 (not (equal f2 f3))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
891 (internal-try-face-font face f3 frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
892 (and (setq f2 (x-make-font-oblique font))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
893 (not (equal font f2))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
894 (setq f3 (x-make-font-demibold f2))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
895 (not (equal f2 f3))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
896 (internal-try-face-font face f3 frame)))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
897
2714
bfe999b19082 * faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents: 2456
diff changeset
898 (defun make-face-unbold (face &optional frame noerror)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
899 "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
900 If NOERROR is non-nil, return nil on failure."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
901 (interactive (list (read-face-name "Make which face non-bold: ")))
5199
b8b8063551e1 (make-face-unitalic, make-face-unbold, make-face-bold)
Richard M. Stallman <rms@gnu.org>
parents: 5092
diff changeset
902 (if (and (eq frame t) (listp (face-font face t)))
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
903 (set-face-font face (if (memq 'italic (face-font face t))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
904 '(italic) nil)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
905 t)
12651
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
906 (let (font font1)
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
907 (if (null frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
908 (let ((frames (frame-list)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
909 ;; Make this face unbold in global-face-data.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
910 (make-face-unbold face t noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
911 ;; Make this face unbold in each frame.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
912 (while frames
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
913 (make-face-unbold face (car frames) noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
914 (setq frames (cdr frames))))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
915 (setq face (internal-get-face face frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
916 (setq font1 (or (face-font face frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
917 (face-font face t)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
918 (if (listp font1)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
919 (setq font1 nil))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
920 (setq font1 (or font1
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
921 (face-font 'default frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
922 (cdr (assq 'font (frame-parameters frame)))))
8732
58d6dc80af5c (make-face-unbold, make-face-unitalic, make-face-bold, make-face-italic,
Karl Heuer <kwzh@gnu.org>
parents: 8515
diff changeset
923 (setq font (and font1 (x-make-font-unbold font1)))
12651
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
924 (or (if font (internal-try-face-font face font frame))
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
925 noerror
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
926 (error "No unbold version of %S" font1))))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
927
2714
bfe999b19082 * faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents: 2456
diff changeset
928 (defun make-face-unitalic (face &optional frame noerror)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
929 "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
930 If NOERROR is non-nil, return nil on failure."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
931 (interactive (list (read-face-name "Make which face non-italic: ")))
5199
b8b8063551e1 (make-face-unitalic, make-face-unbold, make-face-bold)
Richard M. Stallman <rms@gnu.org>
parents: 5092
diff changeset
932 (if (and (eq frame t) (listp (face-font face t)))
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
933 (set-face-font face (if (memq 'bold (face-font face t))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
934 '(bold) nil)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
935 t)
12651
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
936 (let (font font1)
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
937 (if (null frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
938 (let ((frames (frame-list)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
939 ;; Make this face unitalic in global-face-data.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
940 (make-face-unitalic face t noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
941 ;; Make this face unitalic in each frame.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
942 (while frames
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
943 (make-face-unitalic face (car frames) noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
944 (setq frames (cdr frames))))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
945 (setq face (internal-get-face face frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
946 (setq font1 (or (face-font face frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
947 (face-font face t)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
948 (if (listp font1)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
949 (setq font1 nil))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
950 (setq font1 (or font1
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
951 (face-font 'default frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
952 (cdr (assq 'font (frame-parameters frame)))))
8732
58d6dc80af5c (make-face-unbold, make-face-unitalic, make-face-bold, make-face-italic,
Karl Heuer <kwzh@gnu.org>
parents: 8515
diff changeset
953 (setq font (and font1 (x-make-font-unitalic font1)))
12651
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
954 (or (if font (internal-try-face-font face font frame))
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
955 noerror
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
956 (error "No unitalic version of %S" font1))))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
957
4083
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
958 (defvar list-faces-sample-text
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
959 "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ"
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
960 "*Text string to display as the sample text for `list-faces-display'.")
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
961
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
962 ;; The name list-faces would be more consistent, but let's avoid a conflict
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
963 ;; with Lucid, which uses that name differently.
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
964 (defun list-faces-display ()
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
965 "List all faces, using the same sample text in each.
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
966 The sample text is a string that comes from the variable
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
967 `list-faces-sample-text'.
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
968
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
969 It is possible to give a particular face name different appearances in
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
970 different frames. This command shows the appearance in the
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
971 selected frame."
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
972 (interactive)
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
973 (let ((faces (sort (face-list) (function string-lessp)))
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
974 (face nil)
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
975 (frame (selected-frame))
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
976 disp-frame window)
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
977 (with-output-to-temp-buffer "*Faces*"
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
978 (save-excursion
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
979 (set-buffer standard-output)
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
980 (setq truncate-lines t)
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
981 (while faces
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
982 (setq face (car faces))
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
983 (setq faces (cdr faces))
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
984 (insert (format "%25s " (symbol-name face)))
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
985 (let ((beg (point)))
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
986 (insert list-faces-sample-text)
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
987 (insert "\n")
8107
0885b28decc6 (list-faces-display): Line up multiple lines in sample.
Richard M. Stallman <rms@gnu.org>
parents: 8011
diff changeset
988 (put-text-property beg (1- (point)) 'face face)
0885b28decc6 (list-faces-display): Line up multiple lines in sample.
Richard M. Stallman <rms@gnu.org>
parents: 8011
diff changeset
989 ;; If the sample text has multiple lines, line up all of them.
0885b28decc6 (list-faces-display): Line up multiple lines in sample.
Richard M. Stallman <rms@gnu.org>
parents: 8011
diff changeset
990 (goto-char beg)
0885b28decc6 (list-faces-display): Line up multiple lines in sample.
Richard M. Stallman <rms@gnu.org>
parents: 8011
diff changeset
991 (forward-line 1)
0885b28decc6 (list-faces-display): Line up multiple lines in sample.
Richard M. Stallman <rms@gnu.org>
parents: 8011
diff changeset
992 (while (not (eobp))
0885b28decc6 (list-faces-display): Line up multiple lines in sample.
Richard M. Stallman <rms@gnu.org>
parents: 8011
diff changeset
993 (insert " ")
0885b28decc6 (list-faces-display): Line up multiple lines in sample.
Richard M. Stallman <rms@gnu.org>
parents: 8011
diff changeset
994 (forward-line 1))))
4083
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
995 (goto-char (point-min))))
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
996 ;; If the *Faces* buffer appears in a different frame,
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
997 ;; copy all the face definitions from FRAME,
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
998 ;; so that the display will reflect the frame that was selected.
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
999 (setq window (get-buffer-window (get-buffer "*Faces*") t))
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1000 (setq disp-frame (if window (window-frame window)
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1001 (car (frame-list))))
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1002 (or (eq frame disp-frame)
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1003 (let ((faces (face-list)))
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1004 (while faces
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1005 (copy-face (car faces) (car faces) frame disp-frame)
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1006 (setq faces (cdr faces)))))))
12460
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
1007
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
1008 (defun describe-face (face)
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
1009 "Display the properties of face FACE."
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
1010 (interactive (list (read-face-name "Describe face: ")))
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
1011 (with-output-to-temp-buffer "*Help*"
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
1012 (princ "Properties of face `")
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
1013 (princ (face-name face))
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
1014 (princ "':") (terpri)
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
1015 (princ "Foreground: ") (princ (face-foreground face)) (terpri)
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
1016 (princ "Background: ") (princ (face-background face)) (terpri)
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
1017 (princ " Font: ") (princ (face-font face)) (terpri)
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
1018 (princ "Underlined: ") (princ (if (face-underline-p face) "yes" "no")) (terpri)
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
1019 (princ " Stipple: ") (princ (or (face-stipple face) "none"))))
4083
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1020
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1021 ;;; Make the standard faces.
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1022 ;;; The C code knows the default and modeline faces as faces 0 and 1,
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1023 ;;; so they must be the first two faces made.
2764
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
1024 (defun face-initialize ()
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1025 (make-face 'default)
2826
9c22af6d7885 (face-initialize): Do make the modeline face.
Richard M. Stallman <rms@gnu.org>
parents: 2807
diff changeset
1026 (make-face 'modeline)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1027 (make-face 'highlight)
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1028
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1029 ;; These aren't really special in any way, but they're nice to have around.
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1030
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1031 (make-face 'bold)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1032 (make-face 'italic)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1033 (make-face 'bold-italic)
2807
9e8635dafd40 Rename `primary-selection' to `region'.
Richard M. Stallman <rms@gnu.org>
parents: 2800
diff changeset
1034 (make-face 'region)
2764
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
1035 (make-face 'secondary-selection)
3911
06dbadd0e4a7 (face-initialize): Create `underline' face.
Richard M. Stallman <rms@gnu.org>
parents: 3910
diff changeset
1036 (make-face 'underline)
2764
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
1037
2807
9e8635dafd40 Rename `primary-selection' to `region'.
Richard M. Stallman <rms@gnu.org>
parents: 2800
diff changeset
1038 (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
1039
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1040 ;; Specify the global properties of these faces
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1041 ;; so they will come out right on new frames.
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1042
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1043 (make-face-bold 'bold t)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1044 (make-face-italic 'italic t)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1045 (make-face-bold-italic 'bold-italic t)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1046
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1047 (set-face-background 'highlight '("darkseagreen2" "green" t) t)
8377
4ac21edb9f78 (face-initialize): Use underlining for region face
Richard M. Stallman <rms@gnu.org>
parents: 8186
diff changeset
1048 (set-face-background 'region '("gray" underline) t)
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1049 (set-face-background 'secondary-selection '("paleturquoise" "green" t) t)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1050 (set-face-background 'modeline '(t) t)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1051 (set-face-underline-p 'underline t t)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1052
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1053 ;; Set up the faces of all existing X Window frames
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1054 ;; from those global properties, unless already set in a given frame.
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1055
2764
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
1056 (let ((frames (frame-list)))
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
1057 (while frames
10170
5fc240a3e4a0 (face-initialize): Test for framep not t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 10107
diff changeset
1058 (if (not (memq (framep (car frames)) '(t nil)))
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1059 (let ((frame (car frames))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1060 (rest global-face-data))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1061 (while rest
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1062 (let ((face (car (car rest))))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1063 (or (face-differs-from-default-p face)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1064 (face-fill-in face (cdr (car rest)) frame)))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1065 (setq rest (cdr rest)))))
2764
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
1066 (setq frames (cdr frames)))))
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
1067
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1068
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1069 ;; Like x-create-frame but also set up the faces.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1070
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1071 (defun x-create-frame-with-faces (&optional parameters)
11927
20eae371b3f0 (x-create-frame-with-faces): Read geometry resource
Karl Heuer <kwzh@gnu.org>
parents: 11850
diff changeset
1072 ;; Read this frame's geometry resource, if it has an explicit name,
20eae371b3f0 (x-create-frame-with-faces): Read geometry resource
Karl Heuer <kwzh@gnu.org>
parents: 11850
diff changeset
1073 ;; and put the specs into PARAMETERS.
20eae371b3f0 (x-create-frame-with-faces): Read geometry resource
Karl Heuer <kwzh@gnu.org>
parents: 11850
diff changeset
1074 (let* ((name (or (cdr (assq 'name parameters))
12169
67f9dfb23d7c (x-create-frame-with-faces): Don't use initial-frame-alist
Karl Heuer <kwzh@gnu.org>
parents: 12168
diff changeset
1075 (cdr (assq 'name default-frame-alist))))
11927
20eae371b3f0 (x-create-frame-with-faces): Read geometry resource
Karl Heuer <kwzh@gnu.org>
parents: 11850
diff changeset
1076 (x-resource-name name)
17162
97232f50447f clean code.
Simon Marshall <simon@gnu.org>
parents: 17160
diff changeset
1077 (res-geometry (if name (x-get-resource "geometry" "Geometry"))))
11927
20eae371b3f0 (x-create-frame-with-faces): Read geometry resource
Karl Heuer <kwzh@gnu.org>
parents: 11850
diff changeset
1078 (if res-geometry
17162
97232f50447f clean code.
Simon Marshall <simon@gnu.org>
parents: 17160
diff changeset
1079 (let ((parsed (x-parse-geometry res-geometry)))
11927
20eae371b3f0 (x-create-frame-with-faces): Read geometry resource
Karl Heuer <kwzh@gnu.org>
parents: 11850
diff changeset
1080 ;; If the resource specifies a position,
20eae371b3f0 (x-create-frame-with-faces): Read geometry resource
Karl Heuer <kwzh@gnu.org>
parents: 11850
diff changeset
1081 ;; call the position and size "user-specified".
20eae371b3f0 (x-create-frame-with-faces): Read geometry resource
Karl Heuer <kwzh@gnu.org>
parents: 11850
diff changeset
1082 (if (or (assq 'top parsed) (assq 'left parsed))
17162
97232f50447f clean code.
Simon Marshall <simon@gnu.org>
parents: 17160
diff changeset
1083 (setq parsed (append '((user-position . t) (user-size . t))
97232f50447f clean code.
Simon Marshall <simon@gnu.org>
parents: 17160
diff changeset
1084 parsed)))
12169
67f9dfb23d7c (x-create-frame-with-faces): Don't use initial-frame-alist
Karl Heuer <kwzh@gnu.org>
parents: 12168
diff changeset
1085 ;; Put the geometry parameters at the end.
67f9dfb23d7c (x-create-frame-with-faces): Don't use initial-frame-alist
Karl Heuer <kwzh@gnu.org>
parents: 12168
diff changeset
1086 ;; Copy default-frame-alist so that they go after it.
17162
97232f50447f clean code.
Simon Marshall <simon@gnu.org>
parents: 17160
diff changeset
1087 (setq parameters (append parameters default-frame-alist parsed)))))
12562
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1088 (let (frame)
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1089 (if (null global-face-data)
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1090 (setq frame (x-create-frame parameters))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1091 (let* ((visibility-spec (assq 'visibility parameters))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1092 (faces (copy-alist global-face-data))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1093 success
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1094 (rest faces))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1095 (setq frame (x-create-frame (cons '(visibility . nil) parameters)))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1096 (unwind-protect
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1097 (progn
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1098 (set-frame-face-alist frame faces)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1099
12562
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1100 (if (cdr (or (assq 'reverse parameters)
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1101 (assq 'reverse default-frame-alist)
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1102 (let ((resource (x-get-resource "reverseVideo"
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1103 "ReverseVideo")))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1104 (if resource
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1105 (cons nil (member (downcase resource)
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1106 '("on" "true")))))))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1107 (let* ((params (frame-parameters frame))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1108 (bg (cdr (assq 'foreground-color params)))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1109 (fg (cdr (assq 'background-color params))))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1110 (modify-frame-parameters frame
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1111 (list (cons 'foreground-color fg)
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1112 (cons 'background-color bg)))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1113 (if (equal bg (cdr (assq 'border-color params)))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1114 (modify-frame-parameters frame
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1115 (list (cons 'border-color fg))))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1116 (if (equal bg (cdr (assq 'mouse-color params)))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1117 (modify-frame-parameters frame
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1118 (list (cons 'mouse-color fg))))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1119 (if (equal bg (cdr (assq 'cursor-color params)))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1120 (modify-frame-parameters frame
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1121 (list (cons 'cursor-color fg))))))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1122 ;; Copy the vectors that represent the faces.
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1123 ;; Also fill them in from X resources.
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1124 (while rest
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1125 (let ((global (cdr (car rest))))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1126 (setcdr (car rest) (vector 'face
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1127 (face-name (cdr (car rest)))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1128 (face-id (cdr (car rest)))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1129 nil nil nil nil nil))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1130 (face-fill-in (car (car rest)) global frame))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1131 (make-face-x-resource-internal (cdr (car rest)) frame t)
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1132 (setq rest (cdr rest)))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1133 (if (null visibility-spec)
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1134 (make-frame-visible frame)
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1135 (modify-frame-parameters frame (list visibility-spec)))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1136 (setq success t))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1137 (or success
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1138 (delete-frame frame)))))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1139 ;; Set up the background-mode frame parameter
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1140 ;; so that programs can decide good ways of highlighting
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1141 ;; on this frame.
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1142 (let ((bg-resource (x-get-resource ".backgroundMode"
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1143 "BackgroundMode"))
12581
8e4a75fa4b5b (x-create-frame-with-faces):
Richard M. Stallman <rms@gnu.org>
parents: 12562
diff changeset
1144 (params (frame-parameters frame))
12562
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1145 (bg-mode))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1146 (setq bg-mode
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1147 (cond (bg-resource (intern (downcase bg-resource)))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1148 ((< (apply '+ (x-color-values
12581
8e4a75fa4b5b (x-create-frame-with-faces):
Richard M. Stallman <rms@gnu.org>
parents: 12562
diff changeset
1149 (cdr (assq 'background-color params))
8e4a75fa4b5b (x-create-frame-with-faces):
Richard M. Stallman <rms@gnu.org>
parents: 12562
diff changeset
1150 frame))
15510
db0f45c7f885 (x-create-frame-with-faces): Set threshold for "light color"
Richard M. Stallman <rms@gnu.org>
parents: 14880
diff changeset
1151 ;; Just looking at the screen,
db0f45c7f885 (x-create-frame-with-faces): Set threshold for "light color"
Richard M. Stallman <rms@gnu.org>
parents: 14880
diff changeset
1152 ;; colors whose values add up to .6 of the white total
db0f45c7f885 (x-create-frame-with-faces): Set threshold for "light color"
Richard M. Stallman <rms@gnu.org>
parents: 14880
diff changeset
1153 ;; still look dark to me.
db0f45c7f885 (x-create-frame-with-faces): Set threshold for "light color"
Richard M. Stallman <rms@gnu.org>
parents: 14880
diff changeset
1154 (* (apply '+ (x-color-values "white" frame)) .6))
12562
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1155 'dark)
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1156 (t 'light)))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1157 (modify-frame-parameters frame
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1158 (list (cons 'background-mode bg-mode)
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1159 (cons 'display-type
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1160 (cond ((x-display-color-p frame)
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1161 'color)
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1162 ((x-display-grayscale-p frame)
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1163 'grayscale)
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1164 (t 'mono))))))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1165 frame))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1166
7019
74edb669a7e9 (frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6873
diff changeset
1167 ;; Update a frame's faces when we change its default font.
74edb669a7e9 (frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6873
diff changeset
1168 (defun frame-update-faces (frame)
74edb669a7e9 (frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6873
diff changeset
1169 (let* ((faces global-face-data)
74edb669a7e9 (frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6873
diff changeset
1170 (rest faces))
74edb669a7e9 (frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6873
diff changeset
1171 (while rest
74edb669a7e9 (frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6873
diff changeset
1172 (let* ((face (car (car rest)))
74edb669a7e9 (frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6873
diff changeset
1173 (font (face-font face t)))
74edb669a7e9 (frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6873
diff changeset
1174 (if (listp font)
74edb669a7e9 (frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6873
diff changeset
1175 (let ((bold (memq 'bold font))
74edb669a7e9 (frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6873
diff changeset
1176 (italic (memq 'italic font)))
7120
a03d341e9594 (frame-update-faces): Unset old font.
Karl Heuer <kwzh@gnu.org>
parents: 7019
diff changeset
1177 ;; Ignore any previous (string-valued) font, it might not even
a03d341e9594 (frame-update-faces): Unset old font.
Karl Heuer <kwzh@gnu.org>
parents: 7019
diff changeset
1178 ;; be the right size anymore.
a03d341e9594 (frame-update-faces): Unset old font.
Karl Heuer <kwzh@gnu.org>
parents: 7019
diff changeset
1179 (set-face-font face nil frame)
7019
74edb669a7e9 (frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6873
diff changeset
1180 (cond ((and bold italic)
74edb669a7e9 (frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6873
diff changeset
1181 (make-face-bold-italic face frame t))
74edb669a7e9 (frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6873
diff changeset
1182 (bold
74edb669a7e9 (frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6873
diff changeset
1183 (make-face-bold face frame t))
74edb669a7e9 (frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6873
diff changeset
1184 (italic
74edb669a7e9 (frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6873
diff changeset
1185 (make-face-italic face frame t)))))
74edb669a7e9 (frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6873
diff changeset
1186 (setq rest (cdr rest)))
74edb669a7e9 (frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6873
diff changeset
1187 frame)))
74edb669a7e9 (frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6873
diff changeset
1188
10193
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1189 ;; Update the colors of FACE, after FRAME's own colors have been changed.
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1190 ;; This applies only to faces with global color specifications
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1191 ;; that are not simple constants.
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1192 (defun frame-update-face-colors (frame)
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1193 (let ((faces global-face-data))
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1194 (while faces
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1195 (condition-case nil
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1196 (let* ((data (cdr (car faces)))
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1197 (face (car (car faces)))
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1198 (foreground (face-foreground data))
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1199 (background (face-background data)))
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1200 ;; If the global spec is a specific color,
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1201 ;; which doesn't depend on the frame's attributes,
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1202 ;; we don't need to recalculate it now.
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1203 (or (listp foreground)
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1204 (setq foreground nil))
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1205 (or (listp background)
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1206 (setq background nil))
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1207 ;; If we are going to frob this face at all,
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1208 ;; reinitialize it first.
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1209 (if (or foreground background)
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1210 (progn (set-face-foreground face nil frame)
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1211 (set-face-background face nil frame)))
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1212 (if foreground
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1213 (face-try-color-list 'set-face-foreground
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1214 face foreground frame))
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1215 (if background
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1216 (face-try-color-list 'set-face-background
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1217 face background frame)))
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1218 (error nil))
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1219 (setq faces (cdr faces)))))
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1220
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1221 ;; Fill in the face FACE from frame-independent face data DATA.
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1222 ;; DATA should be the non-frame-specific ("global") face vector
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1223 ;; for the face. FACE should be a face name or face object.
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1224 ;; FRAME is the frame to act on; it must be an actual frame, not nil or t.
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1225 (defun face-fill-in (face data frame)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1226 (condition-case nil
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1227 (let ((foreground (face-foreground data))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1228 (background (face-background data))
11850
f9174d73e755 Put property on set-face-stipple, not set-stipple.
Karl Heuer <kwzh@gnu.org>
parents: 11464
diff changeset
1229 (font (face-font data))
f9174d73e755 Put property on set-face-stipple, not set-stipple.
Karl Heuer <kwzh@gnu.org>
parents: 11464
diff changeset
1230 (stipple (face-stipple data)))
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1231 (set-face-underline-p face (face-underline-p data) frame)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1232 (if foreground
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1233 (face-try-color-list 'set-face-foreground
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1234 face foreground frame))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1235 (if background
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1236 (face-try-color-list 'set-face-background
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1237 face background frame))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1238 (if (listp font)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1239 (let ((bold (memq 'bold font))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1240 (italic (memq 'italic font)))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1241 (cond ((and bold italic)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1242 (make-face-bold-italic face frame))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1243 (bold
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1244 (make-face-bold face frame))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1245 (italic
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1246 (make-face-italic face frame))))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1247 (if font
11850
f9174d73e755 Put property on set-face-stipple, not set-stipple.
Karl Heuer <kwzh@gnu.org>
parents: 11464
diff changeset
1248 (set-face-font face font frame)))
f9174d73e755 Put property on set-face-stipple, not set-stipple.
Karl Heuer <kwzh@gnu.org>
parents: 11464
diff changeset
1249 (if stipple
f9174d73e755 Put property on set-face-stipple, not set-stipple.
Karl Heuer <kwzh@gnu.org>
parents: 11464
diff changeset
1250 (set-face-stipple face stipple frame)))
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1251 (error nil)))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1252
10022
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1253 ;; Assuming COLOR is a valid color name,
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1254 ;; return t if it can be displayed on FRAME.
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1255 (defun face-color-supported-p (frame color background-p)
13609
eb141cf52779 (face-color-supported-p): Return nil if no window system.
Richard M. Stallman <rms@gnu.org>
parents: 13432
diff changeset
1256 (and window-system
eb141cf52779 (face-color-supported-p): Return nil if no window system.
Richard M. Stallman <rms@gnu.org>
parents: 13432
diff changeset
1257 (or (x-display-color-p frame)
eb141cf52779 (face-color-supported-p): Return nil if no window system.
Richard M. Stallman <rms@gnu.org>
parents: 13432
diff changeset
1258 ;; A black-and-white display can implement these.
eb141cf52779 (face-color-supported-p): Return nil if no window system.
Richard M. Stallman <rms@gnu.org>
parents: 13432
diff changeset
1259 (member color '("black" "white"))
eb141cf52779 (face-color-supported-p): Return nil if no window system.
Richard M. Stallman <rms@gnu.org>
parents: 13432
diff changeset
1260 ;; A black-and-white display can fake gray for background.
eb141cf52779 (face-color-supported-p): Return nil if no window system.
Richard M. Stallman <rms@gnu.org>
parents: 13432
diff changeset
1261 (and background-p
eb141cf52779 (face-color-supported-p): Return nil if no window system.
Richard M. Stallman <rms@gnu.org>
parents: 13432
diff changeset
1262 (face-color-gray-p color frame))
eb141cf52779 (face-color-supported-p): Return nil if no window system.
Richard M. Stallman <rms@gnu.org>
parents: 13432
diff changeset
1263 ;; A grayscale display can implement colors that are gray (more or less).
eb141cf52779 (face-color-supported-p): Return nil if no window system.
Richard M. Stallman <rms@gnu.org>
parents: 13432
diff changeset
1264 (and (x-display-grayscale-p frame)
eb141cf52779 (face-color-supported-p): Return nil if no window system.
Richard M. Stallman <rms@gnu.org>
parents: 13432
diff changeset
1265 (face-color-gray-p color frame)))))
10022
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1266
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1267 ;; Use FUNCTION to store a color in FACE on FRAME.
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1268 ;; COLORS is either a single color or a list of colors.
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1269 ;; If it is a list, try the colors one by one until one of them
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1270 ;; succeeds. We signal an error only if all the colors failed.
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1271 ;; t as COLORS or as an element of COLORS means to invert the face.
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1272 ;; That can't fail, so any subsequent elements after the t are ignored.
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1273 (defun face-try-color-list (function face colors frame)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1274 (if (stringp colors)
10022
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1275 (if (face-color-supported-p frame colors
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1276 (eq function 'set-face-background))
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1277 (funcall function face colors frame))
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1278 (if (eq colors t)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1279 (invert-face face frame)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1280 (let (done)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1281 (while (and colors (not done))
10375
8652c7b84a5f (face-try-color-list): Treat `underline' as valid.
Richard M. Stallman <rms@gnu.org>
parents: 10193
diff changeset
1282 (if (or (memq (car colors) '(t underline))
10022
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1283 (face-color-supported-p frame (car colors)
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1284 (eq function 'set-face-background)))
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1285 (if (cdr colors)
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1286 ;; If there are more colors to try, catch errors
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1287 ;; and set `done' if we succeed.
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1288 (condition-case nil
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1289 (progn
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1290 (cond ((eq (car colors) t)
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1291 (invert-face face frame))
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1292 ((eq (car colors) 'underline)
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1293 (set-face-underline-p face t frame))
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1294 (t
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1295 (funcall function face (car colors) frame)))
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1296 (setq done t))
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1297 (error nil))
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1298 ;; If this is the last color, let the error get out if it fails.
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1299 ;; If it succeeds, we will exit anyway after this iteration.
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1300 (cond ((eq (car colors) t)
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1301 (invert-face face frame))
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1302 ((eq (car colors) 'underline)
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1303 (set-face-underline-p face t frame))
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1304 (t
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1305 (funcall function face (car colors) frame)))))
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1306 (setq colors (cdr colors)))))))
2764
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
1307
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
1308 ;; If we are already using x-window frames, initialize faces for them.
16590
a0cfcb9f8033 Use w32 instead of ms-windows for window-system symbol
Geoff Voelker <voelker@cs.washington.edu>
parents: 16199
diff changeset
1309 (if (memq (framep (selected-frame)) '(x w32))
2764
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
1310 (face-initialize))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1311
2715
9caee9338229 * faces.el: Call internal-set-face-1, not internat-set-face-1.
Jim Blandy <jimb@redhat.com>
parents: 2714
diff changeset
1312 (provide 'faces)
9caee9338229 * faces.el: Call internal-set-face-1, not internat-set-face-1.
Jim Blandy <jimb@redhat.com>
parents: 2714
diff changeset
1313
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1314 ;;; faces.el ends here