From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 71080@debbugs.gnu.org
Subject: bug#71080: 30.0.50; UTF-8 used unconditionally when saving GPG file
Date: Mon, 20 May 2024 17:08:25 -0400 [thread overview]
Message-ID: <jwvle44gpx9.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <865xv89xd7.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 20 May 2024 21:00:52 +0300")
>> 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?
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
λ
# 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 λ 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
next prev parent reply other threads:[~2024-05-20 21:08 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-20 15:43 bug#71080: 30.0.50; UTF-8 used unconditionally when saving GPG file Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-20 16:20 ` Eli Zaretskii
2024-05-20 16:38 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-20 18:00 ` Eli Zaretskii
2024-05-20 21:08 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-05-23 13:01 ` Eli Zaretskii
2024-05-23 15:44 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-24 20:12 ` Jonas Bernoulli via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-25 6:14 ` Eli Zaretskii
2024-05-25 14:01 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvle44gpx9.fsf-monnier+emacs@gnu.org \
--to=bug-gnu-emacs@gnu.org \
--cc=71080@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.