aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Moellmann2001-03-05 19:59:46 +0000
committerGerd Moellmann2001-03-05 19:59:46 +0000
commitb8f3a9e368013814af8a4b325f254bc76d500e05 (patch)
tree903cb31a368d1ded242a11fda3ea7e46a7ad37ff
parent34359f61f208430e9f7820efca0c5a071ee4da40 (diff)
downloademacs-b8f3a9e368013814af8a4b325f254bc76d500e05.tar.gz
emacs-b8f3a9e368013814af8a4b325f254bc76d500e05.zip
(Faces, Font Lock, Highlight Changes)
(Highlight Interactively, Trailing Whitespace): Moved here from frames.texi. (Faces): Changes for new face implementation. (Font Lock): Remove dscription of M-g M-g since it isn't necessary with jit-lock being the default.
-rw-r--r--man/display.texi367
1 files changed, 366 insertions, 1 deletions
diff --git a/man/display.texi b/man/display.texi
index 2778d4fe060..e7b0519bd5d 100644
--- a/man/display.texi
+++ b/man/display.texi
@@ -1,5 +1,6 @@
1@c This is part of the Emacs manual. 1@c This is part of the Emacs manual.
2@c Copyright (C) 1985, 86, 87, 93, 94, 95, 1997, 2000 Free Software Foundation, Inc. 2@c Copyright (C) 1985, 86, 87, 93, 94, 95, 1997, 2000, 2001
3@c Free Software Foundation, Inc.
3@c See file emacs.texi for copying conditions. 4@c See file emacs.texi for copying conditions.
4@node Display, Search, Registers, Top 5@node Display, Search, Registers, Top
5@chapter Controlling the Display 6@chapter Controlling the Display
@@ -10,6 +11,11 @@ allow you to specify which part of the text you want to see, and how to
10display it. 11display it.
11 12
12@menu 13@menu
14* Faces:: How to change the display style using faces.
15* Font Lock:: Minor mode for syntactic highlighting using faces.
16* Highlight Changes:: Using colors to show where you changed the buffer.
17* Highlight Interactively:: Tell Emacs what text to highlight.
18* Trailing Whitespace:: Showing possibly-spurious trailing whitespace.
13* Scrolling:: Moving text up and down in a window. 19* Scrolling:: Moving text up and down in a window.
14* Horizontal Scrolling:: Moving text left and right in a window. 20* Horizontal Scrolling:: Moving text left and right in a window.
15* Follow Mode:: Follow mode lets two windows scroll as one. 21* Follow Mode:: Follow mode lets two windows scroll as one.
@@ -20,6 +26,365 @@ display it.
20* Cursor Display:: Features for displaying the cursor. 26* Cursor Display:: Features for displaying the cursor.
21@end menu 27@end menu
22 28
29@node Faces
30@section Using Multiple Typefaces
31@cindex faces
32
33 When using Emacs with a window system, you can set up multiple
34styles of displaying characters. Some of the aspects of style that
35you can control are the type font, the foreground color, the
36background color, and whether or not to underline text, and in which
37color.
38
39 Features which rely on text in multiple faces (such as Font Lock
40mode) will also work on non-windowed terminals (including
41MS-DOS@pxref{MS-DOS}), that can display more than one face, whether by
42colors or underlining and emboldening. This includes the console on
43GNU/Linux. Emacs determines automatically whether the terminal has
44this capability.
45
46 The way you control display style is by defining named @dfn{faces}.
47Each face can specify various attributes, like the type font's height,
48weight and slant, foreground and background color, and underlining,
49but it does not have to specify all of them. By specifying the face
50or faces to use for a given part of the text in the buffer, you
51control how that text appears.
52
53 The style of display used for a given character in the text is
54determined by combining several faces. Any aspect of the display
55style that isn't specified by overlays or text properties comes from a
56default face which inherits its settings from the frame itself.
57
58 Enriched mode, the mode for editing formatted text, includes several
59commands and menus for specifying faces. @xref{Format Faces}, for how
60to specify the font for text in the buffer. @xref{Format Colors}, for
61how to specify the foreground and background color.
62
63 To alter the appearance of a face, use the customization buffer.
64@xref{Face Customization}. You can also use X resources to specify
65attributes of particular faces (@pxref{Resources X}).
66
67@cindex face colors, setting
68@findex set-face-foreground
69@findex set-face-background
70 Alternatively, you can change the foreground and background colors
71of a specific face with @kbd{M-x set-face-foreground} and @kbd{M-x
72set-face-background}. These commands prompt in the minibuffer for a
73face name and a color name, with completion, and then set that face to
74use the specified color.
75
76@findex list-faces-display
77 To see what faces are currently defined, and what they look like, type
78@kbd{M-x list-faces-display}. It's possible for a given face to look
79different in different frames; this command shows the appearance in the
80frame in which you type it. Here's a list of the standardly defined
81faces:
82
83@table @code
84@item default
85This face is used for ordinary text that doesn't specify any other face.
86@item mode-line
87This face is used for mode lines. By default, it's drawn with shadows
88for a ``raised'' effect on window systems, and drawn as the inverse of
89the default face on non-windowed terminals. @xref{Display Custom}.
90@item header-line
91Similar to @code{mode-line} for a window's header line. Most modes
92don't use the header line, but the Info mode does.
93@item highlight
94This face is used for highlighting portions of text, in various modes.
95For example, mouse-sensitive text is highlighted using this face.
96@item isearch
97This face is used for highlighting Isearch matches.
98@item isearch-lazy-highlight-face
99This face is used for lazy highlighting of Isearch matches other than
100the current one.
101@item region
102This face is used for displaying a selected region (when Transient Mark
103mode is enabled---see below).
104@item secondary-selection
105This face is used for displaying a secondary X selection (@pxref{Secondary
106Selection}).
107@item bold
108This face uses a bold variant of the default font, if it has one.
109@item italic
110This face uses an italic variant of the default font, if it has one.
111@item bold-italic
112This face uses a bold italic variant of the default font, if it has one.
113@item underline
114This face underlines text.
115@item fixed-pitch
116The basic fixed-pitch face.
117@item fringe
118@cindex fringe
119The face for the fringes to the left and right of windows on graphic
120displays. (The fringes are the narrow portions of the Emacs frame
121between the text area and the frame's border.)
122@item scroll-bar
123This face determines the visual appearance of the scroll bar.
124@item border
125This face determines the color of the frame border.
126@item cursor
127This face determines the color of the cursor.
128@item mouse
129This face determines the color of the mouse pointer.
130@item tool-bar
131This is the basic tool-bar face. No text appears in the tool bar, but the
132colors of this face affect the appearance of tool bar icons.
133@item tooltip
134This face is used for tooltips.
135@item menu
136This face determines the colors and font of Emacs's menus. Setting the
137font of LessTif/Motif menus is currently not supported; attempts to set
138the font are ignored in this case.
139@item trailing-whitespace
140The face for highlighting trailing whitespace when
141@code{show-trailing-whitespace} is non-nil.
142@item variable-pitch
143The basic variable-pitch face.
144@end table
145
146@cindex @code{region} face
147 When Transient Mark mode is enabled, the text of the region is
148highlighted when the mark is active. This uses the face named
149@code{region}; you can control the style of highlighting by changing the
150style of this face (@pxref{Face Customization}). @xref{Transient Mark},
151for more information about Transient Mark mode and activation and
152deactivation of the mark.
153
154 One easy way to use faces is to turn on Font Lock mode. This minor
155mode, which is always local to a particular buffer, arranges to
156choose faces according to the syntax of the text you are editing. It
157can recognize comments and strings in most languages; in several
158languages, it can also recognize and properly highlight various other
159important constructs. @xref{Font Lock}, for more information about
160Font Lock mode and syntactic highlighting.
161
162 You can print out the buffer with the highlighting that appears
163on your screen using the command @code{ps-print-buffer-with-faces}.
164@xref{PostScript}.
165
166@node Font Lock
167@section Font Lock mode
168@cindex Font Lock mode
169@cindex mode, Font Lock
170@cindex syntax highlighting and coloring
171
172 Font Lock mode is a minor mode, always local to a particular
173buffer, which highlights (or ``fontifies'') using various faces
174according to the syntax of the text you are editing. It can
175recognize comments and strings in most languages; in several
176languages, it can also recognize and properly highlight various other
177important constructs---for example, names of functions being defined
178or reserved keywords.
179
180@findex font-lock-mode
181@findex turn-on-font-lock
182 The command @kbd{M-x font-lock-mode} turns Font Lock mode on or off
183according to the argument, and toggles the mode when it has no argument.
184The function @code{turn-on-font-lock} unconditionally enables Font Lock
185mode. This is useful in mode-hook functions. For example, to enable
186Font Lock mode whenever you edit a C file, you can do this:
187
188@example
189(add-hook 'c-mode-hook 'turn-on-font-lock)
190@end example
191
192@findex global-font-lock-mode
193@vindex global-font-lock-mode
194 To turn on Font Lock mode automatically in all modes which support
195it, customize the user option @code{global-font-lock-mode} or use the
196function @code{global-font-lock-mode} in your @file{.emacs} file, like
197this:
198
199@example
200(global-font-lock-mode 1)
201@end example
202
203 Font Lock mode uses several specifically named faces to do its job,
204including @code{font-lock-string-face}, @code{font-lock-comment-face},
205and others. The easiest way to find them all is to use completion
206on the face name in @code{set-face-foreground}.
207
208 To change the colors or the fonts used by Font Lock mode to fontify
209different parts of text, just change these faces. There are
210two ways to do it:
211
212@itemize @bullet
213@item
214Invoke @kbd{M-x set-face-foreground} or @kbd{M-x set-face-background}
215to change the colors of a particular face used by Font Lock.
216@xref{Faces}. The command @kbd{M-x list-faces-display} displays all
217the faces currently known to Emacs, including those used by Font Lock.
218
219@item
220Customize the faces interactively with @kbd{M-x customize-face}, as
221described in @ref{Face Customization}.
222@end itemize
223
224 To get the full benefit of Font Lock mode, you need to choose a
225default font which has bold, italic, and bold-italic variants; or else
226you need to have a color or gray-scale screen.
227
228@vindex font-lock-maximum-decoration
229 The variable @code{font-lock-maximum-decoration} specifies the
230preferred level of fontification, for modes that provide multiple
231levels. Level 1 is the least amount of fontification; some modes
232support levels as high as 3. The normal default is ``as high as
233possible.'' You can specify an integer, which applies to all modes, or
234you can specify different numbers for particular major modes; for
235example, to use level 1 for C/C++ modes, and the default level
236otherwise, use this:
237
238@example
239(setq font-lock-maximum-decoration
240 '((c-mode . 1) (c++-mode . 1)))
241@end example
242
243@vindex font-lock-maximum-size
244 Fontification can be too slow for large buffers, so you can suppress
245it. The variable @code{font-lock-maximum-size} specifies a buffer size,
246beyond which buffer fontification is suppressed.
247
248@c @w is used below to prevent a bad page-break.
249@vindex font-lock-beginning-of-syntax-function
250 Comment and string fontification (or ``syntactic'' fontification)
251relies on analysis of the syntactic structure of the buffer text. For
252the purposes of speed, some modes including C mode and Lisp mode rely on
253a special convention: an open-parenthesis in the leftmost column always
254defines the @w{beginning} of a defun, and is thus always outside any string
255or comment. (@xref{Defuns}.) If you don't follow this convention,
256then Font Lock mode can misfontify the text after an open-parenthesis in
257the leftmost column that is inside a string or comment.
258
259 The variable @code{font-lock-beginning-of-syntax-function} (always
260buffer-local) specifies how Font Lock mode can find a position
261guaranteed to be outside any comment or string. In modes which use the
262leftmost column parenthesis convention, the default value of the variable
263is @code{beginning-of-defun}---that tells Font Lock mode to use the
264convention. If you set this variable to @code{nil}, Font Lock no longer
265relies on the convention. This avoids incorrect results, but the price
266is that, in some cases, fontification for a changed text must rescan
267buffer text from the beginning of the buffer.
268
269@findex font-lock-add-keywords
270 Font Lock highlighting patterns already exist for many modes, but you
271may want to fontify additional patterns. You can use the function
272@code{font-lock-add-keywords}, to add your own highlighting patterns for
273a particular mode. For example, to highlight @samp{FIXME:} words in C
274comments, use this:
275
276@example
277(font-lock-add-keywords
278 'c-mode
279 '(("\\<\\(FIXME\\):" 1 font-lock-warning-face t)))
280@end example
281
282@node Highlight Changes
283@section Highlight Changes Mode
284
285@findex highlight-changes-mode
286 Use @kbd{M-x highlight-changes-mode} to enable a minor mode
287that uses faces (colors, typically) to indicate which parts of
288the buffer were changed most recently.
289
290@node Highlight Interactively
291@section Interactive Highlighting by Matching
292@cindex highlighting by matching
293@cindex interactive highlighting
294
295 It is sometimes useful to highlight the strings that match a certain
296regular expression. For example, you might wish to see all the
297references to a certain variable in a program source file, or highlight
298certain parts in a voluminous output of some program, or make certain
299cliches stand out in an article.
300
301@findex hi-lock-mode
302 Use the @kbd{M-x hi-lock-mode} command to turn on a minor mode that
303allows you to specify regular expressions of the text to be
304highlighted. Hi-lock mode works like Font Lock (@pxref{Font Lock}),
305except that it lets you specify explicitly what parts of text to
306highlight. You control Hi-lock mode with these commands:
307
308@table @kbd
309@item C-x w h @var{regexp} @key{RET} @var{face} @key{RET}
310@kindex C-x w h
311@findex highlight-regexp
312Highlight text that matches
313@var{regexp} using face @var{face} (@code{highlight-regexp}).
314By using this command more than once, you can highlight various
315parts of the text in different ways.
316
317@item C-x w r @var{regexp} @key{RET}
318@kindex C-x w r
319@findex unhighlight-regexp
320Unhighlight @var{regexp} (@code{unhighlight-regexp}). You must enter
321one of the regular expressions currently specified for highlighting.
322(You can use completion, or a menu, to enter one of them
323conveniently.)
324
325@item C-x w l @var{regexp} @key{RET} @var{face} @key{RET}
326@kindex C-x w l
327@findex highlight-lines-matching-regexp
328@cindex lines, highlighting
329@cindex highlighting lines of text
330Highlight lines containing a match for @var{regexp}, using face
331@var{face} (@code{highlight-lines-matching-regexp}).
332
333@item C-x w b
334@kindex C-x w b
335@findex hi-lock-write-interactive-patterns
336Insert all the current highlighting regexp/face pairs into the buffer
337at point, with comment delimiters to prevent them from changing your
338program. This key binding runs the
339@code{hi-lock-write-interactive-patterns} command.
340
341These patterns will be read the next time you visit the file while
342Hi-lock mode is enabled, or whenever you use the @kbd{M-x
343hi-lock-find-patterns} command.
344
345@item C-x w i
346@kindex C-x w i
347@findex hi-lock-find-patterns
348@vindex hi-lock-exclude-modes
349Re-read regexp/face pairs in the current buffer
350(@code{hi-lock-write-interactive-patterns}). The list of pairs is
351found no matter where in the buffer it may be.
352
353This command does nothing if the major mode is a member of the list
354@code{hi-lock-exclude-modes}.
355@end table
356
357@node Trailing Whitespace
358@section Trailing Whitespace
359
360@cindex trailing whitespace
361@cindex whitespace, trailing
362@vindex show-trailing-whitespace
363 It is easy to leave unnecessary spaces at the end of a line without
364realizing it. In most cases, this @dfn{trailing whitespace} has no
365effect, but there are special circumstances where it matters.
366
367 You can make trailing whitespace visible on the screen by setting
368the variable @code{show-trailing-whitespace} to @code{t}. Then Emacs
369displays trailing whitespace in the face @code{trailing-whitespace}.
370
371 Trailing whitespace is defined as spaces or tabs at the end of a
372line. But trailing whitespace is not displayed specially if point is
373at the end of the line containing the whitespace. (Doing that looks
374ugly while you are typing in new text, and the location of point is
375enough in that case to show you that the spaces are present.)
376
377@vindex indicate-empty-lines
378@vindex default-indicate-empty-lines
379@cindex empty lines
380 Emacs can indicate empty lines at the end of the buffer with a
381special bitmap on the left fringe of the window. To enable this
382feature, set the buffer-local variable @code{indicate-empty-lines} to
383a non-@code{nil} value. The default value of this variable is
384controlled by the variable @code{default-indicate-empty-lines};
385by setting that variable, you can enable or disable this feature
386for all new buffers.
387
23@node Scrolling 388@node Scrolling
24@section Scrolling 389@section Scrolling
25 390