bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#65609: 30.0.50; inhibit-eol-conversion breaks revert-buffer


From: Eli Zaretskii
Subject: bug#65609: 30.0.50; inhibit-eol-conversion breaks revert-buffer
Date: Wed, 30 Aug 2023 16:26:35 +0300

> From: Andrew Scott <andj.scott@gmail.com>
> 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))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]