Subject: bug#34765: 26.1; with-temp-buffer should not run buffer-list-update-hook

From: "Basil L. Contovounesios" <[email-masked]>
Date: Fri, 18 Dec 2020 14:57:26 +0000

"Basil L. Contovounesios" <[email-masked]> writes:

>  (defmacro with-temp-file (file &rest body)
>    "Create a new buffer, evaluate BODY there, and write the buffer to FILE.
>  The value returned is the value of the last form in BODY.
> -See also `with-temp-buffer'."
> +The buffer is created using `with-temp-buffer', which see."
>    (declare (indent 1) (debug t))
> -  (let ((temp-file (make-symbol "temp-file"))
> -	(temp-buffer (make-symbol "temp-buffer")))
> -    `(let ((,temp-file ,file)
> -	   (,temp-buffer (generate-new-buffer " *temp file*")))
> -       (unwind-protect
> -	   (prog1
> -	       (with-current-buffer ,temp-buffer
> -		 ,@body)
> -	     (with-current-buffer ,temp-buffer
> -	       (write-region nil nil ,temp-file nil 0)))
> -	 (and (buffer-name ,temp-buffer)
> -	      (kill-buffer ,temp-buffer))))))
> +  `(with-temp-buffer
> +     (prog1 (progn ,@body)
> +       (write-region nil nil ,file nil 0))))

Reading another thread made me realise that this changes the argument
evaluation order, so I'll fix that too.

-- 
Basil