D.1 X Resources
Programs running under the X Window System organize their user
options under a hierarchy of classes and resources. You can specify
default values for these options in your X resources file, usually
named ~/.Xdefaults or ~/.Xresources.
If changes in ~/.Xdefaults do not
take effect, it is because your X server stores its own list of
resources; to update them, use the shell command xrdb—for
instance, ‘xrdb ~/.Xdefaults’.
Each line in the file specifies a value for one option or for a
collection of related options, for one program or for several programs
(optionally even for all programs).
MS-Windows systems don't support ~/.Xdefaults files, but
Emacs compiled for Windows looks for X resources in the Windows
Registry, under the key ‘HKEY_CURRENT_USER\SOFTWARE\GNU\Emacs’
and then under the key ‘HKEY_LOCAL_MACHINE\SOFTWARE\GNU\Emacs’.
The menu and scrollbars are native widgets on MS-Windows, so they are
only customizable via the system-wide settings in the Display Control
Panel. You can also set resources using the ‘-xrm’ command line
option (see below.)
Programs define named resources with particular meanings. They also
define how to group resources into named classes. For instance, in
Emacs, the ‘internalBorder’ resource controls the width of the
internal border, and the ‘borderWidth’ resource controls the width
of the external border. Both of these resources are part of the
‘BorderWidth’ class. Case distinctions are significant in these
Every resource definition is associated with a specific program
name—the name of the executable file that you ran. For Emacs, that
is normally ‘emacs’. To specify a definition for all instances
of Emacs, regardless of their names, use ‘Emacs’.
In ~/.Xdefaults, you can specify a value for a single resource
on one line, like this:
Or you can use a class name to specify the same value for all resources
in that class. Here's an example:
If you specify a value for a class, it becomes the default for all
resources in that class. You can specify values for individual
resources as well; these override the class value, for those particular
resources. Thus, this example specifies 2 as the default width for all
borders, but overrides this value with 4 for the external border:
The order in which the lines appear in the file does not matter.
Also, command-line options always override the X resources file.
Here is a list of X command-line options and their corresponding
- ‘-name name’
- Use name as the resource name (and the title) for the initial
Emacs frame. This option does not affect subsequent frames, but Lisp
programs can specify frame names when they create frames.
If you don't specify this option, the default is to use the Emacs
executable's name as the resource name.
- ‘-xrm resource-values’
- Specify X resource values for this Emacs job (see below).
For consistency, ‘-name’ also specifies the name to use for
other resource values that do not belong to any particular frame.
The resources that name Emacs invocations also belong to a class; its
name is ‘Emacs’. If you write ‘Emacs’ instead of
‘emacs’, the resource applies to all frames in all Emacs jobs,
regardless of frame titles and regardless of the name of the executable
file. Here is an example:
You can specify a string of additional resource values for Emacs to
use with the command line option ‘-xrm resources’. The text
resources should have the same format that you would use inside a file
of X resources. To include multiple resource specifications in
resources, put a newline between them, just as you would in a file.
You can also use ‘#include "filename"’ to include a file full
of resource specifications. Resource values specified with ‘-xrm’
take precedence over all other resource specifications.
One way to experiment with the effect of different resource settings
is to use the
editres program. Select ‘Get Tree’ from the
‘Commands’ menu, then click on an Emacs frame. This will display
a tree showing the structure of X toolkit widgets used in an Emacs
frame. Select one of them, such as ‘menubar’, then select
‘Show Resource Box’ from the ‘Commands’ menu. This displays
a list of all the meaningful X resources and allows you to edit them.
Changes take effect immediately if you click on the ‘Apply’ button.
editres man page for more details.)