Mercurial > emacs
changeset 16311:a56a8c6f2d8f
(with-output-to-string): New macro.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 24 Sep 1996 20:03:15 +0000 |
parents | c987c025d448 |
children | 20690a1ec100 |
files | lisp/subr.el |
diffstat | 1 files changed, 15 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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