unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#25458: 25.1; tar mode does not handle compressed archives without specific extensions
@ 2017-01-16 15:20 Francesco Potortì
  2022-05-13 14:12 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 13+ messages in thread
From: Francesco Potortì @ 2017-01-16 15:20 UTC (permalink / raw)
  To: 25458

While tar handles compressed archives without regard to their file name,
Emacs cannot handle a compressed tar archive unless its file name
suggests the compression type.  To reproduce:

$ tar -Jcf test.tar any.file.name	# create a compressed tar file
$ tar -tvf test.tar			# verify that tar can read it
$ cp test.tar test.tar.xz		# create a copy

If you find the files test.tar and test.tar.gz from Emacs, it will
recognise the contents of the second file, but not those of the first.

By looking at the comments on top of tar-mode.el, I get that it does not
rely on tar to get the archive listing, but reads the archive itself, so
correcting this problem does not appear straightforward to me...


In GNU Emacs 25.1.1 (x86_64-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2016-10-24, modified by Debian built on trouble
Windowing system distributor 'The X.Org Foundation', version 11.0.11900000
System Description:	Debian GNU/Linux testing (stretch)

Configured using:
 'configure --build x86_64-linux-gnu --prefix=/usr
 --sharedstatedir=/var/lib --libexecdir=/usr/lib
 --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --with-pop=yes
 --enable-locallisppath=/etc/emacs25:/etc/emacs:/usr/local/share/emacs/25.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/25.1/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --build x86_64-linux-gnu --prefix=/usr
 --sharedstatedir=/var/lib --libexecdir=/usr/lib
 --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --with-pop=yes
 --enable-locallisppath=/etc/emacs25:/etc/emacs:/usr/local/share/emacs/25.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/25.1/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --with-x=yes --with-x-toolkit=lucid
 --with-toolkit-scroll-bars --without-gconf --without-gsettings
 'CFLAGS=-g -O2
 -fdebug-prefix-map=/build/emacs25-25.1+1=. -fstack-protector-strong
 -Wformat -Werror=format-security -Wall' 'CPPFLAGS=-Wdate-time
 -D_FORTIFY_SOURCE=2' LDFLAGS=-Wl,-z,relro'

Configured features:
XAW3D XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS NOTIFY ACL
LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS LUCID X11

Important settings:
  value of $LC_COLLATE: it_IT.UTF-8
  value of $LC_CTYPE: it_IT.UTF-8
  value of $LC_NUMERIC: C
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: RMAIL

Minor modes in effect:
  global-visual-fill-column-mode: t
  diff-auto-refine-mode: t
  TeX-PDF-mode: t
  desktop-save-mode: t
  epa-global-mail-mode: t
  shell-dirtrack-mode: t
  openwith-mode: t
  xterm-mouse-mode: t
  display-time-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  column-number-mode: t
  line-number-mode: t

Recent messages:
Added to /home/pot/Mail/backup/SMAIL
Sending...done
No following nondeleted message
Expunging deleted messages...done
Showing message 899...
Saving file /home/pot/Mail/RMAIL...
Wrote /home/pot/Mail/RMAIL [2 times]
Beginning of buffer
scroll-signal-boundary-error: Beginning of buffer [2 times]
Mark set

Load-path shadows:
~/elisp/bhl hides /usr/share/emacs/site-lisp/bhl
/usr/share/emacs25/site-lisp/flim/md4 hides /usr/share/emacs/25.1/lisp/md4
/usr/share/emacs25/site-lisp/flim/hex-util hides /usr/share/emacs/25.1/lisp/hex-util
/usr/share/emacs/site-lisp/rst hides /usr/share/emacs/25.1/lisp/textmodes/rst
~/elisp/bibtex hides /usr/share/emacs/25.1/lisp/textmodes/bibtex
/usr/share/emacs25/site-lisp/flim/ntlm hides /usr/share/emacs/25.1/lisp/net/ntlm
/usr/share/emacs25/site-lisp/flim/hmac-md5 hides /usr/share/emacs/25.1/lisp/net/hmac-md5
/usr/share/emacs25/site-lisp/flim/sasl-ntlm hides /usr/share/emacs/25.1/lisp/net/sasl-ntlm
/usr/share/emacs25/site-lisp/flim/sasl-digest hides /usr/share/emacs/25.1/lisp/net/sasl-digest
/usr/share/emacs25/site-lisp/flim/sasl hides /usr/share/emacs/25.1/lisp/net/sasl
/usr/share/emacs25/site-lisp/flim/sasl-cram hides /usr/share/emacs/25.1/lisp/net/sasl-cram
/usr/share/emacs25/site-lisp/flim/hmac-def hides /usr/share/emacs/25.1/lisp/net/hmac-def
/usr/share/emacs25/site-lisp/auctex/tex-fold hides /usr/share/emacs/site-lisp/auctex/tex-fold
/usr/share/emacs25/site-lisp/auctex/context-en hides /usr/share/emacs/site-lisp/auctex/context-en
/usr/share/emacs25/site-lisp/auctex/tex-info hides /usr/share/emacs/site-lisp/auctex/tex-info
/usr/share/emacs25/site-lisp/auctex/plain-tex hides /usr/share/emacs/site-lisp/auctex/plain-tex
/usr/share/emacs25/site-lisp/auctex/tex-mik hides /usr/share/emacs/site-lisp/auctex/tex-mik
/usr/share/emacs25/site-lisp/auctex/texmathp hides /usr/share/emacs/site-lisp/auctex/texmathp
/usr/share/emacs25/site-lisp/auctex/context-nl hides /usr/share/emacs/site-lisp/auctex/context-nl
/usr/share/emacs25/site-lisp/auctex/toolbar-x hides /usr/share/emacs/site-lisp/auctex/toolbar-x
/usr/share/emacs25/site-lisp/auctex/tex hides /usr/share/emacs/site-lisp/auctex/tex
/usr/share/emacs25/site-lisp/auctex/tex-jp hides /usr/share/emacs/site-lisp/auctex/tex-jp
/usr/share/emacs25/site-lisp/auctex/bib-cite hides /usr/share/emacs/site-lisp/auctex/bib-cite
/usr/share/emacs25/site-lisp/auctex/multi-prompt hides /usr/share/emacs/site-lisp/auctex/multi-prompt
/usr/share/emacs25/site-lisp/auctex/font-latex hides /usr/share/emacs/site-lisp/auctex/font-latex
/usr/share/emacs25/site-lisp/auctex/prv-emacs hides /usr/share/emacs/site-lisp/auctex/prv-emacs
/usr/share/emacs25/site-lisp/auctex/tex-style hides /usr/share/emacs/site-lisp/auctex/tex-style
/usr/share/emacs25/site-lisp/auctex/context hides /usr/share/emacs/site-lisp/auctex/context
/usr/share/emacs25/site-lisp/auctex/preview hides /usr/share/emacs/site-lisp/auctex/preview
/usr/share/emacs25/site-lisp/auctex/tex-font hides /usr/share/emacs/site-lisp/auctex/tex-font
/usr/share/emacs25/site-lisp/auctex/tex-bar hides /usr/share/emacs/site-lisp/auctex/tex-bar
/usr/share/emacs25/site-lisp/auctex/latex hides /usr/share/emacs/site-lisp/auctex/latex
/usr/share/emacs25/site-lisp/auctex/tex-buf hides /usr/share/emacs/site-lisp/auctex/tex-buf
~/elisp/bhl hides /usr/share/emacs25/site-lisp/bhl
/usr/share/emacs/site-lisp/debian-startup hides /usr/share/emacs25/site-lisp/debian-startup

Features:
(autorevert filenotify find-dired loadhist novice wdired animate misc
ruler-mode cal-x debug two-column iso-transl apropos pcmpl-gnu
pcmpl-linux macros python tramp-sh tar-mode anything-config anything
woman mailcap undigest cal-move smerge-mode diff doc-view vc-cvs
pcmpl-unix json-mode rx cus-edit wid-edit cus-start cus-load rmailedit
tabify man vc-dir ewoc tramp-cache shadow emacsbug reporter debian-bug
mail-extr texmathp nxml-uchnm rng-xsd xsd-regexp rng-cmpct rng-nxml
rng-valid rng-loc rng-uri rng-parse nxml-parse rng-match rng-dt rng-util
rng-pttrn nxml-ns nxml-mode nxml-outln nxml-rap nxml-util nxml-glyph
nxml-enc xmltok tmm ido etags xref project ediff-merg ediff-wind
ediff-diff ediff-mult ediff-help ediff-init ediff-util ediff js json map
imenu ispell log-view pp visual-fill-column locate dired-aux eieio-opt
speedbar sb-image ezimage dframe find-func timezone rmailsort face-remap
url-handlers nero cl rect log-edit pcvs-util add-log grep dabbrev
diff-mode vc rmailkwd mailalias rmailout shr-color color time-stamp
misearch multi-isearch server parse-time unrmail qp url-util shr dom
subr-x browse-url jka-compr cc-mode cc-fonts cc-guess cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs bibtex info sh-script
executable sgml-mode vc-filewise vc-rcs image-mode view conf-mode
generic octave smie latexenc plain-tex vc-dispatcher vc-svn preview
prv-emacs tex-bar tex-buf toolbar-x noutline outline font-latex latex
easy-mmode edmacro kmacro tex-style tex dbus xml crm tex-mode compile
rmailmm message rfc822 mml mml-sec mm-decode mm-bodies mm-encode
mailabbrev gmm-utils mailheader mail-parse rfc2231 desktop frameset
term/xterm xterm pot skeleton rmailsum rmail warnings sendmail rfc2047
rfc2045 ietf-drums mime-compose epa-mail mail-utils epa derived epg
cal-china lunar solar cal-dst cal-bahai cal-islam cal-hebrew holidays
hol-loaddefs vc-hg appt diary-lib diary-loaddefs cal-menu calendar
cal-loaddefs tramp tramp-compat tramp-loaddefs trampver ucs-normalize
shell pcomplete comint ring format-spec bhl switch-to-shell openwith
hi-lock xt-mouse ffap thingatpt url-parse auth-source cl-seq eieio
eieio-core cl-macs gnus-util time-date mm-util help-fns mail-prsvr
password-cache url-vars scroll-in-place filladapt ansi-color advice time
quail dired-x dired generic-x disp-table finder-inf package epg-config
seq byte-opt gv bytecomp byte-compile cl-extra help-mode easymenu cconv
cl-loaddefs pcase cl-lib debian-el debian-el-loaddefs w3m-load
vm-autoload vm-autoloads vm-version vm-vars vm-init preview-latex
tex-site auto-loads mule-util tooltip eldoc electric uniquify ediff-hook
vc-hooks lisp-float-type mwheel x-win term/common-win x-dnd tool-bar dnd
fontset image regexp-opt fringe tabulated-list newcomment elisp-mode
lisp-mode prog-mode register page menu-bar rfn-eshadow timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame
cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai
tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian
slovak czech european ethiopic indian cyrillic chinese charscript
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote dbusbind inotify
dynamic-setting font-render-setting x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 1182249 215902)
 (symbols 48 60744 50)
 (miscs 40 7096 4577)
 (strings 32 175927 29634)
 (string-bytes 1 5230067)
 (vectors 16 87336)
 (vector-slots 8 2213773 80796)
 (floats 8 1408 1017)
 (intervals 56 165187 8141)
 (buffers 976 238))





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#25458: 25.1; tar mode does not handle compressed archives without specific extensions
  2017-01-16 15:20 bug#25458: 25.1; tar mode does not handle compressed archives without specific extensions Francesco Potortì
