tags:

views:

124

answers:

2

I'd like to be able to open files with extensions other that .zip that have zip contents using Emacs' built-in zip file support. Is this possible? If so, how?

+7  A: 

Open the file, then type

M-: (archive-mode)

If you're doing this a lot, then you might want to create a command to do it (because archive-mode isn't a command. Comments in the function say:

;; This is not interactive because you shouldn't be turning this
;; mode on and off.  You can corrupt things that way.

But you could easily advise it to make it interactive:

(defadvice archive-mode (before archive-mode-interactive activate)
  "Make this interactive"
  (interactive))

At which point you can now do M-x archive-mode.

Trey Jackson
Thanks. That works perfectly.
Chris R
+7  A: 

If you want a more permanent solution, I do something like this in my .emacs:

;; Use archive mode to open Python eggs
(add-to-list 'auto-mode-alist '("\\.egg\\'" . archive-mode))
(add-to-list 'auto-mode-alist '("\\.odp\\'" . archive-mode))
(add-to-list 'auto-mode-alist '("\\.otp\\'" . archive-mode))
;; also for .xo files (zip)
(add-to-list 'auto-mode-alist '("\\.xo\\'" . archive-mode))
matt harrison
True that, I didn't read the question closely enough (I missed the whole "other extensions" line.
Trey Jackson