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