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

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

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


From: Stefan Monnier
Subject: bug#34765: 26.1; with-temp-buffer should not run buffer-list-update-hook
Date: Fri, 18 Dec 2020 10:36:22 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

>  (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))))

You lost the `(with-current-buffer ,temp-buffer` around `write-region`
so your new code will break if `body` doesn't preserve current-buffer.


        Stefan






reply via email to

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