XEmacs 21.2.38 (Peisino)
[chise/xemacs-chise.git.1] / man / lispref / display.texi
1 @c -*-texinfo-*-
2 @c This is part of the XEmacs Lisp Reference Manual.
3 @c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1998 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 * Warnings::            Display of Warnings.
17 * Invisible Text::      Hiding part of the buffer text.
18 * Selective Display::   Hiding part of the buffer text (the old way).
19 * Overlay Arrow::       Display of an arrow to indicate position.
20 * Temporary Displays::  Displays that go away automatically.
21 * Blinking::            How XEmacs shows the matching open parenthesis.
22 * Usual Display::       The usual conventions for displaying nonprinting chars.
23 * Display Tables::      How to specify other conventions.
24 * Beeping::             Audible signal to the user.
25 @end menu
26
27 @node Refresh Screen
28 @section Refreshing the Screen
29
30 The function @code{redraw-frame} redisplays the entire contents of a
31 given frame.  @xref{Frames}.
32
33 @defun redraw-frame &optional frame no-preempt
34 This function clears and redisplays frame @var{frame}.
35
36 @var{frame} defaults to the selected frame if omitted.
37
38 Normally, redisplay is preempted as normal if input arrives.  However,
39 if optional second arg @var{no-preempt} is non-@code{nil}, redisplay
40 will not stop for input and is guaranteed to proceed to completion.
41 @end defun
42
43 Even more powerful is @code{redraw-display}:
44
45 @deffn Command redraw-display &optional device
46 This function redraws all frames on @var{device} marked as having their
47 image garbled.  @var{device} defaults to the selected device.  If
48 @var{device} is @code{t}, all devices will have their frames checked.
49 @end deffn
50
51   Processing user input takes absolute priority over redisplay.  If you
52 call these functions when input is available, they do nothing
53 immediately, but a full redisplay does happen eventually---after all the
54 input has been processed.
55
56   Normally, suspending and resuming XEmacs also refreshes the screen.
57 Some terminal emulators record separate contents for display-oriented
58 programs such as XEmacs and for ordinary sequential display.  If you are
59 using such a terminal, you might want to inhibit the redisplay on
60 resumption.  @xref{Suspending XEmacs}.
61
62 @defvar no-redraw-on-reenter
63 @cindex suspend (cf. @code{no-redraw-on-reenter})
64 @cindex resume (cf. @code{no-redraw-on-reenter})
65 This variable controls whether XEmacs redraws the entire screen after it
66 has been suspended and resumed.  Non-@code{nil} means yes, @code{nil}
67 means no.
68 @end defvar
69
70 @cindex display update
71 @cindex update display
72 @cindex refresh display
73   The above functions do not actually cause the display to be updated;
74 rather, they clear out the internal display records that XEmacs
75 maintains, so that the next time the display is updated it will be
76 redrawn from scratch.  Normally this occurs the next time that
77 @code{next-event} or @code{sit-for} is called; however, a display update
78 will not occur if there is input pending.  @xref{Command Loop}.
79
80 @defun force-cursor-redisplay &optional frame
81 This function causes an immediate update of the cursor on @var{frame},
82 which defaults to the selected frame.
83 @end defun
84
85 @node Truncation
86 @section Truncation
87 @cindex line wrapping
88 @cindex continuation lines
89 @cindex @samp{$} in display
90 @cindex @samp{\} in display
91
92   When a line of text extends beyond the right edge of a window, the
93 line can either be truncated or continued on the next line.  When a line
94 is truncated, this is normally shown with a @samp{\} in the rightmost
95 column of the window on X displays, and with a @samp{$} on TTY devices.
96 When a line is continued or ``wrapped'' onto the next line, this is
97 shown with a curved arrow in the rightmost column of the window (or with
98 a @samp{\} on TTY devices).  The additional screen lines used to display
99 a long text line are called @dfn{continuation} lines.
100
101   Normally, whenever line truncation is in effect for a particular
102 window, a horizontal scrollbar is displayed in that window if the
103 device supports scrollbars.  @xref{Scrollbars}.
104
105   Note that continuation is different from filling; continuation happens
106 on the screen only, not in the buffer contents, and it breaks a line
107 precisely at the right margin, not at a word boundary.  @xref{Filling}.
108
109 @defopt truncate-lines
110 This buffer-local variable controls how XEmacs displays lines that
111 extend beyond the right edge of the window.  If it is non-@code{nil},
112 then XEmacs does not display continuation lines; rather each line of
113 text occupies exactly one screen line, and a backslash appears at the
114 edge of any line that extends to or beyond the edge of the window.  The
115 default is @code{nil}.
116
117 If the variable @code{truncate-partial-width-windows} is non-@code{nil},
118 then truncation is always used for side-by-side windows (within one
119 frame) regardless of the value of @code{truncate-lines}.
120 @end defopt
121
122 @defopt default-truncate-lines
123 This variable is the default value for @code{truncate-lines}, for
124 buffers that do not have local values for it.
125 @end defopt
126
127 @defopt truncate-partial-width-windows
128 This variable controls display of lines that extend beyond the right
129 edge of the window, in side-by-side windows (@pxref{Splitting Windows}).
130 If it is non-@code{nil}, these lines are truncated; otherwise,
131 @code{truncate-lines} says what to do with them.
132 @end defopt
133
134   The backslash and curved arrow used to indicate truncated or continued
135 lines are only defaults, and can be changed.  These images are actually
136 glyphs (@pxref{Glyphs}).  XEmacs provides a great deal of flexibility
137 in how glyphs can be controlled. (This differs from FSF Emacs, which
138 uses display tables to control these images.)
139
140   For details, @ref{Redisplay Glyphs}.
141
142 @ignore Not yet in XEmacs
143   If your buffer contains @strong{very} long lines, and you use
144 continuation to display them, just thinking about them can make Emacs
145 redisplay slow.  The column computation and indentation functions also
146 become slow.  Then you might find it advisable to set
147 @code{cache-long-line-scans} to @code{t}.
148
149 @defvar cache-long-line-scans
150 If this variable is non-@code{nil}, various indentation and motion
151 functions, and Emacs redisplay, cache the results of scanning the
152 buffer, and consult the cache to avoid rescanning regions of the buffer
153 unless they are modified.
154
155 Turning on the cache slows down processing of short lines somewhat.
156
157 This variable is automatically local in every buffer.
158 @end defvar
159 @end ignore
160
161 @node The Echo Area
162 @section The Echo Area
163 @cindex error display
164 @cindex echo area
165
166 The @dfn{echo area} is used for displaying messages made with the
167 @code{message} primitive, and for echoing keystrokes.  It is not the
168 same as the minibuffer, despite the fact that the minibuffer appears
169 (when active) in the same place on the screen as the echo area.  The
170 @cite{XEmacs Lisp Reference Manual} specifies the rules for resolving conflicts
171 between the echo area and the minibuffer for use of that screen space
172 (@pxref{Minibuffer,, The Minibuffer, xemacs, The XEmacs Lisp Reference Manual}).
173 Error messages appear in the echo area; see @ref{Errors}.
174
175 You can write output in the echo area by using the Lisp printing
176 functions with @code{t} as the stream (@pxref{Output Functions}), or as
177 follows:
178
179 @defun message string &rest arguments
180 This function displays a one-line message in the echo area.  The
181 argument @var{string} is similar to a C language @code{printf} control
182 string.  See @code{format} in @ref{String Conversion}, for the details
183 on the conversion specifications.  @code{message} returns the
184 constructed string.
185
186 In batch mode, @code{message} prints the message text on the standard
187 error stream, followed by a newline.
188
189 @c Emacs 19 feature
190 If @var{string} is @code{nil}, @code{message} clears the echo area.  If
191 the minibuffer is active, this brings the minibuffer contents back onto
192 the screen immediately.
193
194 @example
195 @group
196 (message "Minibuffer depth is %d."
197          (minibuffer-depth))
198  @print{} Minibuffer depth is 0.
199 @result{} "Minibuffer depth is 0."
200 @end group
201
202 @group
203 ---------- Echo Area ----------
204 Minibuffer depth is 0.
205 ---------- Echo Area ----------
206 @end group
207 @end example
208 @end defun
209
210 In addition to only displaying a message, XEmacs allows you to
211 @dfn{label} your messages, giving you fine-grained control of their
212 display.  Message label is a symbol denoting the message type.  Some
213 standard labels are:
214
215 @itemize @bullet
216 @item @code{message}---default label used by the @code{message}
217 function;
218
219 @item @code{error}---default label used for reporting errors;
220
221 @item @code{progress}---progress indicators like
222 @samp{Converting... 45%} (not logged by default);
223
224 @item @code{prompt}---prompt-like messages like @samp{Isearch: foo} (not
225 logged by default);
226
227 @item @code{command}---helper command messages like @samp{Mark set} (not
228 logged by default);
229
230 @item @code{no-log}---messages that should never be logged
231 @end itemize
232
233 Several messages may be stacked in the echo area at once.  Lisp programs
234 may access these messages, or remove them as appropriate, via the
235 message stack.
236
237 @defun display-message label message &optional frame stdout-p
238 This function displays @var{message} (a string) labeled as @var{label},
239 as described above.
240
241 The @var{frame} argument specifies the frame to whose minibuffer the
242 message should be printed.  This is currently unimplemented.  The
243 @var{stdout-p} argument is used internally.
244
245 @example
246 (display-message 'command "Mark set")
247 @end example
248 @end defun
249
250 @defun lmessage label string &rest arguments
251 This function displays a message @var{string} with label @var{label}.
252 It is similar to @code{message} in that it accepts a @code{printf}-like
253 strings and any number of arguments.
254
255 @example
256 @group
257 ;; @r{Display a command message.}
258 (lmessage 'command "Comment column set to %d" comment-column)
259 @end group
260
261 @group
262 ;; @r{Display a progress message.}
263 (lmessage 'progress "Fontifying %s... (%d)" buffer percentage)
264 @end group
265
266 @group
267 ;; @r{Display a message that should not be logged.}
268 (lmessage 'no-log "Done")
269 @end group
270 @end example
271 @end defun
272
273 @defun clear-message &optional label frame stdout-p no-restore
274 This function remove any message with the given @var{label}
275 from the message-stack, erasing it from the echo area if it's currently
276 displayed there.
277
278 If a message remains at the head of the message-stack and
279 @var{no-restore} is @code{nil}, it will be displayed.  The string which
280 remains in the echo area will be returned, or @code{nil} if the
281 message-stack is now empty.  If @var{label} is @code{nil}, the entire
282 message-stack is cleared.
283
284 @example
285 ;; @r{Show a message, wait for 2 seconds, and restore old minibuffer}
286 ;; @r{contents.}
287 (message "A message")
288  @print{} A message
289 @result{} "A Message"
290 (lmessage 'my-label "Newsflash!  Newsflash!")
291  @print{} Newsflash!  Newsflash!
292 @result{} "Newsflash!  Newsflash!"
293 (sit-for 2)
294 (clear-message 'my-label)
295  @print{} A message
296 @result{} "A message"
297 @end example
298
299 Unless you need the return value or you need to specify a label,
300 you should just use @code{(message nil)}.
301 @end defun
302
303 @defun current-message &optional frame
304 This function returns the current message in the echo area, or
305 @code{nil}.  The @var{frame} argument is currently unused.
306 @end defun
307
308 Some of the messages displayed in the echo area are also recorded in the
309 @samp{ *Message-Log*} buffer.  Exactly which messages will be recorded
310 can be tuned using the following variables.
311
312 @defopt log-message-max-size
313 This variable specifies the maximum size of the @samp{ *Message-log*}
314 buffer.
315 @end defopt
316
317 @defvar log-message-ignore-labels
318 This variable specifies the labels whose messages will not be logged.
319 It should be a list of symbols.
320 @end defvar
321
322 @defvar log-message-ignore-regexps
323 This variable specifies the regular expressions matching messages that
324 will not be logged.  It should be a list of regular expressions.
325
326 Normally, packages that generate messages that might need to be ignored
327 should label them with @code{progress}, @code{prompt}, or @code{no-log},
328 so they can be filtered by @code{log-message-ignore-labels}.
329 @end defvar
330
331 @defvar echo-keystrokes
332 This variable determines how much time should elapse before command
333 characters echo.  Its value must be a number, which specifies the number
334 of seconds to wait before echoing.  If the user types a prefix key (such
335 as @kbd{C-x}) and then delays this many seconds before continuing, the
336 prefix key is echoed in the echo area.  Any subsequent characters in the
337 same command will be echoed as well.
338
339 If the value is zero, then command input is not echoed.
340 @end defvar
341
342 @defvar cursor-in-echo-area
343 This variable controls where the cursor appears when a message is
344 displayed in the echo area.  If it is non-@code{nil}, then the cursor
345 appears at the end of the message.  Otherwise, the cursor appears at
346 point---not in the echo area at all.
347
348 The value is normally @code{nil}; Lisp programs bind it to @code{t}
349 for brief periods of time.
350 @end defvar
351
352 @node Warnings
353 @section Warnings
354
355 XEmacs contains a facility for unified display of various warnings.
356 Unlike errors, warnings are displayed in the situations when XEmacs
357 encounters a problem that is recoverable, but which should be fixed for
358 safe future operation.
359
360 For example, warnings are printed by the startup code when it encounters
361 problems with X keysyms, when there is an error in @file{.emacs}, and in
362 other problematic situations.  Unlike messages, warnings are displayed
363 in a separate buffer, and include an explanatory message that may span
364 across several lines.  Here is an example of how a warning is displayed:
365
366 @example
367 (1) (initialization/error) An error has occurred while loading ~/.emacs:
368
369 Symbol's value as variable is void: bogus-variable
370
371 To ensure normal operation, you should investigate the cause of the error
372 in your initialization file and remove it.  Use the `-debug-init' option
373 to XEmacs to view a complete error backtrace.
374 @end example
375
376 Each warning has a @dfn{class} and a @dfn{priority level}.  The class is
377 a symbol describing what sort of warning this is, such as
378 @code{initialization}, @code{resource} or @code{key-mapping}.
379
380 The warning priority level specifies how important the warning is.  The
381 recognized warning levels, in increased order of priority, are:
382 @code{debug}, @code{info}, @code{notice}, @code{warning}, @code{error},
383 @code{critical}, @code{alert} and @code{emergency}.
384
385 @defun display-warning class message &optional level
386 This function displays a warning message @var{message} (a string).
387 @var{class} should be a warning class symbol, as described above, or a
388 list of such symbols.  @var{level} describes the warning priority level.
389 If unspecified, it default to @code{warning}.
390
391 @example
392 @group
393 (display-warning 'resource
394   "Bad resource specification encountered:
395 something like
396
397     Emacs*foo: bar
398
399 You should replace the * with a . in order to get proper behavior when
400 you use the specifier and/or `set-face-*' functions.")
401 @end group
402
403 @group
404 ---------- Warning buffer ----------
405 (1) (resource/warning) Bad resource specification encountered:
406 something like
407
408     Emacs*foo: bar
409
410 You should replace the * with a . in order to get proper behavior when
411 you use the specifier and/or `set-face-*' functions.
412 ---------- Warning buffer ----------
413 @end group
414 @end example
415 @end defun
416
417 @defun lwarn class level message &rest args
418 This function displays a formatted labeled warning message.  As above,
419 @var{class} should be the warning class symbol, or a list of such
420 symbols, and @var{level} should specify the warning priority level
421 (@code{warning} by default).
422
423 Unlike in @code{display-warning}, @var{message} may be a formatted
424 message, which will be, together with the rest of the arguments, passed
425 to @code{format}.
426
427 @example
428 (lwarn 'message-log 'warning
429   "Error caught in `remove-message-hook': %s"
430   (error-message-string e))
431 @end example
432 @end defun
433
434 @defvar log-warning-minimum-level
435 This variable specifies the minimum level of warnings that should be
436 generated.  Warnings with level lower than defined by this variable are
437 completely ignored, as if they never happened.
438 @end defvar
439
440 @defvar display-warning-minimum-level
441 This variable specifies the minimum level of warnings that should be
442 displayed.  Unlike @code{log-warning-minimum-level}, setting this
443 function does not suppress warnings entirely---they are still generated
444 in the @samp{*Warnings*} buffer, only they are not displayed by default.
445 @end defvar
446
447 @defvar log-warning-suppressed-classes
448 This variable specifies a list of classes that should not be logged or
449 displayed.  If any of the class symbols associated with a warning is the
450 same as any of the symbols listed here, the warning will be completely
451 ignored, as it they never happened.
452 @end defvar
453
454 @defvar display-warning-suppressed-classes
455 This variable specifies a list of classes that should not be logged or
456 displayed.  If any of the class symbols associated with a warning is the
457 same as any of the symbols listed here, the warning will not be
458 displayed.  The warning will still logged in the *Warnings* buffer
459 (unless also contained in `log-warning-suppressed-classes'), but the
460 buffer will not be automatically popped up.
461 @end defvar
462
463 @node Invisible Text
464 @section Invisible Text
465
466 @cindex invisible text
467 You can make characters @dfn{invisible}, so that they do not appear on
468 the screen, with the @code{invisible} property.  This can be either a
469 text property or a property of an overlay.
470
471 In the simplest case, any non-@code{nil} @code{invisible} property makes
472 a character invisible.  This is the default case---if you don't alter
473 the default value of @code{buffer-invisibility-spec}, this is how the
474 @code{invisibility} property works.  This feature is much like selective
475 display (@pxref{Selective Display}), but more general and cleaner.
476
477 More generally, you can use the variable @code{buffer-invisibility-spec}
478 to control which values of the @code{invisible} property make text
479 invisible.  This permits you to classify the text into different subsets
480 in advance, by giving them different @code{invisible} values, and
481 subsequently make various subsets visible or invisible by changing the
482 value of @code{buffer-invisibility-spec}.
483
484 Controlling visibility with @code{buffer-invisibility-spec} is
485 especially useful in a program to display the list of entries in a data
486 base.  It permits the implementation of convenient filtering commands to
487 view just a part of the entries in the data base.  Setting this variable
488 is very fast, much faster than scanning all the text in the buffer
489 looking for properties to change.
490
491 @defvar buffer-invisibility-spec
492 This variable specifies which kinds of @code{invisible} properties
493 actually make a character invisible.
494
495 @table @asis
496 @item @code{t}
497 A character is invisible if its @code{invisible} property is
498 non-@code{nil}.  This is the default.
499
500 @item a list
501 Each element of the list makes certain characters invisible.
502 Ultimately, a character is invisible if any of the elements of this list
503 applies to it.  The list can have two kinds of elements:
504
505 @table @code
506 @item @var{atom}
507 A character is invisible if its @code{invisible} property value
508 is @var{atom} or if it is a list with @var{atom} as a member.
509
510 @item (@var{atom} . t)
511 A character is invisible if its @code{invisible} property value
512 is @var{atom} or if it is a list with @var{atom} as a member.
513 Moreover, if this character is at the end of a line and is followed
514 by a visible newline, it displays an ellipsis.
515 @end table
516 @end table
517 @end defvar
518
519   Ordinarily, commands that operate on text or move point do not care
520 whether the text is invisible.  However, the user-level line motion
521 commands explicitly ignore invisible newlines.
522
523 @node Selective Display
524 @section Selective Display
525 @cindex selective display
526
527   @dfn{Selective display} is a pair of features that hide certain
528 lines on the screen.
529
530   The first variant, explicit selective display, is designed for use in
531 a Lisp program.  The program controls which lines are hidden by altering
532 the text.  Outline mode has traditionally used this variant.  It has
533 been partially replaced by the invisible text feature (@pxref{Invisible
534 Text}); there is a new version of Outline mode which uses that instead.
535
536   In the second variant, the choice of lines to hide is made
537 automatically based on indentation.  This variant is designed to be a
538 user-level feature.
539
540   The way you control explicit selective display is by replacing a
541 newline (control-j) with a carriage return (control-m).  The text that
542 was formerly a line following that newline is now invisible.  Strictly
543 speaking, it is temporarily no longer a line at all, since only newlines
544 can separate lines; it is now part of the previous line.
545
546   Selective display does not directly affect editing commands.  For
547 example, @kbd{C-f} (@code{forward-char}) moves point unhesitatingly into
548 invisible text.  However, the replacement of newline characters with
549 carriage return characters affects some editing commands.  For example,
550 @code{next-line} skips invisible lines, since it searches only for
551 newlines.  Modes that use selective display can also define commands
552 that take account of the newlines, or that make parts of the text
553 visible or invisible.
554
555   When you write a selectively displayed buffer into a file, all the
556 control-m's are output as newlines.  This means that when you next read
557 in the file, it looks OK, with nothing invisible.  The selective display
558 effect is seen only within XEmacs.
559
560 @defvar selective-display
561 This buffer-local variable enables selective display.  This means that
562 lines, or portions of lines, may be made invisible.
563
564 @itemize @bullet
565 @item
566 If the value of @code{selective-display} is @code{t}, then any portion
567 of a line that follows a control-m is not displayed.
568
569 @item
570 If the value of @code{selective-display} is a positive integer, then
571 lines that start with more than that many columns of indentation are not
572 displayed.
573 @end itemize
574
575 When some portion of a buffer is invisible, the vertical movement
576 commands operate as if that portion did not exist, allowing a single
577 @code{next-line} command to skip any number of invisible lines.
578 However, character movement commands (such as @code{forward-char}) do
579 not skip the invisible portion, and it is possible (if tricky) to insert
580 or delete text in an invisible portion.
581
582 In the examples below, we show the @emph{display appearance} of the
583 buffer @code{foo}, which changes with the value of
584 @code{selective-display}.  The @emph{contents} of the buffer do not
585 change.
586
587 @example
588 @group
589 (setq selective-display nil)
590      @result{} nil
591
592 ---------- Buffer: foo ----------
593 1 on this column
594  2on this column
595   3n this column
596   3n this column
597  2on this column
598 1 on this column
599 ---------- Buffer: foo ----------
600 @end group
601
602 @group
603 (setq selective-display 2)
604      @result{} 2
605
606 ---------- Buffer: foo ----------
607 1 on this column
608  2on this column
609  2on this column
610 1 on this column
611 ---------- Buffer: foo ----------
612 @end group
613 @end example
614 @end defvar
615
616 @defvar selective-display-ellipses
617 If this buffer-local variable is non-@code{nil}, then XEmacs displays
618 @samp{@dots{}} at the end of a line that is followed by invisible text.
619 This example is a continuation of the previous one.
620
621 @example
622 @group
623 (setq selective-display-ellipses t)
624      @result{} t
625
626 ---------- Buffer: foo ----------
627 1 on this column
628  2on this column ...
629  2on this column
630 1 on this column
631 ---------- Buffer: foo ----------
632 @end group
633 @end example
634
635 You can use a display table to substitute other text for the ellipsis
636 (@samp{@dots{}}).  @xref{Display Tables}.
637 @end defvar
638
639 @node Overlay Arrow
640 @section The Overlay Arrow
641 @cindex overlay arrow
642
643   The @dfn{overlay arrow} is useful for directing the user's attention
644 to a particular line in a buffer.  For example, in the modes used for
645 interface to debuggers, the overlay arrow indicates the line of code
646 about to be executed.
647
648 @defvar overlay-arrow-string
649 This variable holds the string to display to call attention to a
650 particular line, or @code{nil} if the arrow feature is not in use.
651 Despite its name, the value of this variable can be either a string
652 or a glyph (@pxref{Glyphs}).
653 @end defvar
654
655 @defvar overlay-arrow-position
656 This variable holds a marker that indicates where to display the overlay
657 arrow.  It should point at the beginning of a line.  The arrow text
658 appears at the beginning of that line, overlaying any text that would
659 otherwise appear.  Since the arrow is usually short, and the line
660 usually begins with indentation, normally nothing significant is
661 overwritten.
662
663 The overlay string is displayed only in the buffer that this marker
664 points into.  Thus, only one buffer can have an overlay arrow at any
665 given time.
666 @c !!! overlay-arrow-position: but the overlay string may remain in the display
667 @c of some other buffer until an update is required.  This should be fixed
668 @c now.  Is it?
669 @end defvar
670
671   You can do the same job by creating an extent with a
672 @code{begin-glyph} property.  @xref{Extent Properties}.
673
674 @node Temporary Displays
675 @section Temporary Displays
676
677   Temporary displays are used by commands to put output into a buffer
678 and then present it to the user for perusal rather than for editing.
679 Many of the help commands use this feature.
680
681 @defspec with-output-to-temp-buffer buffer-name forms@dots{}
682 This function executes @var{forms} while arranging to insert any
683 output they print into the buffer named @var{buffer-name}.  The buffer
684 is then shown in some window for viewing, displayed but not selected.
685
686 The string @var{buffer-name} specifies the temporary buffer, which
687 need not already exist.  The argument must be a string, not a buffer.
688 The buffer is erased initially (with no questions asked), and it is
689 marked as unmodified after @code{with-output-to-temp-buffer} exits.
690
691 @code{with-output-to-temp-buffer} binds @code{standard-output} to the
692 temporary buffer, then it evaluates the forms in @var{forms}.  Output
693 using the Lisp output functions within @var{forms} goes by default to
694 that buffer (but screen display and messages in the echo area, although
695 they are ``output'' in the general sense of the word, are not affected).
696 @xref{Output Functions}.
697
698 The value of the last form in @var{forms} is returned.
699
700 @example
701 @group
702 ---------- Buffer: foo ----------
703  This is the contents of foo.
704 ---------- Buffer: foo ----------
705 @end group
706
707 @group
708 (with-output-to-temp-buffer "foo"
709     (print 20)
710     (print standard-output))
711 @result{} #<buffer foo>
712
713 ---------- Buffer: foo ----------
714 20
715
716 #<buffer foo>
717
718 ---------- Buffer: foo ----------
719 @end group
720 @end example
721 @end defspec
722
723 @defvar temp-buffer-show-function
724 If this variable is non-@code{nil}, @code{with-output-to-temp-buffer}
725 calls it as a function to do the job of displaying a help buffer.  The
726 function gets one argument, which is the buffer it should display.
727
728 In Emacs versions 18 and earlier, this variable was called
729 @code{temp-buffer-show-hook}.
730 @end defvar
731
732 @defun momentary-string-display string position &optional char message
733 This function momentarily displays @var{string} in the current buffer at
734 @var{position}.  It has no effect on the undo list or on the buffer's
735 modification status.
736
737 The momentary display remains until the next input event.  If the next
738 input event is @var{char}, @code{momentary-string-display} ignores it
739 and returns.  Otherwise, that event remains buffered for subsequent use
740 as input.  Thus, typing @var{char} will simply remove the string from
741 the display, while typing (say) @kbd{C-f} will remove the string from
742 the display and later (presumably) move point forward.  The argument
743 @var{char} is a space by default.
744
745 The return value of @code{momentary-string-display} is not meaningful.
746
747 You can do the same job in a more general way by creating an extent
748 with a begin-glyph property.  @xref{Extent Properties}.
749
750 If @var{message} is non-@code{nil}, it is displayed in the echo area
751 while @var{string} is displayed in the buffer.  If it is @code{nil}, a
752 default message says to type @var{char} to continue.
753
754 In this example, point is initially located at the beginning of the
755 second line:
756
757 @example
758 @group
759 ---------- Buffer: foo ----------
760 This is the contents of foo.
761 @point{}Second line.
762 ---------- Buffer: foo ----------
763 @end group
764
765 @group
766 (momentary-string-display
767   "**** Important Message! ****"
768   (point) ?\r
769   "Type RET when done reading")
770 @result{} t
771 @end group
772
773 @group
774 ---------- Buffer: foo ----------
775 This is the contents of foo.
776 **** Important Message! ****Second line.
777 ---------- Buffer: foo ----------
778
779 ---------- Echo Area ----------
780 Type RET when done reading
781 ---------- Echo Area ----------
782 @end group
783 @end example
784
785   This function works by actually changing the text in the buffer.  As a
786 result, if you later undo in this buffer, you will see the message come
787 and go.
788 @end defun
789
790 @node Blinking
791 @section Blinking Parentheses
792 @cindex parenthesis matching
793 @cindex blinking
794 @cindex balancing parentheses
795 @cindex close parenthesis
796
797   This section describes the mechanism by which XEmacs shows a matching
798 open parenthesis when the user inserts a close parenthesis.
799
800 @vindex blink-paren-hook
801 @defvar blink-paren-function
802 The value of this variable should be a function (of no arguments) to
803 be called whenever a character with close parenthesis syntax is inserted.
804 The value of @code{blink-paren-function} may be @code{nil}, in which
805 case nothing is done.
806
807 @quotation
808 @strong{Please note:} This variable was named @code{blink-paren-hook} in
809 older Emacs versions, but since it is not called with the standard
810 convention for hooks, it was renamed to @code{blink-paren-function} in
811 version 19.
812 @end quotation
813 @end defvar
814
815 @defvar blink-matching-paren
816 If this variable is @code{nil}, then @code{blink-matching-open} does
817 nothing.
818 @end defvar
819
820 @defvar blink-matching-paren-distance
821 This variable specifies the maximum distance to scan for a matching
822 parenthesis before giving up.
823 @end defvar
824
825 @defvar blink-matching-paren-delay
826 This variable specifies the number of seconds for the cursor to remain
827 at the matching parenthesis.  A fraction of a second often gives
828 good results, but the default is 1, which works on all systems.
829 @end defvar
830
831 @deffn Command blink-matching-open
832 This function is the default value of @code{blink-paren-function}.  It
833 assumes that point follows a character with close parenthesis syntax and
834 moves the cursor momentarily to the matching opening character.  If that
835 character is not already on the screen, it displays the character's
836 context in the echo area.  To avoid long delays, this function does not
837 search farther than @code{blink-matching-paren-distance} characters.
838
839 Here is an example of calling this function explicitly.
840
841 @smallexample
842 @group
843 (defun interactive-blink-matching-open ()
844   "Indicate momentarily the start of sexp before point."
845   (interactive)
846 @end group
847 @group
848   (let ((blink-matching-paren-distance
849          (buffer-size))
850         (blink-matching-paren t))
851     (blink-matching-open)))
852 @end group
853 @end smallexample
854 @end deffn
855
856 @node Usual Display
857 @section Usual Display Conventions
858
859   The usual display conventions define how to display each character
860 code.  You can override these conventions by setting up a display table
861 (@pxref{Display Tables}).  Here are the usual display conventions:
862
863 @itemize @bullet
864 @item
865 Character codes 32 through 126 map to glyph codes 32 through 126.
866 Normally this means they display as themselves.
867
868 @item
869 Character code 9 is a horizontal tab.  It displays as whitespace
870 up to a position determined by @code{tab-width}.
871
872 @item
873 Character code 10 is a newline.
874
875 @item
876 All other codes in the range 0 through 31, and code 127, display in one
877 of two ways according to the value of @code{ctl-arrow}.  If it is
878 non-@code{nil}, these codes map to sequences of two glyphs, where the
879 first glyph is the @sc{ascii} code for @samp{^}.  (A display table can
880 specify a glyph to use instead of @samp{^}.)  Otherwise, these codes map
881 just like the codes in the range 128 to 255.
882
883 @item
884 Character codes 128 through 255 map to sequences of four glyphs, where
885 the first glyph is the @sc{ascii} code for @samp{\}, and the others are
886 digit characters representing the code in octal.  (A display table can
887 specify a glyph to use instead of @samp{\}.)
888 @end itemize
889
890   The usual display conventions apply even when there is a display
891 table, for any character whose entry in the active display table is
892 @code{nil}.  Thus, when you set up a display table, you need only
893 specify the characters for which you want unusual behavior.
894
895   These variables affect the way certain characters are displayed on the
896 screen.  Since they change the number of columns the characters occupy,
897 they also affect the indentation functions.
898
899 @defopt ctl-arrow
900 @cindex control characters in display
901 This buffer-local variable controls how control characters are
902 displayed.  If it is non-@code{nil}, they are displayed as a caret
903 followed by the character: @samp{^A}.  If it is @code{nil}, they are
904 displayed as a backslash followed by three octal digits: @samp{\001}.
905 @end defopt
906
907 @c Following may have overfull hbox.
908 @defvar default-ctl-arrow
909 The value of this variable is the default value for @code{ctl-arrow} in
910 buffers that do not override it.  @xref{Default Value}.
911 @end defvar
912
913 @defopt tab-width
914 The value of this variable is the spacing between tab stops used for
915 displaying tab characters in Emacs buffers.  The default is 8.  Note
916 that this feature is completely independent from the user-settable tab
917 stops used by the command @code{tab-to-tab-stop}.  @xref{Indent Tabs}.
918 @end defopt
919
920 @node Display Tables
921 @section Display Tables
922
923 @cindex display table
924 You can use the @dfn{display table} feature to control how all 256
925 possible character codes display on the screen.  This is useful for
926 displaying European languages that have letters not in the @sc{ascii}
927 character set.
928
929 The display table maps each character code into a sequence of
930 @dfn{runes}, each rune being an image that takes up one character
931 position on the screen.  You can also define how to display each rune
932 on your terminal, using the @dfn{rune table}.
933
934 @menu
935 * Display Table Format::        What a display table consists of.
936 * Active Display Table::        How XEmacs selects a display table to use.
937 * Character Descriptors::       Format of an individual element of a
938                                   display table.
939 @end menu
940
941 @ignore Not yet working in XEmacs?
942 * ISO Latin 1::                 How to use display tables
943                                   to support the ISO Latin 1 character set.
944 @end ignore
945
946 @node Display Table Format
947 @subsection Display Table Format
948
949   A display table is an array of 256 elements. (In FSF Emacs, a display
950 table is 262 elements.  The six extra elements specify the truncation
951 and continuation glyphs, etc.  This method is very kludgey, and in
952 XEmacs the variables @code{truncation-glyph}, @code{continuation-glyph},
953 etc. are used.  @xref{Truncation}.)
954
955 @defun make-display-table
956 This creates and returns a display table.  The table initially has
957 @code{nil} in all elements.
958 @end defun
959
960   The 256 elements correspond to character codes; the @var{n}th
961 element says how to display the character code @var{n}.  The value
962 should be @code{nil}, a string, a glyph, or a vector of strings and
963 glyphs (@pxref{Character Descriptors}).  If an element is @code{nil},
964 it says to display that character according to the usual display
965 conventions (@pxref{Usual Display}).
966
967   If you use the display table to change the display of newline
968 characters, the whole buffer will be displayed as one long ``line.''
969
970   For example, here is how to construct a display table that mimics the
971 effect of setting @code{ctl-arrow} to a non-@code{nil} value:
972
973 @example
974 (setq disptab (make-display-table))
975 (let ((i 0))
976   (while (< i 32)
977     (or (= i ?\t) (= i ?\n)
978         (aset disptab i (concat "^" (char-to-string (+ i 64)))))
979     (setq i (1+ i)))
980   (aset disptab 127 "^?"))
981 @end example
982
983 @node Active Display Table
984 @subsection Active Display Table
985 @cindex active display table
986
987   The active display table is controlled by the variable
988 @code{current-display-table}.  This is a specifier, which means
989 that you can specify separate values for it in individual buffers,
990 windows, frames, and devices, as well as a global value.  It also
991 means that you cannot set this variable using @code{setq}; use
992 @code{set-specifier} instead.  @xref{Specifiers}. (FSF Emacs
993 uses @code{window-display-table}, @code{buffer-display-table},
994 @code{standard-display-table}, etc. to control the display table.
995 However, specifiers are a cleaner and more powerful way of doing
996 the same thing.  FSF Emacs also uses a different format for
997 the contents of a display table, using additional indirection
998 to a ``glyph table'' and such.  Note that ``glyph'' has a different
999 meaning in XEmacs.)
1000
1001 @defvar current-display-table
1002
1003 The display table currently in use.  This is a specifier.
1004
1005 Display tables are used to control how characters are displayed.  Each
1006 time that redisplay processes a character, it is looked up in all the
1007 display tables that apply (obtained by calling @code{specifier-instance}
1008 on @code{current-display-table} and any overriding display tables
1009 specified in currently active faces).  The first entry found that
1010 matches the character determines how the character is displayed.  If
1011 there is no matching entry, the default display method is
1012 used. (Non-control characters are displayed as themselves and control
1013 characters are displayed according to the buffer-local variable
1014 @code{ctl-arrow}.  Control characters are further affected by
1015 @code{control-arrow-glyph} and @code{octal-escape-glyph}.)
1016
1017 Each instantiator in this specifier and the display-table specifiers
1018 in faces is a display table or a list of such tables.  If a list, each
1019 table will be searched in turn for an entry matching a particular
1020 character.  Each display table is one of
1021
1022 @itemize @bullet
1023 @item
1024 A vector, specifying values for characters starting at 0.
1025 @item
1026 A char table, either of type @code{char} or @code{generic}.
1027 @item
1028 A range table.
1029 @end itemize
1030
1031 Each entry in a display table should be one of
1032
1033 @itemize @bullet
1034 @item
1035 nil (this entry is ignored and the search continues).
1036 @item
1037 A character (use this character; if it happens to be the same as
1038 the original character, default processing happens, otherwise
1039 redisplay attempts to display this character directly;
1040 #### At some point recursive display-table lookup will be
1041 implemented).
1042 @item
1043 A string (display each character in the string directly;
1044 #### At some point recursive display-table lookup will be
1045 implemented).
1046 @item
1047 A glyph (display the glyph;
1048 #### At some point recursive display-table lookup will be
1049 implemented when a string glyph is being processed).
1050 @item
1051 A cons of the form (format "@var{string}") where @var{string} is a
1052 printf-like spec used to process the character. #### Unfortunately no
1053 formatting directives other than %% are implemented.
1054 @item
1055 A vector (each element of the vector is processed recursively;
1056 in such a case, nil elements in the vector are simply ignored).
1057
1058 #### At some point in the near future, display tables are likely to
1059 be expanded to include other features, such as referencing characters
1060 in particular fonts and allowing the character search to continue
1061 all the way up the chain of specifier instantiators.  These features
1062 are necessary to properly display Unicode characters.
1063 @end itemize
1064 @end defvar
1065
1066   Individual faces can also specify an overriding display table;
1067 this is set using @code{set-face-display-table}.  @xref{Faces}.
1068
1069   If no display table can be determined for a particular window,
1070 then XEmacs uses the usual display conventions.  @xref{Usual Display}.
1071
1072 @node Character Descriptors
1073 @subsection Character Descriptors
1074
1075 @cindex character descriptor
1076   Each element of the display-table vector describes how to display
1077 a particular character and is called a @dfn{character descriptor}.
1078 A character descriptor can be:
1079
1080 @table @asis
1081 @item a string
1082 Display this particular string wherever the character is to be displayed.
1083
1084 @item a glyph
1085 Display this particular glyph wherever the character is to be displayed.
1086
1087 @item a vector
1088 The vector may contain strings and/or glyphs.  Display the elements of
1089 the vector one after another wherever the character is to be displayed.
1090
1091 @item @code{nil}
1092 Display according to the standard interpretation (@pxref{Usual Display}).
1093 @end table
1094
1095 @ignore Not yet working in XEmacs?
1096 @node ISO Latin 1
1097 @subsection ISO Latin 1
1098
1099 If you have a terminal that can handle the entire ISO Latin 1 character
1100 set, you can arrange to use that character set as follows:
1101
1102 @example
1103 (require 'disp-table)
1104 ;; @r{Set char codes 160--255 to display as themselves.}
1105 ;; @r{(Codes 128--159 are the additional control characters.)}
1106 (standard-display-8bit 160 255)
1107 @end example
1108
1109 If you are editing buffers written in the ISO Latin 1 character set and
1110 your terminal doesn't handle anything but @sc{ascii}, you can load the
1111 file @file{iso-ascii} to set up a display table that displays the other
1112 ISO characters as explanatory sequences of @sc{ascii} characters.  For
1113 example, the character ``o with umlaut'' displays as @samp{@{"o@}}.
1114
1115 Some European countries have terminals that don't support ISO Latin 1
1116 but do support the special characters for that country's language.  You
1117 can define a display table to work one language using such terminals.
1118 For an example, see @file{lisp/iso-swed.el}, which handles certain
1119 Swedish terminals.
1120
1121 You can load the appropriate display table for your terminal
1122 automatically by writing a terminal-specific Lisp file for the terminal
1123 type.
1124 @end ignore
1125
1126 @node Beeping
1127 @section Beeping
1128 @cindex beeping
1129 @cindex bell
1130 @cindex sound
1131
1132   You can make XEmacs ring a bell, play a sound, or blink the screen to
1133 attract the user's attention.  Be conservative about how often you do
1134 this; frequent bells can become irritating.  Also be careful not to use
1135 beeping alone when signaling an error is appropriate.  (@xref{Errors}.)
1136
1137 @defun ding &optional dont-terminate sound device
1138 @cindex keyboard macro termination
1139 This function beeps, or flashes the screen (see @code{visible-bell}
1140 below).  It also terminates any keyboard macro currently executing
1141 unless @var{dont-terminate} is non-@code{nil}.  If @var{sound} is
1142 specified, it should be a symbol specifying which sound to make.  This
1143 sound will be played if @code{visible-bell} is @code{nil}. (This only
1144 works if sound support was compiled into the executable and you are
1145 running on the console of a Sun SparcStation, SGI, HP9000s700, or Linux
1146 PC. Otherwise you just get a beep.) The optional third argument
1147 specifies what device to make the sound on, and defaults to the selected
1148 device.
1149 @end defun
1150
1151 @defun beep &optional dont-terminate sound device
1152 This is a synonym for @code{ding}.
1153 @end defun
1154
1155 @defopt visible-bell
1156 This variable determines whether XEmacs should flash the screen to
1157 represent a bell.  Non-@code{nil} means yes, @code{nil} means no.  On
1158 TTY devices, this is effective only if the Termcap entry for the
1159 terminal type has the visible bell flag (@samp{vb}) set.
1160 @end defopt
1161
1162 @defvar sound-alist
1163   This variable holds an alist associating names with sounds.  When
1164 @code{beep} or @code{ding} is called with one of the name symbols, the
1165 associated sound will be generated instead of the standard beep.
1166
1167   Each element of @code{sound-alist} is a list describing a sound.  The
1168 first element of the list is the name of the sound being defined.
1169 Subsequent elements of the list are alternating keyword/value pairs:
1170
1171 @table @code
1172 @item sound
1173 A string of raw sound data, or the name of another sound to play.  The
1174 symbol @code{t} here means use the default X beep.
1175 @item volume
1176 An integer from 0-100, defaulting to @code{bell-volume}.
1177 @item pitch
1178 If using the default X beep, the pitch (Hz) to generate.
1179 @item duration
1180 If using the default X beep, the duration (milliseconds).
1181 @end table
1182
1183 For compatibility, elements of `sound-alist' may also be:
1184
1185 @itemize @bullet
1186 @item
1187 @code{( sound-name . <sound> )}
1188 @item
1189 @code{( sound-name <volume> <sound> )}
1190 @end itemize
1191
1192 You should probably add things to this list by calling the function
1193 @code{load-sound-file}.
1194
1195 Caveats:
1196
1197 @itemize @minus
1198 @item
1199 You can only play audio data if running on the console screen of a Sun
1200 SparcStation, SGI, or HP9000s700.
1201
1202 @item
1203 The pitch, duration, and volume options are available everywhere, but
1204 many X servers ignore the `pitch' option.
1205 @end itemize
1206
1207 The following beep-types are used by XEmacs itself:
1208
1209 @table @code
1210 @item auto-save-error
1211 when an auto-save does not succeed
1212 @item command-error
1213 when the XEmacs command loop catches an error
1214 @item undefined-key
1215 when you type a key that is undefined
1216 @item undefined-click
1217 when you use an undefined mouse-click combination
1218 @item no-completion
1219 during completing-read
1220 @item y-or-n-p
1221 when you type something other than 'y' or 'n'
1222 @item yes-or-no-p
1223 when you type something other than 'yes' or 'no'
1224 @item default
1225 used when nothing else is appropriate.
1226 @end table
1227
1228 Other lisp packages may use other beep types, but these are the ones that
1229 the C kernel of XEmacs uses.
1230 @end defvar
1231
1232 @defopt bell-volume
1233 This variable specifies the default volume for sounds, from 0 to 100.
1234 @end defopt
1235
1236 @deffn Command load-default-sounds
1237 This function loads and installs some sound files as beep-types.
1238 @end deffn
1239
1240 @deffn Command load-sound-file filename sound-name &optional volume
1241 This function reads in an audio file and adds it to @code{sound-alist}.
1242 The sound file must be in the Sun/NeXT U-LAW format.  @var{sound-name}
1243 should be a symbol, specifying the name of the sound.  If @var{volume}
1244 is specified, the sound will be played at that volume; otherwise, the
1245 value of @var{bell-volume} will be used.
1246 @end deffn
1247
1248 @defun play-sound sound &optional volume device
1249 This function plays sound @var{sound}, which should be a symbol
1250 mentioned in @code{sound-alist}.  If @var{volume} is specified, it
1251 overrides the value (if any) specified in @code{sound-alist}.
1252 @var{device} specifies the device to play the sound on, and defaults
1253 to the selected device.
1254 @end defun
1255
1256 @deffn Command play-sound-file file &optional volume device
1257 This function plays the named sound file at volume @var{volume}, which
1258 defaults to @code{bell-volume}.  @var{device} specifies the device to
1259 play the sound on, and defaults to the selected device.
1260 @end deffn