[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: using libmagic in Emacs?
From: |
Juri Linkov |
Subject: |
Re: using libmagic in Emacs? |
Date: |
Tue, 25 Aug 2009 23:37:19 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (x86_64-pc-linux-gnu) |
> For instance, Java archive files have the .jar extension but build on
> the ZIP file format, so they can be visited in Emacs with the help of
> `archive-mode'. Enterprise Java archives with the .ear extension
> and Web application Java archives with the .war extension all are
> based on the ZIP file format as well as OpenDocument files with
> extensions .odt .ods .odb .odp .odg .odf, Firefox add-ons (.xpi),
> Keyhole Markup (.kmz), and many other file types that can be potentially
> opened in Emacs if were identified as archive files by libmagic.
>
> How hard would it be to change the code in Emacs to recognize these
> using the existing mechanism?
Not hard at all. For the ZIP file format it's just one line
in `magic-fallback-mode-alist'. Unlike `image-type-auto-detected-p'
from the preloaded image.el, we can't use `archive-find-type' in
`magic-fallback-mode-alist' because arc-mode.el is not preloaded.
So we have to copy archive magic numbers manually from arc-mode.el
to `magic-fallback-mode-alist'.
Index: lisp/files.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/files.el,v
retrieving revision 1.1069
diff -u -r1.1069 files.el
--- lisp/files.el 17 Aug 2009 23:40:22 -0000 1.1069
+++ lisp/files.el 25 Aug 2009 20:36:28 -0000
@@ -2399,6 +2399,7 @@
(defvar magic-fallback-mode-alist
`((image-type-auto-detected-p . image-mode)
+ ("\\(PK00\\)?[P]K\003\004" . archive-mode) ; zip
;; The < comes before the groups (but the first) to reduce backtracking.
;; TODO: UTF-16 <?xml may be preceded by a BOM 0xff 0xfe or 0xfe 0xff.
;; We use [ \t\r\n] instead of `\\s ' to make regex overflow less likely.
--
Juri Linkov
http://www.jurta.org/emacs/
- Re: using libmagic in Emacs?, (continued)
- Re: using libmagic in Emacs?, Juri Linkov, 2009/08/22
- Re: using libmagic in Emacs?, Richard Stallman, 2009/08/23
- Re: using libmagic in Emacs?, Juri Linkov, 2009/08/23
- Re: using libmagic in Emacs?, joakim, 2009/08/24
- Re: using libmagic in Emacs?, Richard Stallman, 2009/08/24
- Re: using libmagic in Emacs?, Miles Bader, 2009/08/24
- Re: using libmagic in Emacs?, joakim, 2009/08/25
- Re: using libmagic in Emacs?, James Cloos, 2009/08/25
- Re: using libmagic in Emacs?, Thien-Thi Nguyen, 2009/08/25
- Re: using libmagic in Emacs?, Stefan Monnier, 2009/08/25
- Re: using libmagic in Emacs?,
Juri Linkov <=
- Re: using libmagic in Emacs?, Juri Linkov, 2009/08/29
- Re: using libmagic in Emacs?, Eli Zaretskii, 2009/08/29
- Re: using libmagic in Emacs?, Juri Linkov, 2009/08/30
- Re: using libmagic in Emacs?, Eli Zaretskii, 2009/08/30
- Re: using libmagic in Emacs?, Juri Linkov, 2009/08/31
- Re: using libmagic in Emacs?, Eli Zaretskii, 2009/08/31
- Re: using libmagic in Emacs?, Richard Stallman, 2009/08/31
- Re: using libmagic in Emacs?, Richard Stallman, 2009/08/30
- Re: using libmagic in Emacs?, Chong Yidong, 2009/08/31
- Re: using libmagic in Emacs?, Juri Linkov, 2009/08/31