comparison man/lispref/display.texi @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children ac2d302a0011
comparison
equal deleted inserted replaced
-1:000000000000 0:376386a54a3c
1 @c -*-texinfo-*-
2 @c This is part of the XEmacs Lisp Reference Manual.
3 @c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
4 @c See the file lispref.texi for copying conditions.
5 @setfilename ../../info/display.info
6 @node Display, Hash Tables, Annotations, Top
7 @chapter Emacs Display
8
9 This chapter describes a number of other features related to the display
10 that XEmacs presents to the user.
11
12 @menu
13 * Refresh Screen:: Clearing the screen and redrawing everything on it.
14 * Truncation:: Folding or wrapping long text lines.
15 * The Echo Area:: Where messages are displayed.
16 * Invisible Text:: Hiding part of the buffer text.
17 * Selective Display:: Hiding part of the buffer text (the old way).
18 * Overlay Arrow:: Display of an arrow to indicate position.
19 * Temporary Displays:: Displays that go away automatically.
20 * Blinking:: How XEmacs shows the matching open parenthesis.
21 * Usual Display:: The usual conventions for displaying nonprinting chars.
22 * Display Tables:: How to specify other conventions.
23 * Beeping:: Audible signal to the user.
24 @end menu
25
26 @node Refresh Screen
27 @section Refreshing the Screen
28
29 The function @code{redraw-frame} redisplays the entire contents of a
30 given frame. @xref{Frames}.
31
32 @c Emacs 19 feature
33 @defun redraw-frame frame
34 This function clears and redisplays frame @var{frame}.
35 @end defun
36
37 Even more powerful is @code{redraw-display}:
38
39 @deffn Command redraw-display &optional device
40 This function redraws all frames on @var{device} marked as having their
41 image garbled. @var{device} defaults to the selected device. If
42 @var{device} is @code{t}, all devices will have their frames checked.
43 @end deffn
44
45 Processing user input takes absolute priority over redisplay. If you
46 call these functions when input is available, they do nothing
47 immediately, but a full redisplay does happen eventually---after all the
48 input has been processed.
49
50 Normally, suspending and resuming XEmacs also refreshes the screen.
51 Some terminal emulators record separate contents for display-oriented
52 programs such as XEmacs and for ordinary sequential display. If you are
53 using such a terminal, you might want to inhibit the redisplay on
54 resumption. @xref{Suspending XEmacs}.
55
56 @defvar no-redraw-on-reenter
57 @cindex suspend (cf. @code{no-redraw-on-reenter})
58 @cindex resume (cf. @code{no-redraw-on-reenter})
59 This variable controls whether XEmacs redraws the entire screen after it
60 has been suspended and resumed. Non-@code{nil} means yes, @code{nil}
61 means no.
62 @end defvar
63
64 @cindex display update
65 @cindex update display
66 @cindex refresh display
67 The above functions do not actually cause the display to be updated;
68 rather, they clear out the internal display records that XEmacs
69 maintains, so that the next time the display is updated it will be
70 redrawn from scratch. Normally this occurs the next time that
71 @code{next-event} or @code{sit-for} is called; however, a display update
72 will not occur if there is input pending. @xref{Command Loop}.
73
74 @deffn Command force-redisplay
75 @cindex force redisplay
76 This function causes an immediate update of the display in all
77 circumstances, whether or not input is pending. (This function does
78 not exist in FSF Emacs.)
79 @end deffn
80
81 @defun force-cursor-redisplay
82 This function causes an immediate update of the cursor on the selected
83 frame. (This function does not exist in FSF Emacs.)
84 @end defun
85
86 @node Truncation
87 @section Truncation
88 @cindex line wrapping
89 @cindex continuation lines
90 @cindex @samp{$} in display
91 @cindex @samp{\} in display
92
93 When a line of text extends beyond the right edge of a window, the
94 line can either be truncated or continued on the next line. When a line
95 is truncated, this is normally shown with a @samp{\} in the rightmost
96 column of the window on X displays, and with a @samp{$} on TTY devices.
97 When a line is continued or ``wrapped'' onto the next line, this is
98 shown with a curved arrow in the rightmost column of the window (or with
99 a @samp{\} on TTY devices). The additional screen lines used to display
100 a long text line are called @dfn{continuation} lines.
101
102 Normally, whenever line truncation is in effect for a particular
103 window, a horizontal scrollbar is displayed in that window if the
104 device supports scrollbars. @xref{Scrollbars}.
105
106 Note that continuation is different from filling; continuation happens
107 on the screen only, not in the buffer contents, and it breaks a line
108 precisely at the right margin, not at a word boundary. @xref{Filling}.
109
110 @defopt truncate-lines
111 This buffer-local variable controls how XEmacs displays lines that
112 extend beyond the right edge of the window. If it is non-@code{nil},
113 then XEmacs does not display continuation lines; rather each line of
114 text occupies exactly one screen line, and a backslash appears at the
115 edge of any line that extends to or beyond the edge of the window. The
116 default is @code{nil}.
117
118 If the variable @code{truncate-partial-width-windows} is non-@code{nil},
119 then truncation is always used for side-by-side windows (within one
120 frame) regardless of the value of @code{truncate-lines}.
121 @end defopt
122
123 @defopt default-truncate-lines
124 This variable is the default value for @code{truncate-lines}, for
125 buffers that do not have local values for it.
126 @end defopt
127
128 @defopt truncate-partial-width-windows
129 This variable controls display of lines that extend beyond the right
130 edge of the window, in side-by-side windows (@pxref{Splitting Windows}).
131 If it is non-@code{nil}, these lines are truncated; otherwise,
132 @code{truncate-lines} says what to do with them.
133 @end defopt
134
135 The backslash and curved arrow used to indicate truncated or continued
136 lines are only defaults, and can be changed. These images are actually
137 glyphs (@pxref{Glyphs}). XEmacs provides a great deal of flexibility
138 in how glyphs can be controlled. (This differs from FSF Emacs, which
139 uses display tables to control these images.)
140
141 For details, @ref{Redisplay Glyphs}.
142
143 @ignore Not yet in XEmacs
144 If your buffer contains @strong{very} long lines, and you use
145 continuation to display them, just thinking about them can make Emacs
146 redisplay slow. The column computation and indentation functions also
147 become slow. Then you might find it advisable to set
148 @code{cache-long-line-scans} to @code{t}.
149
150 @defvar cache-long-line-scans
151 If this variable is non-@code{nil}, various indentation and motion
152 functions, and Emacs redisplay, cache the results of scanning the
153 buffer, and consult the cache to avoid rescanning regions of the buffer
154 unless they are modified.
155
156 Turning on the cache slows down processing of short lines somewhat.
157
158 This variable is automatically local in every buffer.
159 @end defvar
160 @end ignore
161
162 @node The Echo Area
163 @section The Echo Area
164 @cindex error display
165 @cindex echo area
166
167 The @dfn{echo area} is used for displaying messages made with the
168 @code{message} primitive, and for echoing keystrokes. It is not the
169 same as the minibuffer, despite the fact that the minibuffer appears
170 (when active) in the same place on the screen as the echo area. The
171 @cite{XEmacs Reference Manual} specifies the rules for resolving conflicts
172 between the echo area and the minibuffer for use of that screen space
173 (@pxref{Minibuffer,, The Minibuffer, emacs, The XEmacs Reference Manual}).
174 Error messages appear in the echo area; see @ref{Errors}.
175
176 You can write output in the echo area by using the Lisp printing
177 functions with @code{t} as the stream (@pxref{Output Functions}), or as
178 follows:
179
180 @defun message string &rest arguments
181 This function displays a one-line message in the echo area. The
182 argument @var{string} is similar to a C language @code{printf} control
183 string. See @code{format} in @ref{String Conversion}, for the details
184 on the conversion specifications. @code{message} returns the
185 constructed string.
186
187 In batch mode, @code{message} prints the message text on the standard
188 error stream, followed by a newline.
189
190 @c Emacs 19 feature
191 If @var{string} is @code{nil}, @code{message} clears the echo area. If
192 the minibuffer is active, this brings the minibuffer contents back onto
193 the screen immediately.
194
195 @example
196 @group
197 (message "Minibuffer depth is %d."
198 (minibuffer-depth))
199 @print{} Minibuffer depth is 0.
200 @result{} "Minibuffer depth is 0."
201 @end group
202
203 @group
204 ---------- Echo Area ----------
205 Minibuffer depth is 0.
206 ---------- Echo Area ----------
207 @end group
208 @end example
209 @end defun
210
211 Almost all the messages displayed in the echo area are also recorded
212 in the @samp{*Messages*} buffer.
213
214 @defopt message-log-max
215 This variable specifies how many lines to keep in the @samp{*Messages*}
216 buffer. The value @code{t} means there is no limit on how many lines to
217 keep. The value @code{nil} disables message logging entirely. Here's
218 how to display a message and prevent it from being logged:
219
220 @example
221 (let (message-log-max)
222 (message @dots{}))
223 @end example
224 @end defopt
225
226 @defvar echo-keystrokes
227 This variable determines how much time should elapse before command
228 characters echo. Its value must be an integer, which specifies the
229 number of seconds to wait before echoing. If the user types a prefix
230 key (such as @kbd{C-x}) and then delays this many seconds before
231 continuing, the prefix key is echoed in the echo area. Any subsequent
232 characters in the same command will be echoed as well.
233
234 If the value is zero, then command input is not echoed.
235 @end defvar
236
237 @defvar cursor-in-echo-area
238 This variable controls where the cursor appears when a message is
239 displayed in the echo area. If it is non-@code{nil}, then the cursor
240 appears at the end of the message. Otherwise, the cursor appears at
241 point---not in the echo area at all.
242
243 The value is normally @code{nil}; Lisp programs bind it to @code{t}
244 for brief periods of time.
245 @end defvar
246
247 @node Invisible Text
248 @section Invisible Text
249
250 @cindex invisible text
251 You can make characters @dfn{invisible}, so that they do not appear on
252 the screen, with the @code{invisible} property. This can be either a
253 text property or a property of an overlay.
254
255 In the simplest case, any non-@code{nil} @code{invisible} property makes
256 a character invisible. This is the default case---if you don't alter
257 the default value of @code{buffer-invisibility-spec}, this is how the
258 @code{invisibility} property works. This feature is much like selective
259 display (@pxref{Selective Display}), but more general and cleaner.
260
261 More generally, you can use the variable @code{buffer-invisibility-spec}
262 to control which values of the @code{invisible} property make text
263 invisible. This permits you to classify the text into different subsets
264 in advance, by giving them different @code{invisible} values, and
265 subsequently make various subsets visible or invisible by changing the
266 value of @code{buffer-invisibility-spec}.
267
268 Controlling visibility with @code{buffer-invisibility-spec} is
269 especially useful in a program to display the list of entries in a data
270 base. It permits the implementation of convenient filtering commands to
271 view just a part of the entries in the data base. Setting this variable
272 is very fast, much faster than scanning all the text in the buffer
273 looking for properties to change.
274
275 @defvar buffer-invisibility-spec
276 This variable specifies which kinds of @code{invisible} properties
277 actually make a character invisible.
278
279 @table @asis
280 @item @code{t}
281 A character is invisible if its @code{invisible} property is
282 non-@code{nil}. This is the default.
283
284 @item a list
285 Each element of the list makes certain characters invisible.
286 Ultimately, a character is invisible if any of the elements of this list
287 applies to it. The list can have two kinds of elements:
288
289 @table @code
290 @item @var{atom}
291 A character is invisible if its @code{invisible} propery value
292 is @var{atom} or if it is a list with @var{atom} as a member.
293
294 @item (@var{atom} . t)
295 A character is invisible if its @code{invisible} propery value
296 is @var{atom} or if it is a list with @var{atom} as a member.
297 Moreover, if this character is at the end of a line and is followed
298 by a visible newline, it displays an ellipsis.
299 @end table
300 @end table
301 @end defvar
302
303 Ordinarily, commands that operate on text or move point do not care
304 whether the text is invisible. However, the user-level line motion
305 commands explicitly ignore invisible newlines.
306
307 @node Selective Display
308 @section Selective Display
309 @cindex selective display
310
311 @dfn{Selective display} is a pair of features that hide certain
312 lines on the screen.
313
314 The first variant, explicit selective display, is designed for use in
315 a Lisp program. The program controls which lines are hidden by altering
316 the text. Outline mode has traditionally used this variant. It has
317 been partially replaced by the invisible text feature (@pxref{Invisible
318 Text}); there is a new version of Outline mode which uses that instead.
319
320 In the second variant, the choice of lines to hide is made
321 automatically based on indentation. This variant is designed to be a
322 user-level feature.
323
324 The way you control explicit selective display is by replacing a
325 newline (control-j) with a carriage return (control-m). The text that
326 was formerly a line following that newline is now invisible. Strictly
327 speaking, it is temporarily no longer a line at all, since only newlines
328 can separate lines; it is now part of the previous line.
329
330 Selective display does not directly affect editing commands. For
331 example, @kbd{C-f} (@code{forward-char}) moves point unhesitatingly into
332 invisible text. However, the replacement of newline characters with
333 carriage return characters affects some editing commands. For example,
334 @code{next-line} skips invisible lines, since it searches only for
335 newlines. Modes that use selective display can also define commands
336 that take account of the newlines, or that make parts of the text
337 visible or invisible.
338
339 When you write a selectively displayed buffer into a file, all the
340 control-m's are output as newlines. This means that when you next read
341 in the file, it looks OK, with nothing invisible. The selective display
342 effect is seen only within XEmacs.
343
344 @defvar selective-display
345 This buffer-local variable enables selective display. This means that
346 lines, or portions of lines, may be made invisible.
347
348 @itemize @bullet
349 @item
350 If the value of @code{selective-display} is @code{t}, then any portion
351 of a line that follows a control-m is not displayed.
352
353 @item
354 If the value of @code{selective-display} is a positive integer, then
355 lines that start with more than that many columns of indentation are not
356 displayed.
357 @end itemize
358
359 When some portion of a buffer is invisible, the vertical movement
360 commands operate as if that portion did not exist, allowing a single
361 @code{next-line} command to skip any number of invisible lines.
362 However, character movement commands (such as @code{forward-char}) do
363 not skip the invisible portion, and it is possible (if tricky) to insert
364 or delete text in an invisible portion.
365
366 In the examples below, we show the @emph{display appearance} of the
367 buffer @code{foo}, which changes with the value of
368 @code{selective-display}. The @emph{contents} of the buffer do not
369 change.
370
371 @example
372 @group
373 (setq selective-display nil)
374 @result{} nil
375
376 ---------- Buffer: foo ----------
377 1 on this column
378 2on this column
379 3n this column
380 3n this column
381 2on this column
382 1 on this column
383 ---------- Buffer: foo ----------
384 @end group
385
386 @group
387 (setq selective-display 2)
388 @result{} 2
389
390 ---------- Buffer: foo ----------
391 1 on this column
392 2on this column
393 2on this column
394 1 on this column
395 ---------- Buffer: foo ----------
396 @end group
397 @end example
398 @end defvar
399
400 @defvar selective-display-ellipses
401 If this buffer-local variable is non-@code{nil}, then XEmacs displays
402 @samp{@dots{}} at the end of a line that is followed by invisible text.
403 This example is a continuation of the previous one.
404
405 @example
406 @group
407 (setq selective-display-ellipses t)
408 @result{} t
409
410 ---------- Buffer: foo ----------
411 1 on this column
412 2on this column ...
413 2on this column
414 1 on this column
415 ---------- Buffer: foo ----------
416 @end group
417 @end example
418
419 You can use a display table to substitute other text for the ellipsis
420 (@samp{@dots{}}). @xref{Display Tables}.
421 @end defvar
422
423 @node Overlay Arrow
424 @section The Overlay Arrow
425 @cindex overlay arrow
426
427 The @dfn{overlay arrow} is useful for directing the user's attention
428 to a particular line in a buffer. For example, in the modes used for
429 interface to debuggers, the overlay arrow indicates the line of code
430 about to be executed.
431
432 @defvar overlay-arrow-string
433 This variable holds the string to display to call attention to a
434 particular line, or @code{nil} if the arrow feature is not in use.
435 Despite its name, the value of this variable can be either a string
436 or a glyph (@pxref{Glyphs}).
437 @end defvar
438
439 @defvar overlay-arrow-position
440 This variable holds a marker that indicates where to display the overlay
441 arrow. It should point at the beginning of a line. The arrow text
442 appears at the beginning of that line, overlaying any text that would
443 otherwise appear. Since the arrow is usually short, and the line
444 usually begins with indentation, normally nothing significant is
445 overwritten.
446
447 The overlay string is displayed only in the buffer that this marker
448 points into. Thus, only one buffer can have an overlay arrow at any
449 given time.
450 @c !!! overlay-arrow-position: but the overlay string may remain in the display
451 @c of some other buffer until an update is required. This should be fixed
452 @c now. Is it?
453 @end defvar
454
455 You can do the same job by creating an extent with a
456 @code{begin-glyph} property. @xref{Extent Properties}.
457
458 @node Temporary Displays
459 @section Temporary Displays
460
461 Temporary displays are used by commands to put output into a buffer
462 and then present it to the user for perusal rather than for editing.
463 Many of the help commands use this feature.
464
465 @defspec with-output-to-temp-buffer buffer-name forms@dots{}
466 This function executes @var{forms} while arranging to insert any
467 output they print into the buffer named @var{buffer-name}. The buffer
468 is then shown in some window for viewing, displayed but not selected.
469
470 The string @var{buffer-name} specifies the temporary buffer, which
471 need not already exist. The argument must be a string, not a buffer.
472 The buffer is erased initially (with no questions asked), and it is
473 marked as unmodified after @code{with-output-to-temp-buffer} exits.
474
475 @code{with-output-to-temp-buffer} binds @code{standard-output} to the
476 temporary buffer, then it evaluates the forms in @var{forms}. Output
477 using the Lisp output functions within @var{forms} goes by default to
478 that buffer (but screen display and messages in the echo area, although
479 they are ``output'' in the general sense of the word, are not affected).
480 @xref{Output Functions}.
481
482 The value of the last form in @var{forms} is returned.
483
484 @example
485 @group
486 ---------- Buffer: foo ----------
487 This is the contents of foo.
488 ---------- Buffer: foo ----------
489 @end group
490
491 @group
492 (with-output-to-temp-buffer "foo"
493 (print 20)
494 (print standard-output))
495 @result{} #<buffer foo>
496
497 ---------- Buffer: foo ----------
498 20
499
500 #<buffer foo>
501
502 ---------- Buffer: foo ----------
503 @end group
504 @end example
505 @end defspec
506
507 @defvar temp-buffer-show-function
508 If this variable is non-@code{nil}, @code{with-output-to-temp-buffer}
509 calls it as a function to do the job of displaying a help buffer. The
510 function gets one argument, which is the buffer it should display.
511
512 In Emacs versions 18 and earlier, this variable was called
513 @code{temp-buffer-show-hook}.
514 @end defvar
515
516 @defun momentary-string-display string position &optional char message
517 This function momentarily displays @var{string} in the current buffer at
518 @var{position}. It has no effect on the undo list or on the buffer's
519 modification status.
520
521 The momentary display remains until the next input event. If the next
522 input event is @var{char}, @code{momentary-string-display} ignores it
523 and returns. Otherwise, that event remains buffered for subsequent use
524 as input. Thus, typing @var{char} will simply remove the string from
525 the display, while typing (say) @kbd{C-f} will remove the string from
526 the display and later (presumably) move point forward. The argument
527 @var{char} is a space by default.
528
529 The return value of @code{momentary-string-display} is not meaningful.
530
531 You can do the same job in a more general way by creating an extent
532 with a begin-glyph property. @xref{Extent Properties}.
533
534 If @var{message} is non-@code{nil}, it is displayed in the echo area
535 while @var{string} is displayed in the buffer. If it is @code{nil}, a
536 default message says to type @var{char} to continue.
537
538 In this example, point is initially located at the beginning of the
539 second line:
540
541 @example
542 @group
543 ---------- Buffer: foo ----------
544 This is the contents of foo.
545 @point{}Second line.
546 ---------- Buffer: foo ----------
547 @end group
548
549 @group
550 (momentary-string-display
551 "**** Important Message! ****"
552 (point) ?\r
553 "Type RET when done reading")
554 @result{} t
555 @end group
556
557 @group
558 ---------- Buffer: foo ----------
559 This is the contents of foo.
560 **** Important Message! ****Second line.
561 ---------- Buffer: foo ----------
562
563 ---------- Echo Area ----------
564 Type RET when done reading
565 ---------- Echo Area ----------
566 @end group
567 @end example
568
569 This function works by actually changing the text in the buffer. As a
570 result, if you later undo in this buffer, you will see the message come
571 and go.
572 @end defun
573
574 @node Blinking
575 @section Blinking Parentheses
576 @cindex parenthesis matching
577 @cindex blinking
578 @cindex balancing parentheses
579 @cindex close parenthesis
580
581 This section describes the mechanism by which XEmacs shows a matching
582 open parenthesis when the user inserts a close parenthesis.
583
584 @vindex blink-paren-hook
585 @defvar blink-paren-function
586 The value of this variable should be a function (of no arguments) to
587 be called whenever a character with close parenthesis syntax is inserted.
588 The value of @code{blink-paren-function} may be @code{nil}, in which
589 case nothing is done.
590
591 @quotation
592 @strong{Please note:} This variable was named @code{blink-paren-hook} in
593 older Emacs versions, but since it is not called with the standard
594 convention for hooks, it was renamed to @code{blink-paren-function} in
595 version 19.
596 @end quotation
597 @end defvar
598
599 @defvar blink-matching-paren
600 If this variable is @code{nil}, then @code{blink-matching-open} does
601 nothing.
602 @end defvar
603
604 @defvar blink-matching-paren-distance
605 This variable specifies the maximum distance to scan for a matching
606 parenthesis before giving up.
607 @end defvar
608
609 @defvar blink-matching-paren-delay
610 This variable specifies the number of seconds for the cursor to remain
611 at the matching parenthesis. A fraction of a second often gives
612 good results, but the default is 1, which works on all systems.
613 @end defvar
614
615 @defun blink-matching-open
616 This function is the default value of @code{blink-paren-function}. It
617 assumes that point follows a character with close parenthesis syntax and
618 moves the cursor momentarily to the matching opening character. If that
619 character is not already on the screen, it displays the character's
620 context in the echo area. To avoid long delays, this function does not
621 search farther than @code{blink-matching-paren-distance} characters.
622
623 Here is an example of calling this function explicitly.
624
625 @smallexample
626 @group
627 (defun interactive-blink-matching-open ()
628 @c Do not break this line! -- rms.
629 @c The first line of a doc string
630 @c must stand alone.
631 "Indicate momentarily the start of sexp before point."
632 (interactive)
633 @end group
634 @group
635 (let ((blink-matching-paren-distance
636 (buffer-size))
637 (blink-matching-paren t))
638 (blink-matching-open)))
639 @end group
640 @end smallexample
641 @end defun
642
643 @node Usual Display
644 @section Usual Display Conventions
645
646 The usual display conventions define how to display each character
647 code. You can override these conventions by setting up a display table
648 (@pxref{Display Tables}). Here are the usual display conventions:
649
650 @itemize @bullet
651 @item
652 Character codes 32 through 126 map to glyph codes 32 through 126.
653 Normally this means they display as themselves.
654
655 @item
656 Character code 9 is a horizontal tab. It displays as whitespace
657 up to a position determined by @code{tab-width}.
658
659 @item
660 Character code 10 is a newline.
661
662 @item
663 All other codes in the range 0 through 31, and code 127, display in one
664 of two ways according to the value of @code{ctl-arrow}. If it is
665 non-@code{nil}, these codes map to sequences of two glyphs, where the
666 first glyph is the @sc{ASCII} code for @samp{^}. (A display table can
667 specify a glyph to use instead of @samp{^}.) Otherwise, these codes map
668 just like the codes in the range 128 to 255.
669
670 @item
671 Character codes 128 through 255 map to sequences of four glyphs, where
672 the first glyph is the @sc{ASCII} code for @samp{\}, and the others are
673 digit characters representing the code in octal. (A display table can
674 specify a glyph to use instead of @samp{\}.)
675 @end itemize
676
677 The usual display conventions apply even when there is a display
678 table, for any character whose entry in the active display table is
679 @code{nil}. Thus, when you set up a display table, you need only
680 specify the characters for which you want unusual behavior.
681
682 These variables affect the way certain characters are displayed on the
683 screen. Since they change the number of columns the characters occupy,
684 they also affect the indentation functions.
685
686 @defopt ctl-arrow
687 @cindex control characters in display
688 This buffer-local variable controls how control characters are
689 displayed. If it is non-@code{nil}, they are displayed as a caret
690 followed by the character: @samp{^A}. If it is @code{nil}, they are
691 displayed as a backslash followed by three octal digits: @samp{\001}.
692 @end defopt
693
694 @c Following may have overfull hbox.
695 @defvar default-ctl-arrow
696 The value of this variable is the default value for @code{ctl-arrow} in
697 buffers that do not override it. @xref{Default Value}.
698 @end defvar
699
700 @defopt tab-width
701 The value of this variable is the spacing between tab stops used for
702 displaying tab characters in Emacs buffers. The default is 8. Note
703 that this feature is completely independent from the user-settable tab
704 stops used by the command @code{tab-to-tab-stop}. @xref{Indent Tabs}.
705 @end defopt
706
707 @node Display Tables
708 @section Display Tables
709
710 @cindex display table
711 You can use the @dfn{display table} feature to control how all 256
712 possible character codes display on the screen. This is useful for
713 displaying European languages that have letters not in the @sc{ASCII}
714 character set.
715
716 The display table maps each character code into a sequence of
717 @dfn{runes}, each rune being an image that takes up one character
718 position on the screen. You can also define how to display each rune
719 on your terminal, using the @dfn{rune table}.
720
721 @menu
722 * Display Table Format:: What a display table consists of.
723 * Active Display Table:: How XEmacs selects a display table to use.
724 * Character Descriptors:: Format of an individual element of a
725 display table.
726 @end menu
727
728 @ignore Not yet working in XEmacs?
729 * ISO Latin 1:: How to use display tables
730 to support the ISO Latin 1 character set.
731 @end ignore
732
733 @node Display Table Format
734 @subsection Display Table Format
735
736 A display table is an array of 256 elements. (In FSF Emacs, a display
737 table is 262 elements. The six extra elements specify the truncation
738 and continuation glyphs, etc. This method is very kludgey, and in
739 XEmacs the variables @code{truncation-glyph}, @code{continuation-glyph},
740 etc. are used. @xref{Truncation}.)
741
742 @defun make-display-table
743 This creates and returns a display table. The table initially has
744 @code{nil} in all elements.
745 @end defun
746
747 The 256 elements correspond to character codes; the @var{n}th
748 element says how to display the character code @var{n}. The value
749 should be @code{nil}, a string, a glyph, or a vector of strings and
750 glyphs (@pxref{Character Descriptors}). If an element is @code{nil},
751 it says to display that character according to the usual display
752 conventions (@pxref{Usual Display}).
753
754 If you use the display table to change the display of newline
755 characters, the whole buffer will be displayed as one long ``line.''
756
757 For example, here is how to construct a display table that mimics the
758 effect of setting @code{ctl-arrow} to a non-@code{nil} value:
759
760 @example
761 (setq disptab (make-display-table))
762 (let ((i 0))
763 (while (< i 32)
764 (or (= i ?\t) (= i ?\n)
765 (aset disptab i (concat "^" (char-to-string (+ i 64)))))
766 (setq i (1+ i)))
767 (aset disptab 127 "^?"))
768 @end example
769
770 @node Active Display Table
771 @subsection Active Display Table
772 @cindex active display table
773
774 The active display table is controlled by the variable
775 @code{current-display-table}. This is a specifier, which means
776 that you can specify separate values for it in individual buffers,
777 windows, frames, and devices, as well as a global value. It also
778 means that you cannot set this variable using @code{setq}; use
779 @code{set-specifier} instead. @xref{Specifiers}. (FSF Emacs
780 uses @code{window-display-table}, @code{buffer-display-table},
781 @code{standard-display-table}, etc. to control the display table.
782 However, specifiers are a cleaner and more powerful way of doing
783 the same thing. FSF Emacs also uses a different format for
784 the contents of a display table, using additional indirection
785 to a ``glyph table'' and such. Note that ``glyph'' has a different
786 meaning in XEmacs.)
787
788 Individual faces can also specify an overriding display table;
789 this is set using @code{set-face-display-table}. @xref{Faces}.
790
791 If no display table can be determined for a particular window,
792 then XEmacs uses the usual display conventions. @xref{Usual Display}.
793
794 @node Character Descriptors
795 @subsection Character Descriptors
796
797 @cindex character descriptor
798 Each element of the display-table vector describes how to display
799 a particular character and is called a @dfn{character descriptor}.
800 A character descriptor can be:
801
802 @table @asis
803 @item a string
804 Display this particular string wherever the character is to be displayed.
805
806 @item a glyph
807 Display this particular glyph wherever the character is to be displayed.
808
809 @item a vector
810 The vector may contain strings and/or glyphs. Display the elements of
811 the vector one after another wherever the character is to be displayed.
812
813 @item @code{nil}
814 Display according to the standard interpretation (@pxref{Usual Display}).
815 @end table
816
817 @ignore Not yet working in XEmacs?
818 @node ISO Latin 1
819 @subsection ISO Latin 1
820
821 If you have a terminal that can handle the entire ISO Latin 1 character
822 set, you can arrange to use that character set as follows:
823
824 @example
825 (require 'disp-table)
826 ;; @r{Set char codes 160--255 to display as themselves.}
827 ;; @r{(Codes 128--159 are the additional control characters.)}
828 (standard-display-8bit 160 255)
829 @end example
830
831 If you are editing buffers written in the ISO Latin 1 character set and
832 your terminal doesn't handle anything but @sc{ASCII}, you can load the
833 file @file{iso-ascii} to set up a display table that displays the other
834 ISO characters as explanatory sequences of @sc{ASCII} characters. For
835 example, the character ``o with umlaut'' displays as @samp{@{"o@}}.
836
837 Some European countries have terminals that don't support ISO Latin 1
838 but do support the special characters for that country's language. You
839 can define a display table to work one language using such terminals.
840 For an example, see @file{lisp/iso-swed.el}, which handles certain
841 Swedish terminals.
842
843 You can load the appropriate display table for your terminal
844 automatically by writing a terminal-specific Lisp file for the terminal
845 type.
846 @end ignore
847
848 @node Beeping
849 @section Beeping
850 @cindex beeping
851 @cindex bell
852 @cindex sound
853
854 You can make XEmacs ring a bell, play a sound, or blink the screen to
855 attract the user's attention. Be conservative about how often you do
856 this; frequent bells can become irritating. Also be careful not to use
857 beeping alone when signaling an error is appropriate. (@xref{Errors}.)
858
859 @defun ding &optional dont-terminate sound device
860 @cindex keyboard macro termination
861 This function beeps, or flashes the screen (see @code{visible-bell}
862 below). It also terminates any keyboard macro currently executing
863 unless @var{dont-terminate} is non-@code{nil}. If @var{sound} is
864 specified, it should be a symbol specifying which sound to make. This
865 sound will be played if @code{visible-bell} is @code{nil}. (This only
866 works if sound support was compiled into the executable and you are
867 running on the console of a Sun SparcStation, SGI, or HP9000s700.
868 Otherwise you just get a beep.) The optional third argument specifies
869 what device to make the sound on, and defaults to the selected device.
870 @end defun
871
872 @defun beep &optional dont-terminate sound device
873 This is a synonym for @code{ding}.
874 @end defun
875
876 @defopt visible-bell
877 This variable determines whether XEmacs should flash the screen to
878 represent a bell. Non-@code{nil} means yes, @code{nil} means no. On
879 TTY devices, this is effective only if the Termcap entry for the
880 terminal type has the visible bell flag (@samp{vb}) set.
881 @end defopt
882
883 @defvar sound-alist
884 This variable holds an alist associating names with sounds. When
885 @code{beep} or @code{ding} is called with one of the name symbols, the
886 associated sound will be generated instead of the standard beep.
887
888 Each element of @code{sound-alist} is a list describing a sound. The
889 first element of the list is the name of the sound being defined.
890 Subsequent elements of the list are alternating keyword/value pairs:
891
892 @table @code
893 @item sound
894 A string of raw sound data, or the name of another sound to play. The
895 symbol @code{t} here means use the default X beep.
896 @item volume
897 An integer from 0-100, defaulting to @code{bell-volume}.
898 @item pitch
899 If using the default X beep, the pitch (Hz) to generate.
900 @item duration
901 If using the default X beep, the duration (milliseconds).
902 @end table
903
904 For compatibility, elements of `sound-alist' may also be:
905
906 @itemize @bullet
907 @item
908 @code{( sound-name . <sound> )}
909 @item
910 @code{( sound-name <volume> <sound> )}
911 @end itemize
912
913 You should probably add things to this list by calling the function
914 @code{load-sound-file}.
915
916 Caveats:
917
918 @itemize @minus
919 @item
920 You can only play audio data if running on the console screen of a Sun
921 SparcStation, SGI, or HP9000s700.
922
923 @item
924 The pitch, duration, and volume options are available everywhere, but
925 many X servers ignore the `pitch' option.
926 @end itemize
927
928 The following beep-types are used by XEmacs itself:
929
930 @table @code
931 @item auto-save-error
932 when an auto-save does not succeed
933 @item command-error
934 when the XEmacs command loop catches an error
935 @item undefined-key
936 when you type a key that is undefined
937 @item undefined-click
938 when you use an undefined mouse-click combination
939 @item no-completion
940 during completing-read
941 @item y-or-n-p
942 when you type something other than 'y' or 'n'
943 @item yes-or-no-p
944 when you type something other than 'yes' or 'no'
945 @item default
946 used when nothing else is appropriate.
947 @end table
948
949 Other lisp packages may use other beep types, but these are the ones that
950 the C kernel of XEmacs uses.
951 @end defvar
952
953 @defopt bell-volume
954 This variable specifies the default volume for sounds, from 0 to 100.
955 @end defopt
956
957 @deffn Command load-default-sounds
958 This function loads and installs some sound files as beep-types.
959 @end deffn
960
961 @deffn Command load-sound-file filename sound-name &optional volume
962 This function reads in an audio file and adds it to @code{sound-alist}.
963 The sound file must be in the Sun/NeXT U-LAW format. @var{sound-name}
964 should be a symbol, specifying the name of the sound. If @var{volume}
965 is specified, the sound will be played at that volume; otherwise, the
966 value of @var{bell-volume} will be used.
967 @end deffn
968
969 @defun play-sound sound &optional volume device
970 This function plays sound @var{sound}, which should be a symbol
971 mentioned in @code{sound-alist}. If @var{volume} is specified, it
972 overrides the value (if any) specified in @code{sound-alist}.
973 @var{device} specifies the device to play the sound on, and defaults
974 to the selected device.
975 @end defun
976
977 @deffn Command play-sound-file file &optional volume device
978 This function plays the named sound file at volume @var{volume}, which
979 defaults to @code{bell-volume}. @var{device} specifies the device to
980 play the sound on, and defaults to the selected device.
981 @end deffn