Add the bug number #10360 to the entry for 2011-12-23T14:51:51Z!eliz@gnu.org.
[emacs.git] / doc / emacs / xresources.texi
blobb32b3d905e47ed3a58f44e8f7c1018fa080694c2
1 @c This is part of the Emacs manual.
2 @c Copyright (C) 1987, 1993-1995, 1997, 2001-2011
3 @c   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}.
13   When Emacs is built using an ``X toolkit'', such as Lucid or
14 LessTif, you need to use X resources to customize the appearance of
15 the widgets, including the menu-bar, scroll-bar, and dialog boxes.
16 This is because the libraries that implement these don't provide for
17 customization through Emacs.  GTK+ widgets use a separate system of
18 @ifnottex
19 ``GTK resources'', which we will also describe.
20 @end ifnottex
21 @iftex
22 ``GTK resources.''  In this chapter we describe the most commonly used
23 resource specifications.  For full documentation, see the online
24 manual.
26 @c Add xref for LessTif/Motif menu resources.
27 @end iftex
30 @menu
31 * Resources::           Using X resources with Emacs (in general).
32 * Table of Resources::  Table of specific X resources that affect Emacs.
33 * Face Resources::      X resources for customizing faces.
34 * Lucid Resources::     X resources for Lucid menus.
35 * LessTif Resources::   X resources for LessTif and Motif menus.
36 * GTK resources::       Resources for GTK widgets.
37 @end menu
39 @node Resources
40 @appendixsec X Resources
41 @cindex resources
42 @cindex X resources
43 @cindex @file{~/.Xdefaults} file
44 @cindex @file{~/.Xresources} file
46   Programs running under the X Window System organize their user
47 options under a hierarchy of classes and resources.  You can specify
48 default values for these options in your @dfn{X resource file},
49 usually named @file{~/.Xdefaults} or @file{~/.Xresources}.  Changes in
50 this file do not take effect immediately, because the X server stores
51 its own list of resources; to update it, use the command
52 @command{xrdb}---for instance, @samp{xrdb ~/.Xdefaults}.
54 @cindex Registry (MS-Windows)
55   (MS-Windows systems do not support X resource files; on Windows,
56 Emacs looks for X resources in the Windows Registry, first under the
57 key @samp{HKEY_CURRENT_USER\SOFTWARE\GNU\Emacs} and then under the key
58 @samp{HKEY_LOCAL_MACHINE\SOFTWARE\GNU\Emacs}.  The menu and scroll
59 bars are native widgets on MS-Windows, so they are only customizable
60 via the system-wide settings in the Display Control Panel.  You can
61 also set resources using the @samp{-xrm} command line option, as
62 explained below.)
64   Each line in the X resource file specifies a value for one option or
65 for a collection of related options.  Each resource specification
66 consists of a @dfn{program name} and a @dfn{resource name}.  Case
67 distinctions are significant in each of these names.  Here is an
68 example:
70 @example
71 emacs.borderWidth: 2
72 @end example
74 @ifnottex
75   The program name is the name of the executable file to which the
76 resource applies.  For Emacs, this is normally @samp{emacs}.  To
77 specify a definition that applies to all instances of Emacs,
78 regardless of the name of the Emacs executable, use @samp{Emacs}.
80   The resource name is the name of a program setting.  For instance,
81 Emacs recognizes a @samp{borderWidth} resource that controls the width
82 of the external border for graphical frames.
84   Resources are grouped into named classes.  For instance, the
85 @samp{BorderWidth} class contains both the @samp{borderWidth} resource
86 (which we just described), as well as the @samp{internalBorder}
87 resource, which controls the width of the internal border for
88 graphical frames.  Instead of using a resource name, you can use a
89 class name to specify the same value for all resources in that class.
90 Here's an example:
92 @example
93 emacs.BorderWidth: 2
94 @end example
96   If you specify a value for a class, it becomes the default for all
97 resources in that class.  You can specify values for individual
98 resources as well; these override the class value, for those
99 particular resources.  The following example specifies 2 as the
100 default width for all borders, but overrides this value with 4 for the
101 external border:
103 @example
104 emacs.BorderWidth: 2
105 emacs.borderWidth: 4
106 @end example
107 @end ifnottex
109   The order in which the lines appear in the file does not matter.
110 One way to experiment with the effect of different resource settings
111 is to use the @code{editres} program.  See the @code{editres} man page
112 for more details.
114   Emacs does not process X resources at all if you set the variable
115 @code{inhibit-x-resources} to a non-@code{nil} value, or if you
116 specify the @samp{-Q} (or @samp{--quick}) command-line argument
117 (@pxref{Initial Options}).  (The @samp{-Q} argument automatically sets
118 @code{inhibit-x-resources} to @code{t}.)
120 @ifnottex
121   In addition, you can use the following command-line options to
122 override the X resources file:
124 @table @samp
125 @item -name @var{name}
126 @opindex --name
127 @itemx --name=@var{name}
128 @cindex resource name, command-line argument
129 This option sets the program name of the initial Emacs frame to
130 @var{name}.  It also sets the title of the initial frame to
131 @var{name}.  This option does not affect subsequent frames.
133 If you don't specify this option, the default is to use the Emacs
134 executable's name as the program name.
136 For consistency, @samp{-name} also specifies the name to use for other
137 resource values that do not belong to any particular frame.
139 The resources that name Emacs invocations also belong to a class,
140 named @samp{Emacs}.  If you write @samp{Emacs} instead of
141 @samp{emacs}, the resource applies to all frames in all Emacs jobs,
142 regardless of frame titles and regardless of the name of the
143 executable file.
145 @item -xrm @var{resource-values}
146 @opindex --xrm
147 @itemx --xrm=@var{resource-values}
148 @cindex resource values, command-line argument
149 This option specifies X resource values for the present Emacs job.
151 @var{resource-values} should have the same format that you would use
152 inside a file of X resources.  To include multiple resource
153 specifications in @var{resource-values}, put a newline between them,
154 just as you would in a file.  You can also use @samp{#include
155 "@var{filename}"} to include a file full of resource specifications.
156 Resource values specified with @samp{-xrm} take precedence over all
157 other resource specifications.
158 @end table
159 @end ifnottex
161 @node Table of Resources
162 @appendixsec Table of X Resources for Emacs
164   This table lists the resource names that designate options for
165 Emacs, not counting those for the appearance of the menu bar, each
166 with the class that it belongs to:
168 @table @asis
169 @item @code{background} (class @code{Background})
170 Background color name.
172 @item @code{bitmapIcon} (class @code{BitmapIcon})
173 Tell the window manager to display the Emacs icon if @samp{on}; don't
174 do so if @samp{off}.  (The icon is usually shown in the ``taskbar'' on
175 a graphical desktop.)
177 @item @code{borderColor} (class @code{BorderColor})
178 Color name for the external border.
180 @ifnottex
181 @item @code{borderWidth} (class @code{BorderWidth})
182 Width in pixels of the external border.
183 @end ifnottex
185 @item @code{cursorColor} (class @code{Foreground})
186 Color name for text cursor (point).
188 @ifnottex
189 @item @code{cursorBlink} (class @code{CursorBlink})
190 Specifies whether to make the cursor blink. The default is @samp{on}.  Use
191 @samp{off} or @samp{false} to turn cursor blinking off.
192 @end ifnottex
194 @item @code{font} (class @code{Font})
195 Font name for the @code{default} font.  @xref{Fonts}.  You can also
196 specify a fontset name (@pxref{Fontsets}).
198 @item @code{fontBackend} (class @code{FontBackend})
199 The backend(s) to use for drawing fonts; if multiple backends are
200 specified, they must be comma-delimited and given in order of
201 precedence.  On X, for instance, the value @samp{x,xft} tells Emacs to
202 draw fonts using the X core font driver, falling back on the Xft font
203 driver if that fails.  Normally, you can leave this resource unset, in
204 which case Emacs tries using all font backends available on your
205 graphical device.
207 @item @code{foreground} (class @code{Foreground})
208 Color name for text.
210 @item @code{geometry} (class @code{Geometry})
211 Window size and position.  Be careful not to specify this resource as
212 @samp{emacs*geometry}, because that may affect individual menus as well
213 as the Emacs frame itself.
215 If this resource specifies a position, that position applies only to the
216 initial Emacs frame (or, in the case of a resource for a specific frame
217 name, only that frame).  However, the size, if specified here, applies to
218 all frames.
220 @ifnottex
221 @item @code{fullscreen} (class @code{Fullscreen})
222 The desired fullscreen size.  The value can be one of @code{fullboth},
223 @code{maximized}, @code{fullwidth} or @code{fullheight}, which correspond to
224 the command-line options @samp{-fs}, @samp{-mm}, @samp{-fw}, and @samp{-fh}
225 (@pxref{Window Size X}).
227 Note that this applies to the initial frame only.
228 @end ifnottex
230 @item @code{iconName} (class @code{Title})
231 Name to display in the icon.
233 @item @code{internalBorder} (class @code{BorderWidth})
234 Width in pixels of the internal border.
236 @item @code{lineSpacing} (class @code{LineSpacing})
237 @cindex line spacing
238 @cindex leading
239 Additional space (@dfn{leading}) between lines, in pixels.
241 @item @code{menuBar} (class @code{MenuBar})
242 @cindex menu bar
243 Give frames menu bars if @samp{on}; don't have menu bars if @samp{off}.
244 @ifnottex
245 @xref{Lucid Resources}, and @ref{LessTif Resources},
246 @end ifnottex
247 @iftex
248 @xref{Lucid Resources},
249 @end iftex
250 for how to control the appearance of the menu bar if you have one.
252 @ifnottex
253 @item @code{minibuffer} (class @code{Minibuffer})
254 If @samp{none}, don't make a minibuffer in this frame.
255 It will use a separate minibuffer frame instead.
257 @item @code{paneFont} (class @code{Font})
258 @cindex font for menus
259 Font name for menu pane titles, in non-toolkit versions of Emacs.
260 @end ifnottex
262 @item @code{pointerColor} (class @code{Foreground})
263 Color of the mouse cursor.
265 @ifnottex
266 @item @code{privateColormap} (class @code{PrivateColormap})
267 If @samp{on}, use a private color map, in the case where the ``default
268 visual'' of class PseudoColor and Emacs is using it.
270 @item @code{reverseVideo} (class @code{ReverseVideo})
271 Switch foreground and background default colors if @samp{on}, use colors as
272 specified if @samp{off}.
273 @end ifnottex
275 @item @code{screenGamma} (class @code{ScreenGamma})
276 @cindex gamma correction
277 Gamma correction for colors, equivalent to the frame parameter
278 @code{screen-gamma}.
280 @item @code{scrollBarWidth} (class @code{ScrollBarWidth})
281 @cindex scrollbar width
282 The scroll bar width in pixels, equivalent to the frame parameter
283 @code{scroll-bar-width}.
285 @ifnottex
286 @item @code{selectionFont} (class @code{SelectionFont})
287 Font name for pop-up menu items, in non-toolkit versions of Emacs.  (For
288 toolkit versions, see @ref{Lucid Resources}, also see @ref{LessTif
289 Resources}.)
291 @item @code{selectionTimeout} (class @code{SelectionTimeout})
292 Number of milliseconds to wait for a selection reply.
293 If the selection owner doesn't reply in this time, we give up.
294 A value of 0 means wait as long as necessary.
296 @item @code{synchronous} (class @code{Synchronous})
297 @cindex debugging X problems
298 @cindex synchronous X mode
299 Run Emacs in synchronous mode if @samp{on}.  Synchronous mode is
300 useful for debugging X problems.
301 @end ifnottex
303 @item @code{title} (class @code{Title})
304 Name to display in the title bar of the initial Emacs frame.
306 @item @code{toolBar} (class @code{ToolBar})
307 @cindex tool bar
308 Number of lines to reserve for the tool bar.  A zero value suppresses
309 the tool bar.  For the Emacs tool bar (i.e.@: not Gtk+), if the value
310 is non-zero and @code{auto-resize-tool-bars} is non-@code{nil}, the
311 tool bar's size will be changed automatically so that all tool bar
312 items are visible.  If the value of @code{auto-resize-tool-bars} is
313 @code{grow-only}, the tool bar expands automatically, but does not
314 contract automatically.  To contract the tool bar, you must redraw the
315 frame by entering @kbd{C-l}.  For the Gtk+ tool bar, any non-zero
316 value means on and @code{auto-resize-tool-bars} has no effect.
318 @item @code{useXIM} (class @code{UseXIM})
319 @cindex XIM
320 @cindex X input methods
321 @cindex input methods, X
322 Turn off use of X input methods (XIM) if @samp{false} or @samp{off}.
323 This is only relevant if your Emacs is actually built with XIM
324 support.  It is potentially useful to turn off XIM for efficiency,
325 especially slow X client/server links.
327 @item @code{verticalScrollBars} (class @code{ScrollBars})
328 Give frames scroll bars if @samp{on}; don't have scroll bars if
329 @samp{off}.
331 @ifnottex
332 @item @code{visualClass} (class @code{VisualClass})
333 Specify the ``visual'' that X should use.  This tells X how to handle
334 colors.
336 The value should start with one of @samp{TrueColor},
337 @samp{PseudoColor}, @samp{DirectColor}, @samp{StaticColor},
338 @samp{GrayScale}, and @samp{StaticGray}, followed by
339 @samp{-@var{depth}}, where @var{depth} is the number of color planes.
340 Most terminals only allow a few ``visuals,'' and the @samp{dpyinfo}
341 program outputs information saying which ones.
342 @end ifnottex
343 @end table
345 @node Face Resources
346 @appendixsec X Resources for Faces
348   You can use resources to customize the appearance of particular
349 faces (@pxref{Faces}):
351 @table @code
352 @item @var{face}.attributeForeground
353 Foreground color for face @var{face}.
354 @item @var{face}.attributeBackground
355 Background color for face @var{face}.
356 @item @var{face}.attributeUnderline
357 Underline flag for face @var{face}.  Use @samp{on} or @samp{true} for
358 yes.
359 @item @var{face}.attributeStrikeThrough
360 @itemx @var{face}.attributeOverline
361 @itemx @var{face}.attributeBox
362 @itemx @var{face}.attributeInverse
363 Likewise, for other boolean font attributes.
364 @item @var{face}.attributeStipple
365 The name of a pixmap data file to use for the stipple pattern, or
366 @code{false} to not use stipple for the face @var{face}.
367 @item @var{face}.attributeBackgroundPixmap
368 The background pixmap for the face @var{face}.  Should be a name of a
369 pixmap file or @code{false}.
370 @item @var{face}.attributeFont
371 Font name (full XFD name or valid X abbreviation) for face @var{face}.
372 Instead of this, you can specify the font through separate attributes.
373 @end table
375   Instead of using @code{attributeFont} to specify a font name, you can
376 select a font through these separate attributes:
378 @table @code
379 @item @var{face}.attributeFamily
380 Font family for face @var{face}.
381 @item @var{face}.attributeHeight
382 Height of the font to use for face @var{face}: either an integer
383 specifying the height in units of 1/10@dmn{pt}, or a floating point
384 number that specifies a scale factor to scale the underlying face's
385 default font, or a function to be called with the default height which
386 will return a new height.
387 @item @var{face}.attributeWidth
388 @itemx @var{face}.attributeWeight
389 @itemx @var{face}.attributeSlant
390 Each of these resources corresponds to a like-named font attribute,
391 and you write the resource value the same as the symbol you would use
392 for the font attribute value.
393 @item @var{face}.attributeBold
394 Bold flag for face @var{face}---instead of @code{attributeWeight}.  Use @samp{on} or @samp{true} for
395 yes.
396 @item @var{face}.attributeItalic
397 Italic flag for face @var{face}---instead of @code{attributeSlant}.
398 @end table
400 @node Lucid Resources
401 @appendixsec Lucid Menu And Dialog X Resources
402 @cindex Menu X Resources (Lucid widgets)
403 @cindex Dialog X Resources (Lucid widgets)
404 @cindex Lucid Widget X Resources
406 @ifnottex
407   If the Emacs installed at your site was built to use the X toolkit
408 with the Lucid menu widgets, then the menu bar is a separate widget and
409 has its own resources.  The resource names contain @samp{pane.menubar}
410 (following, as always, the name of the Emacs invocation, or @samp{Emacs},
411 which stands for all Emacs invocations).  Specify them like this:
413 @example
414 Emacs.pane.menubar.@var{resource}:  @var{value}
415 @end example
417 @noindent
418 For example, to specify the font @samp{Courier-12} for the menu-bar items,
419 write this:
420 @end ifnottex
421 @iftex
422    If the Emacs installed at your site was built to use the X toolkit
423 with the Lucid menu widgets, then the menu bar is a separate widget
424 and has its own resources.  The resource specifications start with
425 @samp{Emacs.pane.menubar}---for instance, to specify the font
426 @samp{Courier-12} for the menu-bar items, write this:
427 @end iftex
429 @example
430 Emacs.pane.menubar.font:  Courier-12
431 @end example
433 @noindent
434 To specify a font, use fontconfig font names as values to the @code{font}
435 resource, or old style names:
437 @example
438 Emacs.pane.menubar.font: lucidasanstypewriter-10
439 @end example
441 @noindent
442 Emacs first tries to open the font as an old style font, and if that fails
443 as an fontconfig font.  In rare cases, Emacs might do the wrong thing.
445 @noindent
446 The Lucid menus can display multilingual text in your locale with old style
447 fonts.  For more information about fontsets see the man page for
448 @code{XCreateFontSet}.  To enable multilingual menu text you specify a
449 @code{fontSet} resource instead of the font resource.  If both
450 @code{font} and @code{fontSet} resources are specified, the
451 @code{fontSet} resource is used.
453 @noindent
454 Resources for @emph{non-menubar} toolkit pop-up menus have
455 @samp{menu*} instead of @samp{pane.menubar}.  For example, to specify
456 the font @samp{8x16} for the pop-up menu items, write this:
458 @example
459 Emacs.menu*.font:       8x16
460 @end example
462 @noindent
463 For dialog boxes, use @samp{dialog*}:
465 @example
466 Emacs.dialog*.font: Sans-12
467 @end example
469   Here is a list of the specific resources for menu bars and pop-up menus:
471 @table @code
472 @item font
473 Font for menu item text.
474 @item fontSet
475 Fontset for menu item text.
476 @item foreground
477 Color of the foreground.
478 @item background
479 Color of the background.
480 @item buttonForeground
481 In the menu bar, the color of the foreground for a selected item.
482 @ifnottex
483 @item horizontalSpacing
484 Horizontal spacing in pixels between items.  Default is 3.
485 @item verticalSpacing
486 Vertical spacing in pixels between items.  Default is 2.
487 @item arrowSpacing
488 Horizontal spacing between the arrow (which indicates a submenu) and
489 the associated text.  Default is 10.
490 @item shadowThickness
491 Thickness of shadow line around the widget.  Default is 1.
493 Also determines the thickness of shadow lines around other objects,
494 for instance 3D buttons and arrows.  If you have the impression that
495 the arrows in the menus do not stand out clearly enough or that the
496 difference between ``in'' and ``out'' buttons is difficult to see, set
497 this to 2.  If you have no problems with visibility, the default
498 probably looks better.  The background color may also have some effect
499 on the contrast.
500 @end ifnottex
501 @item margin
502 The margin of the menu bar, in characters.  Default is 1.
503 @end table
505 @ifnottex
506 @node LessTif Resources
507 @appendixsec LessTif Menu X Resources
508 @cindex Menu X Resources (LessTif widgets)
509 @cindex LessTif Widget X Resources
511   If the Emacs installed at your site was built to use the X toolkit
512 with the LessTif or Motif widgets, then the menu bar, the dialog
513 boxes, the pop-up menus, and the file-selection box are separate
514 widgets and have their own resources.
516   The resource names for the menu bar contain @samp{pane.menubar}
517 (following, as always, the name of the Emacs invocation, or
518 @samp{Emacs}, which stands for all Emacs invocations).  Specify them
519 like this:
521 @smallexample
522 Emacs.pane.menubar.@var{subwidget}.@var{resource}:  @var{value}
523 @end smallexample
525   Each individual string in the menu bar is a subwidget; the subwidget's
526 name is the same as the menu item string.  For example, the word
527 @samp{File} in the menu bar is part of a subwidget named
528 @samp{emacs.pane.menubar.File}.  Most likely, you want to specify the
529 same resources for the whole menu bar.  To do this, use @samp{*} instead
530 of a specific subwidget name.  For example, to specify the font
531 @samp{8x16} for the menu-bar items, write this:
533 @smallexample
534 Emacs.pane.menubar.*.fontList:  8x16
535 @end smallexample
537 @noindent
538 This also specifies the resource value for submenus.
540   Each item in a submenu in the menu bar also has its own name for X
541 resources; for example, the @samp{File} submenu has an item named
542 @samp{Save (current buffer)}.  A resource specification for a submenu
543 item looks like this:
545 @smallexample
546 Emacs.pane.menubar.popup_*.@var{menu}.@var{item}.@var{resource}: @var{value}
547 @end smallexample
549 @noindent
550 For example, here's how to specify the font for the @samp{Save (current
551 buffer)} item:
553 @smallexample
554 Emacs.pane.menubar.popup_*.File.Save (current buffer).fontList: 8x16
555 @end smallexample
557 @noindent
558 For an item in a second-level submenu, such as @samp{Complete Word}
559 under @samp{Spell Checking} under @samp{Tools}, the resource fits this
560 template:
562 @smallexample
563 Emacs.pane.menubar.popup_*.popup_*.@var{menu}.@var{resource}: @var{value}
564 @end smallexample
566 @noindent
567 For example,
569 @smallexample
570 Emacs.pane.menubar.popup_*.popup_*.Spell Checking.Complete Word: @var{value}
571 @end smallexample
573 @noindent
574 (This should be one long line.)
576   It's impossible to specify a resource for all the menu-bar items
577 without also specifying it for the submenus as well.  So if you want the
578 submenu items to look different from the menu bar itself, you must ask
579 for that in two steps.  First, specify the resource for all of them;
580 then, override the value for submenus alone.  Here is an example:
582 @smallexample
583 Emacs.pane.menubar.*.fontList:  8x16
584 Emacs.pane.menubar.popup_*.fontList: 8x16
585 @end smallexample
587 @noindent
588 For LessTif pop-up menus, use @samp{menu*} instead of
589 @samp{pane.menubar}.  For example, to specify the font @samp{8x16} for
590 the pop-up menu items, write this:
592 @smallexample
593 Emacs.menu*.fontList:  8x16
594 @end smallexample
596 @noindent
597 For LessTif dialog boxes, use @samp{dialog} instead of @samp{menu}:
599 @example
600 Emacs.dialog*.fontList: 8x16
601 Emacs.dialog*.foreground: hotpink
602 @end example
604 To specify resources for the LessTif file-selection box, use
605 @samp{fsb*}, like this:
607 @example
608 Emacs.fsb*.fontList: 8x16
609 @end example
611 @iftex
612 @medbreak
613 @end iftex
614   Here is a list of the specific resources for LessTif menu bars and
615 pop-up menus:
617 @table @code
618 @item armColor
619 The color to show in an armed button.
620 @item fontList
621 The font to use.
622 @item marginBottom
623 @itemx marginHeight
624 @itemx marginLeft
625 @itemx marginRight
626 @itemx marginTop
627 @itemx marginWidth
628 Amount of space to leave around the item, within the border.
629 @item borderWidth
630 The width of the border around the menu item, on all sides.
631 @item shadowThickness
632 The width of the border shadow.
633 @item bottomShadowColor
634 The color for the border shadow, on the bottom and the right.
635 @item topShadowColor
636 The color for the border shadow, on the top and the left.
637 @end table
638 @end ifnottex
641 @node GTK resources
642 @appendixsec GTK resources
643 @iftex
644   The most common way to customize the GTK widgets Emacs uses (menus,
645 dialogs tool bars and scroll bars) is by choosing an appropriate
646 theme, for example with the GNOME theme selector.
648 You can also do Emacs specific customization by inserting GTK style
649 directives in the file @file{~/.emacs.d/gtkrc}, but only if you have a
650 Gtk+ version earlier than 3 (i.e.@: 2).  Some GTK themes ignore
651 customizations in @file{~/.emacs.d/gtkrc} so not everything works with
652 all themes.  To customize Emacs font, background, faces, etc., use the
653 normal X resources (@pxref{Resources}).  We will present some examples
654 of customizations here, but for a more detailed description, see the
655 online manual
657   The first example is just one line.  It changes the font on all GTK widgets
658 to courier with size 12:
660 @smallexample
661 gtk-font-name = "courier 12"
662 @end smallexample
664   The thing to note is that the font name is not an X font name, but a
665 Pango font name.  A Pango font name is basically of the format "family
666 style size", where the style is optional as in the case above.  A name
667 with a style could be for example:
669 @smallexample
670 gtk-font-name = "helvetica bold 10"
671 @end smallexample
673   To customize widgets you first define a style and then apply the style to
674 the widgets.  Here is an example that sets the font for menus, but not
675 for other widgets:
677 @smallexample
678 # @r{Define the style @samp{menufont}.}
679 style "menufont"
681   font_name = "helvetica bold 14"  # This is a Pango font name
684 # @r{Specify that widget type @samp{*emacs-menuitem*} uses @samp{menufont}.}
685 widget "*emacs-menuitem*" style "menufont"
686 @end smallexample
688 The widget name in this example contains wildcards, so the style will be
689 applied to all widgets that match "*emacs-menuitem*".  The widgets are
690 named by the way they are contained, from the outer widget to the inner widget.
691 So to apply the style "my_style" (not shown) with the full, absolute name, for
692 the menubar and the scroll bar in Emacs we use:
694 @smallexample
695 widget "Emacs.pane.menubar" style "my_style"
696 widget "Emacs.pane.emacs.verticalScrollBar" style "my_style"
697 @end smallexample
699 But to avoid having to type it all, wildcards are often used.  @samp{*}
700 matches zero or more characters and @samp{?} matches one character.  So "*"
701 matches all widgets.
703   Each widget has a class (for example GtkMenuItem) and a name (emacs-menuitem).
704 You can assign styles by name or by class.  In this example we have used the
705 class:
707 @smallexample
708 style "menufont"
710   font_name = "helvetica bold 14"
713 widget_class "*GtkMenuBar" style "menufont"
714 @end smallexample
716 @noindent
717 The names and classes for the GTK widgets Emacs uses are:
719 @multitable {@code{verticalScrollbar plus}} {@code{GtkFileSelection} and some}
720 @item @code{emacs-filedialog}
721 @tab @code{GtkFileSelection}
722 @item @code{emacs-dialog}
723 @tab @code{GtkDialog}
724 @item @code{Emacs}
725 @tab @code{GtkWindow}
726 @item @code{pane}
727 @tab @code{GtkVHbox}
728 @item @code{emacs}
729 @tab @code{GtkFixed}
730 @item @code{verticalScrollBar}
731 @tab @code{GtkVScrollbar}
732 @item @code{emacs-toolbar}
733 @tab @code{GtkToolbar}
734 @item @code{menubar}
735 @tab @code{GtkMenuBar}
736 @item @code{emacs-menuitem}
737 @tab anything in menus
738 @end multitable
740   GTK absolute names are quite strange when it comes to menus
741 and dialogs.  The names do not start with @samp{Emacs}, as they are
742 free-standing windows and not contained (in the GTK sense) by the
743 Emacs GtkWindow.  To customize the dialogs and menus, use wildcards like this:
745 @smallexample
746 widget "*emacs-dialog*" style "my_dialog_style"
747 widget "*emacs-filedialog* style "my_file_style"
748 widget "*emacs-menuitem* style "my_menu_style"
749 @end smallexample
751   If you specify a customization in @file{~/.emacs.d/gtkrc}, then it
752 automatically applies only to Emacs, since other programs don't read
753 that file.  For example, the drop down menu in the file dialog can not
754 be customized by any absolute widget name, only by an absolute class
755 name.  This is because the widgets in the drop down menu do not
756 have names and the menu is not contained in the Emacs GtkWindow.  To
757 have all menus in Emacs look the same, use this in
758 @file{~/.emacs.d/gtkrc}:
760 @smallexample
761 widget_class "*Menu*" style "my_menu_style"
762 @end smallexample
764   Here is a more elaborate example, showing how to change the parts of
765 the scroll bar:
767 @smallexample
768 style "scroll"
770   fg[NORMAL] = "red"@ @ @ @ @ # @r{The arrow color.}
771   bg[NORMAL] = "yellow"@ @ # @r{The thumb and background around the arrow.}
772   bg[ACTIVE] = "blue"@ @ @ @ # @r{The trough color.}
773   bg[PRELIGHT] = "white"@ # @r{The thumb color when the mouse is over it.}
776 widget "*verticalScrollBar*" style "scroll"
777 @end smallexample
778 @end iftex
780 @ifnottex
781 @cindex GTK resources and customization
782 @cindex resource files for GTK
783 @cindex @file{~/.gtkrc-2.0} file
784 @cindex @file{~/.emacs.d/gtkrc} file
786   If Emacs was built to use the GTK widget set, then the menu bar, tool bar,
787 scroll bar and the dialogs are customized with the standard GTK
788 customization file, @file{~/.gtkrc-2.0}, or with the Emacs specific
789 file @file{~/.emacs.d/gtkrc}.  We recommend that you use
790 @file{~/.emacs.d/gtkrc} for customizations, since @file{~/.gtkrc-2.0}
791 seems to be ignored when running GConf with GNOME.  These files apply
792 only to GTK widget features.  To customize Emacs font, background,
793 faces, etc., use the normal X resources (@pxref{Resources}).
795   Some GTK themes override these mechanisms, which means that using
796 these mechanisms will not work to customize them.
798   In these files you first define a style and say what it means; then
799 you specify to apply the style to various widget types (@pxref{GTK
800 widget names}).  Here is an example of how to change the font for
801 Emacs menus:
803 @smallexample
804 # @r{Define the style @samp{menufont}.}
805 style "menufont"
807   font_name = "helvetica bold 14"  # This is a Pango font name
810 # @r{Specify that widget type @samp{*emacs-menuitem*} uses @samp{menufont}.}
811 widget "*emacs-menuitem*" style "menufont"
812 @end smallexample
814   Here is a more elaborate example, showing how to change the parts of
815 the scroll bar:
817 @smallexample
818 style "scroll"
820   fg[NORMAL] = "red"@ @ @ @ @ # @r{The arrow color.}
821   bg[NORMAL] = "yellow"@ @ # @r{The thumb and background around the arrow.}
822   bg[ACTIVE] = "blue"@ @ @ @ # @r{The trough color.}
823   bg[PRELIGHT] = "white"@ # @r{The thumb color when the mouse is over it.}
826 widget "*verticalScrollBar*" style "scroll"
827 @end smallexample
829   There are also parameters that affect GTK as a whole.  For example,
830 the property @code{gtk-font-name} sets the default font for GTK.  You
831 must use Pango font names (@pxref{GTK styles}).  A GTK resources file
832 that just sets a default font looks like this:
834 @smallexample
835 gtk-font-name = "courier 12"
836 @end smallexample
838   The GTK resources file is fully described in the GTK API document.
839 This can be found in
840 @file{@var{prefix}/share/gtk-doc/html/gtk/gtk-resource-files.html},
841 where @file{prefix} is the directory in which the GTK libraries were
842 installed (usually @file{/usr} or @file{/usr/local}).  You can also
843 find the document online, at
844 @uref{http://developer.gnome.org/doc/API/2.0/gtk/gtk-Resource-Files.html}.
846 @menu
847 * GTK widget names::      How widgets in GTK are named in general.
848 * GTK Names in Emacs::    GTK widget names in Emacs.
849 * GTK styles::            What can be customized in a GTK widget.
850 @end menu
852 @node GTK widget names
853 @appendixsubsec GTK widget names
854 @cindex GTK widget names
856   A GTK widget is specified by its @dfn{widget class} and
857 @dfn{widget name}.  The widget class is the type of the widget: for
858 example, @code{GtkMenuBar}.  The widget name is the name given to a
859 specific widget.  A widget always has a class, but need not have a
860 name.
862   @dfn{Absolute names} are sequences of widget names or widget
863 classes, corresponding to hierarchies of widgets embedded within
864 other widgets.  For example, if a @code{GtkWindow} named @code{top}
865 contains a @code{GtkVBox} named @code{box}, which in turn contains
866 a @code{GtkMenuBar} called @code{menubar}, the absolute class name
867 of the menu-bar widget is @code{GtkWindow.GtkVBox.GtkMenuBar}, and
868 its absolute widget name is @code{top.box.menubar}.
870   When assigning a style to a widget, you can use the absolute class
871 name or the absolute widget name.
873   There are two commands to specify changes for widgets:
875 @table @asis
876 @item @code{widget_class}
877 specifies a style for widgets based on the absolute class name.
879 @item @code{widget}
880 specifies a style for widgets based on the absolute class name,
881 or just the class.
882 @end table
884 @noindent
885 You must specify the class and the style in double-quotes, and put
886 these commands at the top level in the GTK customization file, like
887 this:
889 @smallexample
890 style "menufont"
892   font_name = "helvetica bold 14"
895 widget "top.box.menubar" style "menufont"
896 widget_class "GtkWindow.GtkVBox.GtkMenuBar" style "menufont"
897 @end smallexample
899   Matching of absolute names uses shell wildcard syntax: @samp{*}
900 matches zero or more characters and @samp{?} matches one character.
901 This example assigns @code{base_style} to all widgets:
903 @smallexample
904 widget "*" style "base_style"
905 @end smallexample
907   Given the absolute class name @code{GtkWindow.GtkVBox.GtkMenuBar}
908 and the corresponding absolute widget name @code{top.box.menubar}, all
909 these examples specify @code{my_style} for the menu bar:
911 @smallexample
912 widget_class "GtkWindow.GtkVBox.GtkMenuBar" style "my_style"
913 widget_class "GtkWindow.*.GtkMenuBar" style "my_style"
914 widget_class "*GtkMenuBar" style "my_style"
915 widget "top.box.menubar" style "my_style"
916 widget "*box*menubar" style "my_style"
917 widget "*menubar" style "my_style"
918 widget "*menu*" style "my_style"
919 @end smallexample
921 @node GTK Names in Emacs
922 @appendixsubsec GTK Widget Names in Emacs
923 @cindex GTK widget names
924 @cindex GTK widget classes
926   In Emacs, the top level widget for a frame is a @code{GtkWindow}
927 that contains a @code{GtkVBox}.  The @code{GtkVBox} contains the
928 @code{GtkMenuBar} and a @code{GtkFixed} widget.  The vertical scroll
929 bars, @code{GtkVScrollbar}, are contained in the @code{GtkFixed}
930 widget.  The text you write in Emacs is drawn in the @code{GtkFixed}
931 widget.
933   Dialogs in Emacs are @code{GtkDialog} widgets.  The file dialog is a
934 @code{GtkFileSelection} widget.
936 @noindent
937 To set a style for the menu bar using the absolute class name, use:
939 @smallexample
940 widget_class "GtkWindow.GtkVBox.GtkMenuBar" style "my_style"
941 @end smallexample
943 @noindent
944 For the scroll bar, the absolute class name is:
946 @smallexample
947 widget_class
948   "GtkWindow.GtkVBox.GtkFixed.GtkVScrollbar"
949      style "my_style"
950 @end smallexample
952 @noindent
953 The names for the emacs widgets, and their classes, are:
955 @multitable {@code{verticalScrollbar plus}} {@code{GtkFileSelection} and some}
956 @item @code{emacs-filedialog}
957 @tab @code{GtkFileSelection}
958 @item @code{emacs-dialog}
959 @tab @code{GtkDialog}
960 @item @code{Emacs}
961 @tab @code{GtkWindow}
962 @item @code{pane}
963 @tab @code{GtkVHbox}
964 @item @code{emacs}
965 @tab @code{GtkFixed}
966 @item @code{verticalScrollBar}
967 @tab @code{GtkVScrollbar}
968 @item @code{emacs-toolbar}
969 @tab @code{GtkToolbar}
970 @item @code{menubar}
971 @tab @code{GtkMenuBar}
972 @item @code{emacs-menuitem}
973 @tab anything in menus
974 @end multitable
976 @noindent
977 Thus, for Emacs you can write the two examples above as:
979 @smallexample
980 widget "Emacs.pane.menubar" style "my_style"
981 widget "Emacs.pane.emacs.verticalScrollBar" style "my_style"
982 @end smallexample
984   GTK absolute names are quite strange when it comes to menus
985 and dialogs.  The names do not start with @samp{Emacs}, as they are
986 free-standing windows and not contained (in the GTK sense) by the
987 Emacs GtkWindow.  To customize the dialogs and menus, use wildcards like this:
989 @smallexample
990 widget "*emacs-dialog*" style "my_dialog_style"
991 widget "*emacs-filedialog* style "my_file_style"
992 widget "*emacs-menuitem* style "my_menu_style"
993 @end smallexample
995   If you specify a customization in @file{~/.emacs.d/gtkrc}, then it
996 automatically applies only to Emacs, since other programs don't read
997 that file.  For example, the drop down menu in the file dialog can not
998 be customized by any absolute widget name, only by an absolute class
999 name.  This is because the widgets in the drop down menu do not
1000 have names and the menu is not contained in the Emacs GtkWindow.  To
1001 have all menus in Emacs look the same, use this in
1002 @file{~/.emacs.d/gtkrc}:
1004 @smallexample
1005 widget_class "*Menu*" style "my_menu_style"
1006 @end smallexample
1008 @node GTK styles
1009 @appendixsubsec GTK styles
1010 @cindex GTK styles
1012   In a GTK style you specify the appearance widgets shall have.  You
1013 can specify foreground and background color, background pixmap and
1014 font.  The edit widget (where you edit the text) in Emacs is a GTK
1015 widget, but trying to specify a style for the edit widget will have no
1016 effect.  This is so that Emacs compiled for GTK is compatible with
1017 Emacs compiled for other X toolkits.  The settings for foreground,
1018 background and font for the edit widget is taken from the X resources;
1019 @pxref{Resources}.  Here is an example of two style declarations,
1020 @samp{default} and @samp{ruler}:
1022 @smallexample
1023 pixmap_path "/usr/share/pixmaps:/usr/include/X11/pixmaps"
1025 style "default"
1027   font_name = "helvetica 12"
1029   bg[NORMAL] = @{ 0.83, 0.80, 0.73 @}
1030   bg[SELECTED] = @{ 0.0, 0.55, 0.55 @}
1031   bg[INSENSITIVE] = @{ 0.77, 0.77, 0.66 @}
1032   bg[ACTIVE] = @{ 0.0, 0.55, 0.55 @}
1033   bg[PRELIGHT] = @{ 0.0, 0.55, 0.55 @}
1035   fg[NORMAL] = "black"
1036   fg[SELECTED] = @{ 0.9, 0.9, 0.9 @}
1037   fg[ACTIVE] = "black"
1038   fg[PRELIGHT] = @{ 0.9, 0.9, 0.9 @}
1040   base[INSENSITIVE] = "#777766"
1041   text[INSENSITIVE] = @{ 0.60, 0.65, 0.57 @}
1043   bg_pixmap[NORMAL] = "background.xpm"
1044   bg_pixmap[INSENSITIVE] = "background.xpm"
1045   bg_pixmap[ACTIVE] = "background.xpm"
1046   bg_pixmap[PRELIGHT] = "<none>"
1050 style "ruler" = "default"
1052   font_name = "helvetica 8"
1055 @end smallexample
1057   The style @samp{ruler} inherits from @samp{default}.  This way you can build
1058 on existing styles.  The syntax for fonts and colors is described below.
1060   As this example shows, it is possible to specify several values for
1061 foreground and background depending on the widget's @dfn{state}.  The
1062 possible states are:
1064 @table @code
1065 @item NORMAL
1066 This is the default state for widgets.
1067 @item ACTIVE
1068 This is the state for a widget that is ready to do something.  It is
1069 also for the trough of a scroll bar, i.e.@: @code{bg[ACTIVE] = "red"}
1070 sets the scroll bar trough to red.  Buttons that have been pressed but
1071 not released yet (``armed'') are in this state.
1072 @item PRELIGHT
1073 This is the state for a widget that can be manipulated, when the mouse
1074 pointer is over it---for example when the mouse is over the thumb in
1075 the scroll bar or over a menu item.  When the mouse is over a button
1076 that is not pressed, the button is in this state.
1077 @item SELECTED
1078 This is the state for data that has been selected by the user.  It can
1079 be selected text or items selected in a list.  This state is not used
1080 in Emacs.
1081 @item INSENSITIVE
1082 This is the state for widgets that are visible, but they can not be
1083 manipulated in the usual way---for example, buttons that can't be
1084 pressed, and disabled menu items.  To display disabled menu items in
1085 yellow, use @code{fg[INSENSITIVE] = "yellow"}.
1086 @end table
1088   Here are the things that can go in a style declaration:
1090 @table @code
1091 @item bg[@var{state}] = @var{color}
1092 This specifies the background color for the widget.  Note that
1093 editable text doesn't use @code{bg}; it uses @code{base} instead.
1095 @item base[@var{state}] = @var{color}
1096 This specifies the background color for editable text.  In Emacs, this
1097 color is used for the background of the text fields in the file
1098 dialog.
1100 @item bg_pixmap[@var{state}] = "@var{pixmap}"
1101 This specifies an image background (instead of a background color).
1102 @var{pixmap} should be the image file name.  GTK can use a number of
1103 image file formats, including XPM, XBM, GIF, JPEG and PNG.  If you
1104 want a widget to use the same image as its parent, use
1105 @samp{<parent>}.  If you don't want any image, use @samp{<none>}.
1106 @samp{<none>} is the way to cancel a background image inherited from a
1107 parent style.
1109 You can't specify the file by its absolute file name.  GTK looks for
1110 the pixmap file in directories specified in @code{pixmap_path}.
1111 @code{pixmap_path} is a colon-separated list of directories within
1112 double quotes, specified at the top level in a @file{gtkrc} file
1113 (i.e.@: not inside a style definition; see example above):
1115 @smallexample
1116 pixmap_path "/usr/share/pixmaps:/usr/include/X11/pixmaps"
1117 @end smallexample
1119 @item fg[@var{state}] = @var{color}
1120 This specifies the foreground color for widgets to use.  It is the
1121 color of text in menus and buttons, and the color for the arrows in
1122 the scroll bar.  For editable text, use @code{text}.
1124 @item text[@var{state}] = @var{color}
1125 This is the color for editable text.  In Emacs, this color is used for the
1126 text fields in the file dialog.
1128 @item font_name = "@var{font}"
1129 This specifies the font for text in the widget.  @var{font} is a
1130 Pango font name, for example @samp{Sans Italic 10}, @samp{Helvetica
1131 Bold 12}, @samp{Courier 14}, @samp{Times 18}.  See below for exact
1132 syntax.  The names are case insensitive.
1133 @end table
1135   There are three ways to specify a color: a color name, an RGB
1136 triplet, or a GTK-style RGB triplet.  @xref{Colors}, for a description
1137 of color names and RGB triplets.  Color names should be enclosed with
1138 double quotes, e.g.@: @samp{"red"}.  RGB triplets should be written
1139 without double quotes, e.g.@: @samp{#ff0000}.  GTK-style RGB triplets
1140 have the form
1142 @smallexample
1143 @code{@{ @var{r}, @var{g}, @var{b} @}}
1144 @end smallexample
1146 @noindent
1147 where @var{r}, @var{g} and @var{b} are either integers in the range
1148 0-65535 or floats in the range 0.0-1.0.
1150   Pango font names have the form ``@var{family-list} @var{style-options}
1151 @var{size}.''
1152 @cindex Pango font name
1153 @noindent
1154 @var{family-list} is a comma separated list of font families optionally
1155 terminated by a comma.  This way you can specify several families and the
1156 first one found will be used.  @var{family} corresponds to the second part in
1157 an X font name, for example in
1159 @smallexample
1160 -adobe-times-medium-r-normal--12-120-75-75-p-64-iso10646-1
1161 @end smallexample
1163 @noindent
1164 the family name is @samp{times}.
1166 @noindent
1167 @var{style-options} is a whitespace separated list of words where each word
1168 is a style, variant, weight, or stretch.  The default value for all of
1169 these is @code{normal}.
1171 @noindent
1172 A `style' corresponds to the fourth part of an X font name.  In X font
1173 names it is the character @samp{r}, @samp{i} or @samp{o}; in Pango
1174 font names the corresponding values are @code{normal}, @code{italic},
1175 or @code{oblique}.
1177 @noindent
1178 A `variant' is either @code{normal} or @code{small-caps}.
1179 Small caps is a font with the lower case characters replaced by
1180 smaller variants of the capital characters.
1182 @noindent
1183 Weight describes the ``boldness'' of a font.  It corresponds to the third
1184 part of an X font name.  It is one of @code{ultra-light}, @code{light},
1185 @code{normal}, @code{bold}, @code{ultra-bold}, or @code{heavy}.
1187 @noindent
1188 Stretch gives the width of the font relative to other designs within a
1189 family.  It corresponds to the fifth part of an X font name.  It is one of
1190 @code{ultra-condensed}, @code{extra-condensed}, @code{condensed},
1191 @code{semi-condensed}, @code{normal}, @code{semi-expanded},
1192 @code{expanded}, @code{extra-expanded}, or @code{ultra-expanded}.
1194 @noindent
1195 @var{size} is a decimal number that describes the font size in points.
1196 @end ifnottex