unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files
       [not found] ` <E1Zm01b-0007SW-BB@vcs.savannah.gnu.org>
@ 2015-10-13 18:28   ` Glenn Morris
  2015-10-13 18:38     ` Paul Eggert
  2015-10-14  7:56     ` Oleh Krehel
  0 siblings, 2 replies; 29+ messages in thread
From: Glenn Morris @ 2015-10-13 18:28 UTC (permalink / raw)
  To: emacs-devel; +Cc: Oleh Krehel

Oleh Krehel wrote:

> branch: master
> commit 6d6bf466477b004035a4314886e35214c6f8603b
>  (defvar dired-compress-file-suffixes
> -  '(("\\.gz\\'" "" "gunzip")
> +  '(("\\.tar\\.gz" "" "tar" "-zxvf")

Missing anchor.

> +    ("\\.gz\\'" "" "gunzip")
>      ("\\.tgz\\'" ".tar" "gunzip")
>      ("\\.Z\\'" "" "uncompress")

This makes ".tar.gz" and ".tgz" be treated differently.
Isn't that a little odd?
Also: .tar.bz2, .tar.xz, .tar, etc are not handled, only the gzip version.

> -  (REGEXP NEW-SUFFIX PROGRAM)
> +  (REGEXP NEW-SUFFIX PROGRAM &rest ARGS)

Using "&rest" will make it difficult to add any future elements beyond ARGS.


Also it seems like this merits a NEWS entry.



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

* Re: master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files
  2015-10-13 18:28   ` master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files Glenn Morris
@ 2015-10-13 18:38     ` Paul Eggert
  2015-10-14  7:58       ` Oleh Krehel
  2015-10-14  7:56     ` Oleh Krehel
  1 sibling, 1 reply; 29+ messages in thread
From: Paul Eggert @ 2015-10-13 18:38 UTC (permalink / raw)
  To: Glenn Morris, emacs-devel; +Cc: Oleh Krehel

On 10/13/2015 11:28 AM, Glenn Morris wrote:
>> -  '(("\\.gz\\'" "" "gunzip")
>> >+  '(("\\.tar\\.gz" "" "tar" "-zxvf")
> Missing anchor.
>
>> >+    ("\\.gz\\'" "" "gunzip")
>> >      ("\\.tgz\\'" ".tar" "gunzip")
>> >      ("\\.Z\\'" "" "uncompress")
> This makes ".tar.gz" and ".tgz" be treated differently.
> Isn't that a little odd?

Also, not every 'tar' has the -z option.  Emacs should use -z only after 
it's verified that the installed 'tar' supports -z.



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

* Re: master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files
  2015-10-13 18:28   ` master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files Glenn Morris
  2015-10-13 18:38     ` Paul Eggert
@ 2015-10-14  7:56     ` Oleh Krehel
  2015-10-14 16:16       ` Eli Zaretskii
  2015-10-15 16:48       ` Glenn Morris
  1 sibling, 2 replies; 29+ messages in thread
From: Oleh Krehel @ 2015-10-14  7:56 UTC (permalink / raw)
  To: Glenn Morris; +Cc: emacs-devel

Glenn Morris <rgm@gnu.org> writes:

> Oleh Krehel wrote:
>
>> branch: master
>> commit 6d6bf466477b004035a4314886e35214c6f8603b
>>  (defvar dired-compress-file-suffixes
>> -  '(("\\.gz\\'" "" "gunzip")
>> +  '(("\\.tar\\.gz" "" "tar" "-zxvf")
>
> Missing anchor.

Thanks, will fix.

>> +    ("\\.gz\\'" "" "gunzip")
>>      ("\\.tgz\\'" ".tar" "gunzip")
>>      ("\\.Z\\'" "" "uncompress")
>
> This makes ".tar.gz" and ".tgz" be treated differently.
> Isn't that a little odd?
> Also: .tar.bz2, .tar.xz, .tar, etc are not handled, only the gzip version.

This will be harder to fix, since I've only ever dealt with .tar.gz
archives (and .zip sometimes). Could someone provide the relative
extraction commands for .tar.bz2, .tar.xz, and .tar?

>> -  (REGEXP NEW-SUFFIX PROGRAM)
>> +  (REGEXP NEW-SUFFIX PROGRAM &rest ARGS)
>
> Using "&rest" will make it difficult to add any future elements beyond
> ARGS.

Would this be better?

    ("\\.tar\\.gz\\'" "" "tar" ("-zxvf"))

I think the customization for decompression could be completely
rewritten to this style:

    ("\\.tar\\.gz\\'" "tar -zxvf %i")

And for compression to this style:

    ("directory" "tar -czf %o %i")

This way, the user will be completely in charge of the
compression/decompression command, with no constraints imposed by the
customization (i.e. input/output/switches in specific order etc).

> Also it seems like this merits a NEWS entry.

OK, will add.



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

* Re: master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files
  2015-10-13 18:38     ` Paul Eggert
@ 2015-10-14  7:58       ` Oleh Krehel
  2015-10-14 15:17         ` Paul Eggert
  0 siblings, 1 reply; 29+ messages in thread
From: Oleh Krehel @ 2015-10-14  7:58 UTC (permalink / raw)
  To: Paul Eggert; +Cc: Glenn Morris, emacs-devel

Paul Eggert <eggert@cs.ucla.edu> writes:

> Also, not every 'tar' has the -z option.  Emacs should use -z only
> after it's verified that the installed 'tar' supports -z.

How can this be determined? In any case, I propose to let the user
fully customize the compression command.



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

* Re: master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files
  2015-10-14  7:58       ` Oleh Krehel
@ 2015-10-14 15:17         ` Paul Eggert
  0 siblings, 0 replies; 29+ messages in thread
From: Paul Eggert @ 2015-10-14 15:17 UTC (permalink / raw)
  To: Oleh Krehel; +Cc: emacs-devel

On 10/14/2015 12:58 AM, Oleh Krehel wrote:
>> Also, not every 'tar' has the -z option.  Emacs should use -z only
>> >after it's verified that the installed 'tar' supports -z.
> How can this be determined?

Pare the output of "tar --help".  For an example, see how 
progmodes/grep.el checks for the --color option of grep.



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

* Re: master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files
  2015-10-14  7:56     ` Oleh Krehel
@ 2015-10-14 16:16       ` Eli Zaretskii
  2015-10-14 18:51         ` Achim Gratz
  2015-10-15 16:48       ` Glenn Morris
  1 sibling, 1 reply; 29+ messages in thread
From: Eli Zaretskii @ 2015-10-14 16:16 UTC (permalink / raw)
  To: Oleh Krehel; +Cc: rgm, emacs-devel

> From: Oleh Krehel <ohwoeowho@gmail.com>
> Date: Wed, 14 Oct 2015 09:56:55 +0200
> Cc: emacs-devel@gnu.org
> 
> >> +    ("\\.gz\\'" "" "gunzip")
> >>      ("\\.tgz\\'" ".tar" "gunzip")
> >>      ("\\.Z\\'" "" "uncompress")
> >
> > This makes ".tar.gz" and ".tgz" be treated differently.
> > Isn't that a little odd?
> > Also: .tar.bz2, .tar.xz, .tar, etc are not handled, only the gzip version.
> 
> This will be harder to fix, since I've only ever dealt with .tar.gz
> archives (and .zip sometimes). Could someone provide the relative
> extraction commands for .tar.bz2, .tar.xz, and .tar?

For .tar.bz2, uncompress with bunzip2 to get .tar, for .tar.xz,
uncompress with unxz to get .tar.  Is that what you wanted?



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

* Re: master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files
  2015-10-14 16:16       ` Eli Zaretskii
@ 2015-10-14 18:51         ` Achim Gratz
  2015-10-14 19:02           ` Eli Zaretskii
  2015-10-15 13:07           ` Oleh Krehel
  0 siblings, 2 replies; 29+ messages in thread
From: Achim Gratz @ 2015-10-14 18:51 UTC (permalink / raw)
  To: emacs-devel

Eli Zaretskii writes:
>> From: Oleh Krehel
>> This will be harder to fix, since I've only ever dealt with .tar.gz
>> archives (and .zip sometimes). Could someone provide the relative
>> extraction commands for .tar.bz2, .tar.xz, and .tar?
>
> For .tar.bz2, uncompress with bunzip2 to get .tar, for .tar.xz,
> uncompress with unxz to get .tar.  Is that what you wanted?

This is what a reasonably recent GNU tar offers:

--8<---------------cut here---------------start------------->8---
 Compression options:

  -a, --auto-compress        use archive suffix to determine the compression
                             program
  -I, --use-compress-program=PROG
                             filter through PROG (must accept -d)
  -j, --bzip2                filter the archive through bzip2
  -J, --xz                   filter the archive through xz
      --lzip                 filter the archive through lzip
      --lzma                 filter the archive through lzma
      --lzop                 filter the archive through xz
      --no-auto-compress     do not use archive suffix to determine the
                             compression program
  -z, --gzip, --gunzip, --ungzip   filter the archive through gzip
  -Z, --compress, --uncompress   filter the archive through compress
--8<---------------cut here---------------end--------------->8---

As long as the suffix is recognized by tar, the selection of the
uncompress flavor is automatic even without "-a" and you need just "-a"
for the creation of archives (which is nice since I never remember if I
need -j or -J).  But as Paul said, different (and mostly older) tar
implementations often do not support those operations or in a different
way.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

SD adaptation for Waldorf microQ V2.22R2:
http://Synth.Stromeko.net/Downloads.html#WaldorfSDada




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

* Re: master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files
  2015-10-14 18:51         ` Achim Gratz
@ 2015-10-14 19:02           ` Eli Zaretskii
  2015-10-15 13:07           ` Oleh Krehel
  1 sibling, 0 replies; 29+ messages in thread
From: Eli Zaretskii @ 2015-10-14 19:02 UTC (permalink / raw)
  To: Achim Gratz; +Cc: emacs-devel

> From: Achim Gratz <Stromeko@nexgo.de>
> Date: Wed, 14 Oct 2015 20:51:19 +0200
> 
> > For .tar.bz2, uncompress with bunzip2 to get .tar, for .tar.xz,
> > uncompress with unxz to get .tar.  Is that what you wanted?
> 
> This is what a reasonably recent GNU tar offers:

GNU Tar needs the programs I mentioned anyway, so if GNU Tar can
handle those archives, an explicit pipe with those programs will also
work.

By contrast, detecting GNU Tar and then providing an alternative for
non-GNU Tar versions will IMO make the code much more complex, for no
good reason.

And, as long as we are talking about this, I'd suggest to add support
for libarchive's bsdtar, which can unpack all those formats (and many
more) without any external programs.  Adding that support boils down
to checking if bsdtar is available.



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

* Re: master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files
  2015-10-14 18:51         ` Achim Gratz
  2015-10-14 19:02           ` Eli Zaretskii
@ 2015-10-15 13:07           ` Oleh Krehel
  2015-10-15 15:55             ` Eli Zaretskii
  2015-10-15 19:46             ` Achim Gratz
  1 sibling, 2 replies; 29+ messages in thread
From: Oleh Krehel @ 2015-10-15 13:07 UTC (permalink / raw)
  To: Achim Gratz; +Cc: emacs-devel

Achim Gratz <Stromeko@nexgo.de> writes:

> This is what a reasonably recent GNU tar offers:
>
>  Compression options:
>
>   -a, --auto-compress        use archive suffix to determine the compression
>                              program

Thanks, Achim.

For creating archives I propose that we use:

    (defcustom dired-compress-command
      "tar -caf %i.tar.gz %i"
      "The default command for creating archives from directories.
    %i denotes the directory name.")

which would translate to:

    tar -caf foo.tar.gz foo/

And leave it up to the user to customize this command.  Additionally, if
the user presses "m Z", prompt her for the output file name.  That
way, it would be possible to compress to *.tar, *.tar.bz2 or *.tar.xz
sometimes, and also have the output file name different from the
auto-generated one.

For extracting archives, I think it's appropriate for foo.tar.gz to call:

    tar -xzf foo.tar.gz

if that is the setting in `dired-compress-file-suffixes'. If the user
has a weird tar, she should customize `dired-compress-file-suffixes',
instead of Emacs running a detection in each session.  This is no
different from typing a command into a shell: if the command errors, the
job of the shell is to output the error, instead of trying to complete
command with a different tool.

Finally, is it possible to compress a collection of marked files and
directories into a single archive? I think Emacs should provide that
option. Currently, "Z" will compress each file one-by-one. I've never
had a situation when I wanted to do that. Instead, I often want to
compress only a subset of the files in the current directory and name
the archive. If that command isn't present, I'd like to add it, and have
it bound by default to something, possibly still "Z".

    Oleh




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

* Re: master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files
  2015-10-15 13:07           ` Oleh Krehel
@ 2015-10-15 15:55             ` Eli Zaretskii
  2015-10-15 19:46             ` Achim Gratz
  1 sibling, 0 replies; 29+ messages in thread
From: Eli Zaretskii @ 2015-10-15 15:55 UTC (permalink / raw)
  To: Oleh Krehel; +Cc: Stromeko, emacs-devel

> From: Oleh Krehel <ohwoeowho@gmail.com>
> Date: Thu, 15 Oct 2015 15:07:08 +0200
> Cc: emacs-devel@gnu.org
> 
> Achim Gratz <Stromeko@nexgo.de> writes:
> 
> > This is what a reasonably recent GNU tar offers:
> >
> >  Compression options:
> >
> >   -a, --auto-compress        use archive suffix to determine the compression
> >                              program
> 
> Thanks, Achim.
> 
> For creating archives I propose that we use:
> 
>     (defcustom dired-compress-command
>       "tar -caf %i.tar.gz %i"
>       "The default command for creating archives from directories.
>     %i denotes the directory name.")
> 
> which would translate to:
> 
>     tar -caf foo.tar.gz foo/
> 
> And leave it up to the user to customize this command.

Isn't the -a option GNU Tar specific?  I don't think we ever
hard-coded GNU/Linux specific options, thus forcing all users of all
the other systems to customize Emacs.  In other cases (like "M-x
grep") we probe the command for support of non-portable options, and
only use them if supported.  Let's not deviate from that practice
here.

Thanks.



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

* Re: master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files
  2015-10-14  7:56     ` Oleh Krehel
  2015-10-14 16:16       ` Eli Zaretskii
@ 2015-10-15 16:48       ` Glenn Morris
  2015-10-15 17:06         ` Eli Zaretskii
  2015-10-16 12:11         ` Oleh Krehel
  1 sibling, 2 replies; 29+ messages in thread
From: Glenn Morris @ 2015-10-15 16:48 UTC (permalink / raw)
  To: Oleh Krehel; +Cc: emacs-devel


Personally I'd just go with:

  uncompress-prog | tar

and simply assume that "uncompress-prog" is present (like the command
does now, I guess). Then you don't have to worry about testing for tar
options. It may be less elegant/efficient, but that hardly seems to matter.

Also, sounds like you can add .zip support too! :)
http://debbugs.gnu.org/21637



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

* Re: master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files
  2015-10-15 16:48       ` Glenn Morris
@ 2015-10-15 17:06         ` Eli Zaretskii
  2015-10-16 10:44           ` Oleh Krehel
  2015-10-16 12:11         ` Oleh Krehel
  1 sibling, 1 reply; 29+ messages in thread
From: Eli Zaretskii @ 2015-10-15 17:06 UTC (permalink / raw)
  To: Glenn Morris; +Cc: ohwoeowho, emacs-devel

> From: Glenn Morris <rgm@gnu.org>
> Date: Thu, 15 Oct 2015 12:48:11 -0400
> Cc: emacs-devel@gnu.org
> 
> Personally I'd just go with:
> 
>   uncompress-prog | tar

(You mean "compress-prog", I think.  This is about compressing.)

I agree.

> and simply assume that "uncompress-prog" is present (like the command
> does now, I guess).

Yes, and it's not a separate assumption: Tar runs that program as well
to uncompress the tarball, so if that program is missing, "tar -caf"
won't work as well.



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

* Re: master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files
  2015-10-15 13:07           ` Oleh Krehel
  2015-10-15 15:55             ` Eli Zaretskii
@ 2015-10-15 19:46             ` Achim Gratz
  1 sibling, 0 replies; 29+ messages in thread
From: Achim Gratz @ 2015-10-15 19:46 UTC (permalink / raw)
  To: emacs-devel

Oleh Krehel writes:
> For creating archives I propose that we use:
>
>     (defcustom dired-compress-command
>       "tar -caf %i.tar.gz %i"
>       "The default command for creating archives from directories.
>     %i denotes the directory name.")

You can't assume to have GNU tar nor that it is sufficiently new nor
that the necessary support has been compiled in.  As necessary in other
places, you need to test the capabilities available and chose from those
that are.  You may well end up using a method that is more complicated
in order to have it work across a larger set of systems.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Wavetables for the Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#BlofeldUserWavetables




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

* Re: master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files
  2015-10-15 17:06         ` Eli Zaretskii
@ 2015-10-16 10:44           ` Oleh Krehel
  2015-10-16 13:23             ` Eli Zaretskii
  2015-10-16 16:26             ` Glenn Morris
  0 siblings, 2 replies; 29+ messages in thread
From: Oleh Krehel @ 2015-10-16 10:44 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Glenn Morris, emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Glenn Morris <rgm@gnu.org>
>> Date: Thu, 15 Oct 2015 12:48:11 -0400
>> Cc: emacs-devel@gnu.org
>> 
>> Personally I'd just go with:
>> 
>>   uncompress-prog | tar
>
> (You mean "compress-prog", I think.  This is about compressing.)
>
> I agree.
>
>> and simply assume that "uncompress-prog" is present (like the command
>> does now, I guess).
>
> Yes, and it's not a separate assumption: Tar runs that program as well
> to uncompress the tarball, so if that program is missing, "tar -caf"
> won't work as well.

OK, is this what you want for compression:

    tar -c example/ | gzip -c9 > example.tar.gz

And this for decompression:

    gzip -dc example.tar.gz | tar -x

I think it would be productive if everyone just wrote down the explicit
shell command they want with all the relevant switches.



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

* Re: master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files
  2015-10-15 16:48       ` Glenn Morris
  2015-10-15 17:06         ` Eli Zaretskii
@ 2015-10-16 12:11         ` Oleh Krehel
  1 sibling, 0 replies; 29+ messages in thread
From: Oleh Krehel @ 2015-10-16 12:11 UTC (permalink / raw)
  To: Glenn Morris; +Cc: emacs-devel

Glenn Morris <rgm@gnu.org> writes:

> Also, sounds like you can add .zip support too! :)
> http://debbugs.gnu.org/21637

