[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Image mode
From: |
Chong Yidong |
Subject: |
Re: Image mode |
Date: |
Mon, 05 Feb 2007 18:50:14 -0500 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.93 (gnu/linux) |
"Juanma Barranquero" <address@hidden> writes:
> On 2/5/07, Chong Yidong <address@hidden> wrote:
>
>> So: can anyone provide an alternative?
>
> I think the first step would be to summarize the existing
> alternatives.
OK, here is my stab at this.
(First, let us recall that when choosing a major mode,
magic-mode-alist has precedence over auto-mode-alist. The former
performs "autodetection", i.e. selecting the mode using the file
contents. The latter performs what we will refer to as "filename
detection", i.e. selecting the mode using the filename.)
Here are three schemes.
Scheme 1: Image autodetection, with two classes of image types
and user prompting
- Handle image autodetection in two steps.
- First, autodetect binary images (jpeg, png, gif, tiff). If
autodetected, check for a non-image mode in auto-mode-alist. If no
match is found, go ahead and open in image-mode. If a match for a
non-image mode is found, ask the user whether to open in
image-mode, or in the mode specified in auto-mode-alist.
- Second, autodetect text-based images (xpm, postscript, xbm).
If autodetected, check for a non-image mode in auto-mode-alist. If
no match is found, open in image-mode (this should not happen). If
a match is found, open in the non-image major mode and
image-minor-mode.
- If autodetection fails, perform filename detection.
- The (existing) option image-type-auto-detectable determines which
image files can be autodetected.
- Advantages: Seems to handle all known problematic cases.
Text-based images are opened in foo-mode with image-minor-mode;
images with funky file-names are opened in image-mode if no other
suitable mode is found, or the user is prompted if there is an
ambiguity.
- Disadvantages: The behavior is complicated. Also, prompting the
user may not be straightforward for other uses of
find-file-nonselect (are there any specific examples?). Also,
setting image-minor-mode is naughty: it violates the standard that
Emacs does not automatically turn on minor-modes on for the user.
Scheme 2: Image autodetection with deference to auto-mode-alist for
binary image files
- As above, except that is a binary image is autodetected, and a
match for a non-image mode is found, fall back on the non-image
mode instead of prompting the user.
- Advantages: Principle of least surprise. A Jpeg file saved as
foo.txt is handled as a text file; one saved as foo.JPG or foo.bar
is handled as an image (since Emacs sees no other choice).
Avoids possible difficulties with user prompting.
- Disadvantages: As above, setting image-minor-mode is naughty. If
foo.c really IS a jpeg file, it might (?) be more correct to
display it as a jpeg file; this doesn't do that.
Scheme 3: No image autodetection
- Images are not autodetected. Only auto-mode-alist is used.
- In particular, XPM and XBM images are opened in C mode (see above).
- The commonly-encountered .JPG extension should be recognized as an
jpeg file, either by making auto-mode-case-fold default to t, or
adding .JPG to auto-mode-alist.
- Advantages: The behavior is simple. As Stefan notes, few or no
other programs auto-detect images as images using their content,
and it may be safer to avoid surprising the user.
- Disadvantages: Richard apparently dislikes auto-mode-case-fold
(this may not be a theoretical disadvantage, but it is a practical
one). On the other hand, if we add .JPG to auto-mode-alist, we
might as well add .PNG, .GIF, etc---which is ugly (though it may be
the practical thing to do).
Personally, I think scheme 2 may be a good compromise.
- Re: Image mode, (continued)
- Re: Image mode, Chong Yidong, 2007/02/05
- Re: Image mode, Juanma Barranquero, 2007/02/05
- Re: Image mode, Chong Yidong, 2007/02/05
- Re: Image mode, Juanma Barranquero, 2007/02/05
- Re: Image mode, Chong Yidong, 2007/02/05
- Re: Image mode, Juanma Barranquero, 2007/02/05
- Re: Image mode,
Chong Yidong <=
- Re: Image mode, Juanma Barranquero, 2007/02/05
- Re: Image mode, David Kastrup, 2007/02/06
- Re: Image mode, Juanma Barranquero, 2007/02/06
- Re: Image mode, David Kastrup, 2007/02/06
- Re: Image mode, Juanma Barranquero, 2007/02/06
- Re: Image mode, David Kastrup, 2007/02/06
- Re: Image mode, Juanma Barranquero, 2007/02/06
- Re: Image mode, David Kastrup, 2007/02/06
- Re: Image mode, Juanma Barranquero, 2007/02/06
- Re: Image mode, David Kastrup, 2007/02/06