@ 2022-05-13 14:12 ` Lars Ingebrigtsen
  2022-05-13 14:18   ` Eli Zaretskii
  2022-05-13 14:36   ` Francesco Potortì
  0 siblings, 2 replies; 13+ messages in thread
From: Lars Ingebrigtsen @ 2022-05-13 14:12 UTC (permalink / raw)
  To: Francesco Potortì; +Cc: 25458

Francesco Potortì <pot@gnu.org> writes:

> By looking at the comments on top of tar-mode.el, I get that it does not
> rely on tar to get the archive listing, but reads the archive itself, so
> correcting this problem does not appear straightforward to me...

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

If Emacs had code to automatically recognise compressed data, I guess
tar-mode could decompress the buffer before it started working on it.
(Does Emacs have that?  I guess we could add stuff to
`magic-fallback-mode-alist' or something in that region...)

But I think the question is -- do we want to support this?  I'm not
quite sure -- it would be pretty unusual for a mode to do something like
this, and it's not clear what the semantics should be.  That is, if
we're saving the tar buffer afterwards, should it be compressed or not?
Either option would surprise somebody.

And finally -- is this a thing that actually exists in the wild?  I
don't think I've ever seen a compressed tar file that didn't have a name
that indicated how it was compressed.

So due to both the unclear semantics and that I doubt the utility, I'm
inclined to close this as a "wontfix".  Anybody got any opinions?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#25458: 25.1; tar mode does not handle compressed archives without specific extensions
  2022-05-13 14:12 ` Lars Ingebrigtsen
@ 2022-05-13 14:18   ` Eli Zaretskii
  2022-05-13 14:45     ` Francesco Potortì
  2022-05-13 15:53     ` Lars Ingebrigtsen
  2022-05-13 14:36   ` Francesco Potortì
  1 sibling, 2 replies; 13+ messages in thread
From: Eli Zaretskii @ 2022-05-13 14:18 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 25458, pot

> Cc: 25458@debbugs.gnu.org
> From: Lars Ingebrigtsen <larsi@gnus.org>
> Date: Fri, 13 May 2022 16:12:24 +0200
> 
> Francesco Potortì <pot@gnu.org> writes:
> 
> > By looking at the comments on top of tar-mode.el, I get that it does not
> > rely on tar to get the archive listing, but reads the archive itself, so
> > correcting this problem does not appear straightforward to me...
> 
> (I'm going through old bug reports that unfortunately weren't resolved
> at the time.)
> 
> If Emacs had code to automatically recognise compressed data, I guess
> tar-mode could decompress the buffer before it started working on it.
> (Does Emacs have that?  I guess we could add stuff to
> `magic-fallback-mode-alist' or something in that region...)