Please check my last commit that also add .zip support.
If we can agree on the final state of `dired-compress-file-suffixes',
I'll also add a NEWS entry.



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

* Re: master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files
  2015-10-16 10:44           ` Oleh Krehel
@ 2015-10-16 13:23             ` Eli Zaretskii
  2015-10-16 13:47               ` Oleh Krehel
  2015-10-16 15:35               ` Paul Eggert
  2015-10-16 16:26             ` Glenn Morris
  1 sibling, 2 replies; 29+ messages in thread
From: Eli Zaretskii @ 2015-10-16 13:23 UTC (permalink / raw)
  To: Oleh Krehel; +Cc: rgm, emacs-devel

> From: Oleh Krehel <ohwoeowho@gmail.com>
> Cc: Glenn Morris <rgm@gnu.org>,  emacs-devel@gnu.org
> Date: Fri, 16 Oct 2015 12:44:59 +0200
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> >>   uncompress-prog | tar
> >
> > (You mean "compress-prog", I think.  This is about compressing.)
> >
> > I agree.
> >
> >> and simply assume that "uncompress-prog" is present (like the command
> >> does now, I guess).
> >
> > Yes, and it's not a separate assumption: Tar runs that program as well
> > to uncompress the tarball, so if that program is missing, "tar -caf"
> > won't work as well.
> 
> OK, is this what you want for compression:
> 
>     tar -c example/ | gzip -c9 > example.tar.gz

