From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "J.P." Newsgroups: gmane.emacs.bugs Subject: bug#60730: 29.0.60; Free variable with :buffer keyword in ert-with-temp-file Date: Sun, 29 Jan 2023 08:18:48 -0800 Message-ID: <87sfftjouv.fsf@neverwas.me> References: <87o7r5ji3q.fsf@neverwas.me> <874jsazqzz.fsf@neverwas.me> <83edreaehg.fsf@gnu.org> <87k016y7o9.fsf@neverwas.me> <838rhmab8f.fsf@gnu.org> <874jsaumk7.fsf@neverwas.me> <875ycqt0t8.fsf@neverwas.me> <83k015976p.fsf@gnu.org> <87lelll9ha.fsf@neverwas.me> <83pmax74wy.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7579"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: stefankangas@gmail.com, 60730@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jan 29 17:20:23 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pMAPm-0001iB-5l for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 29 Jan 2023 17:20:22 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMAPV-0000CE-6U; Sun, 29 Jan 2023 11:20:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMAPS-0000By-OJ for bug-gnu-emacs@gnu.org; Sun, 29 Jan 2023 11:20:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pMAPS-0003nW-FK for bug-gnu-emacs@gnu.org; Sun, 29 Jan 2023 11:20:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pMAPS-0003CQ-4u for bug-gnu-emacs@gnu.org; Sun, 29 Jan 2023 11:20:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: "J.P." Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 29 Jan 2023 16:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60730 X-GNU-PR-Package: emacs Original-Received: via spool by 60730-submit@debbugs.gnu.org id=B60730.167500915212233 (code B ref 60730); Sun, 29 Jan 2023 16:20:02 +0000 Original-Received: (at 60730) by debbugs.gnu.org; 29 Jan 2023 16:19:12 +0000 Original-Received: from localhost ([127.0.0.1]:45285 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pMAOd-0003BF-Fd for submit@debbugs.gnu.org; Sun, 29 Jan 2023 11:19:11 -0500 Original-Received: from mail-108-mta219.mxroute.com ([136.175.108.219]:37913) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pMAOb-0003Ay-0i for 60730@debbugs.gnu.org; Sun, 29 Jan 2023 11:19:10 -0500 Original-Received: from mail-111-mta2.mxroute.com ([136.175.111.2] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta219.mxroute.com (ZoneMTA) with ESMTPSA id 185fe5321d0000011e.001 for <60730@debbugs.gnu.org> (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256); Sun, 29 Jan 2023 16:18:59 +0000 X-Zone-Loop: 8c1c865f134db6afc84d03c0a4a259b0cabb6f5e929b X-Originating-IP: [136.175.111.2] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=neverwas.me ; s=x; h=Content-Type:MIME-Version:Message-ID:Date:References:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=A3AySpsWe933V7zbTIxru9rmNL4WGUE7S52gmIPdyAE=; b=S1u4ftylmiuIFRd1QICSK01IW7 foCyBuRIBuwCIPv+MkZ+uvs8N3fqN3SI5FuDe4HUTCshKp/uO62xsuJyrFd8bCtDEqajrJHa7yTnI Qa97HEmm6ag00KZ0fnDbsFLz1fkTItzJ7nWfntJhH9cSNmD86aOyY39t8U7hXWHgLxLPvVf/oo1Xc 8mD0hcTdy5WNWvv3o61ifMmMpdXk67xs9yAgavbsG4uLbTT+ukDglk6b4XXhQ9go9Jxut8BohQw9Q Rchgwqfq8KbKCYZU21g9k26m97t/M6BEylQslYuVOJkaLW2cdbIWSEHvrZRpzV8bDy9G/7RENseM6 yNPv3ZNw==; In-Reply-To: <83pmax74wy.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 29 Jan 2023 17:10:21 +0200") X-Authenticated-Id: masked@neverwas.me X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:254369 Archived-At: Eli Zaretskii writes: >> From: "J.P." >> Cc: 60730@debbugs.gnu.org, stefankangas@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. If it's unlikely that a user would specify nil explicitly or provide a variable that might evaluate to nil, then the question of whether to fall back to `coding-system-for-write' is less important. >> 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. Interesting. Makes sense to limit any damage done to that variable to the extent of the test run. Guess that should have occurred to me. So, based on what you've said, a couple remaining possibilities are diff --git a/lisp/emacs-lisp/ert-x.el b/lisp/emacs-lisp/ert-x.el index 98a017c8a8e..3439aacf1ab 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 and diff --git a/lisp/emacs-lisp/ert-x.el b/lisp/emacs-lisp/ert-x.el index 98a017c8a8e..3439aacf1ab 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 The bottom one doesn't fall back if `coding' is a variable that evaluates to nil. Of course, there are surely other (perhaps smarter) ways to go about this, in case anyone else wants to take a stab.