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, 2007, 2008, 2009 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
19 ``GTK resources'', which we will also describe.
22 ``GTK resources.'' In this chapter we describe the most commonly used
23 resource specifications. For full documentation, see the online
26 @c Add xref for LessTif/Motif menu resources.
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.
40 @appendixsec 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
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
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.
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
109 The order in which the lines appear in the file does not matter.
110 Also, command-line options always override the X resources file.
113 The following X command-line options affect how X resources are
117 @item -name @var{name}
119 @itemx --name=@var{name}
120 @cindex resource name, command-line argument
121 This option sets the program name of the initial Emacs frame to
122 @var{name}. It also sets the title of the initial frame to
123 @var{name}. This option does not affect subsequent frames.
125 If you don't specify this option, the default is to use the Emacs
126 executable's name as the program name.
128 For consistency, @samp{-name} also specifies the name to use for other
129 resource values that do not belong to any particular frame.
131 The resources that name Emacs invocations also belong to a class,
132 named @samp{Emacs}. If you write @samp{Emacs} instead of
133 @samp{emacs}, the resource applies to all frames in all Emacs jobs,
134 regardless of frame titles and regardless of the name of the
137 @item -xrm @var{resource-values}
139 @itemx --xrm=@var{resource-values}
140 @cindex resource values, command-line argument
141 This option specifies X resource values for the present Emacs job.
143 @var{resource-values} should have the same format that you would use
144 inside a file of X resources. To include multiple resource
145 specifications in @var{resource-values}, put a newline between them,
146 just as you would in a file. You can also use @samp{#include
147 "@var{filename}"} to include a file full of resource specifications.
148 Resource values specified with @samp{-xrm} take precedence over all
149 other resource specifications.
153 One way to experiment with the effect of different resource settings
154 is to use the @code{editres} program. See the @code{editres} man page
157 @node Table of Resources
158 @appendixsec Table of X Resources for Emacs
160 This table lists the resource names that designate options for
161 Emacs, not counting those for the appearance of the menu bar, each
162 with the class that it belongs to:
165 @item @code{background} (class @code{Background})
166 Background color name.
169 @item @code{bitmapIcon} (class @code{BitmapIcon})
170 Use a bitmap icon (a picture of a gnu) if @samp{on}, let the window
171 manager choose an icon if @samp{off}.
174 @item @code{borderColor} (class @code{BorderColor})
175 Color name for the external border.
178 @item @code{borderWidth} (class @code{BorderWidth})
179 Width in pixels of the external border.
182 @item @code{cursorColor} (class @code{Foreground})
183 Color name for text cursor (point).
186 @item @code{cursorBlink} (class @code{CursorBlink})
187 Specifies whether to make the cursor blink. The default is @samp{on}. Use
188 @samp{off} or @samp{false} to turn cursor blinking off.
191 @item @code{font} (class @code{Font})
192 Font name for the @code{default} font. @xref{Font X}. You can also
193 specify a fontset name (@pxref{Fontsets}).
195 @item @code{fontBackend} (class @code{FontBackend})
196 The backend(s) to use for drawing fonts; if multiple backends are
197 specified, they must be comma-delimited and given in order of
198 precedence. On X, for instance, the value @samp{x,xft} tells Emacs to
199 draw fonts using the X core font driver, falling back on the Xft font
200 driver if that fails. Normally, you can leave this resource unset, in
201 which case Emacs tries using all font backends available on your
204 @item @code{foreground} (class @code{Foreground})
207 @item @code{geometry} (class @code{Geometry})
208 Window size and position. Be careful not to specify this resource as
209 @samp{emacs*geometry}, because that may affect individual menus as well
210 as the Emacs frame itself.
212 If this resource specifies a position, that position applies only to the
213 initial Emacs frame (or, in the case of a resource for a specific frame
214 name, only that frame). However, the size, if specified here, applies to
218 @item @code{fullscreen} (class @code{Fullscreen})
219 The desired fullscreen size. The value can be one of @code{fullboth},
220 @code{fullwidth} or @code{fullheight}, which correspond to
221 the command-line options @samp{-fs}, @samp{-fw}, and @samp{-fh}
222 (@pxref{Window Size X}).
224 Note that this applies to the initial frame only.
227 @item @code{iconName} (class @code{Title})
228 Name to display in the icon.
230 @item @code{internalBorder} (class @code{BorderWidth})
231 Width in pixels of the internal border.
233 @item @code{lineSpacing} (class @code{LineSpacing})
236 Additional space (@dfn{leading}) between lines, in pixels.
238 @item @code{menuBar} (class @code{MenuBar})
240 Give frames menu bars if @samp{on}; don't have menu bars if @samp{off}.
242 @xref{Lucid Resources}, and @ref{LessTif Resources},
245 @xref{Lucid Resources},
247 for how to control the appearance of the menu bar if you have one.
250 @item @code{minibuffer} (class @code{Minibuffer})
251 If @samp{none}, don't make a minibuffer in this frame.
252 It will use a separate minibuffer frame instead.
254 @item @code{paneFont} (class @code{Font})
255 @cindex font for menus
256 Font name for menu pane titles, in non-toolkit versions of Emacs.
259 @item @code{pointerColor} (class @code{Foreground})
260 Color of the mouse cursor.
263 @item @code{privateColormap} (class @code{PrivateColormap})
264 If @samp{on}, use a private color map, in the case where the ``default
265 visual'' of class PseudoColor and Emacs is using it.
267 @item @code{reverseVideo} (class @code{ReverseVideo})
268 Switch foreground and background default colors if @samp{on}, use colors as
269 specified if @samp{off}.
272 @item @code{screenGamma} (class @code{ScreenGamma})
273 @cindex gamma correction
274 Gamma correction for colors, equivalent to the frame parameter
277 @item @code{scrollBarWidth} (class @code{ScrollBarWidth})
278 @cindex scrollbar width
279 The scroll bar width in pixels, equivalent to the frame parameter
280 @code{scroll-bar-width}.
283 @item @code{selectionFont} (class @code{SelectionFont})
284 Font name for pop-up menu items, in non-toolkit versions of Emacs. (For
285 toolkit versions, see @ref{Lucid Resources}, also see @ref{LessTif
288 @item @code{selectionTimeout} (class @code{SelectionTimeout})
289 Number of milliseconds to wait for a selection reply.
290 If the selection owner doesn't reply in this time, we give up.
291 A value of 0 means wait as long as necessary.
293 @item @code{synchronous} (class @code{Synchronous})
294 @cindex debugging X problems
295 @cindex synchronous X mode
296 Run Emacs in synchronous mode if @samp{on}. Synchronous mode is
297 useful for debugging X problems.
300 @item @code{title} (class @code{Title})
301 Name to display in the title bar of the initial Emacs frame.
303 @item @code{toolBar} (class @code{ToolBar})
305 Number of lines to reserve for the tool bar. A zero value suppresses
306 the tool bar. If the value is non-zero and
307 @code{auto-resize-tool-bars} is non-@code{nil}, the tool bar's size
308 will be changed automatically so that all tool bar items are visible.
309 If the value of @code{auto-resize-tool-bars} is @code{grow-only},
310 the tool bar expands automatically, but does not contract automatically.
311 To contract the tool bar, you must redraw the frame by entering @kbd{C-l}.
313 @item @code{useXIM} (class @code{UseXIM})
315 @cindex X input methods
316 @cindex input methods, X
317 Turn off use of X input methods (XIM) if @samp{false} or @samp{off}.
318 This is only relevant if your Emacs is actually built with XIM
319 support. It is potentially useful to turn off XIM for efficiency,
320 especially slow X client/server links.
322 @item @code{verticalScrollBars} (class @code{ScrollBars})
323 Give frames scroll bars if @samp{on}; don't have scroll bars if
327 @item @code{visualClass} (class @code{VisualClass})
328 Specify the ``visual'' that X should use. This tells X how to handle
331 The value should start with one of @samp{TrueColor},
332 @samp{PseudoColor}, @samp{DirectColor}, @samp{StaticColor},
333 @samp{GrayScale}, and @samp{StaticGray}, followed by
334 @samp{-@var{depth}}, where @var{depth} is the number of color planes.
335 Most terminals only allow a few ``visuals,'' and the @samp{dpyinfo}
336 program outputs information saying which ones.
341 @appendixsec X Resources for Faces
343 You can use resources to customize the appearance of particular
344 faces (@pxref{Faces}):
347 @item @var{face}.attributeForeground
348 Foreground color for face @var{face}.
349 @item @var{face}.attributeBackground
350 Background color for face @var{face}.
351 @item @var{face}.attributeUnderline
352 Underline flag for face @var{face}. Use @samp{on} or @samp{true} for
354 @item @var{face}.attributeStrikeThrough
355 @itemx @var{face}.attributeOverline
356 @itemx @var{face}.attributeBox
357 @itemx @var{face}.attributeInverse
358 Likewise, for other boolean font attributes.
359 @item @var{face}.attributeStipple
360 The name of a pixmap data file to use for the stipple pattern, or
361 @code{false} to not use stipple for the face @var{face}.
362 @item @var{face}.attributeBackgroundPixmap
363 The background pixmap for the face @var{face}. Should be a name of a
364 pixmap file or @code{false}.
365 @item @var{face}.attributeFont
366 Font name (full XFD name or valid X abbreviation) for face @var{face}.
367 Instead of this, you can specify the font through separate attributes.
370 Instead of using @code{attributeFont} to specify a font name, you can
371 select a font through these separate attributes:
374 @item @var{face}.attributeFamily
375 Font family for face @var{face}.
376 @item @var{face}.attributeHeight
377 Height of the font to use for face @var{face}: either an integer
378 specifying the height in units of 1/10@dmn{pt}, or a floating point
379 number that specifies a scale factor to scale the underlying face's
380 default font, or a function to be called with the default height which
381 will return a new height.
382 @item @var{face}.attributeWidth
383 @itemx @var{face}.attributeWeight
384 @itemx @var{face}.attributeSlant
385 Each of these resources corresponds to a like-named font attribute,
386 and you write the resource value the same as the symbol you would use
387 for the font attribute value.
388 @item @var{face}.attributeBold
389 Bold flag for face @var{face}---instead of @code{attributeWeight}. Use @samp{on} or @samp{true} for
391 @item @var{face}.attributeItalic
392 Italic flag for face @var{face}---instead of @code{attributeSlant}.
395 @node Lucid Resources
396 @appendixsec Lucid Menu X Resources
397 @cindex Menu X Resources (Lucid widgets)
398 @cindex Lucid Widget X Resources
401 If the Emacs installed at your site was built to use the X toolkit
402 with the Lucid menu widgets, then the menu bar is a separate widget and
403 has its own resources. The resource names contain @samp{pane.menubar}
404 (following, as always, the name of the Emacs invocation, or @samp{Emacs},
405 which stands for all Emacs invocations). Specify them like this:
408 Emacs.pane.menubar.@var{resource}: @var{value}
412 For example, to specify the font @samp{8x16} for the menu-bar items,
416 If the Emacs installed at your site was built to use the X toolkit
417 with the Lucid menu widgets, then the menu bar is a separate widget
418 and has its own resources. The resource specifications start with
419 @samp{Emacs.pane.menubar}---for instance, to specify the font
420 @samp{8x16} for the menu-bar items, write this:
424 Emacs.pane.menubar.font: 8x16
428 Resources for @emph{non-menubar} toolkit pop-up menus have
429 @samp{menu*} instead of @samp{pane.menubar}. For example, to specify
430 the font @samp{8x16} for the pop-up menu items, write this:
433 Emacs.menu*.font: 8x16
437 For dialog boxes, use @samp{dialog*}:
440 Emacs.dialog*.font: 8x16
444 The Lucid menus can display multilingual text in your locale. For
445 more information about fontsets see the man page for
446 @code{XCreateFontSet}. To enable multilingual menu text you specify a
447 @code{fontSet} resource instead of the font resource. If both
448 @code{font} and @code{fontSet} resources are specified, the
449 @code{fontSet} resource is used.
451 Thus, to specify @samp{-*-helvetica-medium-r-*--*-120-*-*-*-*-*-*,*}
452 for both the popup and menu bar menus, write this:
455 Emacs*menu*fontSet: -*-helvetica-medium-r-*--*-120-*-*-*-*-*-*,*
459 The @samp{*menu*} as a wildcard matches @samp{pane.menubar} and
462 Experience shows that on some systems you may need to add
463 @samp{shell.}@: before the @samp{pane.menubar} or @samp{menu*}. On
464 some other systems, you must not add @samp{shell.}. The generic wildcard
465 approach should work on both kinds of systems.
467 Here is a list of the specific resources for menu bars and pop-up menus:
471 Font for menu item text.
473 Fontset for menu item text.
475 Color of the foreground.
477 Color of the background.
478 @item buttonForeground
479 In the menu bar, the color of the foreground for a selected item.
481 @item horizontalSpacing
482 Horizontal spacing in pixels between items. Default is 3.
483 @item verticalSpacing
484 Vertical spacing in pixels between items. Default is 2.
486 Horizontal spacing between the arrow (which indicates a submenu) and
487 the associated text. Default is 10.
488 @item shadowThickness
489 Thickness of shadow line around the widget. Default is 1.
491 Also determines the thickness of shadow lines around other objects,
492 for instance 3D buttons and arrows. If you have the impression that
493 the arrows in the menus do not stand out clearly enough or that the
494 difference between ``in'' and ``out'' buttons is difficult to see, set
495 this to 2. If you have no problems with visibility, the default
496 probably looks better. The background color may also have some effect
500 The margin of the menu bar, in characters. Default is 1.
504 @node LessTif Resources
505 @appendixsec LessTif Menu X Resources
506 @cindex Menu X Resources (LessTif widgets)
507 @cindex LessTif Widget X Resources
509 If the Emacs installed at your site was built to use the X toolkit
510 with the LessTif or Motif widgets, then the menu bar, the dialog
511 boxes, the pop-up menus, and the file-selection box are separate
512 widgets and have their own resources.
514 The resource names for the menu bar contain @samp{pane.menubar}
515 (following, as always, the name of the Emacs invocation, or
516 @samp{Emacs}, which stands for all Emacs invocations). Specify them
520 Emacs.pane.menubar.@var{subwidget}.@var{resource}: @var{value}
523 Each individual string in the menu bar is a subwidget; the subwidget's
524 name is the same as the menu item string. For example, the word
525 @samp{File} in the menu bar is part of a subwidget named
526 @samp{emacs.pane.menubar.File}. Most likely, you want to specify the
527 same resources for the whole menu bar. To do this, use @samp{*} instead
528 of a specific subwidget name. For example, to specify the font
529 @samp{8x16} for the menu-bar items, write this:
532 Emacs.pane.menubar.*.fontList: 8x16
536 This also specifies the resource value for submenus.
538 Each item in a submenu in the menu bar also has its own name for X
539 resources; for example, the @samp{File} submenu has an item named
540 @samp{Save (current buffer)}. A resource specification for a submenu
541 item looks like this:
544 Emacs.pane.menubar.popup_*.@var{menu}.@var{item}.@var{resource}: @var{value}
548 For example, here's how to specify the font for the @samp{Save (current
552 Emacs.pane.menubar.popup_*.File.Save (current buffer).fontList: 8x16
556 For an item in a second-level submenu, such as @samp{Complete Word}
557 under @samp{Spell Checking} under @samp{Tools}, the resource fits this
561 Emacs.pane.menubar.popup_*.popup_*.@var{menu}.@var{resource}: @var{value}
568 Emacs.pane.menubar.popup_*.popup_*.Spell Checking.Complete Word: @var{value}
572 (This should be one long line.)
574 It's impossible to specify a resource for all the menu-bar items
575 without also specifying it for the submenus as well. So if you want the
576 submenu items to look different from the menu bar itself, you must ask
577 for that in two steps. First, specify the resource for all of them;
578 then, override the value for submenus alone. Here is an example:
581 Emacs.pane.menubar.*.fontList: 8x16
582 Emacs.pane.menubar.popup_*.fontList: 8x16
586 For LessTif pop-up menus, use @samp{menu*} instead of
587 @samp{pane.menubar}. For example, to specify the font @samp{8x16} for
588 the pop-up menu items, write this:
591 Emacs.menu*.fontList: 8x16
595 For LessTif dialog boxes, use @samp{dialog} instead of @samp{menu}:
598 Emacs.dialog*.fontList: 8x16
599 Emacs.dialog*.foreground: hotpink
602 To specify resources for the LessTif file-selection box, use
603 @samp{fsb*}, like this:
606 Emacs.fsb*.fontList: 8x16
612 Here is a list of the specific resources for LessTif menu bars and
617 The color to show in an armed button.
626 Amount of space to leave around the item, within the border.
628 The width of the border around the menu item, on all sides.
629 @item shadowThickness
630 The width of the border shadow.
631 @item bottomShadowColor
632 The color for the border shadow, on the bottom and the right.
634 The color for the border shadow, on the top and the left.
640 @appendixsec GTK resources
642 The most common way to customize the GTK widgets Emacs uses (menus, dialogs
643 tool bars and scroll bars) is by choosing an appropriate theme, for example
644 with the GNOME theme selector. You can also do Emacs specific customization
645 by inserting GTK style directives in the file @file{~/.emacs.d/gtkrc}. Some GTK
646 themes ignore customizations in @file{~/.emacs.d/gtkrc} so not everything
647 works with all themes. To customize Emacs font, background, faces, etc., use
648 the normal X resources (@pxref{Resources}). We will present some examples of
649 customizations here, but for a more detailed description, see the online manual
651 The first example is just one line. It changes the font on all GTK widgets
652 to courier with size 12:
655 gtk-font-name = "courier 12"
658 The thing to note is that the font name is not an X font name, like
659 -*-helvetica-medium-r-*--*-120-*-*-*-*-*-*, but a Pango font name. A Pango
660 font name is basically of the format "family style size", where the style
661 is optional as in the case above. A name with a style could be for example:
664 gtk-font-name = "helvetica bold 10"
667 To customize widgets you first define a style and then apply the style to
668 the widgets. Here is an example that sets the font for menus, but not
672 # @r{Define the style @samp{menufont}.}
675 font_name = "helvetica bold 14" # This is a Pango font name
678 # @r{Specify that widget type @samp{*emacs-menuitem*} uses @samp{menufont}.}
679 widget "*emacs-menuitem*" style "menufont"
682 The widget name in this example contains wildcards, so the style will be
683 applied to all widgets that match "*emacs-menuitem*". The widgets are
684 named by the way they are contained, from the outer widget to the inner widget.
685 So to apply the style "my_style" (not shown) with the full, absolute name, for
686 the menubar and the scroll bar in Emacs we use:
689 widget "Emacs.pane.menubar" style "my_style"
690 widget "Emacs.pane.emacs.verticalScrollBar" style "my_style"
693 But to avoid having to type it all, wildcards are often used. @samp{*}
694 matches zero or more characters and @samp{?} matches one character. So "*"
697 Each widget has a class (for example GtkMenuItem) and a name (emacs-menuitem).
698 You can assign styles by name or by class. In this example we have used the
704 font_name = "helvetica bold 14"
707 widget_class "*GtkMenuBar" style "menufont"
711 The names and classes for the GTK widgets Emacs uses are:
713 @multitable {@code{verticalScrollbar plus}} {@code{GtkFileSelection} and some}
714 @item @code{emacs-filedialog}
715 @tab @code{GtkFileSelection}
716 @item @code{emacs-dialog}
717 @tab @code{GtkDialog}
719 @tab @code{GtkWindow}
724 @item @code{verticalScrollBar}
725 @tab @code{GtkVScrollbar}
726 @item @code{emacs-toolbar}
727 @tab @code{GtkToolbar}
729 @tab @code{GtkMenuBar}
730 @item @code{emacs-menuitem}
731 @tab anything in menus
734 GTK absolute names are quite strange when it comes to menus
735 and dialogs. The names do not start with @samp{Emacs}, as they are
736 free-standing windows and not contained (in the GTK sense) by the
737 Emacs GtkWindow. To customize the dialogs and menus, use wildcards like this:
740 widget "*emacs-dialog*" style "my_dialog_style"
741 widget "*emacs-filedialog* style "my_file_style"
742 widget "*emacs-menuitem* style "my_menu_style"
745 If you specify a customization in @file{~/.emacs.d/gtkrc}, then it
746 automatically applies only to Emacs, since other programs don't read
747 that file. For example, the drop down menu in the file dialog can not
748 be customized by any absolute widget name, only by an absolute class
749 name. This is because the widgets in the drop down menu do not
750 have names and the menu is not contained in the Emacs GtkWindow. To
751 have all menus in Emacs look the same, use this in
752 @file{~/.emacs.d/gtkrc}:
755 widget_class "*Menu*" style "my_menu_style"
758 Here is a more elaborate example, showing how to change the parts of
764 fg[NORMAL] = "red"@ @ @ @ @ # @r{The arrow color.}
765 bg[NORMAL] = "yellow"@ @ # @r{The thumb and background around the arrow.}
766 bg[ACTIVE] = "blue"@ @ @ @ # @r{The trough color.}
767 bg[PRELIGHT] = "white"@ # @r{The thumb color when the mouse is over it.}
770 widget "*verticalScrollBar*" style "scroll"
775 @cindex GTK resources and customization
776 @cindex resource files for GTK
777 @cindex @file{~/.gtkrc-2.0} file
778 @cindex @file{~/.emacs.d/gtkrc} file
780 If Emacs was built to use the GTK widget set, then the menu bar, tool bar,
781 scroll bar and the dialogs are customized with the standard GTK
782 customization file, @file{~/.gtkrc-2.0}, or with the Emacs specific
783 file @file{~/.emacs.d/gtkrc}. We recommend that you use
784 @file{~/.emacs.d/gtkrc} for customizations, since @file{~/.gtkrc-2.0}
785 seems to be ignored when running GConf with GNOME. These files apply
786 only to GTK widget features. To customize Emacs font, background,
787 faces, etc., use the normal X resources (@pxref{Resources}).
789 Some GTK themes override these mechanisms, which means that using
790 these mechanisms will not work to customize them.
792 In these files you first define a style and say what it means; then
793 you specify to apply the style to various widget types (@pxref{GTK
794 widget names}). Here is an example of how to change the font for
798 # @r{Define the style @samp{menufont}.}
801 font_name = "helvetica bold 14" # This is a Pango font name
804 # @r{Specify that widget type @samp{*emacs-menuitem*} uses @samp{menufont}.}
805 widget "*emacs-menuitem*" style "menufont"
808 Here is a more elaborate example, showing how to change the parts of
814 fg[NORMAL] = "red"@ @ @ @ @ # @r{The arrow color.}
815 bg[NORMAL] = "yellow"@ @ # @r{The thumb and background around the arrow.}
816 bg[ACTIVE] = "blue"@ @ @ @ # @r{The trough color.}
817 bg[PRELIGHT] = "white"@ # @r{The thumb color when the mouse is over it.}
820 widget "*verticalScrollBar*" style "scroll"
823 There are also parameters that affect GTK as a whole. For example,
824 the property @code{gtk-font-name} sets the default font for GTK. You
825 must use Pango font names (@pxref{GTK styles}). A GTK resources file
826 that just sets a default font looks like this:
829 gtk-font-name = "courier 12"
832 The GTK resources file is fully described in the GTK API document.
834 @file{@var{prefix}/share/gtk-doc/html/gtk/gtk-resource-files.html},
835 where @file{prefix} is the directory in which the GTK libraries were
836 installed (usually @file{/usr} or @file{/usr/local}). You can also
837 find the document online, at
838 @uref{http://developer.gnome.org/doc/API/2.0/gtk/gtk-Resource-Files.html}.
841 * GTK widget names:: How widgets in GTK are named in general.
842 * GTK Names in Emacs:: GTK widget names in Emacs.
843 * GTK styles:: What can be customized in a GTK widget.
846 @node GTK widget names
847 @appendixsubsec GTK widget names
848 @cindex GTK widget names
850 A GTK widget is specified by its @dfn{widget class} and
851 @dfn{widget name}. The widget class is the type of the widget: for
852 example, @code{GtkMenuBar}. The widget name is the name given to a
853 specific widget. A widget always has a class, but need not have a
856 @dfn{Absolute names} are sequences of widget names or widget
857 classes, corresponding to hierarchies of widgets embedded within
858 other widgets. For example, if a @code{GtkWindow} named @code{top}
859 contains a @code{GtkVBox} named @code{box}, which in turn contains
860 a @code{GtkMenuBar} called @code{menubar}, the absolute class name
861 of the menu-bar widget is @code{GtkWindow.GtkVBox.GtkMenuBar}, and
862 its absolute widget name is @code{top.box.menubar}.
864 When assigning a style to a widget, you can use the absolute class
865 name or the absolute widget name.
867 There are two commands to specify changes for widgets:
870 @item @code{widget_class}
871 specifies a style for widgets based on the absolute class name.
874 specifies a style for widgets based on the absolute class name,
879 You must specify the class and the style in double-quotes, and put
880 these commands at the top level in the GTK customization file, like
886 font_name = "helvetica bold 14"
889 widget "top.box.menubar" style "menufont"
890 widget_class "GtkWindow.GtkVBox.GtkMenuBar" style "menufont"
893 Matching of absolute names uses shell wildcard syntax: @samp{*}
894 matches zero or more characters and @samp{?} matches one character.
895 This example assigns @code{base_style} to all widgets:
898 widget "*" style "base_style"
901 Given the absolute class name @code{GtkWindow.GtkVBox.GtkMenuBar}
902 and the corresponding absolute widget name @code{top.box.menubar}, all
903 these examples specify @code{my_style} for the menu bar:
906 widget_class "GtkWindow.GtkVBox.GtkMenuBar" style "my_style"
907 widget_class "GtkWindow.*.GtkMenuBar" style "my_style"
908 widget_class "*GtkMenuBar" style "my_style"
909 widget "top.box.menubar" style "my_style"
910 widget "*box*menubar" style "my_style"
911 widget "*menubar" style "my_style"
912 widget "*menu*" style "my_style"
915 @node GTK Names in Emacs
916 @appendixsubsec GTK Widget Names in Emacs
917 @cindex GTK widget names
918 @cindex GTK widget classes
920 In Emacs, the top level widget for a frame is a @code{GtkWindow}
921 that contains a @code{GtkVBox}. The @code{GtkVBox} contains the
922 @code{GtkMenuBar} and a @code{GtkFixed} widget. The vertical scroll
923 bars, @code{GtkVScrollbar}, are contained in the @code{GtkFixed}
924 widget. The text you write in Emacs is drawn in the @code{GtkFixed}
927 Dialogs in Emacs are @code{GtkDialog} widgets. The file dialog is a
928 @code{GtkFileSelection} widget.
931 To set a style for the menu bar using the absolute class name, use:
934 widget_class "GtkWindow.GtkVBox.GtkMenuBar" style "my_style"
938 For the scroll bar, the absolute class name is:
942 "GtkWindow.GtkVBox.GtkFixed.GtkVScrollbar"
947 The names for the emacs widgets, and their classes, are:
949 @multitable {@code{verticalScrollbar plus}} {@code{GtkFileSelection} and some}
950 @item @code{emacs-filedialog}
951 @tab @code{GtkFileSelection}
952 @item @code{emacs-dialog}
953 @tab @code{GtkDialog}
955 @tab @code{GtkWindow}
960 @item @code{verticalScrollBar}
961 @tab @code{GtkVScrollbar}
962 @item @code{emacs-toolbar}
963 @tab @code{GtkToolbar}
965 @tab @code{GtkMenuBar}
966 @item @code{emacs-menuitem}
967 @tab anything in menus
971 Thus, for Emacs you can write the two examples above as:
974 widget "Emacs.pane.menubar" style "my_style"
975 widget "Emacs.pane.emacs.verticalScrollBar" style "my_style"
978 GTK absolute names are quite strange when it comes to menus
979 and dialogs. The names do not start with @samp{Emacs}, as they are
980 free-standing windows and not contained (in the GTK sense) by the
981 Emacs GtkWindow. To customize the dialogs and menus, use wildcards like this:
984 widget "*emacs-dialog*" style "my_dialog_style"
985 widget "*emacs-filedialog* style "my_file_style"
986 widget "*emacs-menuitem* style "my_menu_style"
989 If you specify a customization in @file{~/.emacs.d/gtkrc}, then it
990 automatically applies only to Emacs, since other programs don't read
991 that file. For example, the drop down menu in the file dialog can not
992 be customized by any absolute widget name, only by an absolute class
993 name. This is because the widgets in the drop down menu do not
994 have names and the menu is not contained in the Emacs GtkWindow. To
995 have all menus in Emacs look the same, use this in
996 @file{~/.emacs.d/gtkrc}:
999 widget_class "*Menu*" style "my_menu_style"
1003 @appendixsubsec GTK styles
1006 In a GTK style you specify the appearance widgets shall have. You
1007 can specify foreground and background color, background pixmap and
1008 font. The edit widget (where you edit the text) in Emacs is a GTK
1009 widget, but trying to specify a style for the edit widget will have no
1010 effect. This is so that Emacs compiled for GTK is compatible with
1011 Emacs compiled for other X toolkits. The settings for foreground,
1012 background and font for the edit widget is taken from the X resources;
1013 @pxref{Resources}. Here is an example of two style declarations,
1014 @samp{default} and @samp{ruler}:
1017 pixmap_path "/usr/share/pixmaps:/usr/include/X11/pixmaps"
1021 font_name = "helvetica 12"
1023 bg[NORMAL] = @{ 0.83, 0.80, 0.73 @}
1024 bg[SELECTED] = @{ 0.0, 0.55, 0.55 @}
1025 bg[INSENSITIVE] = @{ 0.77, 0.77, 0.66 @}
1026 bg[ACTIVE] = @{ 0.0, 0.55, 0.55 @}
1027 bg[PRELIGHT] = @{ 0.0, 0.55, 0.55 @}
1029 fg[NORMAL] = "black"
1030 fg[SELECTED] = @{ 0.9, 0.9, 0.9 @}
1031 fg[ACTIVE] = "black"
1032 fg[PRELIGHT] = @{ 0.9, 0.9, 0.9 @}
1034 base[INSENSITIVE] = "#777766"
1035 text[INSENSITIVE] = @{ 0.60, 0.65, 0.57 @}
1037 bg_pixmap[NORMAL] = "background.xpm"
1038 bg_pixmap[INSENSITIVE] = "background.xpm"
1039 bg_pixmap[ACTIVE] = "background.xpm"
1040 bg_pixmap[PRELIGHT] = "<none>"
1044 style "ruler" = "default"
1046 font_name = "helvetica 8"
1051 The style @samp{ruler} inherits from @samp{default}. This way you can build
1052 on existing styles. The syntax for fonts and colors is described below.
1054 As this example shows, it is possible to specify several values for
1055 foreground and background depending on the widget's @dfn{state}. The
1056 possible states are:
1060 This is the default state for widgets.
1062 This is the state for a widget that is ready to do something. It is
1063 also for the trough of a scroll bar, i.e. @code{bg[ACTIVE] = "red"}
1064 sets the scroll bar trough to red. Buttons that have been pressed but
1065 not released yet (``armed'') are in this state.
1067 This is the state for a widget that can be manipulated, when the mouse
1068 pointer is over it---for example when the mouse is over the thumb in
1069 the scroll bar or over a menu item. When the mouse is over a button
1070 that is not pressed, the button is in this state.
1072 This is the state for data that has been selected by the user. It can
1073 be selected text or items selected in a list. This state is not used
1076 This is the state for widgets that are visible, but they can not be
1077 manipulated in the usual way---for example, buttons that can't be
1078 pressed, and disabled menu items. To display disabled menu items in
1079 yellow, use @code{fg[INSENSITIVE] = "yellow"}.
1082 Here are the things that can go in a style declaration:
1085 @item bg[@var{state}] = @var{color}
1086 This specifies the background color for the widget. Note that
1087 editable text doesn't use @code{bg}; it uses @code{base} instead.
1089 @item base[@var{state}] = @var{color}
1090 This specifies the background color for editable text. In Emacs, this
1091 color is used for the background of the text fields in the file
1094 @item bg_pixmap[@var{state}] = "@var{pixmap}"
1095 This specifies an image background (instead of a background color).
1096 @var{pixmap} should be the image file name. GTK can use a number of
1097 image file formats, including XPM, XBM, GIF, JPEG and PNG. If you
1098 want a widget to use the same image as its parent, use
1099 @samp{<parent>}. If you don't want any image, use @samp{<none>}.
1100 @samp{<none>} is the way to cancel a background image inherited from a
1103 You can't specify the file by its absolute file name. GTK looks for
1104 the pixmap file in directories specified in @code{pixmap_path}.
1105 @code{pixmap_path} is a colon-separated list of directories within
1106 double quotes, specified at the top level in a @file{gtkrc} file
1107 (i.e. not inside a style definition; see example above):
1110 pixmap_path "/usr/share/pixmaps:/usr/include/X11/pixmaps"
1113 @item fg[@var{state}] = @var{color}
1114 This specifies the foreground color for widgets to use. It is the
1115 color of text in menus and buttons, and the color for the arrows in
1116 the scroll bar. For editable text, use @code{text}.
1118 @item text[@var{state}] = @var{color}
1119 This is the color for editable text. In Emacs, this color is used for the
1120 text fields in the file dialog.
1122 @item font_name = "@var{font}"
1123 This specifies the font for text in the widget. @var{font} is a
1124 Pango font name, for example @samp{Sans Italic 10}, @samp{Helvetica
1125 Bold 12}, @samp{Courier 14}, @samp{Times 18}. See below for exact
1126 syntax. The names are case insensitive.
1129 There are three ways to specify a color: by name, in hexadecimal
1130 form, and with an RGB triplet.
1133 A color name is written within double quotes, for example @code{"red"}.
1136 Hexadecimal form is the same as in X:
1137 @code{#@var{rrrr}@var{gggg}@var{bbbb}}, where all three color specs
1138 must have the same number of hex digits (1, 2, 3 or 4).
1141 An RGB triplet looks like @code{@{ @var{r}, @var{g}, @var{b} @}},
1142 where @var{r}, @var{g} and @var{b} are either integers in the range
1143 0-65535 or floats in the range 0.0-1.0.
1145 Pango font names have the form ``@var{family-list} @var{style-options}
1147 @cindex Pango font name
1149 @var{family-list} is a comma separated list of font families optionally
1150 terminated by a comma. This way you can specify several families and the
1151 first one found will be used. @var{family} corresponds to the second part in
1152 an X font name, for example in
1155 -adobe-times-medium-r-normal--12-120-75-75-p-64-iso10646-1
1159 the family name is @samp{times}.
1162 @var{style-options} is a whitespace separated list of words where each word
1163 is a style, variant, weight, or stretch. The default value for all of
1164 these is @code{normal}.
1167 A `style' corresponds to the fourth part of an X font name. In X font
1168 names it is the character @samp{r}, @samp{i} or @samp{o}; in Pango
1169 font names the corresponding values are @code{normal}, @code{italic},
1173 A `variant' is either @code{normal} or @code{small-caps}.
1174 Small caps is a font with the lower case characters replaced by
1175 smaller variants of the capital characters.
1178 Weight describes the ``boldness'' of a font. It corresponds to the third
1179 part of an X font name. It is one of @code{ultra-light}, @code{light},
1180 @code{normal}, @code{bold}, @code{ultra-bold}, or @code{heavy}.
1183 Stretch gives the width of the font relative to other designs within a
1184 family. It corresponds to the fifth part of an X font name. It is one of
1185 @code{ultra-condensed}, @code{extra-condensed}, @code{condensed},
1186 @code{semi-condensed}, @code{normal}, @code{semi-expanded},
1187 @code{expanded}, @code{extra-expanded}, or @code{ultra-expanded}.
1190 @var{size} is a decimal number that describes the font size in points.
1194 arch-tag: 9b6ff773-48b6-41f6-b2f9-f114b8bdd97f