From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: C file recoginzed as image file Date: Mon, 08 Jan 2007 10:09:21 -0500 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1168269000 13393 80.91.229.12 (8 Jan 2007 15:10:00 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 8 Jan 2007 15:10:00 +0000 (UTC) Cc: lekktu@gmail.com, emacs-devel@gnu.org, c.a.rendle@gmail.com, dooglus@gmail.com Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jan 08 16:09:58 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1H3w89-0005k3-Ld for ged-emacs-devel@m.gmane.org; Mon, 08 Jan 2007 16:09:45 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H3w89-0005mT-38 for ged-emacs-devel@m.gmane.org; Mon, 08 Jan 2007 10:09:45 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1H3w7s-0005kM-4d for emacs-devel@gnu.org; Mon, 08 Jan 2007 10:09:28 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1H3w7n-0005iM-Vm for emacs-devel@gnu.org; Mon, 08 Jan 2007 10:09:27 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H3w7n-0005iJ-QN for emacs-devel@gnu.org; Mon, 08 Jan 2007 10:09:23 -0500 Original-Received: from [209.226.175.74] (helo=tomts20-srv.bellnexxia.net) by monty-python.gnu.org with esmtp (Exim 4.52) id 1H3w7m-0003CT-Dt; Mon, 08 Jan 2007 10:09:22 -0500 Original-Received: from pastel.home ([74.12.206.167]) by tomts20-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20070108150921.IYBV24907.tomts20-srv.bellnexxia.net@pastel.home>; Mon, 8 Jan 2007 10:09:21 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 52DFC6C2B4; Mon, 8 Jan 2007 10:09:21 -0500 (EST) Original-To: rms@gnu.org In-Reply-To: (Richard Stallman's message of "Mon\, 08 Jan 2007 00\:32\:43 -0500") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.91 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:64975 Archived-At: >> The reason I decided to detect images by their contents >> rather than by their file names is that it seems more correct >> as a way of recognizing them. > Why does it seem that way to you? > The whole point of a magic number is to recognize the file type > from its contents, regardless of file name. But they're heuristics as well. A text file may start with the title "GIF89a file format". Basically, I think that determining the major mode for a given file should neither give precedence to auto-mode-alist nor magic-mode-alist. Instead it should consider both. Each one can associate a file with a set of possible major modes (typically the set will be singleton) or say "don't know" (which would be basically the set of all major modes). E.g. auto-mode-alist would give "don't know" for a file named "/b/c/foo" but would give the set { perl-mode, prolog-mode } for a file named "/b/c/foo.pl". Then magic-mode-alist would give other sets of modes (based on things like the #! interpreter name, the -*- ... -*- cookie, etc...). If the intersection of the two sets is a singleton, then use that major-mode, otherwise query the user to decide whether to believe the file name or the contents. After all, an inconsistently named file is generally a sign that there's something wrong, so it's good to prompt the user about it. Stefan