diff options
| author | Richard M. Stallman | 1999-01-11 15:26:11 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1999-01-11 15:26:11 +0000 |
| commit | d9c21094c7a47b8037393e9427c8e7180a8c6ea2 (patch) | |
| tree | 263a062d64d85e3907d32e6f6e9ed184a11fec44 /src | |
| parent | e48143f0fd269fca8332f0207549bf12ae9b95b2 (diff) | |
| download | emacs-d9c21094c7a47b8037393e9427c8e7180a8c6ea2.tar.gz emacs-d9c21094c7a47b8037393e9427c8e7180a8c6ea2.zip | |
(Qtemp_buffer_setup_hook): New variable.
(syms_of_print): Init and staticpro that.
(temp_output_buffer_setup): Run Qtemp_buffer_setup_hook.
Diffstat (limited to 'src')
| -rw-r--r-- | src/print.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/print.c b/src/print.c index 7087096fb20..a24826f24c4 100644 --- a/src/print.c +++ b/src/print.c | |||
| @@ -41,6 +41,8 @@ Boston, MA 02111-1307, USA. */ | |||
| 41 | 41 | ||
| 42 | Lisp_Object Vstandard_output, Qstandard_output; | 42 | Lisp_Object Vstandard_output, Qstandard_output; |
| 43 | 43 | ||
| 44 | Lisp_Object Qtemp_buffer_setup_hook; | ||
| 45 | |||
| 44 | /* These are used to print like we read. */ | 46 | /* These are used to print like we read. */ |
| 45 | extern Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction; | 47 | extern Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction; |
| 46 | 48 | ||
| @@ -727,9 +729,12 @@ void | |||
| 727 | temp_output_buffer_setup (bufname) | 729 | temp_output_buffer_setup (bufname) |
| 728 | char *bufname; | 730 | char *bufname; |
| 729 | { | 731 | { |
| 732 | int count = specpdl_ptr - specpdl; | ||
| 730 | register struct buffer *old = current_buffer; | 733 | register struct buffer *old = current_buffer; |
| 731 | register Lisp_Object buf; | 734 | register Lisp_Object buf; |
| 732 | 735 | ||
| 736 | record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); | ||
| 737 | |||
| 733 | Fset_buffer (Fget_buffer_create (build_string (bufname))); | 738 | Fset_buffer (Fget_buffer_create (build_string (bufname))); |
| 734 | 739 | ||
| 735 | current_buffer->directory = old->directory; | 740 | current_buffer->directory = old->directory; |
| @@ -741,11 +746,13 @@ temp_output_buffer_setup (bufname) | |||
| 741 | current_buffer->enable_multibyte_characters | 746 | current_buffer->enable_multibyte_characters |
| 742 | = buffer_defaults.enable_multibyte_characters; | 747 | = buffer_defaults.enable_multibyte_characters; |
| 743 | Ferase_buffer (); | 748 | Ferase_buffer (); |
| 744 | |||
| 745 | XSETBUFFER (buf, current_buffer); | 749 | XSETBUFFER (buf, current_buffer); |
| 746 | specbind (Qstandard_output, buf); | ||
| 747 | 750 | ||
| 748 | set_buffer_internal (old); | 751 | call1 (Vrun_hooks, Qtemp_buffer_setup_hook); |
| 752 | |||
| 753 | unbind_to (count, Qnil); | ||
| 754 | |||
| 755 | specbind (Qstandard_output, buf); | ||
| 749 | } | 756 | } |
| 750 | 757 | ||
| 751 | Lisp_Object | 758 | Lisp_Object |
| @@ -779,10 +786,15 @@ DEFUN ("with-output-to-temp-buffer", Fwith_output_to_temp_buffer, Swith_output_t | |||
| 779 | The buffer is cleared out initially, and marked as unmodified when done.\n\ | 786 | The buffer is cleared out initially, and marked as unmodified when done.\n\ |
| 780 | All output done by BODY is inserted in that buffer by default.\n\ | 787 | All output done by BODY is inserted in that buffer by default.\n\ |
| 781 | The buffer is displayed in another window, but not selected.\n\ | 788 | The buffer is displayed in another window, but not selected.\n\ |
| 782 | The hook `temp-buffer-show-hook' is run with that window selected\n\ | ||
| 783 | temporarily and its buffer current.\n\ | ||
| 784 | The value of the last form in BODY is returned.\n\ | 789 | The value of the last form in BODY is returned.\n\ |
| 785 | If BODY does not finish normally, the buffer BUFNAME is not displayed.\n\n\ | 790 | If BODY does not finish normally, the buffer BUFNAME is not displayed.\n\ |
| 791 | \n\ | ||
| 792 | The hook `temp-buffer-setup-hook' is run before BODY,\n\ | ||
| 793 | with the buffer BUFNAME temporarily current.\n\ | ||
| 794 | The hook `temp-buffer-show-hook' is run after the buffer is displayed,\n\ | ||
| 795 | with the buffer temporarily current, and the window that was used\n\ | ||
| 796 | to display it temporarily selected.\n\ | ||
| 797 | \n\ | ||
| 786 | If variable `temp-buffer-show-function' is non-nil, call it at the end\n\ | 798 | If variable `temp-buffer-show-function' is non-nil, call it at the end\n\ |
| 787 | to get the buffer displayed instead of just displaying the non-selected\n\ | 799 | to get the buffer displayed instead of just displaying the non-selected\n\ |
| 788 | buffer and calling the hook. It gets one argument, the buffer to display.") | 800 | buffer and calling the hook. It gets one argument, the buffer to display.") |
| @@ -1834,6 +1846,9 @@ print_interval (interval, printcharfun) | |||
| 1834 | void | 1846 | void |
| 1835 | syms_of_print () | 1847 | syms_of_print () |
| 1836 | { | 1848 | { |
| 1849 | Qtemp_buffer_setup_hook = intern ("temp-buffer-setup-hook"); | ||
| 1850 | staticpro (&Qtemp_buffer_setup_hook); | ||
| 1851 | |||
| 1837 | DEFVAR_LISP ("standard-output", &Vstandard_output, | 1852 | DEFVAR_LISP ("standard-output", &Vstandard_output, |
| 1838 | "Output stream `print' uses by default for outputting a character.\n\ | 1853 | "Output stream `print' uses by default for outputting a character.\n\ |
| 1839 | This may be any function of one argument.\n\ | 1854 | This may be any function of one argument.\n\ |