Yes.

> And this for decompression:
> 
>     gzip -dc example.tar.gz | tar -x

Yes (except that you could use gunzip.)

> I think it would be productive if everyone just wrote down the explicit
> shell command they want with all the relevant switches.

I don't understand: who are those "everyone" that you want to write
the commands?



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

* Re: master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files
  2015-10-16 13:23             ` Eli Zaretskii
@ 2015-10-16 13:47               ` Oleh Krehel
  2015-10-16 14:35                 ` Eli Zaretskii
  2015-10-16 15:35               ` Paul Eggert
  1 sibling, 1 reply; 29+ messages in thread
From: Oleh Krehel @ 2015-10-16 13:47 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> OK, is this what you want for compression:
>> 
>>     tar -c example/ | gzip -c9 > example.tar.gz
>
> Yes.

OK, I propose the following entry in `dired-compress-file-suffixes' to
be used when "Z" is pressed on a directory:

    (t ".tar.gz" "tar -c %i | gzip -c9 > %o")

>> And this for decompression:
>> 
>>     gzip -dc example.tar.gz | tar -x
>
> Yes (except that you could use gunzip.)

So:

    gunzip -dc example.tar.gz | tar -x

and the corresponding entry in `dired-compress-file-suffixes':

    ("\\.tar\\.gz\\'" "" "gunzip -dc %i | tar -xv")

