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#66546: 30.0.50; save-buffer to write-protected file without backup fails Date: Thu, 02 Nov 2023 08:47:14 +0200 Message-ID: <83bkcc8xe5.fsf@gnu.org> References: <87il78cdyf.fsf@sappc2.fritz.box> <83pm1gozi6.fsf@gnu.org> <87edhvd84h.fsf@sappc2.fritz.box> <838r82q0gi.fsf@gnu.org> <87wmvmfi68.fsf@sappc2.fritz.box> <83o7gxo771.fsf@gnu.org> <87ttqpgg8l.fsf@sappc2.fritz.box> <83cyxcnp2f.fsf@gnu.org> <87sf671xe3.fsf@sappc2.fritz.box> <83y1fzmdhm.fsf@gnu.org> <87zg0ez57o.fsf@sappc2.fritz.box> <835y31u8t0.fsf@gnu.org> <87edhnamg3.fsf@sappc2.fritz.box> <83a5sbre7x.fsf@gnu.org> <87bkcrafxt.fsf@sappc2.fritz.box> <834jijqmnd.fsf@gnu.org> <878r7v9ei7.fsf@sappc2.fritz.box> <838r7qkgdp.fsf@gnu.org> <5097ddb3-c8a9-47ce-a6da-4ab73ca31172@vodafonemail.de> <838r7lbih3.fsf@gnu.org> <87wmv1wawz.fsf@sappc2.fritz.box> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27985"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 66546@debbugs.gnu.org To: Jens Schmidt Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Nov 02 07:48:56 2023 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 1qyRVf-00072T-V3 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 02 Nov 2023 07:48:55 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qyRVF-0003yG-M2; Thu, 02 Nov 2023 02:48:29 -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 1qyRVE-0003xW-1a for bug-gnu-emacs@gnu.org; Thu, 02 Nov 2023 02:48:28 -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 1qyRVD-0008S4-Hv for bug-gnu-emacs@gnu.org; Thu, 02 Nov 2023 02:48:27 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qyRVl-0004jj-Vy for bug-gnu-emacs@gnu.org; Thu, 02 Nov 2023 02:49: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: Thu, 02 Nov 2023 06:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66546 X-GNU-PR-Package: emacs Original-Received: via spool by 66546-submit@debbugs.gnu.org id=B66546.169890768917875 (code B ref 66546); Thu, 02 Nov 2023 06:49:01 +0000 Original-Received: (at 66546) by debbugs.gnu.org; 2 Nov 2023 06:48:09 +0000 Original-Received: from localhost ([127.0.0.1]:53763 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qyRUu-0004eE-QY for submit@debbugs.gnu.org; Thu, 02 Nov 2023 02:48:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57458) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qyRUp-0004db-Ph for 66546@debbugs.gnu.org; Thu, 02 Nov 2023 02:48:07 -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 1qyRUA-0008Gw-PA; Thu, 02 Nov 2023 02:47:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=01hzknLM0mQRkJHTMHEXvesPPHrCfSWQiiBdP8qDEdQ=; b=dcfdXUigC9tl jr1O4B1P+ZUH/xQPOQyLkU3WsQOdMor2muXmCdUIQJM6FpbEmK6mPfZdBOgPYH9xLLE87jRd7gIpI s+2KlO0o4GIEGRv/iUaV74fa+E3woUrEipTh0w0pDnJHEUZkuehdB/h3bYpr9QQHJdLzmTCxGfaf2 qi9RAWXYNmwu3ql1oz2dqjFLgtMv9IVDl0EJKrdsfy0BksZ7iBTvFLEg+Brr3W7CHMO2r7+4w9GB5 UQSoYycxJ8+v92xTbeS3nrxkUD0H8ZIe4ggX/yiFgygKa5g8vJD5AuM3sC8w7lnJxRcFJ2GdMkqV6 0qXJE6xTRC31X1KdrVSq5w==; In-Reply-To: <87wmv1wawz.fsf@sappc2.fritz.box> (message from Jens Schmidt on Wed, 01 Nov 2023 20:06:36 +0100) 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:273638 Archived-At: > From: Jens Schmidt > Cc: 66546@debbugs.gnu.org > Date: Wed, 01 Nov 2023 20:06:36 +0100 > > Eli Zaretskii 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.