aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1999-01-11 15:26:11 +0000
committerRichard M. Stallman1999-01-11 15:26:11 +0000
commitd9c21094c7a47b8037393e9427c8e7180a8c6ea2 (patch)
tree263a062d64d85e3907d32e6f6e9ed184a11fec44 /src
parente48143f0fd269fca8332f0207549bf12ae9b95b2 (diff)
downloademacs-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.c27
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
42Lisp_Object Vstandard_output, Qstandard_output; 42Lisp_Object Vstandard_output, Qstandard_output;
43 43
44Lisp_Object Qtemp_buffer_setup_hook;
45
44/* These are used to print like we read. */ 46/* These are used to print like we read. */
45extern Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction; 47extern Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction;
46 48
@@ -727,9 +729,12 @@ void
727temp_output_buffer_setup (bufname) 729temp_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
751Lisp_Object 758Lisp_Object
@@ -779,10 +786,15 @@ DEFUN ("with-output-to-temp-buffer", Fwith_output_to_temp_buffer, Swith_output_t
779The buffer is cleared out initially, and marked as unmodified when done.\n\ 786The buffer is cleared out initially, and marked as unmodified when done.\n\
780All output done by BODY is inserted in that buffer by default.\n\ 787All output done by BODY is inserted in that buffer by default.\n\
781The buffer is displayed in another window, but not selected.\n\ 788The buffer is displayed in another window, but not selected.\n\
782The hook `temp-buffer-show-hook' is run with that window selected\n\
783temporarily and its buffer current.\n\
784The value of the last form in BODY is returned.\n\ 789The value of the last form in BODY is returned.\n\
785If BODY does not finish normally, the buffer BUFNAME is not displayed.\n\n\ 790If BODY does not finish normally, the buffer BUFNAME is not displayed.\n\
791\n\
792The hook `temp-buffer-setup-hook' is run before BODY,\n\
793with the buffer BUFNAME temporarily current.\n\
794The hook `temp-buffer-show-hook' is run after the buffer is displayed,\n\
795with the buffer temporarily current, and the window that was used\n\
796to display it temporarily selected.\n\
797\n\
786If variable `temp-buffer-show-function' is non-nil, call it at the end\n\ 798If variable `temp-buffer-show-function' is non-nil, call it at the end\n\
787to get the buffer displayed instead of just displaying the non-selected\n\ 799to get the buffer displayed instead of just displaying the non-selected\n\
788buffer and calling the hook. It gets one argument, the buffer to display.") 800buffer and calling the hook. It gets one argument, the buffer to display.")
@@ -1834,6 +1846,9 @@ print_interval (interval, printcharfun)
1834void 1846void
1835syms_of_print () 1847syms_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\
1839This may be any function of one argument.\n\ 1854This may be any function of one argument.\n\