Subject: bug#60730: 29.0.60; Free variable with :buffer keyword in ert-with-temp-file

From: "J.P." <[email-masked]>
Date: Sat, 28 Jan 2023 20:35:47 -0800

"J.P." <[email-masked]> writes:

> Eli Zaretskii <[email-masked]> writes:
>
>> Thanks, but I'm not sure I follow: coding-system's name should always
>> be quoted, as it's a symbol.  So why things like the below:
>>
>>    (ert-with-temp-file myfile :coding raw-text)
>>
>> are relevant?  AFAIU, they are a mistake: raw-text should be quoted,
>> as in 'raw-text.

If, as you say, an argument to `:coding' should only ever be quoted, e.g.,

  :coding 'raw-text

then `coding' will end up quoted as well, so something like this might
be enough:

  diff --git a/lisp/emacs-lisp/ert-x.el b/lisp/emacs-lisp/ert-x.el
  index 98a017c8a8e..aa02c79d32f 100644
  --- a/lisp/emacs-lisp/ert-x.el
  +++ b/lisp/emacs-lisp/ert-x.el
  @@ -484,7 +484,7 @@ ert-with-temp-file
             (suffix (or suffix ert-temp-file-suffix
                         (ert--with-temp-file-generate-suffix
                          (or (macroexp-file-name) buffer-file-name)))))
  -      `(let* ((coding-system-for-write ,(or coding coding-system-for-write))
  +      `(let* ((coding-system-for-write ,(or coding `',coding-system-for-write))
                 (,temp-file (,(if directory 'file-name-as-directory 'identity)
                              (make-temp-file ,prefix ,directory ,suffix ,text)))
                 (,name ,(if directory