Also, what is the difference between gzip and gunzip? Both seem to work
the same in this case.

>> I think it would be productive if everyone just wrote down the explicit
>> shell command they want with all the relevant switches.
>
> I don't understand: who are those "everyone" that you want to write
> the commands?

Well, Paul has a weird tar that doesn't understand "-z", so I wonder
what exact command he uses for *.tar.gz.



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

* Re: master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files
  2015-10-16 13:47               ` Oleh Krehel
@ 2015-10-16 14:35                 ` Eli Zaretskii
  2015-10-20  8:59                   ` Oleh Krehel
  0 siblings, 1 reply; 29+ messages in thread
From: Eli Zaretskii @ 2015-10-16 14:35 UTC (permalink / raw)
  To: Oleh Krehel; +Cc: emacs-devel

> From: Oleh Krehel <ohwoeowho@gmail.com>
> Cc: emacs-devel@gnu.org
> Date: Fri, 16 Oct 2015 15:47:03 +0200
> 
> OK, I propose the following entry in `dired-compress-file-suffixes' to
> be used when "Z" is pressed on a directory:
> 
>     (t ".tar.gz" "tar -c %i | gzip -c9 > %o")

If you intend to use redirection at the shell command-line level, the
file name that replaces %o will need on MS-Windows to be run through
some function that converts forward slashes to backslashes.

