Add an entry for Scheme mode.
[bpt/emacs.git] / lispref / display.texi
CommitLineData
42b85554
RS
1@c -*-texinfo-*-
2@c This is part of the GNU Emacs Lisp Reference Manual.
f9f59935 3@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998 Free Software Foundation, Inc.
42b85554
RS
4@c See the file elisp.texi for copying conditions.
5@setfilename ../info/display
969fe9b5 6@node Display, Calendar, Processes, Top
42b85554
RS
7@chapter Emacs Display
8
9 This chapter describes a number of features related to the display
10that Emacs presents to the user.
11
12@menu
13* Refresh Screen:: Clearing the screen and redrawing everything on it.
42b85554
RS
14* Truncation:: Folding or wrapping long text lines.
15* The Echo Area:: Where messages are displayed.
22697dac
KH
16* Invisible Text:: Hiding part of the buffer text.
17* Selective Display:: Hiding part of the buffer text (the old way).
42b85554
RS
18* Overlay Arrow:: Display of an arrow to indicate position.
19* Temporary Displays:: Displays that go away automatically.
20* Overlays:: Use overlays to highlight parts of the buffer.
f9f59935 21* Width:: How wide is a character or string.
42b85554
RS
22* Faces:: A face defines a graphics appearance: font, color, etc.
23* Blinking:: How Emacs shows the matching open parenthesis.
24* Inverse Video:: Specifying how the screen looks.
25* Usual Display:: The usual conventions for displaying nonprinting chars.
26* Display Tables:: How to specify other conventions.
27* Beeping:: Audible signal to the user.
28* Window Systems:: Which window system is being used.
29@end menu
30
31@node Refresh Screen
32@section Refreshing the Screen
33
34The function @code{redraw-frame} redisplays the entire contents of a
1911e6e5 35given frame (@pxref{Frames}).
42b85554
RS
36
37@c Emacs 19 feature
38@defun redraw-frame frame
39This function clears and redisplays frame @var{frame}.
40@end defun
41
42Even more powerful is @code{redraw-display}:
43
44@deffn Command redraw-display
45This function clears and redisplays all visible frames.
46@end deffn
47
bfe721d1
KH
48 Processing user input takes absolute priority over redisplay. If you
49call these functions when input is available, they do nothing
50immediately, but a full redisplay does happen eventually---after all the
51input has been processed.
52
42b85554
RS
53 Normally, suspending and resuming Emacs also refreshes the screen.
54Some terminal emulators record separate contents for display-oriented
55programs such as Emacs and for ordinary sequential display. If you are
56using such a terminal, you might want to inhibit the redisplay on
78608595 57resumption.
42b85554
RS
58
59@defvar no-redraw-on-reenter
60@cindex suspend (cf. @code{no-redraw-on-reenter})
61@cindex resume (cf. @code{no-redraw-on-reenter})
62This variable controls whether Emacs redraws the entire screen after it
f9f59935 63has been suspended and resumed. Non-@code{nil} means there is no need
969fe9b5 64to redraw, @code{nil} means redrawing is needed. The default is @code{nil}.
42b85554
RS
65@end defvar
66
42b85554
RS
67@node Truncation
68@section Truncation
69@cindex line wrapping
70@cindex continuation lines
71@cindex @samp{$} in display
72@cindex @samp{\} in display
73
74 When a line of text extends beyond the right edge of a window, the
75line can either be continued on the next screen line, or truncated to
76one screen line. The additional screen lines used to display a long
77text line are called @dfn{continuation} lines. Normally, a @samp{$} in
78the rightmost column of the window indicates truncation; a @samp{\} on
969fe9b5
RS
79the rightmost column indicates a line that ``wraps'' onto the next line,
80which is also called @dfn{continuing} the line. (The display table can
81specify alternative indicators; see @ref{Display Tables}.)
42b85554
RS
82
83 Note that continuation is different from filling; continuation happens
84on the screen only, not in the buffer contents, and it breaks a line
85precisely at the right margin, not at a word boundary. @xref{Filling}.
86
87@defopt truncate-lines
88This buffer-local variable controls how Emacs displays lines that extend
89beyond the right edge of the window. The default is @code{nil}, which
90specifies continuation. If the value is non-@code{nil}, then these
91lines are truncated.
92
93If the variable @code{truncate-partial-width-windows} is non-@code{nil},
94then truncation is always used for side-by-side windows (within one
95frame) regardless of the value of @code{truncate-lines}.
96@end defopt
97
bfe721d1 98@defopt default-truncate-lines
42b85554 99This variable is the default value for @code{truncate-lines}, for
969fe9b5 100buffers that do not have buffer-local values for it.
bfe721d1 101@end defopt
42b85554
RS
102
103@defopt truncate-partial-width-windows
104This variable controls display of lines that extend beyond the right
105edge of the window, in side-by-side windows (@pxref{Splitting Windows}).
106If it is non-@code{nil}, these lines are truncated; otherwise,
107@code{truncate-lines} says what to do with them.
108@end defopt
109
a9f0a989
RS
110 When horizontal scrolling (@pxref{Horizontal Scrolling}) is in use in
111a window, that forces truncation.
112
f9f59935
RS
113 You can override the glyphs that indicate continuation or truncation
114using the display table; see @ref{Display Tables}.
42b85554 115
1911e6e5 116 If your buffer contains @emph{very} long lines, and you use
22697dac 117continuation to display them, just thinking about them can make Emacs
bfe721d1
KH
118redisplay slow. The column computation and indentation functions also
119become slow. Then you might find it advisable to set
120@code{cache-long-line-scans} to @code{t}.
22697dac
KH
121
122@defvar cache-long-line-scans
123If this variable is non-@code{nil}, various indentation and motion
bfe721d1
KH
124functions, and Emacs redisplay, cache the results of scanning the
125buffer, and consult the cache to avoid rescanning regions of the buffer
126unless they are modified.
22697dac 127
bfe721d1 128Turning on the cache slows down processing of short lines somewhat.
22697dac 129
969fe9b5 130This variable is automatically buffer-local in every buffer.
22697dac
KH
131@end defvar
132
42b85554
RS
133@node The Echo Area
134@section The Echo Area
135@cindex error display
136@cindex echo area
137
22697dac 138The @dfn{echo area} is used for displaying messages made with the
42b85554
RS
139@code{message} primitive, and for echoing keystrokes. It is not the
140same as the minibuffer, despite the fact that the minibuffer appears
141(when active) in the same place on the screen as the echo area. The
142@cite{GNU Emacs Manual} specifies the rules for resolving conflicts
143between the echo area and the minibuffer for use of that screen space
144(@pxref{Minibuffer,, The Minibuffer, emacs, The GNU Emacs Manual}).
145Error messages appear in the echo area; see @ref{Errors}.
146
147You can write output in the echo area by using the Lisp printing
148functions with @code{t} as the stream (@pxref{Output Functions}), or as
149follows:
150
151@defun message string &rest arguments
22697dac 152This function displays a one-line message in the echo area. The
42b85554
RS
153argument @var{string} is similar to a C language @code{printf} control
154string. See @code{format} in @ref{String Conversion}, for the details
155on the conversion specifications. @code{message} returns the
156constructed string.
157
b22f3a19
RS
158In batch mode, @code{message} prints the message text on the standard
159error stream, followed by a newline.
160
42b85554
RS
161@c Emacs 19 feature
162If @var{string} is @code{nil}, @code{message} clears the echo area. If
163the minibuffer is active, this brings the minibuffer contents back onto
164the screen immediately.
b22f3a19 165
42b85554
RS
166@example
167@group
168(message "Minibuffer depth is %d."
169 (minibuffer-depth))
170 @print{} Minibuffer depth is 0.
171@result{} "Minibuffer depth is 0."
172@end group
173
174@group
175---------- Echo Area ----------
176Minibuffer depth is 0.
177---------- Echo Area ----------
178@end group
179@end example
180@end defun
181
f9f59935 182@defun current-message
a9f0a989 183@tindex current-message
f9f59935
RS
184This function returns the message currently being displayed in the
185echo area, or @code{nil} if there is none.
186@end defun
187
969fe9b5
RS
188@defvar cursor-in-echo-area
189This variable controls where the cursor appears when a message is
190displayed in the echo area. If it is non-@code{nil}, then the cursor
191appears at the end of the message. Otherwise, the cursor appears at
192point---not in the echo area at all.
193
194The value is normally @code{nil}; Lisp programs bind it to @code{t}
195for brief periods of time.
196@end defvar
197
f9f59935 198@defvar echo-area-clear-hook
a9f0a989 199@tindex echo-area-clear-hook
f9f59935
RS
200This normal hook is run whenever the echo area is cleared---either by
201@code{(message nil)} or for any other reason.
202@end defvar
203
22697dac
KH
204Almost all the messages displayed in the echo area are also recorded
205in the @samp{*Messages*} buffer.
206
207@defopt message-log-max
208This variable specifies how many lines to keep in the @samp{*Messages*}
209buffer. The value @code{t} means there is no limit on how many lines to
210keep. The value @code{nil} disables message logging entirely. Here's
211how to display a message and prevent it from being logged:
212
213@example
214(let (message-log-max)
215 (message @dots{}))
216@end example
217@end defopt
218
bfe721d1
KH
219@defvar echo-keystrokes
220This variable determines how much time should elapse before command
221characters echo. Its value must be an integer, which specifies the
222number of seconds to wait before echoing. If the user types a prefix
223key (such as @kbd{C-x}) and then delays this many seconds before
a9f0a989
RS
224continuing, the prefix key is echoed in the echo area. (Once echoing
225begins in a key sequence, all subsequent characters in the same key
226sequence are echoed immediately.)
bfe721d1
KH
227
228If the value is zero, then command input is not echoed.
229@end defvar
230
22697dac
KH
231@node Invisible Text
232@section Invisible Text
233
234@cindex invisible text
235You can make characters @dfn{invisible}, so that they do not appear on
236the screen, with the @code{invisible} property. This can be either a
a9f0a989
RS
237text property (@pxref{Text Properties}) or a property of an overlay
238(@pxref{Overlays}).
22697dac
KH
239
240In the simplest case, any non-@code{nil} @code{invisible} property makes
241a character invisible. This is the default case---if you don't alter
242the default value of @code{buffer-invisibility-spec}, this is how the
969fe9b5 243@code{invisible} property works.
22697dac
KH
244
245More generally, you can use the variable @code{buffer-invisibility-spec}
246to control which values of the @code{invisible} property make text
247invisible. This permits you to classify the text into different subsets
248in advance, by giving them different @code{invisible} values, and
249subsequently make various subsets visible or invisible by changing the
250value of @code{buffer-invisibility-spec}.
251
252Controlling visibility with @code{buffer-invisibility-spec} is
253especially useful in a program to display the list of entries in a data
254base. It permits the implementation of convenient filtering commands to
255view just a part of the entries in the data base. Setting this variable
256is very fast, much faster than scanning all the text in the buffer
bfe721d1 257looking for properties to change.
22697dac
KH
258
259@defvar buffer-invisibility-spec
260This variable specifies which kinds of @code{invisible} properties
261actually make a character invisible.
262
263@table @asis
264@item @code{t}
265A character is invisible if its @code{invisible} property is
266non-@code{nil}. This is the default.
267
268@item a list
969fe9b5
RS
269Each element of the list specifies a criterion for invisibility; if a
270character's @code{invisible} property fits any one of these criteria,
271the character is invisible. The list can have two kinds of elements:
22697dac
KH
272
273@table @code
274@item @var{atom}
969fe9b5 275A character is invisible if its @code{invisible} property value
22697dac
KH
276is @var{atom} or if it is a list with @var{atom} as a member.
277
278@item (@var{atom} . t)
969fe9b5 279A character is invisible if its @code{invisible} property value
22697dac
KH
280is @var{atom} or if it is a list with @var{atom} as a member.
281Moreover, if this character is at the end of a line and is followed
282by a visible newline, it displays an ellipsis.
283@end table
284@end table
285@end defvar
286
f9f59935
RS
287 Two functions are specifically provided for adding elements to
288@code{buffer-invisibility-spec} and removing elements from it.
289
f9f59935 290@defun add-to-invisibility-spec element
a9f0a989 291@tindex add-to-invisibility-spec
f9f59935
RS
292Add the element @var{element} to @code{buffer-invisibility-spec}
293(if it is not already present in that list).
294@end defun
295
f9f59935 296@defun remove-from-invisibility-spec element
a9f0a989 297@tindex remove-from-invisibility-spec
f9f59935
RS
298Remove the element @var{element} from @code{buffer-invisibility-spec}.
299@end defun
300
301 One convention about the use of @code{buffer-invisibility-spec} is
302that a major mode should use the mode's own name as an element of
303@code{buffer-invisibility-spec} and as the value of the @code{invisible}
304property:
305
306@example
969fe9b5 307;; @r{If you want to display an ellipsis:}
f9f59935 308(add-to-invisibility-spec '(my-symbol . t))
969fe9b5 309;; @r{If you don't want ellipsis:}
f9f59935
RS
310(add-to-invisibility-spec 'my-symbol)
311
312(overlay-put (make-overlay beginning end)
313 'invisible 'my-symbol)
314
969fe9b5 315;; @r{When done with the overlays:}
f9f59935 316(remove-from-invisibility-spec '(my-symbol . t))
969fe9b5 317;; @r{Or respectively:}
f9f59935
RS
318(remove-from-invisibility-spec 'my-symbol)
319@end example
320
5e8ae792 321@vindex line-move-ignore-invisible
bfe721d1 322 Ordinarily, commands that operate on text or move point do not care
5e8ae792
RS
323whether the text is invisible. The user-level line motion commands
324explicitly ignore invisible newlines if
325@code{line-move-ignore-invisible} is non-@code{nil}, but only because
326they are explicitly programmed to do so.
bfe721d1 327
f9f59935
RS
328 Incremental search can make invisible overlays visible temporarily
329and/or permanently when a match includes invisible text. To enable
330this, the overlay should have a non-@code{nil}
331@code{isearch-open-invisible} property. The property value should be a
332function to be called with the overlay as an argument. This function
333should make the overlay visible permanently; it is used when the match
334overlaps the overlay on exit from the search.
335
336 During the search, such overlays are made temporarily visible by
337temporarily modifying their invisible and intangible properties. If you
1911e6e5 338want this to be done differently for a certain overlay, give it a
f9f59935
RS
339@code{isearch-open-invisible-temporary} property which is a function.
340The function is called with two arguments: the first is the overlay, and
a9f0a989
RS
341the second is @code{t} to make the overlay visible, or @code{nil} to
342make it invisible again.
f9f59935 343
42b85554
RS
344@node Selective Display
345@section Selective Display
346@cindex selective display
347
969fe9b5
RS
348 @dfn{Selective display} refers to a pair of related features for
349hiding certain lines on the screen.
42b85554
RS
350
351 The first variant, explicit selective display, is designed for use in
969fe9b5
RS
352a Lisp program: it controls which lines are hidden by altering the text.
353The invisible text feature (@pxref{Invisible Text}) has partially
354replaced this feature.
22697dac
KH
355
356 In the second variant, the choice of lines to hide is made
bfe721d1 357automatically based on indentation. This variant is designed to be a
22697dac 358user-level feature.
42b85554
RS
359
360 The way you control explicit selective display is by replacing a
78608595 361newline (control-j) with a carriage return (control-m). The text that
42b85554
RS
362was formerly a line following that newline is now invisible. Strictly
363speaking, it is temporarily no longer a line at all, since only newlines
364can separate lines; it is now part of the previous line.
365
366 Selective display does not directly affect editing commands. For
367example, @kbd{C-f} (@code{forward-char}) moves point unhesitatingly into
368invisible text. However, the replacement of newline characters with
369carriage return characters affects some editing commands. For example,
370@code{next-line} skips invisible lines, since it searches only for
371newlines. Modes that use selective display can also define commands
372that take account of the newlines, or that make parts of the text
373visible or invisible.
374
375 When you write a selectively displayed buffer into a file, all the
376control-m's are output as newlines. This means that when you next read
377in the file, it looks OK, with nothing invisible. The selective display
378effect is seen only within Emacs.
379
380@defvar selective-display
381This buffer-local variable enables selective display. This means that
382lines, or portions of lines, may be made invisible.
383
384@itemize @bullet
385@item
386If the value of @code{selective-display} is @code{t}, then any portion
969fe9b5
RS
387of a line that follows a control-m is not displayed. This is explicit
388selective display.
42b85554
RS
389
390@item
391If the value of @code{selective-display} is a positive integer, then
392lines that start with more than that many columns of indentation are not
393displayed.
394@end itemize
395
396When some portion of a buffer is invisible, the vertical movement
397commands operate as if that portion did not exist, allowing a single
398@code{next-line} command to skip any number of invisible lines.
399However, character movement commands (such as @code{forward-char}) do
400not skip the invisible portion, and it is possible (if tricky) to insert
401or delete text in an invisible portion.
402
403In the examples below, we show the @emph{display appearance} of the
404buffer @code{foo}, which changes with the value of
405@code{selective-display}. The @emph{contents} of the buffer do not
406change.
407
408@example
409@group
410(setq selective-display nil)
411 @result{} nil
412
413---------- Buffer: foo ----------
4141 on this column
415 2on this column
416 3n this column
417 3n this column
418 2on this column
4191 on this column
420---------- Buffer: foo ----------
421@end group
422
423@group
424(setq selective-display 2)
425 @result{} 2
426
427---------- Buffer: foo ----------
4281 on this column
429 2on this column
430 2on this column
4311 on this column
432---------- Buffer: foo ----------
433@end group
434@end example
435@end defvar
436
437@defvar selective-display-ellipses
438If this buffer-local variable is non-@code{nil}, then Emacs displays
439@samp{@dots{}} at the end of a line that is followed by invisible text.
440This example is a continuation of the previous one.
441
442@example
443@group
444(setq selective-display-ellipses t)
445 @result{} t
446
447---------- Buffer: foo ----------
4481 on this column
449 2on this column ...
450 2on this column
4511 on this column
452---------- Buffer: foo ----------
453@end group
454@end example
455
456You can use a display table to substitute other text for the ellipsis
457(@samp{@dots{}}). @xref{Display Tables}.
458@end defvar
459
460@node Overlay Arrow
461@section The Overlay Arrow
462@cindex overlay arrow
463
464 The @dfn{overlay arrow} is useful for directing the user's attention
465to a particular line in a buffer. For example, in the modes used for
466interface to debuggers, the overlay arrow indicates the line of code
467about to be executed.
468
469@defvar overlay-arrow-string
78608595
RS
470This variable holds the string to display to call attention to a
471particular line, or @code{nil} if the arrow feature is not in use.
42b85554
RS
472@end defvar
473
474@defvar overlay-arrow-position
78608595
RS
475This variable holds a marker that indicates where to display the overlay
476arrow. It should point at the beginning of a line. The arrow text
477appears at the beginning of that line, overlaying any text that would
478otherwise appear. Since the arrow is usually short, and the line
479usually begins with indentation, normally nothing significant is
480overwritten.
481
482The overlay string is displayed only in the buffer that this marker
42b85554
RS
483points into. Thus, only one buffer can have an overlay arrow at any
484given time.
485@c !!! overlay-arrow-position: but the overlay string may remain in the display
486@c of some other buffer until an update is required. This should be fixed
487@c now. Is it?
488@end defvar
489
969fe9b5 490 You can do a similar job by creating an overlay with a
22697dac
KH
491@code{before-string} property. @xref{Overlay Properties}.
492
42b85554
RS
493@node Temporary Displays
494@section Temporary Displays
495
969fe9b5
RS
496 Temporary displays are used by Lisp programs to put output into a
497buffer and then present it to the user for perusal rather than for
498editing. Many help commands use this feature.
42b85554
RS
499
500@defspec with-output-to-temp-buffer buffer-name forms@dots{}
501This function executes @var{forms} while arranging to insert any
502output they print into the buffer named @var{buffer-name}. The buffer
503is then shown in some window for viewing, displayed but not selected.
504
505The string @var{buffer-name} specifies the temporary buffer, which
506need not already exist. The argument must be a string, not a buffer.
507The buffer is erased initially (with no questions asked), and it is
508marked as unmodified after @code{with-output-to-temp-buffer} exits.
509
510@code{with-output-to-temp-buffer} binds @code{standard-output} to the
511temporary buffer, then it evaluates the forms in @var{forms}. Output
512using the Lisp output functions within @var{forms} goes by default to
513that buffer (but screen display and messages in the echo area, although
514they are ``output'' in the general sense of the word, are not affected).
515@xref{Output Functions}.
516
517The value of the last form in @var{forms} is returned.
518
519@example
520@group
521---------- Buffer: foo ----------
522 This is the contents of foo.
523---------- Buffer: foo ----------
524@end group
525
526@group
527(with-output-to-temp-buffer "foo"
528 (print 20)
529 (print standard-output))
530@result{} #<buffer foo>
531
532---------- Buffer: foo ----------
53320
534
535#<buffer foo>
536
537---------- Buffer: foo ----------
538@end group
539@end example
540@end defspec
541
542@defvar temp-buffer-show-function
78608595 543If this variable is non-@code{nil}, @code{with-output-to-temp-buffer}
42b85554
RS
544calls it as a function to do the job of displaying a help buffer. The
545function gets one argument, which is the buffer it should display.
a9f0a989
RS
546
547It is a good idea for this function to run @code{temp-buffer-show-hook}
548just as @code{with-output-to-temp-buffer} normally would, inside of
549@code{save-window-excursion} and with the chosen window and buffer
550selected.
551@end defvar
552
553@defvar temp-buffer-show-hook
554This normal hook is run by @code{with-output-to-temp-buffer} after
555displaying the help buffer. When the hook runs, the help buffer is
556current, and the window it was displayed in is selected.
42b85554
RS
557@end defvar
558
559@defun momentary-string-display string position &optional char message
560This function momentarily displays @var{string} in the current buffer at
561@var{position}. It has no effect on the undo list or on the buffer's
562modification status.
563
564The momentary display remains until the next input event. If the next
565input event is @var{char}, @code{momentary-string-display} ignores it
566and returns. Otherwise, that event remains buffered for subsequent use
567as input. Thus, typing @var{char} will simply remove the string from
568the display, while typing (say) @kbd{C-f} will remove the string from
569the display and later (presumably) move point forward. The argument
570@var{char} is a space by default.
571
572The return value of @code{momentary-string-display} is not meaningful.
573
bfe721d1 574If the string @var{string} does not contain control characters, you can
969fe9b5
RS
575do the same job in a more general way by creating (and then subsequently
576deleting) an overlay with a @code{before-string} property.
577@xref{Overlay Properties}.
bfe721d1 578
42b85554
RS
579If @var{message} is non-@code{nil}, it is displayed in the echo area
580while @var{string} is displayed in the buffer. If it is @code{nil}, a
581default message says to type @var{char} to continue.
582
583In this example, point is initially located at the beginning of the
584second line:
585
586@example
587@group
588---------- Buffer: foo ----------
589This is the contents of foo.
590@point{}Second line.
591---------- Buffer: foo ----------
592@end group
593
594@group
595(momentary-string-display
596 "**** Important Message! ****"
597 (point) ?\r
598 "Type RET when done reading")
599@result{} t
600@end group
601
602@group
603---------- Buffer: foo ----------
604This is the contents of foo.
605**** Important Message! ****Second line.
606---------- Buffer: foo ----------
607
608---------- Echo Area ----------
609Type RET when done reading
610---------- Echo Area ----------
611@end group
612@end example
613@end defun
614
615@node Overlays
616@section Overlays
617@cindex overlays
618
619You can use @dfn{overlays} to alter the appearance of a buffer's text on
bfe721d1
KH
620the screen, for the sake of presentation features. An overlay is an
621object that belongs to a particular buffer, and has a specified
622beginning and end. It also has properties that you can examine and set;
623these affect the display of the text within the overlay.
42b85554
RS
624
625@menu
626* Overlay Properties:: How to read and set properties.
627 What properties do to the screen display.
628* Managing Overlays:: Creating, moving, finding overlays.
629@end menu
630
631@node Overlay Properties
632@subsection Overlay Properties
633
a9f0a989
RS
634Overlay properties are like text properties in that the properties that
635alter how a character is displayed can come from either source. But in
636most respects they are different. Text properties are considered a part
637of the text; overlays are specifically considered not to be part of the
638text. Thus, copying text between various buffers and strings preserves
639text properties, but does not try to preserve overlays. Changing a
640buffer's text properties marks the buffer as modified, while moving an
641overlay or changing its properties does not. Unlike text property
642changes, overlay changes are not recorded in the buffer's undo list.
643@xref{Text Properties}, for comparison.
42b85554
RS
644
645@table @code
646@item priority
647@kindex priority @r{(overlay property)}
648This property's value (which should be a nonnegative number) determines
649the priority of the overlay. The priority matters when two or more
650overlays cover the same character and both specify a face for display;
651the one whose @code{priority} value is larger takes priority over the
652other, and its face attributes override the face attributes of the lower
653priority overlay.
654
655Currently, all overlays take priority over text properties. Please
656avoid using negative priority values, as we have not yet decided just
657what they should mean.
658
659@item window
660@kindex window @r{(overlay property)}
661If the @code{window} property is non-@code{nil}, then the overlay
662applies only on that window.
663
22697dac
KH
664@item category
665@kindex category @r{(overlay property)}
666If an overlay has a @code{category} property, we call it the
bfe721d1 667@dfn{category} of the overlay. It should be a symbol. The properties
22697dac
KH
668of the symbol serve as defaults for the properties of the overlay.
669
42b85554
RS
670@item face
671@kindex face @r{(overlay property)}
f9f59935
RS
672This property controls the way text is displayed---for example, which
673font and which colors. Its value is a face name or a list of face
674names. @xref{Faces}, for more information.
675
676If the property value is a list, elements may also have the form
677@code{(foreground-color . @var{color-name})} or @code{(background-color
678. @var{color-name})}. These elements specify just the foreground color
679or just the background color; therefore, there is no need to create a
680face for each color that you want to use.
42b85554
RS
681
682@item mouse-face
683@kindex mouse-face @r{(overlay property)}
684This property is used instead of @code{face} when the mouse is within
f9f59935 685the range of the overlay.
42b85554
RS
686
687@item modification-hooks
688@kindex modification-hooks @r{(overlay property)}
689This property's value is a list of functions to be called if any
690character within the overlay is changed or if text is inserted strictly
22697dac
KH
691within the overlay.
692
693The hook functions are called both before and after each change.
694If the functions save the information they receive, and compare notes
695between calls, they can determine exactly what change has been made
696in the buffer text.
697
698When called before a change, each function receives four arguments: the
699overlay, @code{nil}, and the beginning and end of the text range to be
a890e1b0 700modified.
42b85554 701
22697dac
KH
702When called after a change, each function receives five arguments: the
703overlay, @code{t}, the beginning and end of the text range just
704modified, and the length of the pre-change text replaced by that range.
705(For an insertion, the pre-change length is zero; for a deletion, that
706length is the number of characters deleted, and the post-change
bfe721d1 707beginning and end are equal.)
22697dac 708
42b85554
RS
709@item insert-in-front-hooks
710@kindex insert-in-front-hooks @r{(overlay property)}
22697dac
KH
711This property's value is a list of functions to be called before and
712after inserting text right at the beginning of the overlay. The calling
713conventions are the same as for the @code{modification-hooks} functions.
42b85554
RS
714
715@item insert-behind-hooks
716@kindex insert-behind-hooks @r{(overlay property)}
22697dac
KH
717This property's value is a list of functions to be called before and
718after inserting text right at the end of the overlay. The calling
719conventions are the same as for the @code{modification-hooks} functions.
42b85554
RS
720
721@item invisible
722@kindex invisible @r{(overlay property)}
22697dac
KH
723The @code{invisible} property can make the text in the overlay
724invisible, which means that it does not appear on the screen.
725@xref{Invisible Text}, for details.
726
727@item intangible
728@kindex intangible @r{(overlay property)}
729The @code{intangible} property on an overlay works just like the
bfe721d1 730@code{intangible} text property. @xref{Special Properties}, for details.
f9f59935
RS
731
732@item isearch-open-invisible
a9f0a989
RS
733This property tells incremental search how to make an invisible overlay
734visible, permanently, if the final match overlaps it. @xref{Invisible
f9f59935 735Text}.
42b85554 736
a9f0a989
RS
737@item isearch-open-invisible-temporary
738This property tells incremental search how to make an invisible overlay
739visible, temporarily, during the search. @xref{Invisible Text}.
740
42b85554
RS
741@item before-string
742@kindex before-string @r{(overlay property)}
743This property's value is a string to add to the display at the beginning
744of the overlay. The string does not appear in the buffer in any
22697dac
KH
745sense---only on the screen. The string should contain only characters
746that display as a single column---control characters, including tabs or
747newlines, will give strange results.
42b85554
RS
748
749@item after-string
750@kindex after-string @r{(overlay property)}
751This property's value is a string to add to the display at the end of
752the overlay. The string does not appear in the buffer in any
22697dac
KH
753sense---only on the screen. The string should contain only characters
754that display as a single column---control characters, including tabs or
755newlines, will give strange results.
756
757@item evaporate
758@kindex evaporate @r{(overlay property)}
759If this property is non-@code{nil}, the overlay is deleted automatically
760if it ever becomes empty (i.e., if it spans no characters).
d2609065
RS
761
762@item local-map
969fe9b5
RS
763@cindex keymap of character (and overlays)
764@kindex local-map @r{(overlay property)}
d2609065
RS
765If this property is non-@code{nil}, it specifies a keymap for a portion
766of the text. The property's value replaces the buffer's local map, when
767the character after point is within the overlay. @xref{Active Keymaps}.
42b85554
RS
768@end table
769
770 These are the functions for reading and writing the properties of an
771overlay.
772
773@defun overlay-get overlay prop
774This function returns the value of property @var{prop} recorded in
22697dac
KH
775@var{overlay}, if any. If @var{overlay} does not record any value for
776that property, but it does have a @code{category} property which is a
777symbol, that symbol's @var{prop} property is used. Otherwise, the value
778is @code{nil}.
42b85554
RS
779@end defun
780
781@defun overlay-put overlay prop value
782This function sets the value of property @var{prop} recorded in
783@var{overlay} to @var{value}. It returns @var{value}.
784@end defun
785
786 See also the function @code{get-char-property} which checks both
787overlay properties and text properties for a given character.
788@xref{Examining Properties}.
789
790@node Managing Overlays
791@subsection Managing Overlays
792
793 This section describes the functions to create, delete and move
794overlays, and to examine their contents.
795
f9f59935 796@defun make-overlay start end &optional buffer front-advance rear-advance
78608595 797This function creates and returns an overlay that belongs to
42b85554
RS
798@var{buffer} and ranges from @var{start} to @var{end}. Both @var{start}
799and @var{end} must specify buffer positions; they may be integers or
800markers. If @var{buffer} is omitted, the overlay is created in the
801current buffer.
f9f59935
RS
802
803The arguments @var{front-advance} and @var{rear-advance} specify the
804insertion type for the start of the overlay and for the end of the
805overlay. @xref{Marker Insertion Types}.
42b85554
RS
806@end defun
807
808@defun overlay-start overlay
f9f59935
RS
809This function returns the position at which @var{overlay} starts,
810as an integer.
42b85554
RS
811@end defun
812
813@defun overlay-end overlay
f9f59935
RS
814This function returns the position at which @var{overlay} ends,
815as an integer.
42b85554
RS
816@end defun
817
818@defun overlay-buffer overlay
819This function returns the buffer that @var{overlay} belongs to.
820@end defun
821
822@defun delete-overlay overlay
823This function deletes @var{overlay}. The overlay continues to exist as
a9f0a989
RS
824a Lisp object, but ceases to be attached to the buffer it belonged to,
825and ceases to have any effect on display.
826
827A deleted overlay is not permanently useless. You can give it
828a new buffer position by calling @code{move-overlay}.
42b85554
RS
829@end defun
830
831@defun move-overlay overlay start end &optional buffer
832This function moves @var{overlay} to @var{buffer}, and places its bounds
833at @var{start} and @var{end}. Both arguments @var{start} and @var{end}
834must specify buffer positions; they may be integers or markers. If
835@var{buffer} is omitted, the overlay stays in the same buffer.
836
837The return value is @var{overlay}.
838
839This is the only valid way to change the endpoints of an overlay. Do
840not try modifying the markers in the overlay by hand, as that fails to
841update other vital data structures and can cause some overlays to be
842``lost''.
843@end defun
844
845@defun overlays-at pos
846This function returns a list of all the overlays that contain position
847@var{pos} in the current buffer. The list is in no particular order.
848An overlay contains position @var{pos} if it begins at or before
849@var{pos}, and ends after @var{pos}.
850@end defun
851
f9f59935 852@defun overlays-in beg end
a9f0a989 853@tindex overlays-in
f9f59935
RS
854This function returns a list of the overlays that overlap the region
855@var{beg} through @var{end}. ``Overlap'' means that at least one
856character is contained within the overlay and also contained within the
857specified region; however, empty overlays are included in the result if
858they are located at @var{beg} or between @var{beg} and @var{end}.
859@end defun
860
42b85554
RS
861@defun next-overlay-change pos
862This function returns the buffer position of the next beginning or end
863of an overlay, after @var{pos}.
864@end defun
865
22697dac
KH
866@defun previous-overlay-change pos
867This function returns the buffer position of the previous beginning or
868end of an overlay, before @var{pos}.
869@end defun
870
f9f59935
RS
871@node Width
872@section Width
873
874Since not all characters have the same width, these functions let you
969fe9b5
RS
875check the width of a character. @xref{Primitive Indent}, and
876@ref{Screen Lines}, for related functions.
f9f59935 877
f9f59935 878@defun char-width char
a9f0a989 879@tindex char-width
f9f59935
RS
880This function returns the width in columns of the character @var{char},
881if it were displayed in the current buffer and the selected window.
882@end defun
883
f9f59935 884@defun string-width string
a9f0a989 885@tindex string-width
f9f59935
RS
886This function returns the width in columns of the string @var{string},
887if it were displayed in the current buffer and the selected window.
888@end defun
889
f9f59935 890@defun truncate-string-to-width string width &optional start-column padding
a9f0a989 891@tindex truncate-string-to-width
f9f59935
RS
892This function returns the part of @var{string} that fits within
893@var{width} columns, as a new string.
894
895If @var{string} does not reach @var{width}, then the result ends where
896@var{string} ends. If one multi-column character in @var{string}
897extends across the column @var{width}, that character is not included in
898the result. Thus, the result can fall short of @var{width} but cannot
899go beyond it.
900
901The optional argument @var{start-column} specifies the starting column.
902If this is non-@code{nil}, then the first @var{start-column} columns of
903the string are omitted from the value. If one multi-column character in
904@var{string} extends across the column @var{start-column}, that
905character is not included.
906
907The optional argument @var{padding}, if non-@code{nil}, is a padding
908character added at the beginning and end of the result string, to extend
909it to exactly @var{width} columns. The padding character is used at the
910end of the result if it falls short of @var{width}. It is also used at
911the beginning of the result if one multi-column character in
912@var{string} extends across the column @var{start-column}.
913
914@example
915(truncate-string-to-width "\tab\t" 12 4)
916 @result{} "ab"
917(truncate-string-to-width "\tab\t" 12 4 ?\ )
918 @result{} " ab "
919@end example
920@end defun
921
42b85554
RS
922@node Faces
923@section Faces
924@cindex face
925
926A @dfn{face} is a named collection of graphical attributes: font,
f9f59935 927foreground color, background color, and optional underlining. Faces
42b85554
RS
928control the display of text on the screen.
929
930@cindex face id
969fe9b5 931Each face has its own @dfn{face number}, which distinguishes faces at
42b85554
RS
932low levels within Emacs. However, for most purposes, you can refer to
933faces in Lisp programs by their names.
934
22697dac
KH
935@defun facep object
936This function returns @code{t} if @var{object} is a face name symbol (or
937if it is a vector of the kind used internally to record face data). It
938returns @code{nil} otherwise.
939@end defun
940
42b85554
RS
941Each face name is meaningful for all frames, and by default it has the
942same meaning in all frames. But you can arrange to give a particular
943face name a special meaning in one frame if you wish.
944
945@menu
946* Standard Faces:: The faces Emacs normally comes with.
969fe9b5 947* Defining Faces:: How to define a face with @code{defface}.
42b85554
RS
948* Merging Faces:: How Emacs decides which face to use for a character.
949* Face Functions:: How to define and examine faces.
950@end menu
951
952@node Standard Faces
953@subsection Standard Faces
954
955 This table lists all the standard faces and their uses.
956
957@table @code
958@item default
959@kindex default @r{(face name)}
960This face is used for ordinary text.
961
962@item modeline
963@kindex modeline @r{(face name)}
964This face is used for mode lines and menu bars.
965
966@item region
967@kindex region @r{(face name)}
968This face is used for highlighting the region in Transient Mark mode.
969
970@item secondary-selection
971@kindex secondary-selection @r{(face name)}
972This face is used to show any secondary selection you have made.
973
974@item highlight
975@kindex highlight @r{(face name)}
976This face is meant to be used for highlighting for various purposes.
977
978@item underline
979@kindex underline @r{(face name)}
980This face underlines text.
981
982@item bold
983@kindex bold @r{(face name)}
984This face uses a bold font, if possible. It uses the bold variant of
985the frame's font, if it has one. It's up to you to choose a default
986font that has a bold variant, if you want to use one.
987
988@item italic
989@kindex italic @r{(face name)}
990This face uses the italic variant of the frame's font, if it has one.
991
992@item bold-italic
993@kindex bold-italic @r{(face name)}
994This face uses the bold italic variant of the frame's font, if it has
995one.
996@end table
997
969fe9b5 998@node Defining Faces
a9f0a989 999@subsection Defining Faces
969fe9b5
RS
1000
1001 The way to define a new face is with @code{defface}. This creates a
1002kind of customization item (@pxref{Customization}) which the user can
1003customize using the Customization buffer (@pxref{Easy Customization,,,
1004emacs, The GNU Emacs Manual}).
1005
969fe9b5 1006@defmac defface face spec doc [keyword value]...
a9f0a989 1007@tindex defface
969fe9b5
RS
1008Declare @var{face} as a customizable face that defaults according to
1009@var{spec}. Do not quote the symbol @var{face}. The argument @var{doc}
1010specifies the face documentation.
1011
1012When @code{defface} executes, it defines the face according to
a9f0a989
RS
1013@var{spec}, then uses any customizations that were read from the
1014@file{.emacs} file to override that specification.
969fe9b5
RS
1015
1016The purpose of @var{spec} is to specify how the face should appear on
1017different kinds of terminals. It should be an alist whose elements have
1018the form @code{(@var{display} @var{atts})}. The element's @sc{car},
1019@var{display}, specifies a class of terminals. The @sc{cdr},
1020@var{atts}, is a list of face attributes and their values; it specifies
1021what the face should look like on that kind of terminal. The possible
1022attributes are defined in the value of @code{custom-face-attributes}.
1023
1024The @var{display} part of an element of @var{spec} determines which
1025frames the element applies to. If more than one element of @var{spec}
1026matches a given frame, the first matching element is the only one used
1027for that frame. There are two possibilities for @var{display}:
1028
1029@table @asis
1030@item @code{t}
1031This element of @var{spec} matches all frames. Therefore, any
1032subsequent elements of @var{spec} are never used. Normally
1033@code{t} is used in the last (or only) element of @var{spec}.
1034
a9f0a989 1035@item a list
1911e6e5 1036If @var{display} is a list, each element should have the form
969fe9b5
RS
1037@code{(@var{characteristic} @var{value}@dots{})}. Here
1038@var{characteristic} specifies a way of classifying frames, and the
1039@var{value}s are possible classifications which @var{display} should
1040apply to. Here are the possible values of @var{characteristic}:
1041
1042@table @code
1043@item type
1044The kind of window system the frame uses---either @code{x}, @code{pc}
1045(for the MS-DOS console), @code{w32} (for MS Windows 9X/NT), or
1046@code{tty}.
1047
1048@item class
1049What kinds of colors the frame supports---either @code{color},
1050@code{grayscale}, or @code{mono}.
1051
1052@item background
1911e6e5 1053The kind of background---either @code{light} or @code{dark}.
969fe9b5
RS
1054@end table
1055
1056If an element of @var{display} specifies more than one @var{value} for a
1057given @var{characteristic}, any of those values is acceptable. If
1058@var{display} has more than one element, each element should specify a
1059different @var{characteristic}; then @emph{each} characteristic of the
1060frame must match one of the @var{value}s specified for it in
1061@var{display}.
1062@end table
1063@end defmac
1064
1065 Here's how the standard face @code{region} could be defined
1066with @code{defface}:
1067
1068@example
1069(defface region
1070 ((((class color) (background dark))
1071 (:background "blue"))
1072 (t (:background "gray")))
1073 "Used for displaying the region.")
1074@end example
1075
1076 Internally, @code{defface} uses the symbol property
1077@code{face-defface-spec} to record the face attributes specified in
1078@code{defface}, @code{saved-face} for the attributes saved by the user
1079with the customization buffer, and @code{face-documentation} for the
1080documentation string.
1081
1911e6e5
RS
1082@tindex frame-background-mode
1083@defopt frame-background-mode
1084This option, if non-@code{nil}, specifies the background type to use for
1085interpreting face definitions. If it is @code{dark}, then Emacs treats
1086all frames as if they had a dark background, regardless of their actual
1087background colors. If it is @code{light}, then Emacs treats all frames
1088as if they had a light background.
1089@end defopt
1090
42b85554
RS
1091@node Merging Faces
1092@subsection Merging Faces for Display
1093
1094 Here are all the ways to specify which face to use for display of text:
1095
1096@itemize @bullet
1097@item
969fe9b5
RS
1098With defaults. Each frame has a @dfn{default face}, which is used for
1099all text that doesn't somehow specify another face. (We may change this
1100in a forthcoming Emacs version to serve as a default for all text.)
42b85554
RS
1101
1102@item
1103With text properties. A character may have a @code{face} property; if so,
78608595 1104it is displayed with that face. @xref{Special Properties}.
42b85554
RS
1105
1106If the character has a @code{mouse-face} property, that is used instead
1107of the @code{face} property when the mouse is ``near enough'' to the
1108character.
1109
1110@item
1111With overlays. An overlay may have @code{face} and @code{mouse-face}
1112properties too; they apply to all the text covered by the overlay.
1113
bfe721d1
KH
1114@item
1115With a region that is active. In Transient Mark mode, the region is
1116highlighted with a particular face (see @code{region-face}, below).
1117
42b85554 1118@item
969fe9b5 1119With special glyphs. Each glyph can specify a particular face
42b85554
RS
1120number. @xref{Glyphs}.
1121@end itemize
1122
1123 If these various sources together specify more than one face for a
1124particular character, Emacs merges the attributes of the various faces
1125specified. The attributes of the faces of special glyphs come first;
bfe721d1 1126then comes the face for region highlighting, if appropriate;
42b85554
RS
1127then come attributes of faces from overlays, followed by those from text
1128properties, and last the default face.
1129
1130 When multiple overlays cover one character, an overlay with higher
1131priority overrides those with lower priority. @xref{Overlays}.
1132
1133 If an attribute such as the font or a color is not specified in any of
1134the above ways, the frame's own font or color is used.
1135
1136@node Face Functions
1137@subsection Functions for Working with Faces
1138
1139 The attributes a face can specify include the font, the foreground
1140color, the background color, and underlining. The face can also leave
1141these unspecified by giving the value @code{nil} for them.
1142
1143 Here are the primitives for creating and changing faces.
1144
1145@defun make-face name
1146This function defines a new face named @var{name}, initially with all
1147attributes @code{nil}. It does nothing if there is already a face named
1148@var{name}.
1149@end defun
1150
1151@defun face-list
1152This function returns a list of all defined face names.
1153@end defun
1154
1155@defun copy-face old-face new-name &optional frame new-frame
1156This function defines the face @var{new-name} as a copy of the existing
1157face named @var{old-face}. It creates the face @var{new-name} if that
1158doesn't already exist.
1159
1160If the optional argument @var{frame} is given, this function applies
1161only to that frame. Otherwise it applies to each frame individually,
1162copying attributes from @var{old-face} in each frame to @var{new-face}
1163in the same frame.
1164
1165If the optional argument @var{new-frame} is given, then @code{copy-face}
1166copies the attributes of @var{old-face} in @var{frame} to @var{new-name}
1167in @var{new-frame}.
1168@end defun
1169
1170 You can modify the attributes of an existing face with the following
1171functions. If you specify @var{frame}, they affect just that frame;
1172otherwise, they affect all frames as well as the defaults that apply to
1173new frames.
1174
1175@defun set-face-foreground face color &optional frame
1176@defunx set-face-background face color &optional frame
78608595
RS
1177These functions set the foreground (or background, respectively) color
1178of face @var{face} to @var{color}. The argument @var{color} should be a
42b85554 1179string, the name of a color.
bfe721d1
KH
1180
1181Certain shades of gray are implemented by stipple patterns on
1182black-and-white screens.
1183@end defun
1184
1185@defun set-face-stipple face pattern &optional frame
1186This function sets the background stipple pattern of face @var{face} to
1187@var{pattern}. The argument @var{pattern} should be the name of a
1188stipple pattern defined by the X server, or @code{nil} meaning don't use
1189stipple.
1190
1191Normally there is no need to pay attention to stipple patterns, because
1192they are used automatically to handle certain shades of gray.
42b85554
RS
1193@end defun
1194
1195@defun set-face-font face font &optional frame
1196This function sets the font of face @var{face}. The argument @var{font}
a9f0a989
RS
1197should be a string, either a valid font name for your system or the name
1198of an Emacs fontset (@pxref{Fontsets}). Note that if you set the font
1199explicitly, the bold and italic attributes cease to have any effect,
1200because the precise font that you specified is always used.
21cffb83
RS
1201@end defun
1202
f9f59935 1203@defun set-face-bold-p face bold-p &optional frame
a9f0a989 1204@tindex set-face-bold-p
f9f59935
RS
1205This function sets the bold attribute of face @var{face}.
1206Non-@code{nil} means bold; @code{nil} means non-bold.
21cffb83
RS
1207@end defun
1208
f9f59935 1209@defun set-face-italic-p face italic-p &optional frame
a9f0a989 1210@tindex set-face-italic-p
f9f59935
RS
1211This function sets the italic attribute of face @var{face}.
1212Non-@code{nil} means italic; @code{nil} means non-italic.
42b85554
RS
1213@end defun
1214
969fe9b5
RS
1215@defun set-face-underline-p face underline-p &optional frame
1216This function sets the underline attribute of face @var{face}.
1217Non-@code{nil} means do underline; @code{nil} means don't.
1218@end defun
1219
42b85554
RS
1220@defun invert-face face &optional frame
1221Swap the foreground and background colors of face @var{face}. If the
1222face doesn't specify both foreground and background, then its foreground
78608595
RS
1223and background are set to the default background and foreground,
1224respectively.
42b85554
RS
1225@end defun
1226
1227 These functions examine the attributes of a face. If you don't
1228specify @var{frame}, they refer to the default data for new frames.
1229
1230@defun face-foreground face &optional frame
1231@defunx face-background face &optional frame
78608595
RS
1232These functions return the foreground color (or background color,
1233respectively) of face @var{face}, as a string.
42b85554
RS
1234@end defun
1235
bfe721d1
KH
1236@defun face-stipple face &optional frame
1237This function returns the name of the background stipple pattern of face
1238@var{face}, or @code{nil} if it doesn't have one.
1239@end defun
1240
42b85554
RS
1241@defun face-font face &optional frame
1242This function returns the name of the font of face @var{face}.
1243@end defun
1244
f9f59935 1245@defun face-bold-p face &optional frame
a9f0a989 1246@tindex face-bold-p
f9f59935
RS
1247This function returns the bold attribute of face @var{face}.
1248@end defun
1249
f9f59935 1250@defun face-italic-p face &optional frame
a9f0a989 1251@tindex face-italic-p
f9f59935
RS
1252This function returns the italic attribute of face @var{face}.
1253@end defun
1254
969fe9b5
RS
1255@defun face-underline-p face &optional frame
1256This function returns the underline attribute of face @var{face}.
1257@end defun
1258
bfe721d1 1259@defun face-id face
969fe9b5 1260This function returns the face number of face @var{face}.
42b85554
RS
1261@end defun
1262
f9f59935 1263@defun face-documentation face
a9f0a989 1264@tindex face-documentation
f9f59935
RS
1265This function returns the documentation string of face @var{face}, or
1266@code{nil} if none was specified for it.
1267@end defun
1268
42b85554
RS
1269@defun face-equal face1 face2 &optional frame
1270This returns @code{t} if the faces @var{face1} and @var{face2} have the
1271same attributes for display.
1272@end defun
1273
1274@defun face-differs-from-default-p face &optional frame
1275This returns @code{t} if the face @var{face} displays differently from
1276the default face. A face is considered to be ``the same'' as the normal
1277face if each attribute is either the same as that of the default face or
1278@code{nil} (meaning to inherit from the default).
1279@end defun
1280
1281@defvar region-face
969fe9b5 1282This variable's value specifies the face number to use to display characters
42b85554
RS
1283in the region when it is active (in Transient Mark mode only). The face
1284thus specified takes precedence over all faces that come from text
1285properties and overlays, for characters in the region. @xref{The Mark},
1286for more information about Transient Mark mode.
1287
969fe9b5 1288Normally, the value is the face number of the face named @code{region}.
42b85554
RS
1289@end defvar
1290
1911e6e5
RS
1291@tindex frame-update-face-colors
1292@defun frame-update-face-colors frame
1293This function updates the way faces display on @var{frame}, for a change
1294in @var{frame}'s foreground or background color.
1295@end defun
1296
42b85554
RS
1297@node Blinking
1298@section Blinking Parentheses
1299@cindex parenthesis matching
1300@cindex blinking
1301@cindex balancing parentheses
1302@cindex close parenthesis
1303
1304 This section describes the mechanism by which Emacs shows a matching
1305open parenthesis when the user inserts a close parenthesis.
1306
42b85554
RS
1307@defvar blink-paren-function
1308The value of this variable should be a function (of no arguments) to
1309be called whenever a character with close parenthesis syntax is inserted.
1310The value of @code{blink-paren-function} may be @code{nil}, in which
1311case nothing is done.
42b85554
RS
1312@end defvar
1313
1911e6e5 1314@defopt blink-matching-paren
42b85554
RS
1315If this variable is @code{nil}, then @code{blink-matching-open} does
1316nothing.
1911e6e5 1317@end defopt
42b85554 1318
1911e6e5 1319@defopt blink-matching-paren-distance
42b85554
RS
1320This variable specifies the maximum distance to scan for a matching
1321parenthesis before giving up.
1911e6e5 1322@end defopt
42b85554 1323
1911e6e5 1324@defopt blink-matching-delay
bfe721d1
KH
1325This variable specifies the number of seconds for the cursor to remain
1326at the matching parenthesis. A fraction of a second often gives
1327good results, but the default is 1, which works on all systems.
1911e6e5 1328@end defopt
bfe721d1 1329
1911e6e5 1330@deffn Command blink-matching-open
42b85554
RS
1331This function is the default value of @code{blink-paren-function}. It
1332assumes that point follows a character with close parenthesis syntax and
1333moves the cursor momentarily to the matching opening character. If that
1334character is not already on the screen, it displays the character's
1335context in the echo area. To avoid long delays, this function does not
1336search farther than @code{blink-matching-paren-distance} characters.
1337
1338Here is an example of calling this function explicitly.
1339
1340@smallexample
1341@group
1342(defun interactive-blink-matching-open ()
1343@c Do not break this line! -- rms.
1344@c The first line of a doc string
1345@c must stand alone.
1346 "Indicate momentarily the start of sexp before point."
1347 (interactive)
1348@end group
1349@group
1350 (let ((blink-matching-paren-distance
1351 (buffer-size))
1352 (blink-matching-paren t))
1353 (blink-matching-open)))
1354@end group
1355@end smallexample
1911e6e5 1356@end deffn
42b85554
RS
1357
1358@node Inverse Video
1359@section Inverse Video
1360@cindex Inverse Video
1361
1362@defopt inverse-video
1363@cindex highlighting
1364This variable controls whether Emacs uses inverse video for all text
1365on the screen. Non-@code{nil} means yes, @code{nil} means no. The
1366default is @code{nil}.
1367@end defopt
1368
1369@defopt mode-line-inverse-video
1370This variable controls the use of inverse video for mode lines. If it
bfe721d1
KH
1371is non-@code{nil}, then mode lines are displayed in inverse video.
1372Otherwise, mode lines are displayed normally, just like text. The
1373default is @code{t}.
1374
969fe9b5 1375For window frames, this displays mode lines using the face named
bfe721d1
KH
1376@code{modeline}, which is normally the inverse of the default face
1377unless you change it.
42b85554
RS
1378@end defopt
1379
1380@node Usual Display
1381@section Usual Display Conventions
1382
1383 The usual display conventions define how to display each character
1384code. You can override these conventions by setting up a display table
1385(@pxref{Display Tables}). Here are the usual display conventions:
1386
1387@itemize @bullet
1388@item
1389Character codes 32 through 126 map to glyph codes 32 through 126.
1390Normally this means they display as themselves.
1391
1392@item
1393Character code 9 is a horizontal tab. It displays as whitespace
1394up to a position determined by @code{tab-width}.
1395
1396@item
1397Character code 10 is a newline.
1398
1399@item
1400All other codes in the range 0 through 31, and code 127, display in one
78608595 1401of two ways according to the value of @code{ctl-arrow}. If it is
42b85554
RS
1402non-@code{nil}, these codes map to sequences of two glyphs, where the
1403first glyph is the @sc{ASCII} code for @samp{^}. (A display table can
1404specify a glyph to use instead of @samp{^}.) Otherwise, these codes map
1405just like the codes in the range 128 to 255.
1406
1407@item
1408Character codes 128 through 255 map to sequences of four glyphs, where
1409the first glyph is the @sc{ASCII} code for @samp{\}, and the others are
a9f0a989 1410digit characters representing the character code in octal. (A display
969fe9b5
RS
1411table can specify a glyph to use instead of @samp{\}.)
1412
1413@item
1414Multibyte character codes above 256 are displayed as themselves, or as a
1415question mark or empty box if the terminal cannot display that
1416character.
42b85554
RS
1417@end itemize
1418
1419 The usual display conventions apply even when there is a display
1420table, for any character whose entry in the active display table is
1421@code{nil}. Thus, when you set up a display table, you need only
969fe9b5 1422specify the characters for which you want special behavior.
42b85554
RS
1423
1424 These variables affect the way certain characters are displayed on the
1425screen. Since they change the number of columns the characters occupy,
f9f59935
RS
1426they also affect the indentation functions. These variables also affect
1427how the mode line is displayed; if you want to force redisplay of the
1428mode line using the new values, call the function
1429@code{force-mode-line-update} (@pxref{Mode Line Format}).
42b85554
RS
1430
1431@defopt ctl-arrow
1432@cindex control characters in display
1433This buffer-local variable controls how control characters are
1434displayed. If it is non-@code{nil}, they are displayed as a caret
1435followed by the character: @samp{^A}. If it is @code{nil}, they are
1436displayed as a backslash followed by three octal digits: @samp{\001}.
1437@end defopt
1438
1439@c Following may have overfull hbox.
1440@defvar default-ctl-arrow
1441The value of this variable is the default value for @code{ctl-arrow} in
1442buffers that do not override it. @xref{Default Value}.
1443@end defvar
1444
1445@defopt tab-width
1446The value of this variable is the spacing between tab stops used for
1447displaying tab characters in Emacs buffers. The default is 8. Note
f9f59935 1448that this feature is completely independent of the user-settable tab
42b85554
RS
1449stops used by the command @code{tab-to-tab-stop}. @xref{Indent Tabs}.
1450@end defopt
1451
1452@node Display Tables
1453@section Display Tables
1454
1455@cindex display table
969fe9b5
RS
1456You can use the @dfn{display table} feature to control how all possible
1457character codes display on the screen. This is useful for displaying
1458European languages that have letters not in the @sc{ASCII} character
1459set.
42b85554
RS
1460
1461The display table maps each character code into a sequence of
1462@dfn{glyphs}, each glyph being an image that takes up one character
1463position on the screen. You can also define how to display each glyph
1464on your terminal, using the @dfn{glyph table}.
1465
f9f59935
RS
1466Display tables affect how the mode line is displayed; if you want to
1467force redisplay of the mode line using a new display table, call
1468@code{force-mode-line-update} (@pxref{Mode Line Format}).
1469
42b85554
RS
1470@menu
1471* Display Table Format:: What a display table consists of.
1472* Active Display Table:: How Emacs selects a display table to use.
1473* Glyphs:: How to define a glyph, and what glyphs mean.
42b85554
RS
1474@end menu
1475
1476@node Display Table Format
1477@subsection Display Table Format
1478
a9f0a989
RS
1479 A display table is actually a char-table (@pxref{Char-Tables}) with
1480@code{display-table} as its subtype.
42b85554
RS
1481
1482@defun make-display-table
1483This creates and returns a display table. The table initially has
1484@code{nil} in all elements.
1485@end defun
1486
f9f59935
RS
1487 The ordinary elements of the display table are indexed by character
1488codes; the element at index @var{c} says how to display the character
1489code @var{c}. The value should be @code{nil} or a vector of glyph
1490values (@pxref{Glyphs}). If an element is @code{nil}, it says to
1491display that character according to the usual display conventions
1492(@pxref{Usual Display}).
22697dac
KH
1493
1494 If you use the display table to change the display of newline
1495characters, the whole buffer will be displayed as one long ``line.''
42b85554 1496
f9f59935 1497 The display table also has six ``extra slots'' which serve special
969fe9b5
RS
1498purposes. Here is a table of their meanings; @code{nil} in any slot
1499means to use the default for that slot, as stated below.
42b85554
RS
1500
1501@table @asis
f9f59935 1502@item 0
42b85554
RS
1503The glyph for the end of a truncated screen line (the default for this
1504is @samp{$}). @xref{Glyphs}.
f9f59935 1505@item 1
42b85554 1506The glyph for the end of a continued line (the default is @samp{\}).
f9f59935 1507@item 2
42b85554
RS
1508The glyph for indicating a character displayed as an octal character
1509code (the default is @samp{\}).
f9f59935 1510@item 3
42b85554 1511The glyph for indicating a control character (the default is @samp{^}).
f9f59935 1512@item 4
42b85554
RS
1513A vector of glyphs for indicating the presence of invisible lines (the
1514default is @samp{...}). @xref{Selective Display}.
f9f59935 1515@item 5
50b04c36
JB
1516The glyph used to draw the border between side-by-side windows (the
1517default is @samp{|}). @xref{Splitting Windows}.
42b85554
RS
1518@end table
1519
1520 For example, here is how to construct a display table that mimics the
1521effect of setting @code{ctl-arrow} to a non-@code{nil} value:
1522
1523@example
1524(setq disptab (make-display-table))
1525(let ((i 0))
1526 (while (< i 32)
1527 (or (= i ?\t) (= i ?\n)
1528 (aset disptab i (vector ?^ (+ i 64))))
1529 (setq i (1+ i)))
1530 (aset disptab 127 (vector ?^ ??)))
1531@end example
1532
f9f59935 1533@defun display-table-slot display-table slot
a9f0a989 1534@tindex display-table-slot
f9f59935
RS
1535This function returns the value of the extra slot @var{slot} of
1536@var{display-table}. The argument @var{slot} may be a number from 0 to
15375 inclusive, or a slot name (symbol). Valid symbols are
1538@code{truncation}, @code{wrap}, @code{escape}, @code{control},
1539@code{selective-display}, and @code{vertical-border}.
1540@end defun
1541
f9f59935 1542@defun set-display-table-slot display-table slot value
a9f0a989 1543@tindex set-display-table-slot
f9f59935
RS
1544This function stores @var{value} in the extra slot @var{slot} of
1545@var{display-table}. The argument @var{slot} may be a number from 0 to
15465 inclusive, or a slot name (symbol). Valid symbols are
1547@code{truncation}, @code{wrap}, @code{escape}, @code{control},
1548@code{selective-display}, and @code{vertical-border}.
1549@end defun
1550
42b85554
RS
1551@node Active Display Table
1552@subsection Active Display Table
1553@cindex active display table
1554
1555 Each window can specify a display table, and so can each buffer. When
1556a buffer @var{b} is displayed in window @var{w}, display uses the
1557display table for window @var{w} if it has one; otherwise, the display
1558table for buffer @var{b} if it has one; otherwise, the standard display
1559table if any. The display table chosen is called the @dfn{active}
1560display table.
1561
1562@defun window-display-table window
1563This function returns @var{window}'s display table, or @code{nil}
1564if @var{window} does not have an assigned display table.
1565@end defun
1566
1567@defun set-window-display-table window table
1568This function sets the display table of @var{window} to @var{table}.
1569The argument @var{table} should be either a display table or
1570@code{nil}.
1571@end defun
1572
1573@defvar buffer-display-table
969fe9b5
RS
1574This variable is automatically buffer-local in all buffers; its value in
1575a particular buffer specifies the display table for that buffer. If it
1576is @code{nil}, that means the buffer does not have an assigned display
1577table.
42b85554
RS
1578@end defvar
1579
1580@defvar standard-display-table
1581This variable's value is the default display table, used whenever a
1582window has no display table and neither does the buffer displayed in
1583that window. This variable is @code{nil} by default.
1584@end defvar
1585
1586 If there is no display table to use for a particular window---that is,
f9f59935
RS
1587if the window specifies none, its buffer specifies none, and
1588@code{standard-display-table} is @code{nil}---then Emacs uses the usual
42b85554
RS
1589display conventions for all character codes in that window. @xref{Usual
1590Display}.
1591
1592@node Glyphs
1593@subsection Glyphs
1594
1595@cindex glyph
1596 A @dfn{glyph} is a generalization of a character; it stands for an
1597image that takes up a single character position on the screen. Glyphs
1598are represented in Lisp as integers, just as characters are.
1599
1600@cindex glyph table
1601 The meaning of each integer, as a glyph, is defined by the glyph
1602table, which is the value of the variable @code{glyph-table}.
1603
1604@defvar glyph-table
1605The value of this variable is the current glyph table. It should be a
1606vector; the @var{g}th element defines glyph code @var{g}. If the value
1607is @code{nil} instead of a vector, then all glyphs are simple (see
1608below).
1609@end defvar
1610
1611 Here are the possible types of elements in the glyph table:
1612
1911e6e5
RS
1613@table @asis
1614@item @var{string}
42b85554
RS
1615Send the characters in @var{string} to the terminal to output
1616this glyph. This alternative is available on character terminals,
969fe9b5 1617but not under a window system.
42b85554 1618
1911e6e5 1619@item @var{integer}
969fe9b5
RS
1620Define this glyph code as an alias for glyph code @var{integer}. You
1621can use an alias to specify a face code for the glyph; see below.
42b85554
RS
1622
1623@item @code{nil}
969fe9b5
RS
1624This glyph is simple. On an ordinary terminal, the glyph code mod
1625524288 is the character to output. In a window system, the glyph code
1626mod 524288 is the character to output, and the glyph code divided by
1627524288 specifies the face number (@pxref{Face Functions}) to use while
1628outputting it. (524288 is
f9f59935 1629@ifinfo
969fe9b5 16302**19.)
f9f59935
RS
1631@end ifinfo
1632@tex
969fe9b5 1633$2^{19}$.)
f9f59935
RS
1634@end tex
1635@xref{Faces}.
42b85554
RS
1636@end table
1637
1638 If a glyph code is greater than or equal to the length of the glyph
1639table, that code is automatically simple.
1640
42b85554
RS
1641@node Beeping
1642@section Beeping
1643@cindex beeping
1644@cindex bell
1645
f9f59935
RS
1646 This section describes how to make Emacs ring the bell (or blink the
1647screen) to attract the user's attention. Be conservative about how
1648often you do this; frequent bells can become irritating. Also be
1649careful not to use just beeping when signaling an error is more
1650appropriate. (@xref{Errors}.)
42b85554 1651
a9f0a989 1652@defun ding &optional do-not-terminate
42b85554
RS
1653@cindex keyboard macro termination
1654This function beeps, or flashes the screen (see @code{visible-bell} below).
1655It also terminates any keyboard macro currently executing unless
a9f0a989 1656@var{do-not-terminate} is non-@code{nil}.
42b85554
RS
1657@end defun
1658
a9f0a989 1659@defun beep &optional do-not-terminate
42b85554
RS
1660This is a synonym for @code{ding}.
1661@end defun
1662
1911e6e5 1663@defopt visible-bell
42b85554
RS
1664This variable determines whether Emacs should flash the screen to
1665represent a bell. Non-@code{nil} means yes, @code{nil} means no. This
969fe9b5
RS
1666is effective on a window system, and on a character-only terminal
1667provided the terminal's Termcap entry defines the visible bell
1668capability (@samp{vb}).
1911e6e5 1669@end defopt
42b85554 1670
f9f59935 1671@defvar ring-bell-function
a9f0a989 1672@tindex ring-bell-function
f9f59935 1673If this is non-@code{nil}, it specifies how Emacs should ``ring the
a9f0a989 1674bell.'' Its value should be a function of no arguments.
f9f59935
RS
1675@end defvar
1676
42b85554
RS
1677@node Window Systems
1678@section Window Systems
1679
1680 Emacs works with several window systems, most notably the X Window
1681System. Both Emacs and X use the term ``window'', but use it
1682differently. An Emacs frame is a single window as far as X is
1683concerned; the individual Emacs windows are not known to X at all.
1684
1685@defvar window-system
42b85554 1686This variable tells Lisp programs what window system Emacs is running
1911e6e5
RS
1687under. The possible values are
1688
1689@table @code
1690@item x
1691@cindex X Window System
1692Emacs is displaying using X.
1693@item pc
1694Emacs is displaying using MSDOS.
1695@item w32
1696Emacs is displaying using Windows NT or Windows 95.
1697@item nil
1698Emacs is using a character-based terminal.
1699@end table
42b85554
RS
1700@end defvar
1701
42b85554 1702@defvar window-setup-hook
f9f59935
RS
1703This variable is a normal hook which Emacs runs after handling the
1704initialization files. Emacs runs this hook after it has completed
1705loading your @file{.emacs} file, the default initialization file (if
a9f0a989 1706any), and the terminal-specific Lisp code, and running the hook
42b85554
RS
1707@code{term-setup-hook}.
1708
1709This hook is used for internal purposes: setting up communication with
1710the window system, and creating the initial window. Users should not
1711interfere with it.
1712@end defvar