www.delorie.com/gnu/docs/emacs/emacs_78.html   search  
Buy the book!

GNU Emacs Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

J.1 Using Multiple Typefaces

When using Emacs with a window system, you can set up multiple styles of displaying characters. Each style is called a face. Each face can specify various attributes, such as the height, weight and slant of the characters, the foreground and background color, and underlining. But it does not have to specify all of them.

Emacs on a character terminal supports only part of face attributes. Which attributes are supported depends on your display type, but many displays support inverse video, bold, and underline attributes, and some support colors.

Features which rely on text in multiple faces (such as Font Lock mode) will also work on non-windowed terminals that can display more than one face, whether by colors or underlining and emboldening. This includes the console on GNU/Linux, an xterm which supports colors, the MS-DOS display (see section AH. Emacs and MS-DOS), and the MS-Windows version invoked with the `-nw' option. Emacs determines automatically whether the terminal has this capability.

You control the appearance of a part of the text in the buffer by specifying the face or faces to use for it. The style of display used for any given character is determined by combining the attributes of all the applicable faces specified for that character. Any attribute that isn't specified by these faces is taken from the default face, whose attributes reflect the default settings of the frame itself.

Enriched mode, the mode for editing formatted text, includes several commands and menus for specifying faces for text in the buffer. See section T.11.4 Faces in Formatted Text, for how to specify the font for text in the buffer. See section T.11.5 Colors in Formatted Text, for how to specify the foreground and background color.

To alter the appearance of a face, use the customization buffer. See section AD.2.2.3 Customizing Faces. You can also use X resources to specify attributes of particular faces (see section AE.13 X Resources). Alternatively, you can change the foreground and background colors of a specific face with M-x set-face-foreground and M-x set-face-background. These commands prompt in the minibuffer for a face name and a color name, with completion, and then set that face to use the specified color. Changing the colors of the default face also changes the foreground and background colors on all frames, both existing and those to be created in the future. (You can also set foreground and background colors for the current frame only; see P.12 Setting Frame Parameters.)

Emacs 21 can correctly display variable-width fonts, but Emacs commands that calculate width and indentation do not know how to calculate variable widths. This can sometimes lead to incorrect results when you use variable-width fonts. In particular, indentation commands can give inconsistent results, so we recommend you avoid variable-width fonts for editing program source code. Filling will sometimes make lines too long or too short. We plan to address these issues in future Emacs versions.

To see what faces are currently defined, and what they look like, type M-x list-faces-display. It's possible for a given face to look different in different frames; this command shows the appearance in the frame in which you type it. Here's a list of the standard defined faces:

This face is used for ordinary text that doesn't specify any other face.
This face is used for mode lines. By default, it's drawn with shadows for a "raised" effect on window systems, and drawn as the inverse of the default face on non-windowed terminals. See section J.12 Customization of Display.
Similar to mode-line for a window's header line. Most modes don't use the header line, but the Info mode does.
This face is used for highlighting portions of text, in various modes. For example, mouse-sensitive text is highlighted using this face.
This face is used for highlighting Isearch matches.
This face is used for lazy highlighting of Isearch matches other than the current one.
This face is used for displaying a selected region (when Transient Mark mode is enabled--see below).
This face is used for displaying a secondary X selection (see section P.2 Secondary Selection).
This face uses a bold variant of the default font, if it has one.
This face uses an italic variant of the default font, if it has one.
This face uses a bold italic variant of the default font, if it has one.
This face underlines text.
The basic fixed-pitch face.
The face for the fringes to the left and right of windows on graphic displays. (The fringes are the narrow portions of the Emacs frame between the text area and the window's right and left borders.)
This face determines the visual appearance of the scroll bar.
This face determines the color of the frame border.
This face determines the color of the cursor.
This face determines the color of the mouse pointer.
This is the basic tool-bar face. No text appears in the tool bar, but the colors of this face affect the appearance of tool bar icons.
This face is used for tooltips.
This face determines the colors and font of Emacs's menus. Setting the font of LessTif/Motif menus is currently not supported; attempts to set the font are ignored in this case.
The face for highlighting trailing whitespace when show-trailing-whitespace is non-nil; see J.5 Trailing Whitespace.
The basic variable-pitch face.

When Transient Mark mode is enabled, the text of the region is highlighted when the mark is active. This uses the face named region; you can control the style of highlighting by changing the style of this face (see section AD.2.2.3 Customizing Faces). See section H.2 Transient Mark Mode, for more information about Transient Mark mode and activation and deactivation of the mark.

One easy way to use faces is to turn on Font Lock mode. This minor mode, which is always local to a particular buffer, arranges to choose faces according to the syntax of the text you are editing. It can recognize comments and strings in most languages; in several languages, it can also recognize and properly highlight various other important constructs. See section J.2 Font Lock mode, for more information about Font Lock mode and syntactic highlighting.

You can print out the buffer with the highlighting that appears on your screen using the command ps-print-buffer-with-faces. See section AC.19 PostScript Hardcopy.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003