tags:

views:

519

answers:

2

Zip-Archive mode works on systems with zip/unzip. How do you get it to work on Wnidows?

+3  A: 

EMACS uses an external program to do the compression/uncompression. All it needs is to know the right program to use.


Some extended discussion:

As I say, i've got no Windows box, but the LISP code is in arc-mode.el at about line 230:

(defcustom archive-zip-extract
  (if (and (not (executable-find "unzip"))
           (executable-find "pkunzip"))
      '("pkunzip" "-e" "-o-")
    '("unzip" "-qq" "-c"))
  "*Program and its options to run in order to extract a zip file member.
Extraction should happen to standard output.  Archive and member name will
be added."
  :type '(list (string :tag "Program")
     (repeat :tag "Options"
      :inline t
      (string :format "%v")))
  :group 'archive-zip)

Observe the function executable-find. It searches in your EMACS exec-path, which includes some EMACS executable directories that aren't in your normal PATH variable. In my case, it's:

("/usr/bin" 
 "/bin" 
 "/usr/sbin" 
 "/sbin" 
 "/Applications/Emacs.app/Contents/MacOS/libexec" 
 "/Applications/Emacs.app/Contents/MacOS/bin" 
 "~/bin" 
 "/usr/local/bin" 
 "/usr/X11R6/bin")

which includes the two directories inside the EMACS package. Your Windows installation will include equivalent directories somewhere down in the guts of the EMACS setup. That's where to look for the executables if they're not in your regular path.

You can download pkunzip from this site, install it, and add the path to the installation with (add-to-list 'exec-path "c:/path/to/pkunzip")

Charlie Martin
Hmm good observation but not true. On my Emacs 22 on Windows XP, zip browsing works natively even after I commented out the lines that added my cygwin bin to PATH. Quick check with command-shell also shows no zip/unzip executable lying in my PATH somewhere.
polyglot
I checked my exec-path, and there's no unzip in it (even though archive-zip-extract is set to unzip). I'm unclear how it's working...
Trey Jackson
Try a Ctrl-H V archive-zip-extract and see what the result is.
Charlie Martin
That's "describe variable" by the way.
Charlie Martin
+1  A: 

How emacs handles compressed files can be a little confusing, but here is an attempt to summarise the situation. There are two main compression packages: arc-mode (e.g. zip-archive mode) and jka-compr mode (auto-compression-mode).

  1. arc-mode: will display the contents (i.e. simple list of filenames contained within the archive) of multi-file archives (arc, lzh, zip, zoo) without requiring the relevant third-party tool to exist on your system. If you actually want to do any viewing/editing of the actual files contained within the archive using arc-mode you will definitely need the third-party tool to be installed on your system and in the appropriate location. E.g. for zip files it defaults to zip/unzip in the exec-path (which is the operating systems PATH environment). This can be customised using archive-zip-extract and archive-zip-expunge.
  2. jka-compr (auto-compression-mode): will automatically compress/uncompress single file archives (gz, Z, bz2, tbz, etc) and requires the relevant third-party tool to exist on your system.

So to get zip-archive mode fully working on Windows you will just need to find a windows version of command-line zip/unzip and put them into a directory that is in your PATH (e.g. see unzip package at http://gnuwin32.sourceforge.net/).

luapyad
wait, are you saying arc-mode does, or does not, require the third party tools? I'm not clear? My desired usage pattern is a dired, then and key (f) on a zip file to open it.
Cheeso
arc-mode needs the third-party tools to do anything useful (except that it can display the filenames contained within a zipfile without them). So you just need to put a third-party zip/unzip in your path to get your usage pattern.
luapyad