[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#66546: 30.0.50; save-buffer to write-protected file without backup f
From: |
Eli Zaretskii |
Subject: |
bug#66546: 30.0.50; save-buffer to write-protected file without backup fails |
Date: |
Sat, 04 Nov 2023 10:58:18 +0200 |
> From: Jens Schmidt <jschmidt4gnu@vodafonemail.de>
> Cc: 66546@debbugs.gnu.org
> Date: Fri, 03 Nov 2023 22:02:03 +0100
>
> > If you want to make sure the file's contents is _exactly_ some text,
> > you need to write the buffer text to the file with no encoding
> > conversions, and you need then to visit the file with
> > insert-file-contents-literally, to avoid decoding conversions.
> > Otherwise you might get false positives and false negatives due to
> > encoding/decoding of text and of EOLs.
>
> Done: insert-file-contents-literally for reading, binding
>
> (coding-system-for-write 'no-conversion)
>
> for writing.
I think one nit is still missing:
> + (let* (;; Sanitize environment.
> + (coding-system-for-write 'no-conversion)
I think you also need to bind coding-system-for-read to no-conversion,
since you later do this:
> + (with-current-buffer (find-file-noselect file)
^^^^^^^^^^^^^^^^^^^^^^^
Otherwise, find-file-noselect will use insert-file-contents, which
will attempt to decode the text.
Thanks.