Otherwise, OK.

> >> And this for decompression:
> >> 
> >>     gzip -dc example.tar.gz | tar -x
> >
> > Yes (except that you could use gunzip.)
> 
> So:
> 
>     gunzip -dc example.tar.gz | tar -x
> 
> and the corresponding entry in `dired-compress-file-suffixes':
> 
>     ("\\.tar\\.gz\\'" "" "gunzip -dc %i | tar -xv")

You don't need the 'd' part with gunzip.

Also, don't you need to use "tar -xf -"?

> Also, what is the difference between gzip and gunzip?

The -d switch, see above.

> Well, Paul has a weird tar that doesn't understand "-z", so I wonder
> what exact command he uses for *.tar.gz.

The same as you show above.

And there's nothing weird with that: the original Unix Tar didn't
support compression, only GNU Tar added that.  You are "spoiled" by
GNU/Linux which uses GNU tools out of the box.  Other kinds of Unix
don't.



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

* Re: master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files
  2015-10-16 13:23             ` Eli Zaretskii
  2015-10-16 13:47               ` Oleh Krehel
@ 2015-10-16 15:35               ` Paul Eggert
  2015-10-16 16:11                 ` Eli Zaretskii
  1 sibling, 1 reply; 29+ messages in thread
From: Paul Eggert @ 2015-10-16 15:35 UTC (permalink / raw)
  To: Eli Zaretskii, Oleh Krehel; +Cc: rgm, emacs-devel

Eli Zaretskii wrote:
>> >     gzip -dc example.tar.gz | tar -x
> Yes (except that you could use gunzip.)

I suggest sticking with "gzip -d" rather than relying on "gunzip", as some 
installations install gzip without also installing gunzip, and this has bitten 
users of other GNU programs. See, for example:

https://lists.gnu.org/archive/html/bug-texinfo/2009-10/msg00002.html



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

* Re: master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files
  2015-10-16 15:35               ` Paul Eggert
