emacs-pretest-bug
[Top][All Lists]
Advanced

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

Re: image.el doesn't associate image-mode with .JPG files


From: Jason Rumney
Subject: Re: image.el doesn't associate image-mode with .JPG files
Date: Wed, 13 Dec 2006 15:22:50 +0000
User-agent: Thunderbird 1.5.0.8 (Windows/20061025)

Mathias Dahl wrote:
Richard Stallman <address@hidden> writes:

    If .JPG/.JPEG is frequent, perhaps we should add it to
    `auto-mode-alist', then. Or do this:

     (push '("^\xFF\xD8\xFF\xE0\x00\x10JFIF" . image-mode)
           magic-mode-alist)

I am not sure which is better, but I agree we should do one or the
other.

I guess it is a matter of taste, but I would prefer if Emacs uses the
technique above instead of looking at the file name.

The only problem with this method is that the actual regexp you need is more complex, as there are different versions of JFIF, and Exif to check for (most digital cameras use the latter). image-jpeg-p has a much more relaxed check, basically "^\xFF\xD8\xFF[\xE0-\xEF]..+(JFIF|Exif)", but with the search for JFIF|Exif limited based on the first two bytes of the ..+ portion - which indicate the length of the file header. If you can't limit the search to the header, then the regexp may become too inefficient for use in magic-mode-alist.







reply via email to

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