aboutsummaryrefslogtreecommitdiffstats
path: root/src/print.c
diff options
context:
space:
mode:
authorPaul Eggert2011-04-01 13:19:36 -0700
committerPaul Eggert2011-04-01 13:19:36 -0700
commit6ddae4efd9e8a3035eb610c39fb2c8f79e7f9893 (patch)
tree1b704b34e4f2f2bd4a6f13e4d1dd058c61c8a6ff /src/print.c
parent0b918413f336dbfa9a9c266ae857bce103556c57 (diff)
parent034086489cff2a23cb4d9f8c536e18456be617ef (diff)
downloademacs-6ddae4efd9e8a3035eb610c39fb2c8f79e7f9893.tar.gz
emacs-6ddae4efd9e8a3035eb610c39fb2c8f79e7f9893.zip
Merge from mainline.
Diffstat (limited to 'src/print.c')
-rw-r--r--src/print.c57
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! */
524Lisp_Object 525Lisp_Object
525internal_with_output_to_temp_buffer (const char *bufname, Lisp_Object (*function) (Lisp_Object), Lisp_Object args) 526internal_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
546DEFUN ("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
551This construct makes buffer BUFNAME empty before running BODY.
552It does not make the buffer current for BODY.
553Instead it binds `standard-output' to that buffer, so that output
554generated with `prin1' and similar functions in BODY goes into
555the buffer.
556
557At the end of BODY, this marks buffer BUFNAME unmodifed and displays
558it in a window, but does not select it. The normal way to do this is
559by calling `display-buffer', then running `temp-buffer-show-hook'.
560However, if `temp-buffer-show-function' is non-nil, it calls that
561function instead (and does not run `temp-buffer-show-hook'). The
562function gets one argument, the buffer to display.
563
564The return value of `with-output-to-temp-buffer' is the value of the
565last form in BODY. If BODY does not finish normally, the buffer
566BUFNAME is not displayed.
567
568This runs the hook `temp-buffer-setup-hook' before BODY,
569with the buffer BUFNAME temporarily current. It runs the hook
570`temp-buffer-show-hook' after displaying buffer BUFNAME, with that
571buffer temporarily current, and the window that was used to display it
572temporarily selected. But it doesn't run `temp-buffer-show-hook'
573if it uses `temp-buffer-show-function'.
574
575usage: (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
600static void print (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag); 547static void print (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag);
601static void print_preprocess (Lisp_Object obj); 548static 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}