@ 2015-10-16 16:11                 ` Eli Zaretskii
  0 siblings, 0 replies; 29+ messages in thread
From: Eli Zaretskii @ 2015-10-16 16:11 UTC (permalink / raw)
  To: Paul Eggert; +Cc: rgm, ohwoeowho, emacs-devel

> Cc: rgm@gnu.org, emacs-devel@gnu.org
> From: Paul Eggert <eggert@cs.ucla.edu>
> Date: Fri, 16 Oct 2015 08:35:13 -0700
> 
> Eli Zaretskii wrote:
> >> >     gzip -dc example.tar.gz | tar -x
> > Yes (except that you could use gunzip.)
> 
> I suggest sticking with "gzip -d" rather than relying on "gunzip", as some 
> installations install gzip without also installing gunzip, and this has bitten 
> users of other GNU programs.

Fine with me.  I've suggested gunzip only because AFAIK we already use
it in Dired.



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

* Re: master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files
  2015-10-16 10:44           ` Oleh Krehel
  2015-10-16 13:23             ` Eli Zaretskii
@ 2015-10-16 16:26             ` Glenn Morris
  1 sibling, 0 replies; 29+ messages in thread
From: Glenn Morris @ 2015-10-16 16:26 UTC (permalink / raw)
  To: Oleh Krehel; +Cc: Eli Zaretskii, emacs-devel

Oleh Krehel wrote:

> OK, is this what you want for compression:
>
>     tar -c example/ | gzip -c9 > example.tar.gz
>
> And this for decompression:
>
>     gzip -dc example.tar.gz | tar -x

