unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Chong Yidong <cyd@stupidchicken.com>
To: "Juanma Barranquero" <lekktu@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: Image mode
Date: Mon, 05 Feb 2007 18:50:14 -0500	[thread overview]
Message-ID: <87iregmafd.fsf@stupidchicken.com> (raw)
In-Reply-To: <f7ccd24b0702051425y6fae03cdhc84b111a95973c1e@mail.gmail.com> (Juanma Barranquero's message of "Mon\, 5 Feb 2007 23\:25\:21 +0100")

"Juanma Barranquero" <lekktu@gmail.com> writes:

> On 2/5/07, Chong Yidong <cyd@stupidchicken.com> 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.

  reply	other threads:[~2007-02-05 23:50 UTC|newest]

Thread overview: 164+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-04 22:52 Image mode Juri Linkov
2007-02-04 23:40 ` Juanma Barranquero
2007-02-05  1:25   ` Chong Yidong
2007-02-05  9:03     ` Juanma Barranquero
2007-02-05  9:16       ` Juanma Barranquero
2007-02-05  9:28         ` David Kastrup
2007-02-05  9:37           ` David Kastrup
2007-02-05 11:12           ` Juanma Barranquero
2007-02-06  0:16       ` Richard Stallman
2007-02-06  0:25         ` Juanma Barranquero
2007-02-06  1:37         ` Drew Adams
2007-02-06  7:18           ` David Kastrup
2007-02-06 11:09           ` Slawomir Nowaczyk
2007-02-06  0:15     ` Richard Stallman
2007-02-06  0:29       ` Lennart Borgman (gmail)
2007-02-06  4:56         ` Chong Yidong
2007-02-06 23:15           ` Richard Stallman
2007-02-06 23:41             ` Chong Yidong
2007-02-06 23:55               ` Slawomir Nowaczyk
2007-02-05  7:13   ` David Kastrup
2007-02-05  9:06     ` Juanma Barranquero
2007-02-07 19:21   ` Chong Yidong
2007-02-07 19:43     ` Stuart D. Herring
2007-02-07 21:08       ` Chong Yidong
2007-02-07 21:21         ` Stefan Monnier
2007-02-07 21:35         ` Stuart D. Herring
2007-02-07 23:07           ` Stefan Monnier
2007-02-08  9:33       ` Jason Rumney
2007-02-08 16:38         ` Stefan Monnier
2007-02-08 16:55           ` Stuart D. Herring
2007-02-08 18:36             ` Chong Yidong
2007-02-07 22:55     ` Kim F. Storm
2007-02-07 23:27     ` Juri Linkov
2007-02-08  9:30     ` Jason Rumney
2007-02-08 15:23       ` Chong Yidong
2007-02-05  1:40 ` Chong Yidong
2007-02-05  4:21   ` Miles Bader
2007-02-05 10:58     ` Kim F. Storm
2007-02-05 11:02       ` Lennart Borgman (gmail)
2007-02-05 11:16         ` Juanma Barranquero
2007-02-05 11:26           ` David Kastrup
2007-02-05 11:39             ` Juanma Barranquero
2007-02-05 11:48               ` David Kastrup
2007-02-05 12:00                 ` Juanma Barranquero
2007-02-05 12:08                   ` David Kastrup
2007-02-05 12:16                     ` Juanma Barranquero
2007-02-05 19:00                   ` Stefan Monnier
2007-02-06  0:16             ` Richard Stallman
2007-02-06  0:32               ` Lennart Borgman (gmail)
2007-02-06 23:14                 ` Richard Stallman
2007-02-06  7:16               ` David Kastrup
2007-02-05 12:46           ` Lennart Borgman (gmail)
2007-02-05 12:57             ` Juanma Barranquero
2007-02-05 12:58               ` David Kastrup
2007-02-05 14:47               ` Mathias Dahl
2007-02-05 14:54                 ` Juanma Barranquero
2007-02-05 17:08                   ` Chong Yidong
2007-02-05 18:35                     ` Mathias Dahl
2007-02-05 18:35                     ` Jason Rumney
2007-02-05 19:06                       ` Chong Yidong
2007-02-05 19:14                         ` Juanma Barranquero
2007-02-05 19:26                           ` Juanma Barranquero
2007-02-05 19:28                           ` Chong Yidong
2007-02-05 19:51                             ` Juanma Barranquero
2007-02-05 20:12                               ` Stefan Monnier
2007-02-05 20:14                                 ` Juanma Barranquero
2007-02-05 20:13                               ` Chong Yidong
2007-02-05 20:21                                 ` Juanma Barranquero
2007-02-05 20:33                                   ` Chong Yidong
2007-02-05 21:25                                     ` Juanma Barranquero
2007-02-05 21:30                                       ` Chong Yidong
2007-02-05 22:25                                         ` Juanma Barranquero
2007-02-05 23:50                                           ` Chong Yidong [this message]
2007-02-06  0:17                                             ` Juanma Barranquero
2007-02-06  7:06                                               ` David Kastrup
2007-02-06  8:30                                                 ` Juanma Barranquero
2007-02-06  8:42                                                   ` David Kastrup
2007-02-06  9:06                                                     ` Juanma Barranquero
2007-02-06  9:27                                                       ` David Kastrup
2007-02-06  9:43                                                         ` Juanma Barranquero
2007-02-06 10:29                                                           ` David Kastrup
2007-02-06 10:57                                                             ` Juanma Barranquero
2007-02-06 11:10                                                               ` David Kastrup
2007-02-06 11:42                                                                 ` Juanma Barranquero
2007-02-06 11:48                                                                   ` David Kastrup
2007-02-06 12:02                                                                     ` Juanma Barranquero
2007-02-06 23:16                                                                 ` Richard Stallman
2007-02-07  0:06                                                                   ` David Kastrup
2007-02-07 19:41                                                                     ` Richard Stallman
2007-02-07 19:41                                                                     ` Richard Stallman
2007-02-07 16:10                                                                   ` Stuart D. Herring
2007-02-09 17:24                                                                     ` Chris Moore
2007-02-09 18:14                                                                       ` Stuart D. Herring
2007-02-09 18:22                                                                       ` Chong Yidong
2007-02-12  4:55                                                                     ` Richard Stallman
2007-02-13  6:01                                                                       ` Chris Moore
2007-02-13 23:36                                                                         ` Richard Stallman
2007-02-06 23:16                                                             ` Richard Stallman
2007-02-06 23:47                                                               ` David Kastrup
2007-02-07 19:41                                                                 ` Richard Stallman
2007-02-06  1:46                                             ` Miles Bader
2007-02-06 11:53                                             ` Slawomir Nowaczyk
2007-02-06 15:15                                             ` Stefan Monnier
2007-02-06 15:46                                               ` Jason Rumney
2007-02-06 16:08                                                 ` Chong Yidong
2007-02-06 16:58                                                   ` Jason Rumney
2007-02-06 17:10                                                     ` Chong Yidong
2007-02-06 23:51                                                       ` Kim F. Storm
2007-02-07  0:03                                                         ` Chong Yidong
2007-02-07  0:41                                                           ` Kim F. Storm
2007-02-05 20:24                                 ` Juanma Barranquero
2007-02-05 20:36                                   ` Chong Yidong
2007-02-05 20:20                               ` Chong Yidong
2007-02-05 20:33                                 ` Juanma Barranquero
2007-02-06 17:08                               ` Richard Stallman
2007-02-06 17:56                                 ` Juanma Barranquero
2007-02-07  1:37                                   ` Richard Stallman
2007-02-07  1:42                                     ` Juanma Barranquero
2007-02-07  7:15                                       ` David Kastrup
2007-02-07  8:09                                         ` Juanma Barranquero
2007-02-07 19:41                                       ` Richard Stallman
2007-02-06 17:08                             ` Richard Stallman
2007-02-06 23:46                               ` Chris Moore
2007-02-06 23:58                                 ` Chong Yidong
2007-02-07 16:59                                   ` Chris Moore
2007-02-08  0:52                                     ` Richard Stallman
2007-02-09 17:17                                       ` Chris Moore
2007-02-10  9:51                                         ` Eli Zaretskii
2007-02-05 19:06                       ` Juanma Barranquero
2007-02-05 21:27                     ` Juri Linkov
2007-02-06 11:42                     ` Slawomir Nowaczyk
2007-02-05 19:07               ` Lennart Borgman (gmail)
2007-02-06  9:19                 ` Jason Rumney
2007-02-06  9:35                   ` David Kastrup
2007-02-06  9:46                     ` Lennart Borgman (gmail)
2007-02-06 10:21                   ` Mathias Dahl
2007-02-06 16:50                     ` Stefan Monnier
2007-02-05 21:28               ` Juri Linkov
2007-02-05 21:35                 ` Lennart Borgman (gmail)
2007-02-05 21:38                 ` Chong Yidong
2007-02-05 22:02                   ` Stefan Monnier
2007-02-06 17:09                   ` Richard Stallman
2007-02-05 11:15       ` Juanma Barranquero
2007-02-05 21:45         ` Kim F. Storm
2007-02-05 21:53           ` Chris Moore
2007-02-05 12:22       ` Miles Bader
     [not found]       ` <E1HEE0j-0004T3-Rc@fencepost.gnu.org>
2007-02-06  7:20         ` David Kastrup
2007-02-06 23:15           ` Richard Stallman
2007-02-06 10:53         ` Lars Magne Ingebrigtsen
2007-02-06 23:16           ` Richard Stallman
2007-02-06 12:26         ` Kim F. Storm
2007-02-06 12:46           ` David Kastrup
2007-02-06 16:48             ` Stefan Monnier
2007-02-05 18:56   ` Stefan Monnier
2007-02-05 19:08     ` Chong Yidong
2007-02-05 19:28       ` Stefan Monnier
2007-02-05 21:12     ` Chris Moore
2007-02-05 21:28     ` Juri Linkov
2007-02-06 11:09   ` Slawomir Nowaczyk
2007-02-05 19:10 ` Richard Stallman
2007-02-05 21:25   ` Chris Moore
2007-02-06 17:09     ` Richard Stallman
2007-02-06 22:54       ` David Kastrup
2007-02-07  1:37         ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87iregmafd.fsf@stupidchicken.com \
    --to=cyd@stupidchicken.com \
    --cc=emacs-devel@gnu.org \
    --cc=lekktu@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).