summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKim F. Storm <storm@cua.dk>2003-11-23 21:29:45 +0000
committerKim F. Storm <storm@cua.dk>2003-11-23 21:29:45 +0000
commit6a1ff3ba09aca7f30b132ad65973506cf0416b53 (patch)
tree0423777fb4a86c63f7c5251d30b0960268b86850
parent9ac5747987e4df08683ce2af46c8a7d09744dbd7 (diff)
downloademacs-6a1ff3ba09aca7f30b132ad65973506cf0416b53.tar.gz
(Fredirect_debugging_output): New defun.
(syms_of_print): Defsubr it.
-rw-r--r--src/ChangeLog7
-rw-r--r--src/print.c34
2 files changed, 40 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index c353ab7a52b..fac85f28b3d 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,8 +1,13 @@
+2003-11-23 Kim F. Storm <storm@cua.dk>
+
+ * print.c (Fredirect_debugging_output): New defun.
+ (syms_of_print): Defsubr it.
+
2003-11-22 Luc Teirlinck <teirllm@auburn.edu>
* fns.c (Fset_char_table_parent): Doc fix.
-2003-11-23 Kim F. Storm <storm@cua.dk>
+2003-11-22 Kim F. Storm <storm@cua.dk>
* dispnew.c (buffer_posn_from_coords): Return actual row/column
for glyph clicked on, rather than (unused) pixel positions.
diff --git a/src/print.c b/src/print.c
index 5f1506392c2..719fb8fd21a 100644
--- a/src/print.c
+++ b/src/print.c
@@ -911,6 +911,39 @@ to make it write to the debugging output. */)
return character;
}
+FILE *initial_stderr_stream = NULL;
+
+DEFUN ("redirect-debugging-output", Fredirect_debugging_output, Sredirect_debugging_output,
+ 1, 2,
+ "FDebug output file: \nP",
+ doc: /* Redirect debugging output (stderr stream) to file FILE.
+If FILE is nil, reset target to the initial stderr stream.
+Optional arg APPEND non-nil (interactively, with prefix arg) means
+append to existing target file. */)
+ (file, append)
+ Lisp_Object file, append;
+{
+ if (initial_stderr_stream != NULL)
+ fclose(stderr);
+ stderr = initial_stderr_stream;
+ initial_stderr_stream = NULL;
+
+ if (STRINGP (file))
+ {
+ file = Fexpand_file_name (file, Qnil);
+ initial_stderr_stream = stderr;
+ stderr = fopen(SDATA (file), NILP (append) ? "w" : "a");
+ if (stderr == NULL)
+ {
+ stderr = initial_stderr_stream;
+ initial_stderr_stream = NULL;
+ report_file_error ("Cannot open debugging output stream",
+ Fcons (file, Qnil));
+ }
+ }
+ return Qnil;
+}
+
/* This is the interface for debugging printing. */
void
@@ -2164,6 +2197,7 @@ that need to be recorded in the table. */);
defsubr (&Sterpri);
defsubr (&Swrite_char);
defsubr (&Sexternal_debugging_output);
+ defsubr (&Sredirect_debugging_output);
Qexternal_debugging_output = intern ("external-debugging-output");
staticpro (&Qexternal_debugging_output);