Clarify last change.
[bpt/emacs.git] / doc / emacs / xresources.texi
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
7
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}.
12
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.
25
26 @c Add xref for LessTif/Motif menu resources.
27 @end iftex
28
29
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
38
39 @node Resources
40 @appendixsec X Resources
41 @cindex resources
42 @cindex X resources
43 @cindex @file{~/.Xdefaults} file
44 @cindex @file{~/.Xresources} file
45
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}.
53
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.)
63
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:
69
70 @example
71 emacs.borderWidth: 2
72 @end example
73
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}.
79
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.
83
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:
91
92 @example
93 emacs.BorderWidth: 2
94 @end example
95
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:
102
103 @example
104 emacs.BorderWidth: 2
105 emacs.borderWidth: 4
106 @end example
107 @end ifnottex
108
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.
111
112 @ifnottex
113 The following X command-line options affect how X resources are
114 processed:
115
116 @table @samp
117 @item -name @var{name}
118 @opindex --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.
124
125 If you don't specify this option, the default is to use the Emacs
126 executable's name as the program name.
127
128 For consistency, @samp{-name} also specifies the name to use for other
129 resource values that do not belong to any particular frame.
130
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
135 executable file.
136
137 @item -xrm @var{resource-values}
138 @opindex --xrm
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.
142
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.
150 @end table
151 @end ifnottex
152
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
155 for more details.
156
157 @node Table of Resources
158 @appendixsec Table of X Resources for Emacs
159
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:
163
164 @table @asis
165 @item @code{background} (class @code{Background})
166 Background color name.
167
168 @ifnottex
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}.
172 @end ifnottex
173
174 @item @code{borderColor} (class @code{BorderColor})
175 Color name for the external border.
176
177 @ifnottex
178 @item @code{borderWidth} (class @code{BorderWidth})
179 Width in pixels of the external border.
180 @end ifnottex
181
182 @item @code{cursorColor} (class @code{Foreground})
183 Color name for text cursor (point).
184
185 @ifnottex
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.
189 @end ifnottex
190
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}).
194
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
202 graphical device.
203
204 @item @code{foreground} (class @code{Foreground})
205 Color name for text.
206
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.
211
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
215 all frames.
216
217 @ifnottex
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}).
223
224 Note that this applies to the initial frame only.
225 @end ifnottex
226
227 @item @code{iconName} (class @code{Title})
228 Name to display in the icon.
229
230 @item @code{internalBorder} (class @code{BorderWidth})
231 Width in pixels of the internal border.
232
233 @item @code{lineSpacing} (class @code{LineSpacing})
234 @cindex line spacing
235 @cindex leading
236 Additional space (@dfn{leading}) between lines, in pixels.
237
238 @item @code{menuBar} (class @code{MenuBar})
239 @cindex menu bar
240 Give frames menu bars if @samp{on}; don't have menu bars if @samp{off}.
241 @ifnottex
242 @xref{Lucid Resources}, and @ref{LessTif Resources},
243 @end ifnottex
244 @iftex
245 @xref{Lucid Resources},
246 @end iftex
247 for how to control the appearance of the menu bar if you have one.
248
249 @ifnottex
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.
253
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.
257 @end ifnottex
258
259 @item @code{pointerColor} (class @code{Foreground})
260 Color of the mouse cursor.
261
262 @ifnottex
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.
266
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}.
270 @end ifnottex
271
272 @item @code{screenGamma} (class @code{ScreenGamma})
273 @cindex gamma correction
274 Gamma correction for colors, equivalent to the frame parameter
275 @code{screen-gamma}.
276
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}.
281
282 @ifnottex
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
286 Resources}.)
287
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.
292
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.
298 @end ifnottex
299
300 @item @code{title} (class @code{Title})
301 Name to display in the title bar of the initial Emacs frame.
302
303 @item @code{toolBar} (class @code{ToolBar})
304 @cindex tool bar
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}.
312
313 @item @code{useXIM} (class @code{UseXIM})
314 @cindex XIM
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.
321
322 @item @code{verticalScrollBars} (class @code{ScrollBars})
323 Give frames scroll bars if @samp{on}; don't have scroll bars if
324 @samp{off}.
325
326 @ifnottex
327 @item @code{visualClass} (class @code{VisualClass})
328 Specify the ``visual'' that X should use. This tells X how to handle
329 colors.
330
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.
337 @end ifnottex
338 @end table
339
340 @node Face Resources
341 @appendixsec X Resources for Faces
342
343 You can use resources to customize the appearance of particular
344 faces (@pxref{Faces}):
345
346 @table @code
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
353 yes.
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.
368 @end table
369
370 Instead of using @code{attributeFont} to specify a font name, you can
371 select a font through these separate attributes:
372
373 @table @code
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
390 yes.
391 @item @var{face}.attributeItalic
392 Italic flag for face @var{face}---instead of @code{attributeSlant}.
393 @end table
394
395 @node Lucid Resources
396 @appendixsec Lucid Menu X Resources
397 @cindex Menu X Resources (Lucid widgets)
398 @cindex Lucid Widget X Resources
399
400 @ifnottex
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:
406
407 @example
408 Emacs.pane.menubar.@var{resource}: @var{value}
409 @end example
410
411 @noindent
412 For example, to specify the font @samp{8x16} for the menu-bar items,
413 write this:
414 @end ifnottex
415 @iftex
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:
421 @end iftex
422
423 @example
424 Emacs.pane.menubar.font: 8x16
425 @end example
426
427 @noindent
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:
431
432 @example
433 Emacs.menu*.font: 8x16
434 @end example
435
436 @noindent
437 For dialog boxes, use @samp{dialog*}:
438
439 @example
440 Emacs.dialog*.font: 8x16
441 @end example
442
443 @noindent
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.
450
451 Thus, to specify @samp{-*-helvetica-medium-r-*--*-120-*-*-*-*-*-*,*}
452 for both the popup and menu bar menus, write this:
453
454 @example
455 Emacs*menu*fontSet: -*-helvetica-medium-r-*--*-120-*-*-*-*-*-*,*
456 @end example
457
458 @noindent
459 The @samp{*menu*} as a wildcard matches @samp{pane.menubar} and
460 @samp{menu@dots{}}.
461
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.
466
467 Here is a list of the specific resources for menu bars and pop-up menus:
468
469 @table @code
470 @item font
471 Font for menu item text.
472 @item fontSet
473 Fontset for menu item text.
474 @item foreground
475 Color of the foreground.
476 @item background
477 Color of the background.
478 @item buttonForeground
479 In the menu bar, the color of the foreground for a selected item.
480 @ifnottex
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.
485 @item arrowSpacing
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.
490
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
497 on the contrast.
498 @end ifnottex
499 @item margin
500 The margin of the menu bar, in characters. Default is 1.
501 @end table
502
503 @ifnottex
504 @node LessTif Resources
505 @appendixsec LessTif Menu X Resources
506 @cindex Menu X Resources (LessTif widgets)
507 @cindex LessTif Widget X Resources
508
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.
513
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
517 like this:
518
519 @smallexample
520 Emacs.pane.menubar.@var{subwidget}.@var{resource}: @var{value}
521 @end smallexample
522
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:
530
531 @smallexample
532 Emacs.pane.menubar.*.fontList: 8x16
533 @end smallexample
534
535 @noindent
536 This also specifies the resource value for submenus.
537
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:
542
543 @smallexample
544 Emacs.pane.menubar.popup_*.@var{menu}.@var{item}.@var{resource}: @var{value}
545 @end smallexample
546
547 @noindent
548 For example, here's how to specify the font for the @samp{Save (current
549 buffer)} item:
550
551 @smallexample
552 Emacs.pane.menubar.popup_*.File.Save (current buffer).fontList: 8x16
553 @end smallexample
554
555 @noindent
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
558 template:
559
560 @smallexample
561 Emacs.pane.menubar.popup_*.popup_*.@var{menu}.@var{resource}: @var{value}
562 @end smallexample
563
564 @noindent
565 For example,
566
567 @smallexample
568 Emacs.pane.menubar.popup_*.popup_*.Spell Checking.Complete Word: @var{value}
569 @end smallexample
570
571 @noindent
572 (This should be one long line.)
573
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:
579
580 @smallexample
581 Emacs.pane.menubar.*.fontList: 8x16
582 Emacs.pane.menubar.popup_*.fontList: 8x16
583 @end smallexample
584
585 @noindent
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:
589
590 @smallexample
591 Emacs.menu*.fontList: 8x16
592 @end smallexample
593
594 @noindent
595 For LessTif dialog boxes, use @samp{dialog} instead of @samp{menu}:
596
597 @example
598 Emacs.dialog*.fontList: 8x16
599 Emacs.dialog*.foreground: hotpink
600 @end example
601
602 To specify resources for the LessTif file-selection box, use
603 @samp{fsb*}, like this:
604
605 @example
606 Emacs.fsb*.fontList: 8x16
607 @end example
608
609 @iftex
610 @medbreak
611 @end iftex
612 Here is a list of the specific resources for LessTif menu bars and
613 pop-up menus:
614
615 @table @code
616 @item armColor
617 The color to show in an armed button.
618 @item fontList
619 The font to use.
620 @item marginBottom
621 @itemx marginHeight
622 @itemx marginLeft
623 @itemx marginRight
624 @itemx marginTop
625 @itemx marginWidth
626 Amount of space to leave around the item, within the border.
627 @item borderWidth
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.
633 @item topShadowColor
634 The color for the border shadow, on the top and the left.
635 @end table
636 @end ifnottex
637
638
639 @node GTK resources
640 @appendixsec GTK resources
641 @iftex
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
650
651 The first example is just one line. It changes the font on all GTK widgets
652 to courier with size 12:
653
654 @smallexample
655 gtk-font-name = "courier 12"
656 @end smallexample
657
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:
662
663 @smallexample
664 gtk-font-name = "helvetica bold 10"
665 @end smallexample
666
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
669 for other widgets:
670
671 @smallexample
672 # @r{Define the style @samp{menufont}.}
673 style "menufont"
674 @{
675 font_name = "helvetica bold 14" # This is a Pango font name
676 @}
677
678 # @r{Specify that widget type @samp{*emacs-menuitem*} uses @samp{menufont}.}
679 widget "*emacs-menuitem*" style "menufont"
680 @end smallexample
681
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:
687
688 @smallexample
689 widget "Emacs.pane.menubar" style "my_style"
690 widget "Emacs.pane.emacs.verticalScrollBar" style "my_style"
691 @end smallexample
692
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 "*"
695 matches all widgets.
696
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
699 class:
700
701 @smallexample
702 style "menufont"
703 @{
704 font_name = "helvetica bold 14"
705 @}
706
707 widget_class "*GtkMenuBar" style "menufont"
708 @end smallexample
709
710 @noindent
711 The names and classes for the GTK widgets Emacs uses are:
712
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}
718 @item @code{Emacs}
719 @tab @code{GtkWindow}
720 @item @code{pane}
721 @tab @code{GtkVHbox}
722 @item @code{emacs}
723 @tab @code{GtkFixed}
724 @item @code{verticalScrollBar}
725 @tab @code{GtkVScrollbar}
726 @item @code{emacs-toolbar}
727 @tab @code{GtkToolbar}
728 @item @code{menubar}
729 @tab @code{GtkMenuBar}
730 @item @code{emacs-menuitem}
731 @tab anything in menus
732 @end multitable
733
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:
738
739 @smallexample
740 widget "*emacs-dialog*" style "my_dialog_style"
741 widget "*emacs-filedialog* style "my_file_style"
742 widget "*emacs-menuitem* style "my_menu_style"
743 @end smallexample
744
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}:
753
754 @smallexample
755 widget_class "*Menu*" style "my_menu_style"
756 @end smallexample
757
758 Here is a more elaborate example, showing how to change the parts of
759 the scroll bar:
760
761 @smallexample
762 style "scroll"
763 @{
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.}
768 @}
769
770 widget "*verticalScrollBar*" style "scroll"
771 @end smallexample
772 @end iftex
773
774 @ifnottex
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
779
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}).
788
789 Some GTK themes override these mechanisms, which means that using
790 these mechanisms will not work to customize them.
791
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
795 Emacs menus:
796
797 @smallexample
798 # @r{Define the style @samp{menufont}.}
799 style "menufont"
800 @{
801 font_name = "helvetica bold 14" # This is a Pango font name
802 @}
803
804 # @r{Specify that widget type @samp{*emacs-menuitem*} uses @samp{menufont}.}
805 widget "*emacs-menuitem*" style "menufont"
806 @end smallexample
807
808 Here is a more elaborate example, showing how to change the parts of
809 the scroll bar:
810
811 @smallexample
812 style "scroll"
813 @{
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.}
818 @}
819
820 widget "*verticalScrollBar*" style "scroll"
821 @end smallexample
822
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:
827
828 @smallexample
829 gtk-font-name = "courier 12"
830 @end smallexample
831
832 The GTK resources file is fully described in the GTK API document.
833 This can be found in
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}.
839
840 @menu
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.
844 @end menu
845
846 @node GTK widget names
847 @appendixsubsec GTK widget names
848 @cindex GTK widget names
849
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
854 name.
855
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}.
863
864 When assigning a style to a widget, you can use the absolute class
865 name or the absolute widget name.
866
867 There are two commands to specify changes for widgets:
868
869 @table @asis
870 @item @code{widget_class}
871 specifies a style for widgets based on the absolute class name.
872
873 @item @code{widget}
874 specifies a style for widgets based on the absolute class name,
875 or just the class.
876 @end table
877
878 @noindent
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
881 this:
882
883 @smallexample
884 style "menufont"
885 @{
886 font_name = "helvetica bold 14"
887 @}
888
889 widget "top.box.menubar" style "menufont"
890 widget_class "GtkWindow.GtkVBox.GtkMenuBar" style "menufont"
891 @end smallexample
892
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:
896
897 @smallexample
898 widget "*" style "base_style"
899 @end smallexample
900
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:
904
905 @smallexample
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"
913 @end smallexample
914
915 @node GTK Names in Emacs
916 @appendixsubsec GTK Widget Names in Emacs
917 @cindex GTK widget names
918 @cindex GTK widget classes
919
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}
925 widget.
926
927 Dialogs in Emacs are @code{GtkDialog} widgets. The file dialog is a
928 @code{GtkFileSelection} widget.
929
930 @noindent
931 To set a style for the menu bar using the absolute class name, use:
932
933 @smallexample
934 widget_class "GtkWindow.GtkVBox.GtkMenuBar" style "my_style"
935 @end smallexample
936
937 @noindent
938 For the scroll bar, the absolute class name is:
939
940 @smallexample
941 widget_class
942 "GtkWindow.GtkVBox.GtkFixed.GtkVScrollbar"
943 style "my_style"
944 @end smallexample
945
946 @noindent
947 The names for the emacs widgets, and their classes, are:
948
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}
954 @item @code{Emacs}
955 @tab @code{GtkWindow}
956 @item @code{pane}
957 @tab @code{GtkVHbox}
958 @item @code{emacs}
959 @tab @code{GtkFixed}
960 @item @code{verticalScrollBar}
961 @tab @code{GtkVScrollbar}
962 @item @code{emacs-toolbar}
963 @tab @code{GtkToolbar}
964 @item @code{menubar}
965 @tab @code{GtkMenuBar}
966 @item @code{emacs-menuitem}
967 @tab anything in menus
968 @end multitable
969
970 @noindent
971 Thus, for Emacs you can write the two examples above as:
972
973 @smallexample
974 widget "Emacs.pane.menubar" style "my_style"
975 widget "Emacs.pane.emacs.verticalScrollBar" style "my_style"
976 @end smallexample
977
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:
982
983 @smallexample
984 widget "*emacs-dialog*" style "my_dialog_style"
985 widget "*emacs-filedialog* style "my_file_style"
986 widget "*emacs-menuitem* style "my_menu_style"
987 @end smallexample
988
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}:
997
998 @smallexample
999 widget_class "*Menu*" style "my_menu_style"
1000 @end smallexample
1001
1002 @node GTK styles
1003 @appendixsubsec GTK styles
1004 @cindex GTK styles
1005
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}:
1015
1016 @smallexample
1017 pixmap_path "/usr/share/pixmaps:/usr/include/X11/pixmaps"
1018
1019 style "default"
1020 @{
1021 font_name = "helvetica 12"
1022
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 @}
1028
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 @}
1033
1034 base[INSENSITIVE] = "#777766"
1035 text[INSENSITIVE] = @{ 0.60, 0.65, 0.57 @}
1036
1037 bg_pixmap[NORMAL] = "background.xpm"
1038 bg_pixmap[INSENSITIVE] = "background.xpm"
1039 bg_pixmap[ACTIVE] = "background.xpm"
1040 bg_pixmap[PRELIGHT] = "<none>"
1041
1042 @}
1043
1044 style "ruler" = "default"
1045 @{
1046 font_name = "helvetica 8"
1047 @}
1048
1049 @end smallexample
1050
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.
1053
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:
1057
1058 @table @code
1059 @item NORMAL
1060 This is the default state for widgets.
1061 @item ACTIVE
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.
1066 @item PRELIGHT
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.
1071 @item SELECTED
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
1074 in Emacs.
1075 @item INSENSITIVE
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"}.
1080 @end table
1081
1082 Here are the things that can go in a style declaration:
1083
1084 @table @code
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.
1088
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
1092 dialog.
1093
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
1101 parent style.
1102
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):
1108
1109 @smallexample
1110 pixmap_path "/usr/share/pixmaps:/usr/include/X11/pixmaps"
1111 @end smallexample
1112
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}.
1117
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.
1121
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.
1127 @end table
1128
1129 There are three ways to specify a color: by name, in hexadecimal
1130 form, and with an RGB triplet.
1131
1132 @noindent
1133 A color name is written within double quotes, for example @code{"red"}.
1134
1135 @noindent
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).
1139
1140 @noindent
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.
1144
1145 Pango font names have the form ``@var{family-list} @var{style-options}
1146 @var{size}.''
1147 @cindex Pango font name
1148 @noindent
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
1153
1154 @smallexample
1155 -adobe-times-medium-r-normal--12-120-75-75-p-64-iso10646-1
1156 @end smallexample
1157
1158 @noindent
1159 the family name is @samp{times}.
1160
1161 @noindent
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}.
1165
1166 @noindent
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},
1170 or @code{oblique}.
1171
1172 @noindent
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.
1176
1177 @noindent
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}.
1181
1182 @noindent
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}.
1188
1189 @noindent
1190 @var{size} is a decimal number that describes the font size in points.
1191 @end ifnottex
1192
1193 @ignore
1194 arch-tag: 9b6ff773-48b6-41f6-b2f9-f114b8bdd97f
1195 @end ignore