# HG changeset patch # User Richard M. Stallman # Date 843595395 0 # Node ID a56a8c6f2d8fb819bfbdc49bdff091f181972388 # Parent c987c025d448040e020dc3499a9f1a2aabec3a9e (with-output-to-string): New macro. diff -r c987c025d448 -r a56a8c6f2d8f lisp/subr.el --- a/lisp/subr.el Tue Sep 24 19:40:24 1996 +0000 +++ b/lisp/subr.el Tue Sep 24 20:03:15 1996 +0000 @@ -740,6 +740,21 @@ (set-buffer ,buffer) . ,body)) +(defmacro with-output-to-string (&rest body) + "Execute BODY, return the text it sent to `standard-output', as a string." + `(let ((standard-output (get-buffer-create " *string-output*"))) + (save-excursion + (set-buffer standard-output) + (buffer-disable-undo (current-buffer)) + (let ((inhibit-read-only t)) + (erase-buffer)) + (setq buffer-read-only nil)) + (let ((standard-output standard-output)) + ,@body) + (save-excursion + (set-buffer standard-output) + (buffer-string)))) + (defvar save-match-data-internal) ;; We use save-match-data-internal as the local variable because