Mercurial > emacs
changeset 79204:588d507a3ebf
(Fwith_output_to_temp_buffer): Doc fix.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 24 Oct 2007 08:22:35 +0000 |
parents | 883dd6a77245 |
children | b68f875d7f68 |
files | src/print.c |
diffstat | 1 files changed, 22 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/print.c Wed Oct 24 08:21:54 2007 +0000 +++ b/src/print.c Wed Oct 24 08:22:35 2007 +0000 @@ -674,21 +674,30 @@ Fwith_output_to_temp_buffer, Swith_output_to_temp_buffer, 1, UNEVALLED, 0, doc: /* Bind `standard-output' to buffer BUFNAME, eval BODY, then show that buffer. -The buffer is cleared out initially, and marked as unmodified when done. -All output done by BODY is inserted in that buffer by default. -The buffer is displayed in another window, but not selected. -The value of the last form in BODY is returned. -If BODY does not finish normally, the buffer BUFNAME is not displayed. + +This construct makes buffer BUFNAME empty before running BODY. +It does not make the buffer current for BODY. +Instead it binds `standard-output' to that buffer, so that output +generated with `prin1' and similar functions in BODY goes into +the buffer. -The hook `temp-buffer-setup-hook' is run before BODY, -with the buffer BUFNAME temporarily current. -The hook `temp-buffer-show-hook' is run after the buffer is displayed, -with the buffer temporarily current, and the window that was used -to display it temporarily selected. +At the end of BODY, this marks buffer BUFNAME unmodifed and displays +it in a window, but does not select it. The normal way to do this is +by calling `display-buffer', then running `temp-buffer-show-hook'. +However, if `temp-buffer-show-function' is non-nil, it calls that +function instead (and does not run `temp-buffer-show-hook'). The +function gets one argument, the buffer to display. -If variable `temp-buffer-show-function' is non-nil, call it at the end -to get the buffer displayed instead of just displaying the non-selected -buffer and calling the hook. It gets one argument, the buffer to display. +The return value of `with-output-to-temp-buffer' is the value of the +last form in BODY. If BODY does not finish normally, the buffer +BUFNAME is not displayed. + +This runs the hook `temp-buffer-setup-hook' before BODY, +with the buffer BUFNAME temporarily current. It runs the hook +`temp-buffer-show-hook' after displaying buffer BUFNAME, with that +buffer temporarily current, and the window that was used to display it +temporarily selected. But it doesn't run `temp-buffer-show-hook' +if it uses `temp-buffer-show-function'. usage: (with-output-to-temp-buffer BUFNAME BODY...) */) (args)