aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/subr.el15
1 files changed, 15 insertions, 0 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index c1ab778f38a..34cd3e7abe0 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -740,6 +740,21 @@ The value returned is the value of the last form in BODY."
740 (set-buffer ,buffer) 740 (set-buffer ,buffer)
741 . ,body)) 741 . ,body))
742 742
743(defmacro with-output-to-string (&rest body)
744 "Execute BODY, return the text it sent to `standard-output', as a string."
745 `(let ((standard-output (get-buffer-create " *string-output*")))
746 (save-excursion
747 (set-buffer standard-output)
748 (buffer-disable-undo (current-buffer))
749 (let ((inhibit-read-only t))
750 (erase-buffer))
751 (setq buffer-read-only nil))
752 (let ((standard-output standard-output))
753 ,@body)
754 (save-excursion
755 (set-buffer standard-output)
756 (buffer-string))))
757
743(defvar save-match-data-internal) 758(defvar save-match-data-internal)
744 759
745;; We use save-match-data-internal as the local variable because 760;; We use save-match-data-internal as the local variable because