In Emacs, when you open a compressed file like foo.txt.gz
, it will
transparently decompress it (using gzip
in the case above) and open
as a regular file. However, what will happen if the above file is not
compressed at all?
Here is my case. I'm using excellent rclone to
open remote S3 drives by mounting them in the local folder. From
there, Emacs and dired
works much better than any
TRAMP hack I tried.
However, an application that would ship logs to S3, would ship them with gzip extension attached (hence foo.txt.gz), but files would not be compressed. I'm not sure if this behavior is intentional or bug in the script, but this will cause Emacs to fail with this error:
Error while executing "gzip -c -q -d < foo.txt.gz"
gzip: stdin: not in gzip format
Unsurprisingly, vim
will fail as well, but less
will open it correctly
because it looks in the file header, not the extension.
Emacs has find-file-literally for cases like this - it will open the file without applying any conversion. Usually, the first choice and excellent tool for debugging malformed content.
But, other modes like dired
or
VLF will not work, because they
are using find-file
for opening files, and this function will try to
apply all conversion magic usually we get when Emacs opens a file.
What worked in my case is this: I disabled
auto-compression-mode,
which is enabled by default, calling M-x auto-compression-mode
. And
suddenly dired and VLF, start opening those files without problems.
To remind you not to forget to enable auto-compression-mode again or
reading links from Emacs documentation (e.g. M-x describe-function
),
maybe even other stuff, will silently stop working ;)