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