From: Eli Zaretskii <eliz@gnu.org>
To: Jens Schmidt <jschmidt4gnu@vodafonemail.de>
Cc: 66546@debbugs.gnu.org
Subject: bug#66546: 30.0.50; save-buffer to write-protected file without backup fails
Date: Thu, 02 Nov 2023 08:47:14 +0200 [thread overview]
Message-ID: <83bkcc8xe5.fsf@gnu.org> (raw)
In-Reply-To: <87wmv1wawz.fsf@sappc2.fritz.box> (message from Jens Schmidt on Wed, 01 Nov 2023 20:06:36 +0100)
> From: Jens Schmidt <jschmidt4gnu@vodafonemail.de>
> Cc: 66546@debbugs.gnu.org
> Date: Wed, 01 Nov 2023 20:06:36 +0100
>
> Eli Zaretskii <eliz@gnu.org> writes:
>
> > Sure, addition to the test suite are always welcome.
>
> Please review attached test. I hope I haven't been overperforming.
Thanks, a few comments below:
> + (cl-letf* (;; Define convenience functions.
> + ((symbol-function 'file-contents)
> + (lambda (file)
> + (if (file-exists-p file)
> + (condition-case err
> + (with-temp-buffer
> + (insert-file-contents file)
> + (buffer-string))
> + ((error err)))
> + 'missing)))
> [...]
> + (should (equal (file-contents file) "foo\n"))
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.
Also, compiling the new test I get byte-compiler warnings:
In toplevel form:
lisp/files-tests.el:1748:39: Warning: Unused lexical variable `err'
lisp/files-tests.el:1763:17: Warning: `local-write-file-hooks' is an obsolete variable (as of 22.1); use `write-file-functions' instead.
In end of data:
lisp/files-tests.el:1802:29: Warning: the function `file-contents' is not known to be defined.
next prev parent reply other threads:[~2023-11-02 6:47 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-14 19:09 bug#66546: 30.0.50; save-buffer to write-protected file without backup fails Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-14 19:32 ` Eli Zaretskii
2023-10-14 20:31 ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-15 5:33 ` Eli Zaretskii
2023-10-15 9:34 ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-15 9:54 ` Eli Zaretskii
2023-10-15 11:39 ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-15 12:12 ` Eli Zaretskii
2023-10-15 18:59 ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-16 11:19 ` Eli Zaretskii
2023-10-16 20:04 ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-17 10:48 ` Eli Zaretskii
2023-10-17 20:12 ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-18 11:32 ` Eli Zaretskii
2023-10-18 20:36 ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-19 4:40 ` Eli Zaretskii
2023-10-19 21:12 ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-20 6:06 ` Eli Zaretskii
2023-10-21 17:56 ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-21 19:02 ` Eli Zaretskii
2023-10-21 20:17 ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-22 4:57 ` Eli Zaretskii
2023-10-22 9:45 ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-25 12:58 ` Eli Zaretskii
2023-10-29 14:23 ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-29 14:39 ` Eli Zaretskii
2023-11-01 19:06 ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-02 6:47 ` Eli Zaretskii [this message]
2023-11-03 21:02 ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-04 8:58 ` Eli Zaretskii
2023-11-04 12:30 ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-04 12:59 ` Eli Zaretskii
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83bkcc8xe5.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=66546@debbugs.gnu.org \
--cc=jschmidt4gnu@vodafonemail.de \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).