But decompressing means, for most compression types, running an
external program on the file.  Or does OP suggest that we link Emacs
against libbz2, liblz4, liblzma, etc. to have these decompression
methods available in core?





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#25458: 25.1; tar mode does not handle compressed archives without specific extensions
  2022-05-13 14:12 ` Lars Ingebrigtsen
  2022-05-13 14:18   ` Eli Zaretskii
@ 2022-05-13 14:36   ` Francesco Potortì
  2022-05-13 15:54     ` Lars Ingebrigtsen
  1 sibling, 1 reply; 13+ messages in thread
From: Francesco Potortì @ 2022-05-13 14:36 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 25458

I am not saying that it's worth the trouble, and anyway I would not have the time to help working on it, sorry.  However, here is some food for thought.

>> By looking at the comments on top of tar-mode.el, I get that it does not
>> rely on tar to get the archive listing, but reads the archive itself, so
>> correcting this problem does not appear straightforward to me...
>
>(I'm going through old bug reports that unfortunately weren't resolved
>at the time.)
>
>If Emacs had code to automatically recognise compressed data, I guess
>tar-mode could decompress the buffer before it started working on it.
>(Does Emacs have that?  I guess we could add stuff to
>`magic-fallback-mode-alist' or something in that region...)
>
>But I think the question is -- do we want to support this?  I'm not
>quite sure -- it would be pretty unusual for a mode to do something like
>this, and it's not clear what the semantics should be.  That is, if
>we're saving the tar buffer afterwards, should it be compressed or not?
>Either option would surprise somebody.

Not really.  If I read a compressed file, Emacs uncompresses it when loading it to a buffer, then you can edit it and save it.  Compression and decompression are transparent.  I use this feature quite often, and so I am led to expect it of compressed archives too.  If it was compressed to begin with, it should be saved compressed too.

>And finally -- is this a thing that actually exists in the wild?  I
>don't think I've ever seen a compressed tar file that didn't have a name
>that indicated how it was compressed.

Hm, maybe it's only me, but I routinely produce tar files without any compression suffix, as tar automatically does the right thing with compressed archives (it has done for many years now).  I think that adding compression suffixes to tar files is (should be?) a thing of the past.

>So due to both the unclear semantics and that I doubt the utility, I'm
>inclined to close this as a "wontfix".  Anybody got any opinions?

I definitely think that it would be useful, and the semantics is clear at least to me (I may miss things, obviously).  However, that needs someone implementing it who thinks the same...

-- fp





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#25458: 25.1; tar mode does not handle compressed archives without specific extensions
  2022-05-13 14:18   ` Eli Zaretskii
@ 2022-05-13 14:45     ` Francesco Potortì
  2022-05-13 15:53     ` Lars Ingebrigtsen
  1 sibling, 0 replies; 13+ messages in thread
From: Francesco Potortì @ 2022-05-13 14:45 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 25458, Lars Ingebrigtsen

>> Cc: 25458@debbugs.gnu.org
>> From: Lars Ingebrigtsen <larsi@gnus.org>
>> Date: Fri, 13 May 2022 16:12:24 +0200
>> 
>> Francesco Potortì <pot@gnu.org> writes:
>> 
>> > By looking at the comments on top of tar-mode.el, I get that it does not
>> > rely on tar to get the archive listing, but reads the archive itself, so
>> > correcting this problem does not appear straightforward to me...
>> 
>> (I'm going through old bug reports that unfortunately weren't resolved
>> at the time.)
>> 
>> If Emacs had code to automatically recognise compressed data, I guess
>> tar-mode could decompress the buffer before it started working on it.
>> (Does Emacs have that?  I guess we could add stuff to
>> `magic-fallback-mode-alist' or something in that region...)
>
>But decompressing means, for most compression types, running an
>external program on the file.  Or does OP suggest that we link Emacs
>against libbz2, liblz4, liblzma, etc. to have these decompression
>methods available in core?

If Emacs parses the tar file itself, without relying on tar, in principle it should read compressed tar files too.  It could do that by using external compression tools, or more efficiently by natively handling compression.

However, I think that in general this requires uncompressing the whole tar file in memory or on disk, which is against one of the main purposes stated in the inital comments of tar-mode.el.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#25458: 25.1; tar mode does not handle compressed archives without specific extensions
  2022-05-13 14:18   ` Eli Zaretskii
  2022-05-13 14:45     ` Francesco Potortì
@ 2022-05-13 15:53     ` Lars Ingebrigtsen
  2022-05-13 16:02       ` Eli Zaretskii
  1 sibling, 1 reply; 13+ messages in thread
From: Lars Ingebrigtsen @ 2022-05-13 15:53 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 25458, pot

Eli Zaretskii <eliz@gnu.org> writes:

> But decompressing means, for most compression types, running an
> external program on the file.  Or does OP suggest that we link Emacs
> against libbz2, liblz4, liblzma, etc. to have these decompression
> methods available in core?

No, it would work just like when you read a tar.gz file -- we use
external decompressors for that, too, even if we then parse the
resulting tar file ourselves. 

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#25458: 25.1; tar mode does not handle compressed archives without specific extensions
  2022-05-13 14:36   ` Francesco Potortì
@ 2022-05-13 15:54     ` Lars Ingebrigtsen
  2022-05-13 22:18       ` Francesco Potortì
  0 siblings, 1 reply; 13+ messages in thread
From: Lars Ingebrigtsen @ 2022-05-13 15:54 UTC (permalink / raw)
  To: Francesco Potortì; +Cc: 25458

Francesco Potortì <pot@gnu.org> writes:

>>But I think the question is -- do we want to support this?  I'm not
>>quite sure -- it would be pretty unusual for a mode to do something like
>>this, and it's not clear what the semantics should be.  That is, if
>>we're saving the tar buffer afterwards, should it be compressed or not?
>>Either option would surprise somebody.
>
> Not really.  If I read a compressed file, Emacs uncompresses it when
> loading it to a buffer, then you can edit it and save it.  Compression
> and decompression are transparent.  I use this feature quite often,
> and so I am led to expect it of compressed archives too.  If it was
> compressed to begin with, it should be saved compressed too.

But the file name is "foo.tar" -- there'd be no way to tell Emacs that
the user wants to save that uncompressed.

You can load bar.gz into a buffer, and write out bar, and Emacs won't
compress that.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#25458: 25.1; tar mode does not handle compressed archives without specific extensions
  2022-05-13 15:53     ` Lars Ingebrigtsen
@ 2022-05-13 16:02       ` Eli Zaretskii
  2022-05-13 22:25         ` Francesco Potortì
  0 siblings, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2022-05-13 16:02 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 25458, pot

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: pot@gnu.org,  25458@debbugs.gnu.org
> Date: Fri, 13 May 2022 17:53:15 +0200
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > But decompressing means, for most compression types, running an
> > external program on the file.  Or does OP suggest that we link Emacs
> > against libbz2, liblz4, liblzma, etc. to have these decompression
> > methods available in core?
> 
> No, it would work just like when you read a tar.gz file -- we use
> external decompressors for that, too, even if we then parse the
> resulting tar file ourselves. 

Then I guess I don't understand what is the problem we are asked to
fix here.  Francesco, can you explain?





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#25458: 25.1; tar mode does not handle compressed archives without specific extensions
  2022-05-13 15:54     ` Lars Ingebrigtsen
@ 2022-05-13 22:18       ` Francesco Potortì
  2022-05-14  1:13         ` Lars Ingebrigtsen
  0 siblings, 1 reply; 13+ messages in thread
From: Francesco Potortì @ 2022-05-13 22:18 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 25458

>>>But I think the question is -- do we want to support this?  I'm not
>>>quite sure -- it would be pretty unusual for a mode to do something like
>>>this, and it's not clear what the semantics should be.  That is, if
>>>we're saving the tar buffer afterwards, should it be compressed or not?
>>>Either option would surprise somebody.
>>
>> Not really.  If I read a compressed file, Emacs uncompresses it when
>> loading it to a buffer, then you can edit it and save it.  Compression
>> and decompression are transparent.  I use this feature quite often,
>> and so I am led to expect it of compressed archives too.  If it was
>> compressed to begin with, it should be saved compressed too.
>
>But the file name is "foo.tar" -- there'd be no way to tell Emacs that
>the user wants to save that uncompressed.

In fact, if the file was compressed, Emacs should save it compressed with the same method.

>You can load bar.gz into a buffer, and write out bar, and Emacs won't
>compress that.

- I load bar.gz
- Edit it
- C-x C-s saves it with the same name, compressed with the same method

Same with foo.tar.gz

It should be the same with foo.tar, if foo.tar was compressed

And no, there would be no way to tell Emacs to save foo.tar uncompressed.  I do not think that it would be important to be able to save it uncompressed.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#25458: 25.1; tar mode does not handle compressed archives without specific extensions
  2022-05-13 16:02       ` Eli Zaretskii
@ 2022-05-13 22:25         ` Francesco Potortì
  2022-05-14  6:15           ` Eli Zaretskii
  0 siblings, 1 reply; 13+ messages in thread
From: Francesco Potortì @ 2022-05-13 22:25 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 25458, Lars Ingebrigtsen

>> From: Lars Ingebrigtsen <larsi@gnus.org>
>> Cc: pot@gnu.org,  25458@debbugs.gnu.org
>> Date: Fri, 13 May 2022 17:53:15 +0200
>> 
>> Eli Zaretskii <eliz@gnu.org> writes:
>> 
>> > But decompressing means, for most compression types, running an
>> > external program on the file.  Or does OP suggest that we link Emacs
>> > against libbz2, liblz4, liblzma, etc. to have these decompression
>> > methods available in core?
>> 
>> No, it would work just like when you read a tar.gz file -- we use
>> external decompressors for that, too, even if we then parse the
>> resulting tar file ourselves. 
>
>Then I guess I don't understand what is the problem we are asked to
>fix here.  Francesco, can you explain?

If I read foo.tar into Emacs, where foo.tar was created with

$ tar -Jcf foo.tar any.file.name

then Emacs does not recognise it as a tar file.  Instead, it should look at it, understand that it is a compressed tar file, uncompress and parse it.  If asked to save it after modification, it should compress it before saving, using the same compression method that was used in the first place.

Compression would be transparent to Emacs if it relied on Tar for parsing the tar file, because Tar manages compressed files transparently.  But since Emacs parses the tar file itself, it should behave as Tar does, that is, uncompress the file if it was compressed in the first place, and recompress when saving it after editing.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#25458: 25.1; tar mode does not handle compressed archives without specific extensions
  2022-05-13 22:18       ` Francesco Potortì
@ 2022-05-14  1:13         ` Lars Ingebrigtsen
  2022-05-16 14:24           ` Francesco Potortì
  0 siblings, 1 reply; 13+ messages in thread
From: Lars Ingebrigtsen @ 2022-05-14  1:13 UTC (permalink / raw)
  To: Francesco Potortì; +Cc: 25458

Francesco Potortì <pot@gnu.org> writes:

> And no, there would be no way to tell Emacs to save foo.tar
> uncompressed.  I do not think that it would be important to be able to
> save it uncompressed.

I understand that that's your use case.  I'm saying that it would be
surprising to many, and that that's something that others might well
want to.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#25458: 25.1; tar mode does not handle compressed archives without specific extensions
  2022-05-13 22:25         ` Francesco Potortì
@ 2022-05-14  6:15           ` Eli Zaretskii
  0 siblings, 0 replies; 13+ messages in thread
From: Eli Zaretskii @ 2022-05-14  6:15 UTC (permalink / raw)
  To: Francesco Potortì; +Cc: 25458, larsi

> From: Francesco Potortì <pot@gnu.org>
> Date: Sat, 14 May 2022 00:25:36 +0200
> Cc: 25458@debbugs.gnu.org,
> 	Lars Ingebrigtsen <larsi@gnus.org>
> 
> >Then I guess I don't understand what is the problem we are asked to
> >fix here.  Francesco, can you explain?
> 
> If I read foo.tar into Emacs, where foo.tar was created with
> 
> $ tar -Jcf foo.tar any.file.name
> 
> then Emacs does not recognise it as a tar file.  Instead, it should look at it, understand that it is a compressed tar file, uncompress and parse it.  If asked to save it after modification, it should compress it before saving, using the same compression method that was used in the first place.

You could do that by using magic-mode-alist, I guess?  It's just a
matter of writing the FUNCTION to put into the association for the
magic signatures of the compression methods you want to support.

FWIW, I don't think Emacs should do this by default, because looking
at the file's contents before looking at its file-name extension will
slow down visiting files, and having a .tar file that is actually a
.tar.xz file is quite unusual in the wild.  So this sounds like your
personal preference, and therefore customizing magic-mode-alist for
you sounds like TRT to fulfill your personal needs.

> Compression would be transparent to Emacs if it relied on Tar for parsing the tar file, because Tar manages compressed files transparently.  But since Emacs parses the tar file itself, it should behave as Tar does, that is, uncompress the file if it was compressed in the first place, and recompress when saving it after editing.

I don't think it's a good idea for Emacs to require Tar for visiting
archives.  For starters, Tar is not always available, and when it is
available, it doesn't always support all the compression methods
people could use.  We could use bsdtar (from libarchive), which
supports every archive format and compression method under the sun,
but its availability is even less than that of Tar.

So I think what we have now hits a good balance between functionality
in the popular use cases and reliability.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#25458: 25.1; tar mode does not handle compressed archives without specific extensions
  2022-05-14  1:13         ` Lars Ingebrigtsen
@ 2022-05-16 14:24           ` Francesco Potortì
  0 siblings, 0 replies; 13+ messages in thread
From: Francesco Potortì @ 2022-05-16 14:24 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 25458

>Francesco Potortì <pot@gnu.org> writes:
>
>> And no, there would be no way to tell Emacs to save foo.tar
>> uncompressed.  I do not think that it would be important to be able to
>> save it uncompressed.
>
>I understand that that's your use case.  I'm saying that it would be
>surprising to many, and that that's something that others might well
>want to.

I'll try one last time to illustrate my point of view.

From Emacs:
1. I read foo.tar and I write it out as foo.tar (I don't care if it's compressed or not)
2. I read foo.tar.gz and write it out a foo.tar.gz
3. I read foo.tar.xx and write it out as foo.tar.yy, that is, with a different compression method
4. I read foo.tar.xx and write it out as foo.tar (I explicitly remove compression)
5. I read foo.tar and write it out as foo.tar.xx (I explicitly add compression)

In my opinion, 1 and 2 are by far the most common use cases.  My proposal is to make tar-mode.el to behave as tar does in case 1: it does not care about the name suffix, and it does the right thing whether the file is compressed or not, which has been true since 2008.

You are objecting that if I read foo.tar and it's compressed, I cannot write it out uncompressed using Emacs.  I think that this use case is definitely exotic.  Especially with respect with people wanting to just read tar files and writing them without worrying whether they are compressed or not.





^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-05-16 14:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-16 15:20 bug#25458: 25.1; tar mode does not handle compressed archives without specific extensions Francesco Potortì
2022-05-13 14:12 ` Lars Ingebrigtsen
2022-05-13 14:18   ` Eli Zaretskii
2022-05-13 14:45     ` Francesco Potortì
2022-05-13 15:53     ` Lars Ingebrigtsen
2022-05-13 16:02       ` Eli Zaretskii
2022-05-13 22:25         ` Francesco Potortì
2022-05-14  6:15           ` Eli Zaretskii
2022-05-13 14:36   ` Francesco Potortì
2022-05-13 15:54     ` Lars Ingebrigtsen
2022-05-13 22:18       ` Francesco Potortì
2022-05-14  1:13         ` Lars Ingebrigtsen
2022-05-16 14:24           ` Francesco Potortì

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).