15

I want to work easier with archives in Emacs dired-mode. And I think that my needs are not only mine.

What I want? Two things in Dired:

  1. z to zip file or dir on cursor (or all marked files/dirs if marks are exists); the name of new archive should be changeable (but if one file/dir selected than name should be the same);
  2. Z to unarchive any type of archives (zip or gz or tar) at cursor; by default content should be placed in new directory with the same name.

How can one achieve that?

drobnbobn
  • 585
  • 4
  • 15
  • @Drew, Z in Dired replace (not added another) file with it's *.gz archive (not *.zip). – drobnbobn Mar 08 '16 at 01:51
  • Yes. Apparently (now) that is not what you want. But you have not specified what you want. As I said, the question is not very clear. I suppose that for someone who is familiar with dired-atool, or who takes the time to follow the link and study what it does, the question will be clearer, but you should clarify the question itself, IMHO. – Drew Mar 08 '16 at 03:34
  • @Drew, I rewrite my question. Is it clearly now? – drobnbobn Mar 08 '16 at 03:47
  • 1
    This feature is coming up in the next emacs release (25.1) [Relevant commit]. If you wish, you can try the 3rd pretest (25.0.92) from here. Copying @abo-abo. – Kaushal Modi Mar 08 '16 at 20:25
  • @Drew, sorry, it's my fault! Surely I mean "inside of Dired". – drobnbobn Mar 09 '16 at 00:37

1 Answers1

16

emacs 25.x

The emacs 25.1 release will have in-built support for handling different kinds of archives from within dired. Below is the relevant excerpt from the NEWS file (C-h C-n).

+++
*** The command `dired-do-compress' bound to `Z' now can compress
directories and decompress zip files.

+++
*** New command `dired-do-compress-to' bound to `c' can be used to
compress many marked files into a single named archive.  The
compression command is determined from the new
`dired-compress-files-alist' variable.

dired-do-compress | Z

Check out the dired-compress-file-suffixes variable to get a list of supported compressed file formats. The correct program will be used to uncompress a file (or files) when using the Z binding (dired-do-compress).

While the above will uncompress a wide range of formats, it will always compress using gzip.

dired-do-compress-to | c

Check out the dired-compress-files-alist variable to get a list of supported file formats that can be compressed to using the c binding (dired-do-compress-to).

As of emacs 25.1, it supports compressing using tar + (gzip/bzip2/xz) or zip.

Kaushal Modi
  • 25,651
  • 4
  • 80
  • 183