From: Paul Eggert Date: Fri, 18 Jul 2025 06:00:38 +0000 (-0700) Subject: Fix insert-file-contents optimization glitch X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9a3c35203fc2435e1a73fa0f5b8861d9ff1008de;p=emacs.git Fix insert-file-contents optimization glitch This improves on recent fixes to Bug#77315. * src/fileio.c (Finsert_file_contents): When optimizing do not seek to 0 if the initial file offset is positive, as that causes the optimized code to behave differently from the nonoptimized. (cherry picked from commit 5f4b71b0c4872b6bd9f8b4ced9f4715062db1bad) --- diff --git a/src/fileio.c b/src/fileio.c index 248a369341a..fc5d4c27cfb 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -4291,13 +4291,8 @@ by calling `format-decode', which see. */) else { /* Don't try looking inside a file for a coding system - specification if it is not a regular, seekable file. */ - bool look_inside = (regular && seekable - && !NILP (Vset_auto_coding_function)); - if (look_inside && 0 < initial_offset - && emacs_fd_lseek (fd, 0, SEEK_SET) < 0) - look_inside = seekable = false; - if (look_inside) + specification if it is not a regular file. */ + if (regular && !NILP (Vset_auto_coding_function)) { /* Find a coding system specified in the heading two lines or in the tailing several lines of the file.