Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get emacs Zip-Archive mode to work on Windows

Tags:

emacs

windows

zip

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

like image 719
Cheeso Avatar asked May 16 '09 14:05

Cheeso


3 Answers

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

like image 127
Charlie Martin Avatar answered Nov 13 '22 13:11

Charlie Martin


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 table-of-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/).

like image 24
luapyad Avatar answered Nov 13 '22 14:11

luapyad


you can use [chololatey]: https://chocolatey.org/ , the package management for windows , to install unzip.

choco install unzip
like image 28
dingyi342 Avatar answered Nov 13 '22 13:11

dingyi342