Where the (un)compress prog could perhaps be looked up in the existing
dired-compress-file-suffixes. AFAIK, all such commands use "-c" for
compatibility with each other, so that probably doesn't need to be an
option. So the only new config entry needed would be the tar command.
Wrt creating the archive, either make the compression scheme a custom
option, or a separate step (which would probably require "make a
tarfile" to be a separate command).



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

* Re: master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files
  2015-10-16 14:35                 ` Eli Zaretskii
@ 2015-10-20  8:59                   ` Oleh Krehel
  2015-10-20 14:57                     ` Eli Zaretskii
  2015-10-20 22:51                     ` Juri Linkov
  0 siblings, 2 replies; 29+ messages in thread
From: Oleh Krehel @ 2015-10-20  8:59 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>>     (t ".tar.gz" "tar -c %i | gzip -c9 > %o")
>
> If you intend to use redirection at the shell command-line level, the
> file name that replaces %o will need on MS-Windows to be run through
> some function that converts forward slashes to backslashes.

Doesn't `file-name-nondirectory' already do that? I don't have
MS-Windows, so I can't check.

I just pushed an update that takes care of most of the comments in this
thread. Let me know if it's fine.

I also want to add a new command to dired that compresses all marked
files into a single named archive: the user gets prompted for a name
(through `completing-read'+`read-file-name-internal') and the shell
command is resolved from that name. I'd like for it to be bound by
default, like "Z". Maybe like this:

    (define-key map "c" 'dired-compress)

The proposed key isn't bound by default. Is that OK?



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

* Re: master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files
  2015-10-20  8:59                   ` Oleh Krehel
@ 2015-10-20 14:57                     ` Eli Zaretskii
  2015-10-21  7:57                       ` Oleh Krehel
  2015-10-21 15:04                       ` Oleh Krehel
  2015-10-20 22:51                     ` Juri Linkov
  1 sibling, 2 replies; 29+ messages in thread
From: Eli Zaretskii @ 2015-10-20 14:57 UTC (permalink / raw)
  To: Oleh Krehel; +Cc: emacs-devel

> From: Oleh Krehel <ohwoeowho@gmail.com>
> Cc: emacs-devel@gnu.org
> Date: Tue, 20 Oct 2015 10:59:38 +0200
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> >>     (t ".tar.gz" "tar -c %i | gzip -c9 > %o")
> >
> > If you intend to use redirection at the shell command-line level, the
> > file name that replaces %o will need on MS-Windows to be run through
> > some function that converts forward slashes to backslashes.
> 
> Doesn't `file-name-nondirectory' already do that?

Is that what %o stands for?  If so, I apologize for not looking
deeper: relative file names without any leading directories of course
cannot have any such problems.  (Does that mean that this command will
only support producing the tarball in the same directory which Dired
displays?)

> I also want to add a new command to dired that compresses all marked
> files into a single named archive: the user gets prompted for a name
> (through `completing-read'+`read-file-name-internal') and the shell
> command is resolved from that name. I'd like for it to be bound by
> default, like "Z". Maybe like this:
> 
>     (define-key map "c" 'dired-compress)
> 
> The proposed key isn't bound by default. Is that OK?

Sounds OK to me, but maybe wait for a while for others to speak up.

Thanks.



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

* Re: master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files
  2015-10-20  8:59                   ` Oleh Krehel
  2015-10-20 14:57                     ` Eli Zaretskii
@ 2015-10-20 22:51                     ` Juri Linkov
  2015-10-21  8:00                       ` Oleh Krehel
  1 sibling, 1 reply; 29+ messages in thread
From: Juri Linkov @ 2015-10-20 22:51 UTC (permalink / raw)
  To: Oleh Krehel; +Cc: Eli Zaretskii, emacs-devel

> I also want to add a new command to dired that compresses all marked
> files into a single named archive: the user gets prompted for a name
> (through `completing-read'+`read-file-name-internal') and the shell
> command is resolved from that name. I'd like for it to be bound by
> default, like "Z". Maybe like this:
>
>     (define-key map "c" 'dired-compress)
>
> The proposed key isn't bound by default. Is that OK?

Aren't upper-case Dired keys reserved for potentially dangerous commands
because upper-case keys are harder to press (require holding Shift-key).
I guess if your command will ask additional information from the minibuffer
then either lower-case "c" or "z" are fine because they won't run immediately.
"Z" would be good too if you could improve it in a backward-compatible way.



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

* Re: master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files
  2015-10-20 14:57                     ` Eli Zaretskii
@ 2015-10-21  7:57                       ` Oleh Krehel
  2015-10-21 15:04                       ` Oleh Krehel
  1 sibling, 0 replies; 29+ messages in thread
From: Oleh Krehel @ 2015-10-21  7:57 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> >>     (t ".tar.gz" "tar -c %i | gzip -c9 > %o")
>> >
>> > If you intend to use redirection at the shell command-line level, the
>> > file name that replaces %o will need on MS-Windows to be run through
>> > some function that converts forward slashes to backslashes.
>> 
>> Doesn't `file-name-nondirectory' already do that?
>
> Is that what %o stands for?  If so, I apologize for not looking
> deeper: relative file names without any leading directories of course
> cannot have any such problems.  (Does that mean that this command will
> only support producing the tarball in the same directory which Dired
> displays?)

Yes, only in the current directory, which makes sense for "Z", which
compresses all marked files to a map of their own names in their own
directory.

>> I also want to add a new command to dired that compresses all marked
>> files into a single named archive: the user gets prompted for a name
>> (through `completing-read'+`read-file-name-internal') and the shell
>> command is resolved from that name. I'd like for it to be bound by
>> default, like "Z". Maybe like this:
>> 
>>     (define-key map "c" 'dired-compress)
>> 
>> The proposed key isn't bound by default. Is that OK?
>
> Sounds OK to me, but maybe wait for a while for others to speak up.

The new `dired-compress' would be able to compress to any directory on
the file system.



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

* Re: master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files
  2015-10-20 22:51                     ` Juri Linkov
@ 2015-10-21  8:00                       ` Oleh Krehel
  0 siblings, 0 replies; 29+ messages in thread
From: Oleh Krehel @ 2015-10-21  8:00 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Eli Zaretskii, emacs-devel

Juri Linkov <juri@linkov.net> writes:

>> I also want to add a new command to dired that compresses all marked
>> files into a single named archive: the user gets prompted for a name
>> (through `completing-read'+`read-file-name-internal') and the shell
>> command is resolved from that name. I'd like for it to be bound by
>> default, like "Z". Maybe like this:
>>
>>     (define-key map "c" 'dired-compress)
>>
>> The proposed key isn't bound by default. Is that OK?
>
> Aren't upper-case Dired keys reserved for potentially dangerous commands
> because upper-case keys are harder to press (require holding Shift-key).
> I guess if your command will ask additional information from the minibuffer
> then either lower-case "c" or "z" are fine because they won't run immediately.
> "Z" would be good too if you could improve it in a backward-compatible way.

I don't think it's possible to extend "Z", unless it's with a prefix arg
or something, just because it already has a very different behavior for
a group of marked files.

Pressing something like "c" or "z" is much shorter than "C-u Z". And the
logic is different anyway.



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

* Re: master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files
  2015-10-20 14:57                     ` Eli Zaretskii
  2015-10-21  7:57                       ` Oleh Krehel
@ 2015-10-21 15:04                       ` Oleh Krehel
  2015-10-21 16:28                         ` Eli Zaretskii
  1 sibling, 1 reply; 29+ messages in thread
From: Oleh Krehel @ 2015-10-21 15:04 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>>     (define-key map "c" 'dired-compress)
>> 
>> The proposed key isn't bound by default. Is that OK?
>
> Sounds OK to me, but maybe wait for a while for others to speak up.

I've committed this new command, turns out `dired-compress' was already
taken:

    (define-key map "c" 'dired-do-compress-to)

Please check if I didn't end up doing something strange. A few points:

1. Is using `cl-find-if' OK in dired.el (I assume this should be fine).

2. There's some autoload regeneration rule that modifies dired.el when
dired-aux.el is modified. Should that autoload be committed together
with a change?

3. Other recipes can be added to `dired-compress-files-alist'. I just
added the two that I'm familiar with. It also needs to be checked if
"zip" typically supports --filesync.

4. I've added NEWS entries, but I forgot how the +++/---/ markers
work. Where is that info? I can document the changes in the manual once
we agree that the change is fine.



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

* Re: master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files
  2015-10-21 15:04                       ` Oleh Krehel
@ 2015-10-21 16:28                         ` Eli Zaretskii
  2015-10-22 10:59                           ` Oleh Krehel
  0 siblings, 1 reply; 29+ messages in thread
From: Eli Zaretskii @ 2015-10-21 16:28 UTC (permalink / raw)
  To: Oleh Krehel; +Cc: emacs-devel

> From: Oleh Krehel <ohwoeowho@gmail.com>
> Cc: emacs-devel@gnu.org
> Date: Wed, 21 Oct 2015 17:04:13 +0200
> 
> I've committed this new command, turns out `dired-compress' was already
> taken:
> 
>     (define-key map "c" 'dired-do-compress-to)
> 
> Please check if I didn't end up doing something strange.

Thanks, looks good to me, but the comment about non-GNU Tar has a
typo.

> 2. There's some autoload regeneration rule that modifies dired.el when
> dired-aux.el is modified. Should that autoload be committed together
> with a change?

It would be nice, although Glenn has set up an automatic job for that,
which runs once in a few days.

> 4. I've added NEWS entries, but I forgot how the +++/---/ markers
> work. Where is that info?

At the beginning of the NEWS file.



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

* Re: master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files
  2015-10-21 16:28                         ` Eli Zaretskii
@ 2015-10-22 10:59                           ` Oleh Krehel
  0 siblings, 0 replies; 29+ messages in thread
From: Oleh Krehel @ 2015-10-22 10:59 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

> Thanks, looks good to me, but the comment about non-GNU Tar has a
> typo.

Thanks, fixed.

>> 2. There's some autoload regeneration rule that modifies dired.el when
>> dired-aux.el is modified. Should that autoload be committed together
>> with a change?
>
> It would be nice, although Glenn has set up an automatic job for that,
> which runs once in a few days.

OK, I'll extend the commit after calling "make" from now on.

>> 4. I've added NEWS entries, but I forgot how the +++/---/ markers
>> work. Where is that info?
>
> At the beginning of the NEWS file.

Oops, didn't think to look there. I've added an index entry for
`dired-do-compress-to'.

I don't think `dired-do-compress' needs extra description (unless a
whole new node is make for dired/compression), it's intuitive that it
should work for directories.



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

end of thread, other threads:[~2015-10-22 10:59 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20151013135354.28594.43074@vcs.savannah.gnu.org>
     [not found] ` <E1Zm01b-0007SW-BB@vcs.savannah.gnu.org>
2015-10-13 18:28   ` master 6d6bf46 2/2: Make dired-do-compress work for *.tar.gz files Glenn Morris
2015-10-13 18:38     ` Paul Eggert
2015-10-14  7:58       ` Oleh Krehel
2015-10-14 15:17         ` Paul Eggert
2015-10-14  7:56     ` Oleh Krehel
2015-10-14 16:16       ` Eli Zaretskii
2015-10-14 18:51         ` Achim Gratz
2015-10-14 19:02           ` Eli Zaretskii
2015-10-15 13:07           ` Oleh Krehel
2015-10-15 15:55             ` Eli Zaretskii
2015-10-15 19:46             ` Achim Gratz
2015-10-15 16:48       ` Glenn Morris
2015-10-15 17:06         ` Eli Zaretskii
2015-10-16 10:44           ` Oleh Krehel
2015-10-16 13:23             ` Eli Zaretskii
2015-10-16 13:47               ` Oleh Krehel
2015-10-16 14:35                 ` Eli Zaretskii
2015-10-20  8:59                   ` Oleh Krehel
2015-10-20 14:57                     ` Eli Zaretskii
2015-10-21  7:57                       ` Oleh Krehel
2015-10-21 15:04                       ` Oleh Krehel
2015-10-21 16:28                         ` Eli Zaretskii
2015-10-22 10:59                           ` Oleh Krehel
2015-10-20 22:51                     ` Juri Linkov
2015-10-21  8:00                       ` Oleh Krehel
2015-10-16 15:35               ` Paul Eggert
2015-10-16 16:11                 ` Eli Zaretskii
2015-10-16 16:26             ` Glenn Morris
2015-10-16 12:11         ` Oleh Krehel

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