summaryrefslogtreecommitdiff
path: root/src/print.c
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1999-01-11 15:26:11 +0000
committerRichard M. Stallman <rms@gnu.org>1999-01-11 15:26:11 +0000
commita7af76d18531a5ee3b2e7007abdb3faacf243004 (patch)
treec9d8a4acb58a6fb7749ec95cabfcb06699213bdc /src/print.c
parent7173e1e1bb7ae8c43b2af72c80ebef631241c7db (diff)
downloademacs-a7af76d18531a5ee3b2e7007abdb3faacf243004.tar.gz
(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/print.c')
-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. */
Lisp_Object Vstandard_output, Qstandard_output;
+Lisp_Object Qtemp_buffer_setup_hook;
+
/* These are used to print like we read. */
extern Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction;
@@ -727,9 +729,12 @@ void
temp_output_buffer_setup (bufname)
char *bufname;
{
+ int count = specpdl_ptr - specpdl;
register struct buffer *old = current_buffer;
register Lisp_Object buf;
+ record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ());
+
Fset_buffer (Fget_buffer_create (build_string (bufname)));
current_buffer->directory = old->directory;
@@ -741,11 +746,13 @@ temp_output_buffer_setup (bufname)
current_buffer->enable_multibyte_characters
= buffer_defaults.enable_multibyte_characters;
Ferase_buffer ();
-
XSETBUFFER (buf, current_buffer);
- specbind (Qstandard_output, buf);
- set_buffer_internal (old);
+ call1 (Vrun_hooks, Qtemp_buffer_setup_hook);
+
+ unbind_to (count, Qnil);
+
+ specbind (Qstandard_output, buf);
}
Lisp_Object
@@ -779,10 +786,15 @@ DEFUN ("with-output-to-temp-buffer", Fwith_output_to_temp_buffer, Swith_output_t
The buffer is cleared out initially, and marked as unmodified when done.\n\
All output done by BODY is inserted in that buffer by default.\n\
The buffer is displayed in another window, but not selected.\n\
-The hook `temp-buffer-show-hook' is run with that window selected\n\
-temporarily and its buffer current.\n\
The value of the last form in BODY is returned.\n\
-If BODY does not finish normally, the buffer BUFNAME is not displayed.\n\n\
+If BODY does not finish normally, the buffer BUFNAME is not displayed.\n\
+\n\
+The hook `temp-buffer-setup-hook' is run before BODY,\n\
+with the buffer BUFNAME temporarily current.\n\
+The hook `temp-buffer-show-hook' is run after the buffer is displayed,\n\
+with the buffer temporarily current, and the window that was used\n\
+to display it temporarily selected.\n\
+\n\
If variable `temp-buffer-show-function' is non-nil, call it at the end\n\
to get the buffer displayed instead of just displaying the non-selected\n\
buffer and calling the hook. It gets one argument, the buffer to display.")
@@ -1834,6 +1846,9 @@ print_interval (interval, printcharfun)
void
syms_of_print ()
{
+ Qtemp_buffer_setup_hook = intern ("temp-buffer-setup-hook");
+ staticpro (&Qtemp_buffer_setup_hook);
+
DEFVAR_LISP ("standard-output", &Vstandard_output,
"Output stream `print' uses by default for outputting a character.\n\
This may be any function of one argument.\n\