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

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

Re: Emacs opens only first 16384 bytes of file?!


From: Óscar Fuentes
Subject: Re: Emacs opens only first 16384 bytes of file?!
Date: Sun, 12 Feb 2023 05:55:41 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Christoph Groth <christoph@grothesque.org> writes:

> Hello,
>
> I just noticed something that made me doubt my own sanity:  With Emacs
> 27.1 (from Debian stable running Debian’s Linux kernel
> 6.0.0-0.deb11.6-amd64) the command
>
>   emacs -q -nw /proc/cpuinfo
>
> reproducibly opens cpuinfo only up to a portion of line 272, while the
> entire file is 560 lines long on that machine.  I checked on a different
> machine (with same Emacs), and I see the same behavior.
>
> C-u C-x = tells that the file is read up to position 16384 (= 2^14).
>
> Running M-x revert-buffer loads the whole file...
>
> Is/was this a known issue?  I could not find anything on the web.
>
> ----------------------------------------------------------------
>
> I’m willing to investigate this further, but it would seem very strange
> if Emacs indeed had a bug that prevented it from loading some files
> entirely.  Perhaps someone here knows the answer.

As of today (Emacs 30, current development branch) the same is true.

/proc/cpuinfo is not a regular file, in the sense that its content is
not stored in a device. AFAIK it is generated on-the-fly when it is
read.

You can do some simple observations:

$ ls -l /proc/cpuinfo 
-r--r--r-- 1 root root 0 feb  7 03:34 /proc/cpuinfo
$ du /proc/cpuinfo 
0       /proc/cpuinfo

Here those tools are saying that the file's size is 0.

I guess that Emacs detects that the file is special and reads its
contents following some heuristics. What surprises me is that M-x
revert-file actually reads all the content.

Of course, looking at the sources would be enlightening, but why do the
effort of actually clearing the matter when it is so cheap to throw
speculation? ;-)

(I looked at insert-file-contents, but bailed out after the fifth
screenful of code. A 1000+ lines function, no kidding.)



reply via email to

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