1 @c This is part of the Emacs manual.
2 @c Copyright (C) 1987, 1993, 1994, 1995, 1997, 2001, 2002, 2003,
3 @c 2004, 2005, 2006 Free Software Foundation, Inc.
4 @c See file emacs.texi for copying conditions.
5 @node X Resources, Antinews, Emacs Invocation, Top
6 @appendix X Options and Resources
8 You can customize some X-related aspects of Emacs behavior using X
9 resources, as is usual for programs that use X. On MS-Windows, you
10 can customize some of the same aspects using the system registry.
11 @xref{MS-Windows Registry}. Likewise, Emacs on MacOS Carbon emulates X
12 resources using the Preferences system. @xref{Mac Environment Variables}.
14 When Emacs is built using an ``X toolkit'', such as Lucid or
15 LessTif, you need to use X resources to customize the appearance of
16 the widgets, including the menu-bar, scroll-bar, and dialog boxes.
17 This is because the libraries that implement these don't provide for
18 customization through Emacs. GTK+ widgets use a separate system of
19 ``GTK resources''. In this chapter we describe the most commonly used
20 resource specifications. For full documentation, see the online
23 @c Add xref for LessTif/Motif menu resources.
26 * Resources:: Using X resources with Emacs (in general).
27 * Table of Resources:: Table of specific X resources that affect Emacs.
28 * Face Resources:: X resources for customizing faces.
29 * Lucid Resources:: X resources for Lucid menus.
30 * GTK resources:: Resources for GTK widgets.
34 @appendixsec X Resources
37 @cindex @file{~/.Xdefaults} file
38 @cindex @file{~/.Xresources} file
40 Programs running under the X Window System organize their user
41 options under a hierarchy of classes and resources. You can specify
42 default values for these options in your X resources file, usually
43 named @file{~/.Xdefaults} or @file{~/.Xresources}.
44 If changes in @file{~/.Xdefaults} do not
45 take effect, it is because your X server stores its own list of
46 resources; to update them, use the shell command @command{xrdb}---for
47 instance, @samp{xrdb ~/.Xdefaults}.
49 Each line in the file specifies a value for one option or for a
50 collection of related options, for one program or for several programs
51 (optionally even for all programs).
53 @cindex Registry (MS-Windows)
54 MS-Windows systems don't support @file{~/.Xdefaults} files, but
55 Emacs compiled for Windows looks for X resources in the Windows
56 Registry, under the key @samp{HKEY_CURRENT_USER\SOFTWARE\GNU\Emacs}
57 and then under the key @samp{HKEY_LOCAL_MACHINE\SOFTWARE\GNU\Emacs}.
58 The menu and scrollbars are native widgets on MS-Windows, so they are
59 only customizable via the system-wide settings in the Display Control
60 Panel. You can also set resources using the @samp{-xrm} command line
63 Applications such as Emacs look for resources with specific names
64 and their particular meanings. Case distinctions are significant in
65 these names. Each resource specification in @file{~/.Xdefaults}
66 states the name of the program and the name of the resource. For
67 Emacs, the program name is @samp{Emacs}. It looks like this:
73 The order in which the lines appear in the file does not matter.
74 Also, command-line options always override the X resources file.
76 You can experiment with the effect of different resource settings
77 with the @code{editres} program. Select @samp{Get Tree} from the
78 @samp{Commands} menu, then click on an Emacs frame. This will display
79 a tree showing the structure of X toolkit widgets used in an Emacs
80 frame. Select one of them, such as @samp{menubar}, then select
81 @samp{Show Resource Box} from the @samp{Commands} menu. This displays
82 a list of all the meaningful X resources for that widget, and allows
83 you to edit them. Changes take effect when you click on the
84 @samp{Apply} button. (See the @code{editres} man page for more
87 @node Table of Resources
88 @appendixsec Table of X Resources for Emacs
90 This table lists the resource names that designate options for
91 Emacs, not counting those for the appearance of the menu bar, each
92 with the class that it belongs to:
95 @item @code{background} (class @code{Background})
96 Background color name.
98 @item @code{borderColor} (class @code{BorderColor})
99 Color name for the external border.
101 @item @code{cursorColor} (class @code{Foreground})
102 Color name for text cursor (point).
104 @item @code{font} (class @code{Font})
105 Font name (or fontset name, @pxref{Fontsets}) for @code{default} font.
107 @item @code{foreground} (class @code{Foreground})
110 @item @code{geometry} (class @code{Geometry})
111 Window size and position. Be careful not to specify this resource as
112 @samp{emacs*geometry}, because that may affect individual menus as well
113 as the Emacs frame itself.
115 If this resource specifies a position, that position applies only to the
116 initial Emacs frame (or, in the case of a resource for a specific frame
117 name, only that frame). However, the size, if specified here, applies to
120 @item @code{iconName} (class @code{Title})
121 Name to display in the icon.
123 @item @code{internalBorder} (class @code{BorderWidth})
124 Width in pixels of the internal border.
126 @item @code{lineSpacing} (class @code{LineSpacing})
129 Additional space (@dfn{leading}) between lines, in pixels.
131 @item @code{menuBar} (class @code{MenuBar})
133 Give frames menu bars if @samp{on}; don't have menu bars if
134 @samp{off}. @xref{Lucid Resources}, for how to control the appearance
135 of the menu bar if you have one.
137 @item @code{pointerColor} (class @code{Foreground})
138 Color of the mouse cursor.
140 @item @code{screenGamma} (class @code{ScreenGamma})
141 @cindex gamma correction
142 Gamma correction for colors, equivalent to the frame parameter
145 @item @code{title} (class @code{Title})
146 Name to display in the title bar of the initial Emacs frame.
148 @item @code{toolBar} (class @code{ToolBar})
150 Number of lines to reserve for the tool bar. A zero value suppresses
151 the tool bar. If the value is non-zero and
152 @code{auto-resize-tool-bars} is non-@code{nil}, the tool bar's size
153 will be changed automatically so that all tool bar items are visible.
155 @item @code{useXIM} (class @code{UseXIM})
157 @cindex X input methods
158 @cindex input methods, X
159 Turn off use of X input methods (XIM) if @samp{false} or @samp{off}.
160 This is only relevant if your Emacs is actually built with XIM
161 support. It is potentially useful to turn off XIM for efficiency,
162 especially slow X client/server links.
164 @item @code{verticalScrollBars} (class @code{ScrollBars})
165 Give frames scroll bars if @samp{on}; don't have scroll bars if
170 @appendixsec X Resources for Faces
172 You can use resources to customize the appearance of particular
173 faces (@pxref{Faces}):
176 @item @var{face}.attributeForeground
177 Foreground color for face @var{face}.
178 @item @var{face}.attributeBackground
179 Background color for face @var{face}.
180 @item @var{face}.attributeUnderline
181 Underline flag for face @var{face}. Use @samp{on} or @samp{true} for
183 @item @var{face}.attributeStrikeThrough
184 @itemx @var{face}.attributeOverline
185 @itemx @var{face}.attributeBox
186 @itemx @var{face}.attributeInverse
187 Likewise, for other boolean font attributes.
188 @item @var{face}.attributeStipple
189 The name of a pixmap data file to use for the stipple pattern, or
190 @code{false} to not use stipple for the face @var{face}.
191 @item @var{face}.attributeBackgroundPixmap
192 The background pixmap for the face @var{face}. Should be a name of a
193 pixmap file or @code{false}.
194 @item @var{face}.attributeFont
195 Font name (full XFD name or valid X abbreviation) for face @var{face}.
196 Instead of this, you can specify the font through separate attributes.
199 Instead of using @code{attributeFont} to specify a font name, you can
200 select a font through these separate attributes:
203 @item @var{face}.attributeFamily
204 Font family for face @var{face}.
205 @item @var{face}.attributeHeight
206 Height of the font to use for face @var{face}: either an integer
207 specifying the height in units of 1/10@dmn{pt}, or a floating point
208 number that specifies a scale factor to scale the underlying face's
209 default font, or a function to be called with the default height which
210 will return a new height.
211 @item @var{face}.attributeWidth
212 @itemx @var{face}.attributeWeight
213 @itemx @var{face}.attributeSlant
214 Each of these resources corresponds to a like-named font attribute,
215 and you write the resource value the same as the symbol you would use
216 for the font attribute value.
217 @item @var{face}.attributeBold
218 Bold flag for face @var{face}---instead of @code{attributeWeight}. Use @samp{on} or @samp{true} for
220 @item @var{face}.attributeItalic
221 Italic flag for face @var{face}---instead of @code{attributeSlant}.
224 @node Lucid Resources
225 @appendixsec Lucid Menu X Resources
226 @cindex Menu X Resources (Lucid widgets)
227 @cindex Lucid Widget X Resources
229 If the Emacs installed at your site was built to use the X toolkit
230 with the Lucid menu widgets, then the menu bar is a separate widget
231 and has its own resources. The resource specifications start with
232 @samp{Emacs.pane.menubar}---for instance, to specify the font
233 @samp{8x16} for the menu-bar items, write this:
236 Emacs.pane.menubar.font: 8x16
240 Resources for @emph{non-menubar} toolkit pop-up menus have
241 @samp{menu*} instead of @samp{pane.menubar}. For example, to specify
242 the font @samp{8x16} for the pop-up menu items, write this:
245 Emacs.menu*.font: 8x16
249 For dialog boxes, use @samp{dialog*}:
252 Emacs.dialog*.font: 8x16
256 The Lucid menus can display multilingual text in your locale. For
257 more information about fontsets see the man page for
258 @code{XCreateFontSet}. To enable multilingual menu text you specify a
259 @code{fontSet} resource instead of the font resource. If both
260 @code{font} and @code{fontSet} resources are specified, the
261 @code{fontSet} resource is used.
263 Thus, to specify @samp{-*-helvetica-medium-r-*--*-120-*-*-*-*-*-*,*}
264 for both the popup and menu bar menus, write this:
267 Emacs*menu*fontSet: -*-helvetica-medium-r-*--*-120-*-*-*-*-*-*,*
271 The @samp{*menu*} as a wildcard matches @samp{pane.menubar} and
274 Experience shows that on some systems you may need to add
275 @samp{shell.}@: before the @samp{pane.menubar} or @samp{menu*}. On
276 some other systems, you must not add @samp{shell.}. The generic wildcard
277 approach should work on both kinds of systems.
279 Here is a list of the specific resources for menu bars and pop-up menus:
283 Font for menu item text.
285 Fontset for menu item text.
287 Color of the foreground.
289 Color of the background.
290 @item buttonForeground
291 In the menu bar, the color of the foreground for a selected item.
293 The margin of the menu bar, in characters. Default is 1.
297 @appendixsec GTK resources
299 The most common way to customize the GTK widgets Emacs uses (menus, dialogs
300 tool bars and scroll bars) is by choosing an appropriate theme, for example
301 with the GNOME theme selector. You can also do Emacs specific customization
302 by inserting GTK style directives in the file @file{~/.emacs.d/gtkrc}. Some GTK
303 themes ignore customizations in @file{~/.emacs.d/gtkrc} so not everything
304 works with all themes. To customize Emacs font, background, faces, etc., use
305 the normal X resources (@pxref{Resources}). We will present some examples of
306 customizations here, but for a more detailed description, see the online manual.
308 The first example is just one line. It changes the font on all GTK widgets
309 to courier with size 12:
312 gtk-font-name = "courier 12"
315 The thing to note is that the font name is not an X font name, like
316 -*-helvetica-medium-r-*--*-120-*-*-*-*-*-*, but a Pango font name. A Pango
317 font name is basically of the format "family style size", where the style
318 is optional as in the case above. A name with a style could be for example:
321 gtk-font-name = "helvetica bold 10"
324 To customize widgets you first define a style and then apply the style to
325 the widgets. Here is an example that sets the font for menus, but not
329 # @r{Define the style @samp{menufont}.}
332 font_name = "helvetica bold 14" # This is a Pango font name
335 # @r{Specify that widget type @samp{*emacs-menuitem*} uses @samp{menufont}.}
336 widget "*emacs-menuitem*" style "menufont"
339 The widget name in this example contains wildcards, so the style will be
340 applied to all widgets that match "*emacs-menuitem*". The widgets are
341 named by the way they are contained, from the outer widget to the inner widget.
342 So to apply the style "my_style" (not shown) with the full, absolute name, for
343 the menubar and the scroll bar in Emacs we use:
346 widget "Emacs.pane.menubar" style "my_style"
347 widget "Emacs.pane.emacs.verticalScrollBar" style "my_style"
350 But to avoid having to type it all, wildcards are often used. @samp{*}
351 matches zero or more characters and @samp{?} matches one character. So "*"
354 Each widget has a class (for example GtkMenuItem) and a name (emacs-menuitem).
355 You can assign styles by name or by class. In this example we have used the
361 font_name = "helvetica bold 14"
364 widget_class "*GtkMenuBar" style "menufont"
368 The names and classes for the GTK widgets Emacs uses are:
370 @multitable {@code{verticalScrollbar plus}} {@code{GtkFileSelection} and some}
371 @item @code{emacs-filedialog}
372 @tab @code{GtkFileSelection}
373 @item @code{emacs-dialog}
374 @tab @code{GtkDialog}
376 @tab @code{GtkWindow}
381 @item @code{verticalScrollBar}
382 @tab @code{GtkVScrollbar}
383 @item @code{emacs-toolbar}
384 @tab @code{GtkToolbar}
386 @tab @code{GtkMenuBar}
387 @item @code{emacs-menuitem}
388 @tab anything in menus
391 GTK absolute names are quite strange when it comes to menus
392 and dialogs. The names do not start with @samp{Emacs}, as they are
393 free-standing windows and not contained (in the GTK sense) by the
394 Emacs GtkWindow. To customize the dialogs and menus, use wildcards like this:
397 widget "*emacs-dialog*" style "my_dialog_style"
398 widget "*emacs-filedialog* style "my_file_style"
399 widget "*emacs-menuitem* style "my_menu_style"
402 If you specify a customization in @file{~/.emacs.d/gtkrc}, then it
403 automatically applies only to Emacs, since other programs don't read
404 that file. For example, the drop down menu in the file dialog can not
405 be customized by any absolute widget name, only by an absolute class
406 name. This is because the widgets in the drop down menu do not
407 have names and the menu is not contained in the Emacs GtkWindow. To
408 have all menus in Emacs look the same, use this in
409 @file{~/.emacs.d/gtkrc}:
412 widget_class "*Menu*" style "my_menu_style"
415 Here is a more elaborate example, showing how to change the parts of
421 fg[NORMAL] = "red"@ @ @ @ @ # @r{The arrow color.}
422 bg[NORMAL] = "yellow"@ @ # @r{The thumb and background around the arrow.}
423 bg[ACTIVE] = "blue"@ @ @ @ # @r{The trough color.}
424 bg[PRELIGHT] = "white"@ # @r{The thumb color when the mouse is over it.}
427 widget "*verticalScrollBar*" style "scroll"
431 arch-tag: e1856f29-2482-42c0-a990-233cdccd1f21