From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#71080: 30.0.50; UTF-8 used unconditionally when saving GPG file Date: Mon, 20 May 2024 21:00:52 +0300 Message-ID: <865xv89xd7.fsf@gnu.org> References: <867cfoa1zs.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2869"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 71080@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 20 20:02:21 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 1s97L2-0000Vl-Kc for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 20 May 2024 20:02:20 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s97Kl-00018a-GE; Mon, 20 May 2024 14:02:03 -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 1s97Kg-000151-DA for bug-gnu-emacs@gnu.org; Mon, 20 May 2024 14:01:59 -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 1s97Kf-000609-VN for bug-gnu-emacs@gnu.org; Mon, 20 May 2024 14:01:58 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s97Kk-00059x-5Q for bug-gnu-emacs@gnu.org; Mon, 20 May 2024 14:02:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 20 May 2024 18:02: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.171622807219815 (code B ref 71080); Mon, 20 May 2024 18:02:02 +0000 Original-Received: (at 71080) by debbugs.gnu.org; 20 May 2024 18:01:12 +0000 Original-Received: from localhost ([127.0.0.1]:43964 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s97Jv-00059X-Fp for submit@debbugs.gnu.org; Mon, 20 May 2024 14:01:11 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:46282) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s97Js-00059N-2r for 71080@debbugs.gnu.org; Mon, 20 May 2024 14:01:10 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s97Jh-0005pP-Gv; Mon, 20 May 2024 14:00:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=WQDxUOXmpvgBeYkd+K3gX6rH2Nj4E6wziicn5hPpOdU=; b=fPbJ6P1qJaqX7xbEgt1p uC3Ye13f/zH/T5L66emOAxvKbB4HQC4i/RtBlf1yZUkH2oGvGPmo5IsPzqHpCQNqX0Ygc1Fqe48y7 CaDGMm9VpSLUwfoGdSdps05hlC9DezMOnFZKVk8a7CJ/U/YM2Bm8oa6Xyz9mwq/63HYaShlj2SYPB 3Enbie0d8xl6GZto/2j9Xp/qi3J5zXmONnZvo1EcxliLNZqByCEc7ubwafFDcxWkFPtBEV/Hwls++ 2L8Hl75Ia9cHoSZkr/c0Esy0Xm6sa7aX92TkzQtJdodrrFd4dXPG934QnF+Gt2RZj43/cTBWAbYSR Z/J6oyBMUsOJ8w==; In-Reply-To: (message from Stefan Monnier on Mon, 20 May 2024 12:38:50 -0400) 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:285489 Archived-At: > From: Stefan Monnier > Cc: 71080@debbugs.gnu.org > Date: Mon, 20 May 2024 12:38:50 -0400 > > > How can this work reliably, unless the *.gpg files can have some > > meta-data that tells Emacs how to decode them? > > GPG takes bytes in and split bytes out, so there's no encoding > issue there. Yes, but what bytes? You can encode a buffer using UTF-8 or you can encode it using ISO 2022, and in each case you will get a different bytestream. GPG doesn't care either way, but the bytes it will get and encode will be different. > 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 sequence > is not turned into `λ` but is kept as `eight-bit` chars) but not when saving. Any evidence for that? 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, but maybe I'm not looking in the right place. > > When encoding, we could perhaps use buffer-file-coding-system (AFAICT, > > we do that indirectly now, via select-safe-coding-system), but what to > > do when decoding? > > 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. 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. > > 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". > And it should not be needed since the file-local var states very > explicitly what we should use. 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. Thanks.