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#65609: 30.0.50; inhibit-eol-conversion breaks revert-buffer Date: Wed, 30 Aug 2023 16:26:35 +0300 Message-ID: <837cpchd9w.fsf@gnu.org> References: 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="11160"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 65609@debbugs.gnu.org To: Andrew Scott , Po Lu , Gerd =?UTF-8?Q?M=C3=B6llmann?= , "Herbert J. Skuhra" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Aug 30 15:28:07 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 1qbLEs-0002ew-UD for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 30 Aug 2023 15:28:07 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qbLEj-000077-67; Wed, 30 Aug 2023 09:27:57 -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 1qbLEg-00006a-Sx for bug-gnu-emacs@gnu.org; Wed, 30 Aug 2023 09:27:55 -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 1qbLEg-0004Mm-L5 for bug-gnu-emacs@gnu.org; Wed, 30 Aug 2023 09:27:54 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qbLEn-0002Cu-W6 for bug-gnu-emacs@gnu.org; Wed, 30 Aug 2023 09:28: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: Wed, 30 Aug 2023 13:28:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65609 X-GNU-PR-Package: emacs Original-Received: via spool by 65609-submit@debbugs.gnu.org id=B65609.16934020358430 (code B ref 65609); Wed, 30 Aug 2023 13:28:01 +0000 Original-Received: (at 65609) by debbugs.gnu.org; 30 Aug 2023 13:27:15 +0000 Original-Received: from localhost ([127.0.0.1]:52422 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbLE3-0002Bs-2O for submit@debbugs.gnu.org; Wed, 30 Aug 2023 09:27:15 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34550) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbLDz-0002Be-Mn for 65609@debbugs.gnu.org; Wed, 30 Aug 2023 09:27:14 -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 1qbLDl-00049i-5W; Wed, 30 Aug 2023 09:26: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=77LjO670aYiaNn5ji0DIsKIk2j0sv6LB2qTcQHtG6JI=; b=f3mEjN1aysirByyOBaUT +MgY1TGUEIVMWrBdyPME2WLlmaZq3d5Sj6ibfaDCU2cdOAOl0odOB6+2va4muUJSw/E4BVtK726cx QjinAQ0OkIIDziTVU8e8XseiVoP2lvc2EJh7TlQf+pc7tZpTTPeQWs54HtmaS9p9IENV/nQeRCxnn 3krnYgpgrIW32oU417HMsCJ4sng1pRnVB7knda5mFQYHnoSG9DEhBwuk+JDbWYuuCJP4vhTZJccF2 4DnyLo4GpZPGEoYGMuGzsCyhlg5K93+6/8sZjDZ0YEzNwB6CRbgFRshVvcofECT4p2EidqLu9peV3 RLmS4AmGUrHwfg==; In-Reply-To: (message from Andrew Scott on Tue, 29 Aug 2023 16:45:39 +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:268707 Archived-At: > From: Andrew Scott > Date: Tue, 29 Aug 2023 16:45:39 +0100 > > It appears that inhibit-eol-conversion breaks insert-file-contents's > replace functionality when a change was made in the middle of the file > to be reverted as the file contents get duplicated in the buffer. The > issue can be reproduced on a fresh Emacs with a file named bug.el with > contents: > > ;; 1. Launch Emacs: nix run emacs-overlay#emacs-git -- bug.el -Q --load bug.el > ;; 2. Outside of Emacs, add text in below empty line: > ;; 3. In Emacs, revert-buffer > > (setq inhibit-eol-conversion t) > > The contents of the buffer after revert-buffer: > > ;; 1. Launch Emacs: nix run emacs-overlay#emacs-git -- bug.el -Q --load bug.el > ;; 2. Outside of Emacs, add text in below empty line: > ;; 3. In Emacs, revert-buffer > foo > (setq inhibit-eol-conversion t) > > (setq inhibit-eol-conversion t) Thanks for an easy test case. We are reading too much from the file on disk when reverting in this case. Po Lu, I think we need the patch below to fix this. Gerd, does this solve your problem as well, including the abort during bootstrap? Herbert, I think this could also be related to the problems you see, so please try the patch below. diff --git a/src/fileio.c b/src/fileio.c index 23e1a83..8919e08 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -4805,7 +4805,7 @@ DEFUN ("insert-file-contents", Finsert_file_contents, Sinsert_file_contents, /* 'try' is reserved in some compilers (Microsoft C). */ ptrdiff_t trytry = min (gap_size, READ_BUF_SIZE); - if (!NILP (end)) + if (seekable || !NILP (end)) trytry = min (trytry, total - inserted); if (!seekable && NILP (end))