diff options
| author | Paul Eggert | 2011-04-01 13:19:36 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-04-01 13:19:36 -0700 |
| commit | 6ddae4efd9e8a3035eb610c39fb2c8f79e7f9893 (patch) | |
| tree | 1b704b34e4f2f2bd4a6f13e4d1dd058c61c8a6ff /src/print.c | |
| parent | 0b918413f336dbfa9a9c266ae857bce103556c57 (diff) | |
| parent | 034086489cff2a23cb4d9f8c536e18456be617ef (diff) | |
| download | emacs-6ddae4efd9e8a3035eb610c39fb2c8f79e7f9893.tar.gz emacs-6ddae4efd9e8a3035eb610c39fb2c8f79e7f9893.zip | |
Merge from mainline.
Diffstat (limited to 'src/print.c')
| -rw-r--r-- | src/print.c | 57 |
1 files changed, 1 insertions, 56 deletions
diff --git a/src/print.c b/src/print.c index dd3d1c9bbb2..3e0e168381b 100644 --- a/src/print.c +++ b/src/print.c | |||
| @@ -521,6 +521,7 @@ temp_output_buffer_setup (const char *bufname) | |||
| 521 | specbind (Qstandard_output, buf); | 521 | specbind (Qstandard_output, buf); |
| 522 | } | 522 | } |
| 523 | 523 | ||
| 524 | /* FIXME: Use Lisp's with-output-to-temp-buffer instead! */ | ||
| 524 | Lisp_Object | 525 | Lisp_Object |
| 525 | internal_with_output_to_temp_buffer (const char *bufname, Lisp_Object (*function) (Lisp_Object), Lisp_Object args) | 526 | internal_with_output_to_temp_buffer (const char *bufname, Lisp_Object (*function) (Lisp_Object), Lisp_Object args) |
| 526 | { | 527 | { |
| @@ -542,60 +543,6 @@ internal_with_output_to_temp_buffer (const char *bufname, Lisp_Object (*function | |||
| 542 | 543 | ||
| 543 | return unbind_to (count, val); | 544 | return unbind_to (count, val); |
| 544 | } | 545 | } |
| 545 | |||
| 546 | DEFUN ("with-output-to-temp-buffer", | ||
| 547 | Fwith_output_to_temp_buffer, Swith_output_to_temp_buffer, | ||
| 548 | 1, UNEVALLED, 0, | ||
| 549 | doc: /* Bind `standard-output' to buffer BUFNAME, eval BODY, then show that buffer. | ||
| 550 | |||
| 551 | This construct makes buffer BUFNAME empty before running BODY. | ||
| 552 | It does not make the buffer current for BODY. | ||
| 553 | Instead it binds `standard-output' to that buffer, so that output | ||
| 554 | generated with `prin1' and similar functions in BODY goes into | ||
| 555 | the buffer. | ||
| 556 | |||
| 557 | At the end of BODY, this marks buffer BUFNAME unmodifed and displays | ||
| 558 | it in a window, but does not select it. The normal way to do this is | ||
| 559 | by calling `display-buffer', then running `temp-buffer-show-hook'. | ||
| 560 | However, if `temp-buffer-show-function' is non-nil, it calls that | ||
| 561 | function instead (and does not run `temp-buffer-show-hook'). The | ||
| 562 | function gets one argument, the buffer to display. | ||
| 563 | |||
| 564 | The return value of `with-output-to-temp-buffer' is the value of the | ||
| 565 | last form in BODY. If BODY does not finish normally, the buffer | ||
| 566 | BUFNAME is not displayed. | ||
| 567 | |||
| 568 | This runs the hook `temp-buffer-setup-hook' before BODY, | ||
| 569 | with the buffer BUFNAME temporarily current. It runs the hook | ||
| 570 | `temp-buffer-show-hook' after displaying buffer BUFNAME, with that | ||
| 571 | buffer temporarily current, and the window that was used to display it | ||
| 572 | temporarily selected. But it doesn't run `temp-buffer-show-hook' | ||
| 573 | if it uses `temp-buffer-show-function'. | ||
| 574 | |||
| 575 | usage: (with-output-to-temp-buffer BUFNAME BODY...) */) | ||
| 576 | (Lisp_Object args) | ||
| 577 | { | ||
| 578 | struct gcpro gcpro1; | ||
| 579 | Lisp_Object name; | ||
| 580 | int count = SPECPDL_INDEX (); | ||
| 581 | Lisp_Object buf, val; | ||
| 582 | |||
| 583 | GCPRO1(args); | ||
| 584 | name = Feval (Fcar (args)); | ||
| 585 | CHECK_STRING (name); | ||
| 586 | temp_output_buffer_setup (SSDATA (name)); | ||
| 587 | buf = Vstandard_output; | ||
| 588 | UNGCPRO; | ||
| 589 | |||
| 590 | val = Fprogn (XCDR (args)); | ||
| 591 | |||
| 592 | GCPRO1 (val); | ||
| 593 | temp_output_buffer_show (buf); | ||
| 594 | UNGCPRO; | ||
| 595 | |||
| 596 | return unbind_to (count, val); | ||
| 597 | } | ||
| 598 | |||
| 599 | 546 | ||
| 600 | static void print (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag); | 547 | static void print (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag); |
| 601 | static void print_preprocess (Lisp_Object obj); | 548 | static void print_preprocess (Lisp_Object obj); |
| @@ -2289,6 +2236,4 @@ priorities. */); | |||
| 2289 | 2236 | ||
| 2290 | print_prune_charset_plist = Qnil; | 2237 | print_prune_charset_plist = Qnil; |
| 2291 | staticpro (&print_prune_charset_plist); | 2238 | staticpro (&print_prune_charset_plist); |
| 2292 | |||
| 2293 | defsubr (&Swith_output_to_temp_buffer); | ||
| 2294 | } | 2239 | } |