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

Previous Next

Package: emacs;

Reported by: "J.P." <jp <at> neverwas.me>

Date: Wed, 11 Jan 2023 13:51:01 UTC

Severity: normal

Found in version 29.0.60

Done: Stefan Kangas <stefankangas <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #46 received at 60730 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: "J.P." <jp <at> neverwas.me>
Cc: stefankangas <at> gmail.com, 60730 <at> debbugs.gnu.org
Subject: Re: bug#60730: 29.0.60; Free variable with :buffer keyword in
 ert-with-temp-file
Date: Sun, 29 Jan 2023 17:10:21 +0200
> From: "J.P." <jp <at> neverwas.me>
> Cc: 60730 <at> debbugs.gnu.org,  stefankangas <at> gmail.com
> Date: Sun, 29 Jan 2023 06:08:01 -0800
> 
> > What we need to ensure that both
> >
> >   :coding 'raw-text
> >
> > and
> >
> >   :coding some-coding-variable
> >
> > do work as expected, including when coding-system-for-write's value is
> > a non-nil symbol of a coding-system.
> 
> Right, whatever the solution, it should cover those bases. Although, if
> `some-coding-variable' evaluates to nil, the change I proposed would not
> fall back on `coding-system-for-write'. (But perhaps it should? [1])

Setting :coding to nil is unusual and I don't expect that to happen.
Its semantics is tricky and most people aren't aware of that, so they
(rightfully) don't use it.

>   diff --git a/lisp/emacs-lisp/ert-x.el b/lisp/emacs-lisp/ert-x.el
>   index 98a017c8a8e..2605fc22ddf 100644
>   --- a/lisp/emacs-lisp/ert-x.el
>   +++ b/lisp/emacs-lisp/ert-x.el
>   @@ -475,7 +475,7 @@ ert-with-temp-file
>            (:directory (setq directory (pop body)))
>            (:text (setq text (pop body)))
>            (:buffer (setq buffer (pop body)))
>   -        (:coding (setq coding (pop body)))
>   +        (:coding (setq coding (list (pop body))))
>            (_ (push keyw extra-keywords) (pop body))))
>        (when extra-keywords
>          (error "Invalid keywords: %s" (mapconcat #'symbol-name extra-keywords " ")))
>   @@ -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* (,@(and coding `((coding-system-for-write ,(car coding))))
>                  (,temp-file (,(if directory 'file-name-as-directory 'identity)
>                               (make-temp-file ,prefix ,directory ,suffix ,text)))
>                  (,name ,(if directory

I don't think this is right.  coding-system-for-write exists and
should be heeded because it gives the user control on binding the
encoding just for this single command via "C-x RET c" prefix.  By
contrast, the value that comes from :coding is determined by the Lisp
program, and "C-x RET c" should override it.




This bug report was last modified 2 years and 169 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.