How to open a file with extension without zip as a zip file in emacs?

I would like to be able to open files with extensions other than that .zip that have zip content using the built-in support for Emacs ZIP archives. Is it possible? If so, how?

+3
source share
2 answers

Open the file, then enter

M-: (archive-mode)

If you do this a lot, then you may need to create a command for this (because archive mode is not a command. Comments in the say function:

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

But you can easily advise him to make it interactive:

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

Now you can do it M-x archive-mode.

+7
source

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

Source: https://habr.com/ru/post/1717937/


All Articles