From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#71080: 30.0.50; UTF-8 used unconditionally when saving GPG file Date: Mon, 20 May 2024 17:08:25 -0400 Message-ID: References: <867cfoa1zs.fsf@gnu.org> <865xv89xd7.fsf@gnu.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15804"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 71080@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 20 23:09:22 2024 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 1s9AG1-0003sb-99 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 20 May 2024 23:09:21 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9AFf-0004Vh-8Y; Mon, 20 May 2024 17:08:59 -0400 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 1s9AFd-0004VY-UK for bug-gnu-emacs@gnu.org; Mon, 20 May 2024 17:08:57 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s9AFd-0000dY-Lc for bug-gnu-emacs@gnu.org; Mon, 20 May 2024 17:08:57 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s9AFi-0001cj-1m for bug-gnu-emacs@gnu.org; Mon, 20 May 2024 17:09:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 20 May 2024 21:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71080 X-GNU-PR-Package: emacs Original-Received: via spool by 71080-submit@debbugs.gnu.org id=B71080.17162393246229 (code B ref 71080); Mon, 20 May 2024 21:09:02 +0000 Original-Received: (at 71080) by debbugs.gnu.org; 20 May 2024 21:08:44 +0000 Original-Received: from localhost ([127.0.0.1]:44819 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s9AFQ-0001cP-Bt for submit@debbugs.gnu.org; Mon, 20 May 2024 17:08:44 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:22882) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s9AFL-0001cJ-Ra for 71080@debbugs.gnu.org; Mon, 20 May 2024 17:08:42 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 1AFEE803CA; Mon, 20 May 2024 17:08:29 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1716239307; bh=u4l6yYk6jYIrXNsjO4aVFjoaWMDV1+bLsFtJqpNTaV4=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=neZI/4svRHAsCz7AEL6yhCNehi9iuX/ETTGMYzxrbnSOnVnlkISvgmnEEzos5ieb1 7emCTlWnFhl/LCXDCRcvn8qp0hKeNcdjVZgHEbSNxw+vM56vsSIUIbBQWzxu6TRck8 rcnCBQnM8QPHAxIunIZKT6p3PAcS6d+sBhMmIAW3zFMTDipufpgB5AATc5QT4GTzlR bGPjWVolnJNPHQggmIKqH9xs5jACVdqrCdSa/LaHdjmfi0SnirTbdm7VuZIN9IMxNg NG2q8qi/5980qkQLGqIqjkBPjRSQqDRNm5Leh1teEbQ2yLcbFmyTbFvd7+ocgLCnpH UWoLvtFXhYfbA== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 93F6B803B1; Mon, 20 May 2024 17:08:27 -0400 (EDT) Original-Received: from pastel (unknown [45.72.201.215]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 6D96D1201D8; Mon, 20 May 2024 17:08:27 -0400 (EDT) In-Reply-To: <865xv89xd7.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 20 May 2024 21:00:52 +0300") 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:285509 Archived-At: >> The contents in my example very much comes with the needed >> meta-data (in the form of a `coding` file-local var). That meta-data is >> correctly used when opening the file (which is why the UTF-8 byte sequen= ce >> is not turned into `=CE=BB` but is kept as `eight-bit` chars) but not wh= en saving. > Any evidence for that? Of what exactly? > Can you take me through the code to show that buffer's encoding is > ignored? What I see there is that we choose a reasonable encoding > when sending data to GPG, I think my recipe is pretty clear: we start with =CE=BB # Local Variables: # coding: iso-2022-7bit # End: and after save and `revert-buffer` we end up with \316\273 # Local Variables: # coding: iso-2022-7bit # End: \316\273 is the encoding of =CE=BB in UTF-8, not in `iso-2022-7bit`, so it seems pretty clear that Emacs encoded the buffer using (some version of) utf-8, thus disregarding the `coding:` cookie. >> As mentioned, AFAICT we DTRT already when decoding (at least when the >> coding system is specified via a file-local var). The problem is when >> saving: `select-safe-coding-system` ends up returning `no-conversion` >> despite the `coding:` cookie. > > Please tell where in the code you see that. Try and reproduce my recipe after doing `M-x trace-function RET select-safe-coding-system`. > AFAIK, the coding cookie is supposed to determine > buffer-file-coding-system, and select-safe-coding-system tries > buffer-file-coding-system as part of the values it attempts to use. AFAICT this gets overridden by the return value of `find-auto-coding` we setup for `.gpg` files. >> > If _you_ know the correct encoding, you could use "C-x RET c" before >> > the commands (as in "C-x RET c iso-2022-7bit RET C-x C-w"). Did you >> > try that? >> I tried `C-x RET f`. It makes no difference. > Not "C-x RET f", but "C-x RET c". I haven't tried that, no. > Yes, but "C-x RET c" is generally stronger, so if it helps, it's a > sign that the code is correct, but uses incorrect defaults. That's > why I suggested to try it. However, if you know the code and can tell > how and where we determine which encoding to use, that'd be more > efficient. I stepped through `select-safe-coding-system`, which is where I got the info I described about `find-auto-coding` and `find-coding-systems-region`. Stefan