emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: with-output-to-string improvement


From: Stefan Monnier
Subject: Re: with-output-to-string improvement
Date: Thu, 03 Apr 2003 11:34:46 -0500

> Is this change OK, to make the macro robust against the body inserting
> anything (but a bit less efficient)?

I don't have time to look at it carefully, but I remember that last time
I tried to fiddle with it (I wanted it to use with-temp-buffer) I bumped
into some surprises.
Note for example that it is not supposed to change current-buffer
which it seems your macro does.


        Stefan


> 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."
> 
> 
> _______________________________________________
> Emacs-pretest-bug mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/emacs-pretest-bug
> 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]