emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C file recoginzed as image file


From: Jason Rumney
Subject: Re: C file recoginzed as image file
Date: Sat, 06 Jan 2007 00:12:51 +0000
User-agent: Thunderbird 1.5.0.9 (Windows/20061207)

Chris Moore wrote:
On 1/5/07, Juanma Barranquero <address@hidden> wrote:

`magic-mode-alist' is more specific. The problem is that some of these
regexps are too permissive.

Even if magic-mode-alist was just right, and it only opened files as
images when they contain images, I don't want this mysterious .c file
I just received in the mail being opened as an image, because who
knows what it might do...

I think this can be fixed by using image-mode-maybe in magic-mode-alist, instead of image-mode. image-mode-maybe also needs to bind magic-mode-alist to nil to avoid infinite recursion.


Index: files.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/files.el,v
retrieving revision 1.876
diff -c -r1.876 files.el
*** files.el    4 Jan 2007 22:14:32 -0000       1.876
--- files.el    6 Jan 2007 00:09:43 -0000
***************
*** 2126,2132 ****
 associated with that interpreter in `interpreter-mode-alist'.")

 (defvar magic-mode-alist
!   `((image-type-auto-detected-p . image-mode)
;; 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\n] instead of `\\s ' to make regex overflow less likely.
--- 2126,2132 ----
 associated with that interpreter in `interpreter-mode-alist'.")

 (defvar magic-mode-alist
!   `((image-type-auto-detected-p . image-mode-maybe)
;; 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\n] instead of `\\s ' to make regex overflow less likely.
Index: image-mode.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/image-mode.el,v
retrieving revision 1.15
diff -c -r1.15 image-mode.el
*** image-mode.el       29 Aug 2006 13:02:53 -0000      1.15
--- image-mode.el       6 Jan 2007 00:09:10 -0000
***************
*** 111,117 ****
                        elt))
                    auto-mode-alist))))
     (if (assoc-default buffer-file-name mode-alist 'string-match)
!       (let ((auto-mode-alist mode-alist))
         (set-auto-mode)
         (image-minor-mode t))
       (image-mode))))
--- 111,118 ----
                        elt))
                    auto-mode-alist))))
     (if (assoc-default buffer-file-name mode-alist 'string-match)
!       (let ((auto-mode-alist mode-alist)
!             (magic-mode-alist nil))
         (set-auto-mode)
         (image-minor-mode t))
       (image-mode))))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]