Give syntax of keywords.
[bpt/emacs.git] / lispref / display.texi
CommitLineData
42b85554
RS
1@c -*-texinfo-*-
2@c This is part of the GNU Emacs Lisp Reference Manual.
3@c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
4@c See the file elisp.texi for copying conditions.
5@setfilename ../info/display
6@node Display, Calendar, System Interface, Top
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.
14* Screen Size:: How big is the Emacs screen.
15* Truncation:: Folding or wrapping long text lines.
16* The Echo Area:: Where messages are displayed.
17* Selective Display:: Hiding part of the buffer text.
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.
21* Faces:: A face defines a graphics appearance: font, color, etc.
22* Blinking:: How Emacs shows the matching open parenthesis.
23* Inverse Video:: Specifying how the screen looks.
24* Usual Display:: The usual conventions for displaying nonprinting chars.
25* Display Tables:: How to specify other conventions.
26* Beeping:: Audible signal to the user.
27* Window Systems:: Which window system is being used.
28@end menu
29
30@node Refresh Screen
31@section Refreshing the Screen
32
33The function @code{redraw-frame} redisplays the entire contents of a
34given frame. @xref{Frames}.
35
36@c Emacs 19 feature
37@defun redraw-frame frame
38This function clears and redisplays frame @var{frame}.
39@end defun
40
41Even more powerful is @code{redraw-display}:
42
43@deffn Command redraw-display
44This function clears and redisplays all visible frames.
45@end deffn
46
47 Normally, suspending and resuming Emacs also refreshes the screen.
48Some terminal emulators record separate contents for display-oriented
49programs such as Emacs and for ordinary sequential display. If you are
50using such a terminal, you might want to inhibit the redisplay on
78608595 51resumption.
42b85554
RS
52
53@defvar no-redraw-on-reenter
54@cindex suspend (cf. @code{no-redraw-on-reenter})
55@cindex resume (cf. @code{no-redraw-on-reenter})
56This variable controls whether Emacs redraws the entire screen after it
57has been suspended and resumed. Non-@code{nil} means yes, @code{nil}
58means no.
59@end defvar
60
61 Processing user input takes absolute priority over redisplay. If you
62call these functions when input is available, they do nothing
63immediately, but a full redisplay does happen eventually---after all the
64input has been processed.
65
66@node Screen Size
67@section Screen Size
68@cindex size of screen
69@cindex screen size
70@cindex display lines
71@cindex display columns
72@cindex resize redisplay
73
78608595 74 The screen size functions access or specify the height or width of
42b85554
RS
75the terminal. When you are using multiple frames, they apply to the
76selected frame (@pxref{Frames}).
77
78@defun screen-height
79This function returns the number of lines on the screen that are
80available for display.
81
82@example
83@group
84(screen-height)
85 @result{} 50
86@end group
87@end example
88@end defun
89
90@defun screen-width
91This function returns the number of columns on the screen that are
92available for display.
93
94@example
95@group
96(screen-width)
97 @result{} 80
98@end group
99@end example
100@end defun
101
102@defun set-screen-height lines &optional not-actual-size
103This function declares that the terminal can display @var{lines} lines.
104The sizes of existing windows are altered proportionally to fit.
105
106If @var{not-actual-size} is non-@code{nil}, then Emacs displays
107@var{lines} lines of output, but does not change its value for the
108actual height of the screen. (Knowing the correct actual size may be
109necessary for correct cursor positioning.) Using a smaller height than
110the terminal actually implements may be useful to reproduce behavior
111observed on a smaller screen, or if the terminal malfunctions when using
112its whole screen.
113
114If @var{lines} is different from what it was previously, then the
115entire screen is cleared and redisplayed using the new size.
116
117This function returns @code{nil}.
118@end defun
119
120@defun set-screen-width columns &optional not-actual-size
121This function declares that the terminal can display @var{columns}
122columns. The details are as in @code{set-screen-height}.
123@end defun
124
125@node Truncation
126@section Truncation
127@cindex line wrapping
128@cindex continuation lines
129@cindex @samp{$} in display
130@cindex @samp{\} in display
131
132 When a line of text extends beyond the right edge of a window, the
133line can either be continued on the next screen line, or truncated to
134one screen line. The additional screen lines used to display a long
135text line are called @dfn{continuation} lines. Normally, a @samp{$} in
136the rightmost column of the window indicates truncation; a @samp{\} on
137the rightmost column indicates a line that ``wraps'' or is continued
138onto the next line. (The display table can specify alternative
a890e1b0 139indicators; see @ref{Display Tables}.)
42b85554
RS
140
141 Note that continuation is different from filling; continuation happens
142on the screen only, not in the buffer contents, and it breaks a line
143precisely at the right margin, not at a word boundary. @xref{Filling}.
144
145@defopt truncate-lines
146This buffer-local variable controls how Emacs displays lines that extend
147beyond the right edge of the window. The default is @code{nil}, which
148specifies continuation. If the value is non-@code{nil}, then these
149lines are truncated.
150
151If the variable @code{truncate-partial-width-windows} is non-@code{nil},
152then truncation is always used for side-by-side windows (within one
153frame) regardless of the value of @code{truncate-lines}.
154@end defopt
155
156@defvar default-truncate-lines
157This variable is the default value for @code{truncate-lines}, for
158buffers that do not have local values for it.
159@end defvar
160
161@defopt truncate-partial-width-windows
162This variable controls display of lines that extend beyond the right
163edge of the window, in side-by-side windows (@pxref{Splitting Windows}).
164If it is non-@code{nil}, these lines are truncated; otherwise,
165@code{truncate-lines} says what to do with them.
166@end defopt
167
168 You can override the images that indicate continuation or truncation
169with the display table; see @ref{Display Tables}.
170
171@node The Echo Area
172@section The Echo Area
173@cindex error display
174@cindex echo area
175
176 The @dfn{echo area} is used for displaying messages made with the
177@code{message} primitive, and for echoing keystrokes. It is not the
178same as the minibuffer, despite the fact that the minibuffer appears
179(when active) in the same place on the screen as the echo area. The
180@cite{GNU Emacs Manual} specifies the rules for resolving conflicts
181between the echo area and the minibuffer for use of that screen space
182(@pxref{Minibuffer,, The Minibuffer, emacs, The GNU Emacs Manual}).
183Error messages appear in the echo area; see @ref{Errors}.
184
185You can write output in the echo area by using the Lisp printing
186functions with @code{t} as the stream (@pxref{Output Functions}), or as
187follows:
188
189@defun message string &rest arguments
190This function prints a one-line message in the echo area. The
191argument @var{string} is similar to a C language @code{printf} control
192string. See @code{format} in @ref{String Conversion}, for the details
193on the conversion specifications. @code{message} returns the
194constructed string.
195
b22f3a19
RS
196In batch mode, @code{message} prints the message text on the standard
197error stream, followed by a newline.
198
42b85554
RS
199@c Emacs 19 feature
200If @var{string} is @code{nil}, @code{message} clears the echo area. If
201the minibuffer is active, this brings the minibuffer contents back onto
202the screen immediately.
b22f3a19 203
42b85554
RS
204@example
205@group
206(message "Minibuffer depth is %d."
207 (minibuffer-depth))
208 @print{} Minibuffer depth is 0.
209@result{} "Minibuffer depth is 0."
210@end group
211
212@group
213---------- Echo Area ----------
214Minibuffer depth is 0.
215---------- Echo Area ----------
216@end group
217@end example
218@end defun
219
220@defvar cursor-in-echo-area
221This variable controls where the cursor appears when a message is
222displayed in the echo area. If it is non-@code{nil}, then the cursor
223appears at the end of the message. Otherwise, the cursor appears at
224point---not in the echo area at all.
225
226The value is normally @code{nil}; Lisp programs bind it to @code{t}
227for brief periods of time.
228@end defvar
229
230@node Selective Display
231@section Selective Display
232@cindex selective display
233
234 @dfn{Selective display} is a class of minor modes in which specially
235marked lines do not appear on the screen, or in which highly indented
236lines do not appear.
237
238 The first variant, explicit selective display, is designed for use in
239a Lisp program. The program controls which lines are hidden by altering
240the text. Outline mode uses this variant. In the second variant, the
241choice of lines to hide is made automatically based on indentation.
242This variant is designed as a user-level feature.
243
244 The way you control explicit selective display is by replacing a
78608595 245newline (control-j) with a carriage return (control-m). The text that
42b85554
RS
246was formerly a line following that newline is now invisible. Strictly
247speaking, it is temporarily no longer a line at all, since only newlines
248can separate lines; it is now part of the previous line.
249
250 Selective display does not directly affect editing commands. For
251example, @kbd{C-f} (@code{forward-char}) moves point unhesitatingly into
252invisible text. However, the replacement of newline characters with
253carriage return characters affects some editing commands. For example,
254@code{next-line} skips invisible lines, since it searches only for
255newlines. Modes that use selective display can also define commands
256that take account of the newlines, or that make parts of the text
257visible or invisible.
258
259 When you write a selectively displayed buffer into a file, all the
260control-m's are output as newlines. This means that when you next read
261in the file, it looks OK, with nothing invisible. The selective display
262effect is seen only within Emacs.
263
264@defvar selective-display
265This buffer-local variable enables selective display. This means that
266lines, or portions of lines, may be made invisible.
267
268@itemize @bullet
269@item
270If the value of @code{selective-display} is @code{t}, then any portion
271of a line that follows a control-m is not displayed.
272
273@item
274If the value of @code{selective-display} is a positive integer, then
275lines that start with more than that many columns of indentation are not
276displayed.
277@end itemize
278
279When some portion of a buffer is invisible, the vertical movement
280commands operate as if that portion did not exist, allowing a single
281@code{next-line} command to skip any number of invisible lines.
282However, character movement commands (such as @code{forward-char}) do
283not skip the invisible portion, and it is possible (if tricky) to insert
284or delete text in an invisible portion.
285
286In the examples below, we show the @emph{display appearance} of the
287buffer @code{foo}, which changes with the value of
288@code{selective-display}. The @emph{contents} of the buffer do not
289change.
290
291@example
292@group
293(setq selective-display nil)
294 @result{} nil
295
296---------- Buffer: foo ----------
2971 on this column
298 2on this column
299 3n this column
300 3n this column
301 2on this column
3021 on this column
303---------- Buffer: foo ----------
304@end group
305
306@group
307(setq selective-display 2)
308 @result{} 2
309
310---------- Buffer: foo ----------
3111 on this column
312 2on this column
313 2on this column
3141 on this column
315---------- Buffer: foo ----------
316@end group
317@end example
318@end defvar
319
320@defvar selective-display-ellipses
321If this buffer-local variable is non-@code{nil}, then Emacs displays
322@samp{@dots{}} at the end of a line that is followed by invisible text.
323This example is a continuation of the previous one.
324
325@example
326@group
327(setq selective-display-ellipses t)
328 @result{} t
329
330---------- Buffer: foo ----------
3311 on this column
332 2on this column ...
333 2on this column
3341 on this column
335---------- Buffer: foo ----------
336@end group
337@end example
338
339You can use a display table to substitute other text for the ellipsis
340(@samp{@dots{}}). @xref{Display Tables}.
341@end defvar
342
343@node Overlay Arrow
344@section The Overlay Arrow
345@cindex overlay arrow
346
347 The @dfn{overlay arrow} is useful for directing the user's attention
348to a particular line in a buffer. For example, in the modes used for
349interface to debuggers, the overlay arrow indicates the line of code
350about to be executed.
351
352@defvar overlay-arrow-string
78608595
RS
353This variable holds the string to display to call attention to a
354particular line, or @code{nil} if the arrow feature is not in use.
42b85554
RS
355@end defvar
356
357@defvar overlay-arrow-position
78608595
RS
358This variable holds a marker that indicates where to display the overlay
359arrow. It should point at the beginning of a line. The arrow text
360appears at the beginning of that line, overlaying any text that would
361otherwise appear. Since the arrow is usually short, and the line
362usually begins with indentation, normally nothing significant is
363overwritten.
364
365The overlay string is displayed only in the buffer that this marker
42b85554
RS
366points into. Thus, only one buffer can have an overlay arrow at any
367given time.
368@c !!! overlay-arrow-position: but the overlay string may remain in the display
369@c of some other buffer until an update is required. This should be fixed
370@c now. Is it?
371@end defvar
372
373@node Temporary Displays
374@section Temporary Displays
375
376 Temporary displays are used by commands to put output into a buffer
377and then present it to the user for perusal rather than for editing.
378Many of the help commands use this feature.
379
380@defspec with-output-to-temp-buffer buffer-name forms@dots{}
381This function executes @var{forms} while arranging to insert any
382output they print into the buffer named @var{buffer-name}. The buffer
383is then shown in some window for viewing, displayed but not selected.
384
385The string @var{buffer-name} specifies the temporary buffer, which
386need not already exist. The argument must be a string, not a buffer.
387The buffer is erased initially (with no questions asked), and it is
388marked as unmodified after @code{with-output-to-temp-buffer} exits.
389
390@code{with-output-to-temp-buffer} binds @code{standard-output} to the
391temporary buffer, then it evaluates the forms in @var{forms}. Output
392using the Lisp output functions within @var{forms} goes by default to
393that buffer (but screen display and messages in the echo area, although
394they are ``output'' in the general sense of the word, are not affected).
395@xref{Output Functions}.
396
397The value of the last form in @var{forms} is returned.
398
399@example
400@group
401---------- Buffer: foo ----------
402 This is the contents of foo.
403---------- Buffer: foo ----------
404@end group
405
406@group
407(with-output-to-temp-buffer "foo"
408 (print 20)
409 (print standard-output))
410@result{} #<buffer foo>
411
412---------- Buffer: foo ----------
41320
414
415#<buffer foo>
416
417---------- Buffer: foo ----------
418@end group
419@end example
420@end defspec
421
422@defvar temp-buffer-show-function
78608595 423If this variable is non-@code{nil}, @code{with-output-to-temp-buffer}
42b85554
RS
424calls it as a function to do the job of displaying a help buffer. The
425function gets one argument, which is the buffer it should display.
426
427In Emacs versions 18 and earlier, this variable was called
428@code{temp-buffer-show-hook}.
429@end defvar
430
431@defun momentary-string-display string position &optional char message
432This function momentarily displays @var{string} in the current buffer at
433@var{position}. It has no effect on the undo list or on the buffer's
434modification status.
435
436The momentary display remains until the next input event. If the next
437input event is @var{char}, @code{momentary-string-display} ignores it
438and returns. Otherwise, that event remains buffered for subsequent use
439as input. Thus, typing @var{char} will simply remove the string from
440the display, while typing (say) @kbd{C-f} will remove the string from
441the display and later (presumably) move point forward. The argument
442@var{char} is a space by default.
443
444The return value of @code{momentary-string-display} is not meaningful.
445
446If @var{message} is non-@code{nil}, it is displayed in the echo area
447while @var{string} is displayed in the buffer. If it is @code{nil}, a
448default message says to type @var{char} to continue.
449
450In this example, point is initially located at the beginning of the
451second line:
452
453@example
454@group
455---------- Buffer: foo ----------
456This is the contents of foo.
457@point{}Second line.
458---------- Buffer: foo ----------
459@end group
460
461@group
462(momentary-string-display
463 "**** Important Message! ****"
464 (point) ?\r
465 "Type RET when done reading")
466@result{} t
467@end group
468
469@group
470---------- Buffer: foo ----------
471This is the contents of foo.
472**** Important Message! ****Second line.
473---------- Buffer: foo ----------
474
475---------- Echo Area ----------
476Type RET when done reading
477---------- Echo Area ----------
478@end group
479@end example
480@end defun
481
482@node Overlays
483@section Overlays
484@cindex overlays
485
486You can use @dfn{overlays} to alter the appearance of a buffer's text on
78608595 487the screen. An overlay is an object that belongs to a particular
42b85554
RS
488buffer, and has a specified beginning and end. It also has properties
489that you can examine and set; these affect the display of the text
490within the overlay.
491
492@menu
493* Overlay Properties:: How to read and set properties.
494 What properties do to the screen display.
495* Managing Overlays:: Creating, moving, finding overlays.
496@end menu
497
498@node Overlay Properties
499@subsection Overlay Properties
500
501Overlay properties are like text properties in some respects, but the
502differences are more important than the similarities. Text properties
503are considered a part of the text; overlays are specifically considered
504not to be part of the text. Thus, copying text between various buffers
505and strings preserves text properties, but does not try to preserve
506overlays. Changing a buffer's text properties marks the buffer as
507modified, while moving an overlay or changing its properties does not.
508Unlike text propery changes, overlay changes are not recorded in the
509buffer's undo list.
510
511@table @code
512@item priority
513@kindex priority @r{(overlay property)}
514This property's value (which should be a nonnegative number) determines
515the priority of the overlay. The priority matters when two or more
516overlays cover the same character and both specify a face for display;
517the one whose @code{priority} value is larger takes priority over the
518other, and its face attributes override the face attributes of the lower
519priority overlay.
520
521Currently, all overlays take priority over text properties. Please
522avoid using negative priority values, as we have not yet decided just
523what they should mean.
524
525@item window
526@kindex window @r{(overlay property)}
527If the @code{window} property is non-@code{nil}, then the overlay
528applies only on that window.
529
530@item face
531@kindex face @r{(overlay property)}
532This property controls the font and color of text. @xref{Faces}, for
533more information. This feature is temporary; in the future, we may
534replace it with other ways of specifying how to display text.
535
536@item mouse-face
537@kindex mouse-face @r{(overlay property)}
538This property is used instead of @code{face} when the mouse is within
539the range of the overlay. This feature may be temporary, like
540@code{face}.
541
542@item modification-hooks
543@kindex modification-hooks @r{(overlay property)}
544This property's value is a list of functions to be called if any
545character within the overlay is changed or if text is inserted strictly
a890e1b0
RS
546within the overlay. Each function receives three arguments: the
547overlay, and the beginning and end of the part of the buffer being
548modified.
42b85554
RS
549
550@item insert-in-front-hooks
551@kindex insert-in-front-hooks @r{(overlay property)}
552This property's value is a list of functions to be called
553if text is inserted right at the beginning of the overlay.
554
555@item insert-behind-hooks
556@kindex insert-behind-hooks @r{(overlay property)}
557This property's value is a list of functions to be called if text is
558inserted right at the end of the overlay.
559
560@item invisible
561@kindex invisible @r{(overlay property)}
562A non-@code{nil} @code{invisible} property means that the text in the
563overlay does not appear on the screen. This works much like selective
564display. Details of this feature are likely to change in future
565versions, so check the @file{etc/NEWS} file in the version you are
566using.
567
568@item before-string
569@kindex before-string @r{(overlay property)}
570This property's value is a string to add to the display at the beginning
571of the overlay. The string does not appear in the buffer in any
572sense---only on the screen. This is not yet implemented, but will be.
573
574@item after-string
575@kindex after-string @r{(overlay property)}
576This property's value is a string to add to the display at the end of
577the overlay. The string does not appear in the buffer in any
578sense---only on the screen. This is not yet implemented, but will be.
579@end table
580
581 These are the functions for reading and writing the properties of an
582overlay.
583
584@defun overlay-get overlay prop
585This function returns the value of property @var{prop} recorded in
586@var{overlay}. If @var{overlay} does not record any value for that
587property, then the value is @code{nil}.
588@end defun
589
590@defun overlay-put overlay prop value
591This function sets the value of property @var{prop} recorded in
592@var{overlay} to @var{value}. It returns @var{value}.
593@end defun
594
595 See also the function @code{get-char-property} which checks both
596overlay properties and text properties for a given character.
597@xref{Examining Properties}.
598
599@node Managing Overlays
600@subsection Managing Overlays
601
602 This section describes the functions to create, delete and move
603overlays, and to examine their contents.
604
605@defun make-overlay start end &optional buffer
78608595 606This function creates and returns an overlay that belongs to
42b85554
RS
607@var{buffer} and ranges from @var{start} to @var{end}. Both @var{start}
608and @var{end} must specify buffer positions; they may be integers or
609markers. If @var{buffer} is omitted, the overlay is created in the
610current buffer.
611@end defun
612
613@defun overlay-start overlay
614This function returns the position at which @var{overlay} starts.
615@end defun
616
617@defun overlay-end overlay
618This function returns the position at which @var{overlay} ends.
619@end defun
620
621@defun overlay-buffer overlay
622This function returns the buffer that @var{overlay} belongs to.
623@end defun
624
625@defun delete-overlay overlay
626This function deletes @var{overlay}. The overlay continues to exist as
627a Lisp object, but ceases to be part of the buffer it belonged to, and
628ceases to have any effect on display.
629@end defun
630
631@defun move-overlay overlay start end &optional buffer
632This function moves @var{overlay} to @var{buffer}, and places its bounds
633at @var{start} and @var{end}. Both arguments @var{start} and @var{end}
634must specify buffer positions; they may be integers or markers. If
635@var{buffer} is omitted, the overlay stays in the same buffer.
636
637The return value is @var{overlay}.
638
639This is the only valid way to change the endpoints of an overlay. Do
640not try modifying the markers in the overlay by hand, as that fails to
641update other vital data structures and can cause some overlays to be
642``lost''.
643@end defun
644
645@defun overlays-at pos
646This function returns a list of all the overlays that contain position
647@var{pos} in the current buffer. The list is in no particular order.
648An overlay contains position @var{pos} if it begins at or before
649@var{pos}, and ends after @var{pos}.
650@end defun
651
652@defun next-overlay-change pos
653This function returns the buffer position of the next beginning or end
654of an overlay, after @var{pos}.
655@end defun
656
657@node Faces
658@section Faces
659@cindex face
660
661A @dfn{face} is a named collection of graphical attributes: font,
662foreground color, background color and optional underlining. Faces
663control the display of text on the screen.
664
665@cindex face id
666Each face has its own @dfn{face id number} which distinguishes faces at
667low levels within Emacs. However, for most purposes, you can refer to
668faces in Lisp programs by their names.
669
670Each face name is meaningful for all frames, and by default it has the
671same meaning in all frames. But you can arrange to give a particular
672face name a special meaning in one frame if you wish.
673
674@menu
675* Standard Faces:: The faces Emacs normally comes with.
676* Merging Faces:: How Emacs decides which face to use for a character.
677* Face Functions:: How to define and examine faces.
678@end menu
679
680@node Standard Faces
681@subsection Standard Faces
682
683 This table lists all the standard faces and their uses.
684
685@table @code
686@item default
687@kindex default @r{(face name)}
688This face is used for ordinary text.
689
690@item modeline
691@kindex modeline @r{(face name)}
692This face is used for mode lines and menu bars.
693
694@item region
695@kindex region @r{(face name)}
696This face is used for highlighting the region in Transient Mark mode.
697
698@item secondary-selection
699@kindex secondary-selection @r{(face name)}
700This face is used to show any secondary selection you have made.
701
702@item highlight
703@kindex highlight @r{(face name)}
704This face is meant to be used for highlighting for various purposes.
705
706@item underline
707@kindex underline @r{(face name)}
708This face underlines text.
709
710@item bold
711@kindex bold @r{(face name)}
712This face uses a bold font, if possible. It uses the bold variant of
713the frame's font, if it has one. It's up to you to choose a default
714font that has a bold variant, if you want to use one.
715
716@item italic
717@kindex italic @r{(face name)}
718This face uses the italic variant of the frame's font, if it has one.
719
720@item bold-italic
721@kindex bold-italic @r{(face name)}
722This face uses the bold italic variant of the frame's font, if it has
723one.
724@end table
725
726@node Merging Faces
727@subsection Merging Faces for Display
728
729 Here are all the ways to specify which face to use for display of text:
730
731@itemize @bullet
732@item
733With defaults. Each frame has a @dfn{default face}, whose id number is
734zero, which is used for all text that doesn't somehow specify another
735face.
736
737@item
738With text properties. A character may have a @code{face} property; if so,
78608595 739it is displayed with that face. @xref{Special Properties}.
42b85554
RS
740
741If the character has a @code{mouse-face} property, that is used instead
742of the @code{face} property when the mouse is ``near enough'' to the
743character.
744
745@item
746With overlays. An overlay may have @code{face} and @code{mouse-face}
747properties too; they apply to all the text covered by the overlay.
748
749@item
750With special glyphs. Each glyph can specify a particular face id
751number. @xref{Glyphs}.
752@end itemize
753
754 If these various sources together specify more than one face for a
755particular character, Emacs merges the attributes of the various faces
756specified. The attributes of the faces of special glyphs come first;
757then come attributes of faces from overlays, followed by those from text
758properties, and last the default face.
759
760 When multiple overlays cover one character, an overlay with higher
761priority overrides those with lower priority. @xref{Overlays}.
762
763 If an attribute such as the font or a color is not specified in any of
764the above ways, the frame's own font or color is used.
765
766@node Face Functions
767@subsection Functions for Working with Faces
768
769 The attributes a face can specify include the font, the foreground
770color, the background color, and underlining. The face can also leave
771these unspecified by giving the value @code{nil} for them.
772
773 Here are the primitives for creating and changing faces.
774
775@defun make-face name
776This function defines a new face named @var{name}, initially with all
777attributes @code{nil}. It does nothing if there is already a face named
778@var{name}.
779@end defun
780
781@defun face-list
782This function returns a list of all defined face names.
783@end defun
784
785@defun copy-face old-face new-name &optional frame new-frame
786This function defines the face @var{new-name} as a copy of the existing
787face named @var{old-face}. It creates the face @var{new-name} if that
788doesn't already exist.
789
790If the optional argument @var{frame} is given, this function applies
791only to that frame. Otherwise it applies to each frame individually,
792copying attributes from @var{old-face} in each frame to @var{new-face}
793in the same frame.
794
795If the optional argument @var{new-frame} is given, then @code{copy-face}
796copies the attributes of @var{old-face} in @var{frame} to @var{new-name}
797in @var{new-frame}.
798@end defun
799
800 You can modify the attributes of an existing face with the following
801functions. If you specify @var{frame}, they affect just that frame;
802otherwise, they affect all frames as well as the defaults that apply to
803new frames.
804
805@defun set-face-foreground face color &optional frame
806@defunx set-face-background face color &optional frame
78608595
RS
807These functions set the foreground (or background, respectively) color
808of face @var{face} to @var{color}. The argument @var{color} should be a
42b85554
RS
809string, the name of a color.
810@end defun
811
812@defun set-face-font face font &optional frame
813This function sets the font of face @var{face}. The argument @var{font}
814should be a string.
815@end defun
816
817@defun set-face-underline-p face underline-p &optional frame
818This function sets the underline attribute of face @var{face}.
819Non-@code{nil} means do underline; @code{nil} means don't.
820@end defun
821
822@defun invert-face face &optional frame
823Swap the foreground and background colors of face @var{face}. If the
824face doesn't specify both foreground and background, then its foreground
78608595
RS
825and background are set to the default background and foreground,
826respectively.
42b85554
RS
827@end defun
828
829 These functions examine the attributes of a face. If you don't
830specify @var{frame}, they refer to the default data for new frames.
831
832@defun face-foreground face &optional frame
833@defunx face-background face &optional frame
78608595
RS
834These functions return the foreground color (or background color,
835respectively) of face @var{face}, as a string.
42b85554
RS
836@end defun
837
838@defun face-font face &optional frame
839This function returns the name of the font of face @var{face}.
840@end defun
841
842@defun face-underline-p face &optional frame
843This function returns the underline attribute of face @var{face}.
844@end defun
845
846@defun face-id-number face
847This function returns the face id number of face @var{face}.
848@end defun
849
850@defun face-equal face1 face2 &optional frame
851This returns @code{t} if the faces @var{face1} and @var{face2} have the
852same attributes for display.
853@end defun
854
855@defun face-differs-from-default-p face &optional frame
856This returns @code{t} if the face @var{face} displays differently from
857the default face. A face is considered to be ``the same'' as the normal
858face if each attribute is either the same as that of the default face or
859@code{nil} (meaning to inherit from the default).
860@end defun
861
862@defvar region-face
863This variable's value specifies the face id to use to display characters
864in the region when it is active (in Transient Mark mode only). The face
865thus specified takes precedence over all faces that come from text
866properties and overlays, for characters in the region. @xref{The Mark},
867for more information about Transient Mark mode.
868
869Normally, the value is the id number of the face named @code{region}.
870@end defvar
871
872@node Blinking
873@section Blinking Parentheses
874@cindex parenthesis matching
875@cindex blinking
876@cindex balancing parentheses
877@cindex close parenthesis
878
879 This section describes the mechanism by which Emacs shows a matching
880open parenthesis when the user inserts a close parenthesis.
881
882@vindex blink-paren-hook
883@defvar blink-paren-function
884The value of this variable should be a function (of no arguments) to
885be called whenever a character with close parenthesis syntax is inserted.
886The value of @code{blink-paren-function} may be @code{nil}, in which
887case nothing is done.
888
889@quotation
b22f3a19 890@strong{Please note:} This variable was named @code{blink-paren-hook} in
42b85554
RS
891older Emacs versions, but since it is not called with the standard
892convention for hooks, it was renamed to @code{blink-paren-function} in
893version 19.
894@end quotation
895@end defvar
896
897@defvar blink-matching-paren
898If this variable is @code{nil}, then @code{blink-matching-open} does
899nothing.
900@end defvar
901
902@defvar blink-matching-paren-distance
903This variable specifies the maximum distance to scan for a matching
904parenthesis before giving up.
905@end defvar
906
907@defun blink-matching-open
908This function is the default value of @code{blink-paren-function}. It
909assumes that point follows a character with close parenthesis syntax and
910moves the cursor momentarily to the matching opening character. If that
911character is not already on the screen, it displays the character's
912context in the echo area. To avoid long delays, this function does not
913search farther than @code{blink-matching-paren-distance} characters.
914
915Here is an example of calling this function explicitly.
916
917@smallexample
918@group
919(defun interactive-blink-matching-open ()
920@c Do not break this line! -- rms.
921@c The first line of a doc string
922@c must stand alone.
923 "Indicate momentarily the start of sexp before point."
924 (interactive)
925@end group
926@group
927 (let ((blink-matching-paren-distance
928 (buffer-size))
929 (blink-matching-paren t))
930 (blink-matching-open)))
931@end group
932@end smallexample
933@end defun
934
935@node Inverse Video
936@section Inverse Video
937@cindex Inverse Video
938
939@defopt inverse-video
940@cindex highlighting
941This variable controls whether Emacs uses inverse video for all text
942on the screen. Non-@code{nil} means yes, @code{nil} means no. The
943default is @code{nil}.
944@end defopt
945
946@defopt mode-line-inverse-video
947This variable controls the use of inverse video for mode lines. If it
948is non-@code{nil}, then mode lines are displayed in inverse video (under
949X, this uses the face named @code{modeline}, which you can set as you
950wish). Otherwise, mode lines are displayed normally, just like text.
951The default is @code{t}.
952@end defopt
953
954@node Usual Display
955@section Usual Display Conventions
956
957 The usual display conventions define how to display each character
958code. You can override these conventions by setting up a display table
959(@pxref{Display Tables}). Here are the usual display conventions:
960
961@itemize @bullet
962@item
963Character codes 32 through 126 map to glyph codes 32 through 126.
964Normally this means they display as themselves.
965
966@item
967Character code 9 is a horizontal tab. It displays as whitespace
968up to a position determined by @code{tab-width}.
969
970@item
971Character code 10 is a newline.
972
973@item
974All other codes in the range 0 through 31, and code 127, display in one
78608595 975of two ways according to the value of @code{ctl-arrow}. If it is
42b85554
RS
976non-@code{nil}, these codes map to sequences of two glyphs, where the
977first glyph is the @sc{ASCII} code for @samp{^}. (A display table can
978specify a glyph to use instead of @samp{^}.) Otherwise, these codes map
979just like the codes in the range 128 to 255.
980
981@item
982Character codes 128 through 255 map to sequences of four glyphs, where
983the first glyph is the @sc{ASCII} code for @samp{\}, and the others are
984digit characters representing the code in octal. (A display table can
985specify a glyph to use instead of @samp{\}.)
986@end itemize
987
988 The usual display conventions apply even when there is a display
989table, for any character whose entry in the active display table is
990@code{nil}. Thus, when you set up a display table, you need only
991specify the the characters for which you want unusual behavior.
992
993 These variables affect the way certain characters are displayed on the
994screen. Since they change the number of columns the characters occupy,
995they also affect the indentation functions.
996
997@defopt ctl-arrow
998@cindex control characters in display
999This buffer-local variable controls how control characters are
1000displayed. If it is non-@code{nil}, they are displayed as a caret
1001followed by the character: @samp{^A}. If it is @code{nil}, they are
1002displayed as a backslash followed by three octal digits: @samp{\001}.
1003@end defopt
1004
1005@c Following may have overfull hbox.
1006@defvar default-ctl-arrow
1007The value of this variable is the default value for @code{ctl-arrow} in
1008buffers that do not override it. @xref{Default Value}.
1009@end defvar
1010
1011@defopt tab-width
1012The value of this variable is the spacing between tab stops used for
1013displaying tab characters in Emacs buffers. The default is 8. Note
1014that this feature is completely independent from the user-settable tab
1015stops used by the command @code{tab-to-tab-stop}. @xref{Indent Tabs}.
1016@end defopt
1017
1018@node Display Tables
1019@section Display Tables
1020
1021@cindex display table
1022You can use the @dfn{display table} feature to control how all 256
1023possible character codes display on the screen. This is useful for
1024displaying European languages that have letters not in the @sc{ASCII}
1025character set.
1026
1027The display table maps each character code into a sequence of
1028@dfn{glyphs}, each glyph being an image that takes up one character
1029position on the screen. You can also define how to display each glyph
1030on your terminal, using the @dfn{glyph table}.
1031
1032@menu
1033* Display Table Format:: What a display table consists of.
1034* Active Display Table:: How Emacs selects a display table to use.
1035* Glyphs:: How to define a glyph, and what glyphs mean.
1036* ISO Latin 1:: How to use display tables
1037 to support the ISO Latin 1 character set.
1038@end menu
1039
1040@node Display Table Format
1041@subsection Display Table Format
1042
50b04c36 1043 A display table is actually an array of 262 elements.
42b85554
RS
1044
1045@defun make-display-table
1046This creates and returns a display table. The table initially has
1047@code{nil} in all elements.
1048@end defun
1049
1050 The first 256 elements correspond to character codes; the @var{n}th
1051element says how to display the character code @var{n}. The value
1052should be @code{nil} or a vector of glyph values (@pxref{Glyphs}). If
1053an element is @code{nil}, it says to display that character according to
b663a40d
RS
1054the usual display conventions (@pxref{Usual Display}). Note that the
1055display table has no effect on the tab and newline characters; they are
1056always displayed as whitespace in their usual special fashion.
42b85554 1057
50b04c36 1058 The remaining six elements of a display table serve special purposes,
42b85554
RS
1059and @code{nil} means use the default stated below.
1060
1061@table @asis
1062@item 256
1063The glyph for the end of a truncated screen line (the default for this
1064is @samp{$}). @xref{Glyphs}.
1065@item 257
1066The glyph for the end of a continued line (the default is @samp{\}).
1067@item 258
1068The glyph for indicating a character displayed as an octal character
1069code (the default is @samp{\}).
1070@item 259
1071The glyph for indicating a control character (the default is @samp{^}).
1072@item 260
1073A vector of glyphs for indicating the presence of invisible lines (the
1074default is @samp{...}). @xref{Selective Display}.
50b04c36
JB
1075@item 261
1076The glyph used to draw the border between side-by-side windows (the
1077default is @samp{|}). @xref{Splitting Windows}.
42b85554
RS
1078@end table
1079
1080 For example, here is how to construct a display table that mimics the
1081effect of setting @code{ctl-arrow} to a non-@code{nil} value:
1082
1083@example
1084(setq disptab (make-display-table))
1085(let ((i 0))
1086 (while (< i 32)
1087 (or (= i ?\t) (= i ?\n)
1088 (aset disptab i (vector ?^ (+ i 64))))
1089 (setq i (1+ i)))
1090 (aset disptab 127 (vector ?^ ??)))
1091@end example
1092
1093@node Active Display Table
1094@subsection Active Display Table
1095@cindex active display table
1096
1097 Each window can specify a display table, and so can each buffer. When
1098a buffer @var{b} is displayed in window @var{w}, display uses the
1099display table for window @var{w} if it has one; otherwise, the display
1100table for buffer @var{b} if it has one; otherwise, the standard display
1101table if any. The display table chosen is called the @dfn{active}
1102display table.
1103
1104@defun window-display-table window
1105This function returns @var{window}'s display table, or @code{nil}
1106if @var{window} does not have an assigned display table.
1107@end defun
1108
1109@defun set-window-display-table window table
1110This function sets the display table of @var{window} to @var{table}.
1111The argument @var{table} should be either a display table or
1112@code{nil}.
1113@end defun
1114
1115@defvar buffer-display-table
1116This variable is automatically local in all buffers; its value in a
1117particular buffer is the display table for that buffer, or @code{nil} if
1118the buffer does not have an assigned display table.
1119@end defvar
1120
1121@defvar standard-display-table
1122This variable's value is the default display table, used whenever a
1123window has no display table and neither does the buffer displayed in
1124that window. This variable is @code{nil} by default.
1125@end defvar
1126
1127 If there is no display table to use for a particular window---that is,
1128if the window has none, its buffer has none, and
1129@code{standard-display-table} has none---then Emacs uses the usual
1130display conventions for all character codes in that window. @xref{Usual
1131Display}.
1132
1133@node Glyphs
1134@subsection Glyphs
1135
1136@cindex glyph
1137 A @dfn{glyph} is a generalization of a character; it stands for an
1138image that takes up a single character position on the screen. Glyphs
1139are represented in Lisp as integers, just as characters are.
1140
1141@cindex glyph table
1142 The meaning of each integer, as a glyph, is defined by the glyph
1143table, which is the value of the variable @code{glyph-table}.
1144
1145@defvar glyph-table
1146The value of this variable is the current glyph table. It should be a
1147vector; the @var{g}th element defines glyph code @var{g}. If the value
1148is @code{nil} instead of a vector, then all glyphs are simple (see
1149below).
1150@end defvar
1151
1152 Here are the possible types of elements in the glyph table:
1153
1154@table @var
1155@item string
1156Send the characters in @var{string} to the terminal to output
1157this glyph. This alternative is available on character terminals,
1158but not under X.
1159
1160@item integer
1161Define this glyph code as an alias for code @var{integer}. You can use
1162an alias to specify a face code for the glyph; see below.
1163
1164@item @code{nil}
1165This glyph is simple. On an ordinary terminal, the glyph code mod 256
1166is the character to output. With X, the glyph code mod 256 is the
1167character to output, and the glyph code divided by 256 specifies the
1168@dfn{face id number} to use while outputting it. @xref{Faces}.
1169@end table
1170
1171 If a glyph code is greater than or equal to the length of the glyph
1172table, that code is automatically simple.
1173
1174@node ISO Latin 1
1175@subsection ISO Latin 1
1176
1177If you have a terminal that can handle the entire ISO Latin 1 character
1178set, you can arrange to use that character set as follows:
1179
1180@example
1181(require 'disp-table)
1182;; @r{Set char codes 160--255 to display as themselves.}
1183;; @r{(Codes 128--159 are the additional control characters.)}
1184(standard-display-8bit 160 255)
1185@end example
1186
1187If you are editing buffers written in the ISO Latin 1 character set and
78608595
RS
1188your terminal doesn't handle anything but @sc{ASCII}, you can load the
1189file @file{iso-ascii} to set up a display table that displays the other
1190ISO characters as explanatory sequences of @sc{ASCII} characters. For
1191example, the character ``o with umlaut'' displays as @samp{@{"o@}}.
42b85554
RS
1192
1193Some European countries have terminals that don't support ISO Latin 1
1194but do support the special characters for that country's language. You
1195can define a display table to work one language using such terminals.
1196For an example, see @file{lisp/iso-swed.el}, which handles certain
1197Swedish terminals.
1198
1199You can load the appropriate display table for your terminal
1200automatically by writing a terminal-specific Lisp file for the terminal
1201type.
1202
1203@node Beeping
1204@section Beeping
1205@cindex beeping
1206@cindex bell
1207
1208 You can make Emacs ring a bell (or blink the screen) to attract the
1209user's attention. Be conservative about how often you do this; frequent
1210bells can become irritating. Also be careful not to use beeping alone
1211when signaling an error is appropriate. (@xref{Errors}.)
1212
1213@defun ding &optional dont-terminate
1214@cindex keyboard macro termination
1215This function beeps, or flashes the screen (see @code{visible-bell} below).
1216It also terminates any keyboard macro currently executing unless
1217@var{dont-terminate} is non-@code{nil}.
1218@end defun
1219
1220@defun beep &optional dont-terminate
1221This is a synonym for @code{ding}.
1222@end defun
1223
1224@defvar visible-bell
1225This variable determines whether Emacs should flash the screen to
1226represent a bell. Non-@code{nil} means yes, @code{nil} means no. This
2b1e7b27
RS
1227is effective under X windows, and on a character-only terminal provided
1228the terminal's Termcap entry defines the visible bell capability
1229(@samp{vb}).
42b85554
RS
1230@end defvar
1231
1232@node Window Systems
1233@section Window Systems
1234
1235 Emacs works with several window systems, most notably the X Window
1236System. Both Emacs and X use the term ``window'', but use it
1237differently. An Emacs frame is a single window as far as X is
1238concerned; the individual Emacs windows are not known to X at all.
1239
1240@defvar window-system
1241@cindex X Window System
1242This variable tells Lisp programs what window system Emacs is running
1243under. Its value should be a symbol such as @code{x} (if Emacs is
1244running under X) or @code{nil} (if Emacs is running on an ordinary
1245terminal).
1246@end defvar
1247
1248@defvar window-system-version
1249This variable distinguishes between different versions of the X Window
1250System. Its value is 10 or 11 when using X; @code{nil} otherwise.
1251@end defvar
1252
1253@defvar window-setup-hook
1254This variable is a normal hook which Emacs runs after loading your
1255@file{.emacs} file and the default initialization file (if any), after
1256loading terminal-specific Lisp code, and after running the hook
1257@code{term-setup-hook}.
1258
1259This hook is used for internal purposes: setting up communication with
1260the window system, and creating the initial window. Users should not
1261interfere with it.
1262@end defvar