* bug#13006: recognizing compressed files with arbitrary names
@ 2012-11-27 1:31 Karl Berry
2012-11-27 8:50 ` Andreas Schwab
0 siblings, 1 reply; 5+ messages in thread
From: Karl Berry @ 2012-11-27 1:31 UTC (permalink / raw
To: 13006
As the documentation says
(http://www.gnu.org/software/emacs/manual/html_node/emacs/Compressed-Files.html)
"Emacs recognizes compressed files by their file names."
But compressed files don't always have the expected names. For
instance, using the autobackup feature of Emacs or many other programs
will result in names ending in, say, .~1~ ... Example for concreteness:
$ echo foo | gzip >/tmp/foo.gz.~1~
$ emacs --no-site-file --no-init /tmp/foo.gz.~1~
And observe binary junk instead of text. (This is with 24.2.)
Another implication is problems using M-x grep on such files. After
changing the program to zgrep from grep, matches in the *grep* buffer
are displayed as usual, but then when one visits the file in Emacs,
it's junk.
It would be nice to at least have an easy way to manually tell Emacs
"this is a compressed file, despite its weird name". If there's a way
to do that now, I'd like to know (and it should presumably be in the
manual). I looked at jka-compr.el but could not find it.
Of course, a more robust solution would be to use magic numbers instead
of filenames to recognize file types. I see there was a long thread
about that several years ago, starting at
http://lists.gnu.org/archive/html/emacs-devel/2009-08/msg01023.html. I
know it's been discussed at other times, too, but I can't see any way to
accomplish it (short of using crypt++, which doesn't work well with
Emacs 23 or later, which is why I stopped using it ... anyway).
Thanks,
karl
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#13006: recognizing compressed files with arbitrary names
2012-11-27 1:31 bug#13006: recognizing compressed files with arbitrary names Karl Berry
@ 2012-11-27 8:50 ` Andreas Schwab
2012-11-27 18:41 ` Glenn Morris
0 siblings, 1 reply; 5+ messages in thread
From: Andreas Schwab @ 2012-11-27 8:50 UTC (permalink / raw
To: Karl Berry; +Cc: 13006
karl@freefriends.org (Karl Berry) writes:
> $ echo foo | gzip >/tmp/foo.gz.~1~
> $ emacs --no-site-file --no-init /tmp/foo.gz.~1~
>
> And observe binary junk instead of text. (This is with 24.2.)
This is a regression from Emacs 23. It should disregard the backup
suffix when matching the extension.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#13006: recognizing compressed files with arbitrary names
2012-11-27 8:50 ` Andreas Schwab
@ 2012-11-27 18:41 ` Glenn Morris
2012-11-27 23:04 ` Karl Berry
2012-11-28 8:39 ` Glenn Morris
0 siblings, 2 replies; 5+ messages in thread
From: Glenn Morris @ 2012-11-27 18:41 UTC (permalink / raw
To: Andreas Schwab; +Cc: 13006, Karl Berry
Andreas Schwab wrote:
> This is a regression from Emacs 23. It should disregard the backup
> suffix when matching the extension.
Presumably the 2010-12-08 change to jka-compr-compression-info-list.
(There is a comment above jka-compr-compression-info-list which was
ignored and no longer applies. Also the :version was not bumped.)
Anyway, this seems to fix the immediate problem:
*** lisp/jka-cmpr-hook.el 2012-01-29 17:41:43 +0000
--- lisp/jka-cmpr-hook.el 2012-11-27 18:35:37 +0000
***************
*** 109,114 ****
--- 109,115 ----
"Return information about the compression scheme of FILENAME.
The determination as to which compression scheme, if any, to use is
based on the filename itself and `jka-compr-compression-info-list'."
+ (setq filename (file-name-sans-versions filename))
(catch 'compression-info
(let ((case-fold-search nil))
(dolist (x jka-compr-compression-info-list)
There's a separate question of handling arbitrarily named compressed
files via magic-fallback-mode-alist or somesuch.
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#13006: recognizing compressed files with arbitrary names
2012-11-27 18:41 ` Glenn Morris
@ 2012-11-27 23:04 ` Karl Berry
2012-11-28 8:39 ` Glenn Morris
1 sibling, 0 replies; 5+ messages in thread
From: Karl Berry @ 2012-11-27 23:04 UTC (permalink / raw
To: rgm; +Cc: 13006, schwab
+ (setq filename (file-name-sans-versions filename))
Thanks.
There's a separate question of handling arbitrarily named compressed
files via magic-fallback-mode-alist or somesuch.
Right. The backup versions was just an example of problematic names.
Though it's certainly good to have that fixed.
There's also the (potentially related) question of making it possible
for users to tell Emacs "this is a compressed file". Regardless of the
method(s) used to detect compression, this seems like it would be
useful. I have plenty of times been forced to decompress files outside
of Emacs and then visit the plain file. Clearly it's not the end of the
world to do that, but ...
If you want me to send separate reports for either or both of those
things, let me know.
Thanks,
k
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#13006: recognizing compressed files with arbitrary names
2012-11-27 18:41 ` Glenn Morris
2012-11-27 23:04 ` Karl Berry
@ 2012-11-28 8:39 ` Glenn Morris
1 sibling, 0 replies; 5+ messages in thread
From: Glenn Morris @ 2012-11-28 8:39 UTC (permalink / raw
To: 13006
Glenn Morris wrote:
> + (setq filename (file-name-sans-versions filename))
Applied for 24.2.91.
Leaving this open as a wishlist for:
a) detecting compressed files by magic bytes
b) explicit command to open a file using a given compression
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-11-28 8:39 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-27 1:31 bug#13006: recognizing compressed files with arbitrary names Karl Berry
2012-11-27 8:50 ` Andreas Schwab
2012-11-27 18:41 ` Glenn Morris
2012-11-27 23:04 ` Karl Berry
2012-11-28 8:39 ` Glenn Morris
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).