Next: , Up: Temporary Displays   [Index]


H.1.1 Display as a Help Buffer

Function: with-output-to-temp-buffer buffer-name body

Bind ‘standard-output’ to buffer ‘BUFFER-NAME’, eval ‘BODY’, then show that buffer.

This function executes the forms in ‘BODY’ while arranging to insert any output they print into the buffer named ‘BUFFER-NAME’, which is first created if necessary, and put into ‘Help’ mode. It does not make the buffer current for ‘BODY’.

BUFFER-NAME

The string ‘BUFFER-NAME’ specifies the temporary buffer, which need not already exist. The argument must be a string, not a buffer. The buffer is erased initially (with no questions asked), and it is marked as unmodified after this function exits.

BODY

This function binds ‘STANDARD-OUTPUT’ to the temporary buffer, then it evaluates the forms in ‘BODY’. At the end of ‘BODY’, this marks buffer ‘BUFFER-NAME’ unmodified and displays it in a window, but does not select it.

By default, the setup hook puts the buffer into ‘Help’ mode before running ‘BODY’. If ‘BODY’ does not change the major mode, the show hook makes the buffer read-only, and scans it for function and variable names to make them into clickable cross-references.

HOOKS

Several hooks are available for customizing the behavior of this construct;

temp-buffer-setup-hook

hook run before evaluating ‘BODY’, and ‘BUFFER-NAME’ is current.

temp-buffer-show-hook

hook run after displaying the temporary buffer, and with the temporary buffer being current.

RETURN

The value of the last form in ‘BODY’ is returned.

temp-buffer-show-function

If this variable is non-nil, with-output-to-temp-buffer calls it as a function to do the job of displaying a ‘help’ buffer. The function gets one argument, which is the buffer it should display.


Next: Macros for Display of Non-help Buffers, Up: Temporary Displays   [Index]