changeset 93396:c15f559a5ada

(with-temp-buffer): Assume kill-buffer can change current-buffer.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sat, 29 Mar 2008 22:50:11 +0000
parents 79d7508228c3
children b532cf17d6ad
files lisp/ChangeLog lisp/subr.el
diffstat 2 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sat Mar 29 22:43:16 2008 +0000
+++ b/lisp/ChangeLog	Sat Mar 29 22:50:11 2008 +0000
@@ -1,5 +1,7 @@
 2008-03-29  Stefan Monnier  <monnier@iro.umontreal.ca>
 
+	* subr.el (with-temp-buffer): Assume kill-buffer can change cur-buf.
+
 	* textmodes/remember.el (remember-diary-convert-entry): Prefer boundp
 	to with-no-warnings.
 
--- a/lisp/subr.el	Sat Mar 29 22:43:16 2008 +0000
+++ b/lisp/subr.el	Sat Mar 29 22:50:11 2008 +0000
@@ -2557,11 +2557,12 @@
   (declare (indent 0) (debug t))
   (let ((temp-buffer (make-symbol "temp-buffer")))
     `(let ((,temp-buffer (generate-new-buffer " *temp*")))
-       (unwind-protect
-	   (with-current-buffer ,temp-buffer
-	     ,@body)
-	 (and (buffer-name ,temp-buffer)
-	      (kill-buffer ,temp-buffer))))))
+       ;; FIXME: kill-buffer can change current-buffer in some odd cases.
+       (with-current-buffer ,temp-buffer
+         (unwind-protect
+	     (progn ,@body)
+           (and (buffer-name ,temp-buffer)
+                (kill-buffer ,temp-buffer)))))))
 
 (defmacro with-output-to-string (&rest body)
   "Execute BODY, return the text it sent to `standard-output', as a string."