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, 2010 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 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
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}.)
121 In addition, you can use the following command-line options to
122 override the X resources file:
125 @item -name @var{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
145 @item -xrm @var{resource-values}
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.
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:
169 @item @code{background} (class @code{Background})
170 Background color name.
173 @item @code{bitmapIcon} (class @code{BitmapIcon})
174 Use a bitmap icon (a picture of a gnu) if @samp{on}, let the window
175 manager choose an icon if @samp{off}.
178 @item @code{borderColor} (class @code{BorderColor})
179 Color name for the external border.
182 @item @code{borderWidth} (class @code{BorderWidth})
183 Width in pixels of the external border.
186 @item @code{cursorColor} (class @code{Foreground})
187 Color name for text cursor (point).
190 @item @code{cursorBlink} (class @code{CursorBlink})
191 Specifies whether to make the cursor blink. The default is @samp{on}. Use
192 @samp{off} or @samp{false} to turn cursor blinking off.
195 @item @code{font} (class @code{Font})
196 Font name for the @code{default} font. @xref{Fonts}. You can also
197 specify a fontset name (@pxref{Fontsets}).
199 @item @code{fontBackend} (class @code{FontBackend})
200 The backend(s) to use for drawing fonts; if multiple backends are
201 specified, they must be comma-delimited and given in order of
202 precedence. On X, for instance, the value @samp{x,xft} tells Emacs to
203 draw fonts using the X core font driver, falling back on the Xft font
204 driver if that fails. Normally, you can leave this resource unset, in
205 which case Emacs tries using all font backends available on your
208 @item @code{foreground} (class @code{Foreground})
211 @item @code{geometry} (class @code{Geometry})
212 Window size and position. Be careful not to specify this resource as
213 @samp{emacs*geometry}, because that may affect individual menus as well
214 as the Emacs frame itself.
216 If this resource specifies a position, that position applies only to the
217 initial Emacs frame (or, in the case of a resource for a specific frame
218 name, only that frame). However, the size, if specified here, applies to
222 @item @code{fullscreen} (class @code{Fullscreen})
223 The desired fullscreen size. The value can be one of @code{fullboth},
224 @code{maximized}, @code{fullwidth} or @code{fullheight}, which correspond to
225 the command-line options @samp{-fs}, @samp{-mm}, @samp{-fw}, and @samp{-fh}
226 (@pxref{Window Size X}).
228 Note that this applies to the initial frame only.
231 @item @code{iconName} (class @code{Title})
232 Name to display in the icon.
234 @item @code{internalBorder} (class @code{BorderWidth})
235 Width in pixels of the internal border.
237 @item @code{lineSpacing} (class @code{LineSpacing})
240 Additional space (@dfn{leading}) between lines, in pixels.
242 @item @code{menuBar} (class @code{MenuBar})
244 Give frames menu bars if @samp{on}; don't have menu bars if @samp{off}.
246 @xref{Lucid Resources}, and @ref{LessTif Resources},
249 @xref{Lucid Resources},
251 for how to control the appearance of the menu bar if you have one.
254 @item @code{minibuffer} (class @code{Minibuffer})
255 If @samp{none}, don't make a minibuffer in this frame.
256 It will use a separate minibuffer frame instead.
258 @item @code{paneFont} (class @code{Font})
259 @cindex font for menus
260 Font name for menu pane titles, in non-toolkit versions of Emacs.
263 @item @code{pointerColor} (class @code{Foreground})
264 Color of the mouse cursor.
267 @item @code{privateColormap} (class @code{PrivateColormap})
268 If @samp{on}, use a private color map, in the case where the ``default
269 visual'' of class PseudoColor and Emacs is using it.
271 @item @code{reverseVideo} (class @code{ReverseVideo})
272 Switch foreground and background default colors if @samp{on}, use colors as
273 specified if @samp{off}.
276 @item @code{screenGamma} (class @code{ScreenGamma})
277 @cindex gamma correction
278 Gamma correction for colors, equivalent to the frame parameter
281 @item @code{scrollBarWidth} (class @code{ScrollBarWidth})
282 @cindex scrollbar width
283 The scroll bar width in pixels, equivalent to the frame parameter
284 @code{scroll-bar-width}.
287 @item @code{selectionFont} (class @code{SelectionFont})
288 Font name for pop-up menu items, in non-toolkit versions of Emacs. (For
289 toolkit versions, see @ref{Lucid Resources}, also see @ref{LessTif
292 @item @code{selectionTimeout} (class @code{SelectionTimeout})
293 Number of milliseconds to wait for a selection reply.
294 If the selection owner doesn't reply in this time, we give up.
295 A value of 0 means wait as long as necessary.
297 @item @code{synchronous} (class @code{Synchronous})
298 @cindex debugging X problems
299 @cindex synchronous X mode
300 Run Emacs in synchronous mode if @samp{on}. Synchronous mode is
301 useful for debugging X problems.
304 @item @code{title} (class @code{Title})
305 Name to display in the title bar of the initial Emacs frame.
307 @item @code{toolBar} (class @code{ToolBar})
309 Number of lines to reserve for the tool bar. A zero value suppresses
310 the tool bar. For the Emacs tool bar (i.e. not Gtk+), if the value is
311 non-zero and @code{auto-resize-tool-bars} is non-@code{nil}, the tool bar's
312 size will be changed automatically so that all tool bar items are visible.
313 If the value of @code{auto-resize-tool-bars} is @code{grow-only},
314 the tool bar expands automatically, but does not contract automatically.
315 To contract the tool bar, you must redraw the frame by entering @kbd{C-l}.
316 For the Gtk+ tool bar, any non-zero value means on and
317 @code{auto-resize-tool-bars} has no effect.
319 @item @code{useXIM} (class @code{UseXIM})
321 @cindex X input methods
322 @cindex input methods, X
323 Turn off use of X input methods (XIM) if @samp{false} or @samp{off}.
324 This is only relevant if your Emacs is actually built with XIM
325 support. It is potentially useful to turn off XIM for efficiency,
326 especially slow X client/server links.
328 @item @code{verticalScrollBars} (class @code{ScrollBars})
329 Give frames scroll bars if @samp{on}; don't have scroll bars if
333 @item @code{visualClass} (class @code{VisualClass})
334 Specify the ``visual'' that X should use. This tells X how to handle
337 The value should start with one of @samp{TrueColor},
338 @samp{PseudoColor}, @samp{DirectColor}, @samp{StaticColor},
339 @samp{GrayScale}, and @samp{StaticGray}, followed by
340 @samp{-@var{depth}}, where @var{depth} is the number of color planes.
341 Most terminals only allow a few ``visuals,'' and the @samp{dpyinfo}
342 program outputs information saying which ones.
347 @appendixsec X Resources for Faces
349 You can use resources to customize the appearance of particular
350 faces (@pxref{Faces}):
353 @item @var{face}.attributeForeground
354 Foreground color for face @var{face}.
355 @item @var{face}.attributeBackground
356 Background color for face @var{face}.
357 @item @var{face}.attributeUnderline
358 Underline flag for face @var{face}. Use @samp{on} or @samp{true} for
360 @item @var{face}.attributeStrikeThrough
361 @itemx @var{face}.attributeOverline
362 @itemx @var{face}.attributeBox
363 @itemx @var{face}.attributeInverse
364 Likewise, for other boolean font attributes.
365 @item @var{face}.attributeStipple
366 The name of a pixmap data file to use for the stipple pattern, or
367 @code{false} to not use stipple for the face @var{face}.
368 @item @var{face}.attributeBackgroundPixmap
369 The background pixmap for the face @var{face}. Should be a name of a
370 pixmap file or @code{false}.
371 @item @var{face}.attributeFont
372 Font name (full XFD name or valid X abbreviation) for face @var{face}.
373 Instead of this, you can specify the font through separate attributes.
376 Instead of using @code{attributeFont} to specify a font name, you can
377 select a font through these separate attributes:
380 @item @var{face}.attributeFamily
381 Font family for face @var{face}.
382 @item @var{face}.attributeHeight
383 Height of the font to use for face @var{face}: either an integer
384 specifying the height in units of 1/10@dmn{pt}, or a floating point
385 number that specifies a scale factor to scale the underlying face's
386 default font, or a function to be called with the default height which
387 will return a new height.
388 @item @var{face}.attributeWidth
389 @itemx @var{face}.attributeWeight
390 @itemx @var{face}.attributeSlant
391 Each of these resources corresponds to a like-named font attribute,
392 and you write the resource value the same as the symbol you would use
393 for the font attribute value.
394 @item @var{face}.attributeBold
395 Bold flag for face @var{face}---instead of @code{attributeWeight}. Use @samp{on} or @samp{true} for
397 @item @var{face}.attributeItalic
398 Italic flag for face @var{face}---instead of @code{attributeSlant}.
401 @node Lucid Resources
402 @appendixsec Lucid Menu And Dialog X Resources
403 @cindex Menu X Resources (Lucid widgets)
404 @cindex Dialog X Resources (Lucid widgets)
405 @cindex Lucid Widget X Resources
408 If the Emacs installed at your site was built to use the X toolkit
409 with the Lucid menu widgets, then the menu bar is a separate widget and
410 has its own resources. The resource names contain @samp{pane.menubar}
411 (following, as always, the name of the Emacs invocation, or @samp{Emacs},
412 which stands for all Emacs invocations). Specify them like this:
415 Emacs.pane.menubar.@var{resource}: @var{value}
419 For example, to specify the font @samp{Courier-12} for the menu-bar items,
423 If the Emacs installed at your site was built to use the X toolkit
424 with the Lucid menu widgets, then the menu bar is a separate widget
425 and has its own resources. The resource specifications start with
426 @samp{Emacs.pane.menubar}---for instance, to specify the font
427 @samp{Courier-12} for the menu-bar items, write this:
431 Emacs.pane.menubar.faceName: Courier-12
435 To specify a font, use fontconfig font names as values to the @code{faceName}
438 If Emacs is not built with the Xft library, Lucid menus and dialogs
439 can only display old style fonts. If Emacs is built with Xft and you
440 prefer the old fonts, you have to specify @samp{none} to
444 Emacs.pane.menubar.faceName: none
445 Emacs.pane.dialog.faceName: none
449 To specify a non-Xft font, use @code{font}. For example:
452 Emacs.pane.menubar.font: lucidasanstypewriter-10
456 The Lucid menus can display multilingual text in your locale with old style
457 fonts. For more information about fontsets see the man page for
458 @code{XCreateFontSet}. To enable multilingual menu text you specify a
459 @code{fontSet} resource instead of the font resource. If both
460 @code{font} and @code{fontSet} resources are specified, the
461 @code{fontSet} resource is used.
463 Thus, to specify @samp{-*-helvetica-medium-r-*--*-120-*-*-*-*-*-*,*}
464 for both the popup and menu bar menus, write this:
467 Emacs*menu*fontSet: -*-helvetica-medium-r-*--*-120-*-*-*-*-*-*,*
471 Resources for @emph{non-menubar} toolkit pop-up menus have
472 @samp{menu*} instead of @samp{pane.menubar}. For example, to specify
473 the font @samp{8x16} for the pop-up menu items, write this:
476 Emacs.menu*.font: 8x16
480 For dialog boxes, use @samp{dialog*}:
483 Emacs.dialog*.faceName: Sans-12
487 The @samp{*menu*} as a wildcard matches @samp{pane.menubar} and
490 Experience shows that on some systems you may need to add
491 @samp{shell.}@: before the @samp{pane.menubar} or @samp{menu*}. On
492 some other systems, you must not add @samp{shell.}. The generic wildcard
493 approach should work on both kinds of systems.
495 Here is a list of the specific resources for menu bars and pop-up menus:
499 Xft font for menu item text.
501 Font for menu item text.
503 Fontset for menu item text.
505 Color of the foreground.
507 Color of the background.
508 @item buttonForeground
509 In the menu bar, the color of the foreground for a selected item.
511 @item horizontalSpacing
512 Horizontal spacing in pixels between items. Default is 3.
513 @item verticalSpacing
514 Vertical spacing in pixels between items. Default is 2.
516 Horizontal spacing between the arrow (which indicates a submenu) and
517 the associated text. Default is 10.
518 @item shadowThickness
519 Thickness of shadow line around the widget. Default is 1.
521 Also determines the thickness of shadow lines around other objects,
522 for instance 3D buttons and arrows. If you have the impression that
523 the arrows in the menus do not stand out clearly enough or that the
524 difference between ``in'' and ``out'' buttons is difficult to see, set
525 this to 2. If you have no problems with visibility, the default
526 probably looks better. The background color may also have some effect
530 The margin of the menu bar, in characters. Default is 1.
534 @node LessTif Resources
535 @appendixsec LessTif Menu X Resources
536 @cindex Menu X Resources (LessTif widgets)
537 @cindex LessTif Widget X Resources
539 If the Emacs installed at your site was built to use the X toolkit
540 with the LessTif or Motif widgets, then the menu bar, the dialog
541 boxes, the pop-up menus, and the file-selection box are separate
542 widgets and have their own resources.
544 The resource names for the menu bar contain @samp{pane.menubar}
545 (following, as always, the name of the Emacs invocation, or
546 @samp{Emacs}, which stands for all Emacs invocations). Specify them
550 Emacs.pane.menubar.@var{subwidget}.@var{resource}: @var{value}
553 Each individual string in the menu bar is a subwidget; the subwidget's
554 name is the same as the menu item string. For example, the word
555 @samp{File} in the menu bar is part of a subwidget named
556 @samp{emacs.pane.menubar.File}. Most likely, you want to specify the
557 same resources for the whole menu bar. To do this, use @samp{*} instead
558 of a specific subwidget name. For example, to specify the font
559 @samp{8x16} for the menu-bar items, write this:
562 Emacs.pane.menubar.*.fontList: 8x16
566 This also specifies the resource value for submenus.
568 Each item in a submenu in the menu bar also has its own name for X
569 resources; for example, the @samp{File} submenu has an item named
570 @samp{Save (current buffer)}. A resource specification for a submenu
571 item looks like this:
574 Emacs.pane.menubar.popup_*.@var{menu}.@var{item}.@var{resource}: @var{value}
578 For example, here's how to specify the font for the @samp{Save (current
582 Emacs.pane.menubar.popup_*.File.Save (current buffer).fontList: 8x16
586 For an item in a second-level submenu, such as @samp{Complete Word}
587 under @samp{Spell Checking} under @samp{Tools}, the resource fits this
591 Emacs.pane.menubar.popup_*.popup_*.@var{menu}.@var{resource}: @var{value}
598 Emacs.pane.menubar.popup_*.popup_*.Spell Checking.Complete Word: @var{value}
602 (This should be one long line.)
604 It's impossible to specify a resource for all the menu-bar items
605 without also specifying it for the submenus as well. So if you want the
606 submenu items to look different from the menu bar itself, you must ask
607 for that in two steps. First, specify the resource for all of them;
608 then, override the value for submenus alone. Here is an example:
611 Emacs.pane.menubar.*.fontList: 8x16
612 Emacs.pane.menubar.popup_*.fontList: 8x16
616 For LessTif pop-up menus, use @samp{menu*} instead of
617 @samp{pane.menubar}. For example, to specify the font @samp{8x16} for
618 the pop-up menu items, write this:
621 Emacs.menu*.fontList: 8x16
625 For LessTif dialog boxes, use @samp{dialog} instead of @samp{menu}:
628 Emacs.dialog*.fontList: 8x16
629 Emacs.dialog*.foreground: hotpink
632 To specify resources for the LessTif file-selection box, use
633 @samp{fsb*}, like this:
636 Emacs.fsb*.fontList: 8x16
642 Here is a list of the specific resources for LessTif menu bars and
647 The color to show in an armed button.
656 Amount of space to leave around the item, within the border.
658 The width of the border around the menu item, on all sides.
659 @item shadowThickness
660 The width of the border shadow.
661 @item bottomShadowColor
662 The color for the border shadow, on the bottom and the right.
664 The color for the border shadow, on the top and the left.
670 @appendixsec GTK resources
672 The most common way to customize the GTK widgets Emacs uses (menus, dialogs
673 tool bars and scroll bars) is by choosing an appropriate theme, for example
674 with the GNOME theme selector. You can also do Emacs specific customization
675 by inserting GTK style directives in the file @file{~/.emacs.d/gtkrc}. Some GTK
676 themes ignore customizations in @file{~/.emacs.d/gtkrc} so not everything
677 works with all themes. To customize Emacs font, background, faces, etc., use
678 the normal X resources (@pxref{Resources}). We will present some examples of
679 customizations here, but for a more detailed description, see the online manual
681 The first example is just one line. It changes the font on all GTK widgets
682 to courier with size 12:
685 gtk-font-name = "courier 12"
688 The thing to note is that the font name is not an X font name, like
689 -*-helvetica-medium-r-*--*-120-*-*-*-*-*-*, but a Pango font name. A Pango
690 font name is basically of the format "family style size", where the style
691 is optional as in the case above. A name with a style could be for example:
694 gtk-font-name = "helvetica bold 10"
697 To customize widgets you first define a style and then apply the style to
698 the widgets. Here is an example that sets the font for menus, but not
702 # @r{Define the style @samp{menufont}.}
705 font_name = "helvetica bold 14" # This is a Pango font name
708 # @r{Specify that widget type @samp{*emacs-menuitem*} uses @samp{menufont}.}
709 widget "*emacs-menuitem*" style "menufont"
712 The widget name in this example contains wildcards, so the style will be
713 applied to all widgets that match "*emacs-menuitem*". The widgets are
714 named by the way they are contained, from the outer widget to the inner widget.
715 So to apply the style "my_style" (not shown) with the full, absolute name, for
716 the menubar and the scroll bar in Emacs we use:
719 widget "Emacs.pane.menubar" style "my_style"
720 widget "Emacs.pane.emacs.verticalScrollBar" style "my_style"
723 But to avoid having to type it all, wildcards are often used. @samp{*}
724 matches zero or more characters and @samp{?} matches one character. So "*"
727 Each widget has a class (for example GtkMenuItem) and a name (emacs-menuitem).
728 You can assign styles by name or by class. In this example we have used the
734 font_name = "helvetica bold 14"
737 widget_class "*GtkMenuBar" style "menufont"
741 The names and classes for the GTK widgets Emacs uses are:
743 @multitable {@code{verticalScrollbar plus}} {@code{GtkFileSelection} and some}
744 @item @code{emacs-filedialog}
745 @tab @code{GtkFileSelection}
746 @item @code{emacs-dialog}
747 @tab @code{GtkDialog}
749 @tab @code{GtkWindow}
754 @item @code{verticalScrollBar}
755 @tab @code{GtkVScrollbar}
756 @item @code{emacs-toolbar}
757 @tab @code{GtkToolbar}
759 @tab @code{GtkMenuBar}
760 @item @code{emacs-menuitem}
761 @tab anything in menus
764 GTK absolute names are quite strange when it comes to menus
765 and dialogs. The names do not start with @samp{Emacs}, as they are
766 free-standing windows and not contained (in the GTK sense) by the
767 Emacs GtkWindow. To customize the dialogs and menus, use wildcards like this:
770 widget "*emacs-dialog*" style "my_dialog_style"
771 widget "*emacs-filedialog* style "my_file_style"
772 widget "*emacs-menuitem* style "my_menu_style"
775 If you specify a customization in @file{~/.emacs.d/gtkrc}, then it
776 automatically applies only to Emacs, since other programs don't read
777 that file. For example, the drop down menu in the file dialog can not
778 be customized by any absolute widget name, only by an absolute class
779 name. This is because the widgets in the drop down menu do not
780 have names and the menu is not contained in the Emacs GtkWindow. To
781 have all menus in Emacs look the same, use this in
782 @file{~/.emacs.d/gtkrc}:
785 widget_class "*Menu*" style "my_menu_style"
788 Here is a more elaborate example, showing how to change the parts of
794 fg[NORMAL] = "red"@ @ @ @ @ # @r{The arrow color.}
795 bg[NORMAL] = "yellow"@ @ # @r{The thumb and background around the arrow.}
796 bg[ACTIVE] = "blue"@ @ @ @ # @r{The trough color.}
797 bg[PRELIGHT] = "white"@ # @r{The thumb color when the mouse is over it.}
800 widget "*verticalScrollBar*" style "scroll"
805 @cindex GTK resources and customization
806 @cindex resource files for GTK
807 @cindex @file{~/.gtkrc-2.0} file
808 @cindex @file{~/.emacs.d/gtkrc} file
810 If Emacs was built to use the GTK widget set, then the menu bar, tool bar,
811 scroll bar and the dialogs are customized with the standard GTK
812 customization file, @file{~/.gtkrc-2.0}, or with the Emacs specific
813 file @file{~/.emacs.d/gtkrc}. We recommend that you use
814 @file{~/.emacs.d/gtkrc} for customizations, since @file{~/.gtkrc-2.0}
815 seems to be ignored when running GConf with GNOME. These files apply
816 only to GTK widget features. To customize Emacs font, background,
817 faces, etc., use the normal X resources (@pxref{Resources}).
819 Some GTK themes override these mechanisms, which means that using
820 these mechanisms will not work to customize them.
822 In these files you first define a style and say what it means; then
823 you specify to apply the style to various widget types (@pxref{GTK
824 widget names}). Here is an example of how to change the font for
828 # @r{Define the style @samp{menufont}.}
831 font_name = "helvetica bold 14" # This is a Pango font name
834 # @r{Specify that widget type @samp{*emacs-menuitem*} uses @samp{menufont}.}
835 widget "*emacs-menuitem*" style "menufont"
838 Here is a more elaborate example, showing how to change the parts of
844 fg[NORMAL] = "red"@ @ @ @ @ # @r{The arrow color.}
845 bg[NORMAL] = "yellow"@ @ # @r{The thumb and background around the arrow.}
846 bg[ACTIVE] = "blue"@ @ @ @ # @r{The trough color.}
847 bg[PRELIGHT] = "white"@ # @r{The thumb color when the mouse is over it.}
850 widget "*verticalScrollBar*" style "scroll"
853 There are also parameters that affect GTK as a whole. For example,
854 the property @code{gtk-font-name} sets the default font for GTK. You
855 must use Pango font names (@pxref{GTK styles}). A GTK resources file
856 that just sets a default font looks like this:
859 gtk-font-name = "courier 12"
862 The GTK resources file is fully described in the GTK API document.
864 @file{@var{prefix}/share/gtk-doc/html/gtk/gtk-resource-files.html},
865 where @file{prefix} is the directory in which the GTK libraries were
866 installed (usually @file{/usr} or @file{/usr/local}). You can also
867 find the document online, at
868 @uref{http://developer.gnome.org/doc/API/2.0/gtk/gtk-Resource-Files.html}.
871 * GTK widget names:: How widgets in GTK are named in general.
872 * GTK Names in Emacs:: GTK widget names in Emacs.
873 * GTK styles:: What can be customized in a GTK widget.
876 @node GTK widget names
877 @appendixsubsec GTK widget names
878 @cindex GTK widget names
880 A GTK widget is specified by its @dfn{widget class} and
881 @dfn{widget name}. The widget class is the type of the widget: for
882 example, @code{GtkMenuBar}. The widget name is the name given to a
883 specific widget. A widget always has a class, but need not have a
886 @dfn{Absolute names} are sequences of widget names or widget
887 classes, corresponding to hierarchies of widgets embedded within
888 other widgets. For example, if a @code{GtkWindow} named @code{top}
889 contains a @code{GtkVBox} named @code{box}, which in turn contains
890 a @code{GtkMenuBar} called @code{menubar}, the absolute class name
891 of the menu-bar widget is @code{GtkWindow.GtkVBox.GtkMenuBar}, and
892 its absolute widget name is @code{top.box.menubar}.
894 When assigning a style to a widget, you can use the absolute class
895 name or the absolute widget name.
897 There are two commands to specify changes for widgets:
900 @item @code{widget_class}
901 specifies a style for widgets based on the absolute class name.
904 specifies a style for widgets based on the absolute class name,
909 You must specify the class and the style in double-quotes, and put
910 these commands at the top level in the GTK customization file, like
916 font_name = "helvetica bold 14"
919 widget "top.box.menubar" style "menufont"
920 widget_class "GtkWindow.GtkVBox.GtkMenuBar" style "menufont"
923 Matching of absolute names uses shell wildcard syntax: @samp{*}
924 matches zero or more characters and @samp{?} matches one character.
925 This example assigns @code{base_style} to all widgets:
928 widget "*" style "base_style"
931 Given the absolute class name @code{GtkWindow.GtkVBox.GtkMenuBar}
932 and the corresponding absolute widget name @code{top.box.menubar}, all
933 these examples specify @code{my_style} for the menu bar:
936 widget_class "GtkWindow.GtkVBox.GtkMenuBar" style "my_style"
937 widget_class "GtkWindow.*.GtkMenuBar" style "my_style"
938 widget_class "*GtkMenuBar" style "my_style"
939 widget "top.box.menubar" style "my_style"
940 widget "*box*menubar" style "my_style"
941 widget "*menubar" style "my_style"
942 widget "*menu*" style "my_style"
945 @node GTK Names in Emacs
946 @appendixsubsec GTK Widget Names in Emacs
947 @cindex GTK widget names
948 @cindex GTK widget classes
950 In Emacs, the top level widget for a frame is a @code{GtkWindow}
951 that contains a @code{GtkVBox}. The @code{GtkVBox} contains the
952 @code{GtkMenuBar} and a @code{GtkFixed} widget. The vertical scroll
953 bars, @code{GtkVScrollbar}, are contained in the @code{GtkFixed}
954 widget. The text you write in Emacs is drawn in the @code{GtkFixed}
957 Dialogs in Emacs are @code{GtkDialog} widgets. The file dialog is a
958 @code{GtkFileSelection} widget.
961 To set a style for the menu bar using the absolute class name, use:
964 widget_class "GtkWindow.GtkVBox.GtkMenuBar" style "my_style"
968 For the scroll bar, the absolute class name is:
972 "GtkWindow.GtkVBox.GtkFixed.GtkVScrollbar"
977 The names for the emacs widgets, and their classes, are:
979 @multitable {@code{verticalScrollbar plus}} {@code{GtkFileSelection} and some}
980 @item @code{emacs-filedialog}
981 @tab @code{GtkFileSelection}
982 @item @code{emacs-dialog}
983 @tab @code{GtkDialog}
985 @tab @code{GtkWindow}
990 @item @code{verticalScrollBar}
991 @tab @code{GtkVScrollbar}
992 @item @code{emacs-toolbar}
993 @tab @code{GtkToolbar}
995 @tab @code{GtkMenuBar}
996 @item @code{emacs-menuitem}
997 @tab anything in menus
1001 Thus, for Emacs you can write the two examples above as:
1004 widget "Emacs.pane.menubar" style "my_style"
1005 widget "Emacs.pane.emacs.verticalScrollBar" style "my_style"
1008 GTK absolute names are quite strange when it comes to menus
1009 and dialogs. The names do not start with @samp{Emacs}, as they are
1010 free-standing windows and not contained (in the GTK sense) by the
1011 Emacs GtkWindow. To customize the dialogs and menus, use wildcards like this:
1014 widget "*emacs-dialog*" style "my_dialog_style"
1015 widget "*emacs-filedialog* style "my_file_style"
1016 widget "*emacs-menuitem* style "my_menu_style"
1019 If you specify a customization in @file{~/.emacs.d/gtkrc}, then it
1020 automatically applies only to Emacs, since other programs don't read
1021 that file. For example, the drop down menu in the file dialog can not
1022 be customized by any absolute widget name, only by an absolute class
1023 name. This is because the widgets in the drop down menu do not
1024 have names and the menu is not contained in the Emacs GtkWindow. To
1025 have all menus in Emacs look the same, use this in
1026 @file{~/.emacs.d/gtkrc}:
1029 widget_class "*Menu*" style "my_menu_style"
1033 @appendixsubsec GTK styles
1036 In a GTK style you specify the appearance widgets shall have. You
1037 can specify foreground and background color, background pixmap and
1038 font. The edit widget (where you edit the text) in Emacs is a GTK
1039 widget, but trying to specify a style for the edit widget will have no
1040 effect. This is so that Emacs compiled for GTK is compatible with
1041 Emacs compiled for other X toolkits. The settings for foreground,
1042 background and font for the edit widget is taken from the X resources;
1043 @pxref{Resources}. Here is an example of two style declarations,
1044 @samp{default} and @samp{ruler}:
1047 pixmap_path "/usr/share/pixmaps:/usr/include/X11/pixmaps"
1051 font_name = "helvetica 12"
1053 bg[NORMAL] = @{ 0.83, 0.80, 0.73 @}
1054 bg[SELECTED] = @{ 0.0, 0.55, 0.55 @}
1055 bg[INSENSITIVE] = @{ 0.77, 0.77, 0.66 @}
1056 bg[ACTIVE] = @{ 0.0, 0.55, 0.55 @}
1057 bg[PRELIGHT] = @{ 0.0, 0.55, 0.55 @}
1059 fg[NORMAL] = "black"
1060 fg[SELECTED] = @{ 0.9, 0.9, 0.9 @}
1061 fg[ACTIVE] = "black"
1062 fg[PRELIGHT] = @{ 0.9, 0.9, 0.9 @}
1064 base[INSENSITIVE] = "#777766"
1065 text[INSENSITIVE] = @{ 0.60, 0.65, 0.57 @}
1067 bg_pixmap[NORMAL] = "background.xpm"
1068 bg_pixmap[INSENSITIVE] = "background.xpm"
1069 bg_pixmap[ACTIVE] = "background.xpm"
1070 bg_pixmap[PRELIGHT] = "<none>"
1074 style "ruler" = "default"
1076 font_name = "helvetica 8"
1081 The style @samp{ruler} inherits from @samp{default}. This way you can build
1082 on existing styles. The syntax for fonts and colors is described below.
1084 As this example shows, it is possible to specify several values for
1085 foreground and background depending on the widget's @dfn{state}. The
1086 possible states are:
1090 This is the default state for widgets.
1092 This is the state for a widget that is ready to do something. It is
1093 also for the trough of a scroll bar, i.e. @code{bg[ACTIVE] = "red"}
1094 sets the scroll bar trough to red. Buttons that have been pressed but
1095 not released yet (``armed'') are in this state.
1097 This is the state for a widget that can be manipulated, when the mouse
1098 pointer is over it---for example when the mouse is over the thumb in
1099 the scroll bar or over a menu item. When the mouse is over a button
1100 that is not pressed, the button is in this state.
1102 This is the state for data that has been selected by the user. It can
1103 be selected text or items selected in a list. This state is not used
1106 This is the state for widgets that are visible, but they can not be
1107 manipulated in the usual way---for example, buttons that can't be
1108 pressed, and disabled menu items. To display disabled menu items in
1109 yellow, use @code{fg[INSENSITIVE] = "yellow"}.
1112 Here are the things that can go in a style declaration:
1115 @item bg[@var{state}] = @var{color}
1116 This specifies the background color for the widget. Note that
1117 editable text doesn't use @code{bg}; it uses @code{base} instead.
1119 @item base[@var{state}] = @var{color}
1120 This specifies the background color for editable text. In Emacs, this
1121 color is used for the background of the text fields in the file
1124 @item bg_pixmap[@var{state}] = "@var{pixmap}"
1125 This specifies an image background (instead of a background color).
1126 @var{pixmap} should be the image file name. GTK can use a number of
1127 image file formats, including XPM, XBM, GIF, JPEG and PNG. If you
1128 want a widget to use the same image as its parent, use
1129 @samp{<parent>}. If you don't want any image, use @samp{<none>}.
1130 @samp{<none>} is the way to cancel a background image inherited from a
1133 You can't specify the file by its absolute file name. GTK looks for
1134 the pixmap file in directories specified in @code{pixmap_path}.
1135 @code{pixmap_path} is a colon-separated list of directories within
1136 double quotes, specified at the top level in a @file{gtkrc} file
1137 (i.e. not inside a style definition; see example above):
1140 pixmap_path "/usr/share/pixmaps:/usr/include/X11/pixmaps"
1143 @item fg[@var{state}] = @var{color}
1144 This specifies the foreground color for widgets to use. It is the
1145 color of text in menus and buttons, and the color for the arrows in
1146 the scroll bar. For editable text, use @code{text}.
1148 @item text[@var{state}] = @var{color}
1149 This is the color for editable text. In Emacs, this color is used for the
1150 text fields in the file dialog.
1152 @item font_name = "@var{font}"
1153 This specifies the font for text in the widget. @var{font} is a
1154 Pango font name, for example @samp{Sans Italic 10}, @samp{Helvetica
1155 Bold 12}, @samp{Courier 14}, @samp{Times 18}. See below for exact
1156 syntax. The names are case insensitive.
1159 There are three ways to specify a color: by name, in hexadecimal
1160 form, and with an RGB triplet.
1163 A color name is written within double quotes, for example @code{"red"}.
1166 Hexadecimal form is the same as in X:
1167 @code{#@var{rrrr}@var{gggg}@var{bbbb}}, where all three color specs
1168 must have the same number of hex digits (1, 2, 3 or 4).
1171 An RGB triplet looks like @code{@{ @var{r}, @var{g}, @var{b} @}},
1172 where @var{r}, @var{g} and @var{b} are either integers in the range
1173 0-65535 or floats in the range 0.0-1.0.
1175 Pango font names have the form ``@var{family-list} @var{style-options}
1177 @cindex Pango font name
1179 @var{family-list} is a comma separated list of font families optionally
1180 terminated by a comma. This way you can specify several families and the
1181 first one found will be used. @var{family} corresponds to the second part in
1182 an X font name, for example in
1185 -adobe-times-medium-r-normal--12-120-75-75-p-64-iso10646-1
1189 the family name is @samp{times}.
1192 @var{style-options} is a whitespace separated list of words where each word
1193 is a style, variant, weight, or stretch. The default value for all of
1194 these is @code{normal}.
1197 A `style' corresponds to the fourth part of an X font name. In X font
1198 names it is the character @samp{r}, @samp{i} or @samp{o}; in Pango
1199 font names the corresponding values are @code{normal}, @code{italic},
1203 A `variant' is either @code{normal} or @code{small-caps}.
1204 Small caps is a font with the lower case characters replaced by
1205 smaller variants of the capital characters.
1208 Weight describes the ``boldness'' of a font. It corresponds to the third
1209 part of an X font name. It is one of @code{ultra-light}, @code{light},
1210 @code{normal}, @code{bold}, @code{ultra-bold}, or @code{heavy}.
1213 Stretch gives the width of the font relative to other designs within a
1214 family. It corresponds to the fifth part of an X font name. It is one of
1215 @code{ultra-condensed}, @code{extra-condensed}, @code{condensed},
1216 @code{semi-condensed}, @code{normal}, @code{semi-expanded},
1217 @code{expanded}, @code{extra-expanded}, or @code{ultra-expanded}.
1220 @var{size} is a decimal number that describes the font size in points.
1224 arch-tag: 9b6ff773-48b6-41f6-b2f9-f114b8bdd97f