[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
with-output-to-string improvement
From: |
Dave Love |
Subject: |
with-output-to-string improvement |
Date: |
03 Apr 2003 17:26:54 +0100 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 |
Is this change OK, to make the macro robust against the body inserting
anything (but a bit less efficient)?
Index: subr.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/subr.el,v
retrieving revision 1.344
diff -u -p -c -r1.344 subr.el
cvs server: conflicting specifications of output style
*** subr.el 14 Mar 2003 22:36:57 -0000 1.344
--- subr.el 3 Apr 2003 16:22:40 -0000
*************** See also `with-temp-file' and `with-outp
*** 1639,1652 ****
(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 (generate-new-buffer-name " *string-output*"))))
! (let ((standard-output standard-output))
! ,@body)
! (with-current-buffer standard-output
! (prog1
! (buffer-string)
! (kill-buffer nil)))))
(defmacro with-local-quit (&rest body)
"Execute BODY with `inhibit-quit' temporarily bound to nil."
--- 1640,1650 ----
(defmacro with-output-to-string (&rest body)
"Execute BODY, return the text it sent to `standard-output', as a string."
! `(with-temp-buffer
! (let ((standard-output (current-buffer)))
! (with-temp-buffer ; in case body inserts anything
! ,@body)
! (buffer-string))))
(defmacro with-local-quit (&rest body)
"Execute BODY with `inhibit-quit' temporarily bound to nil."
- with-output-to-string improvement,
Dave Love <=