From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Juanma Barranquero" Newsgroups: gmane.emacs.devel Subject: Re: C file recoginzed as image file Date: Fri, 5 Jan 2007 23:44:35 +0100 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1168037104 29126 80.91.229.12 (5 Jan 2007 22:45:04 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 5 Jan 2007 22:45:04 +0000 (UTC) Cc: Charles Rendleman , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jan 05 23:45:04 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 1H2xnw-0004Xm-DY for ged-emacs-devel@m.gmane.org; Fri, 05 Jan 2007 23:44:52 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H2xnv-0008F5-SM for ged-emacs-devel@m.gmane.org; Fri, 05 Jan 2007 17:44:51 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1H2xnk-0008Cw-5h for emacs-devel@gnu.org; Fri, 05 Jan 2007 17:44:40 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1H2xni-0008AZ-H5 for emacs-devel@gnu.org; Fri, 05 Jan 2007 17:44:39 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H2xni-0008AW-EY for emacs-devel@gnu.org; Fri, 05 Jan 2007 17:44:38 -0500 Original-Received: from [64.233.182.190] (helo=nf-out-0910.google.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1H2xnh-0002Rw-Pd for emacs-devel@gnu.org; Fri, 05 Jan 2007 17:44:38 -0500 Original-Received: by nf-out-0910.google.com with SMTP id h2so1183287nfe for ; Fri, 05 Jan 2007 14:44:36 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=TioSlyw/61QMtY13xDkTFuzIn3XSRJGOkcQWP51SomLdkRcaxsl8eeshkDP4MUBV+5xer14gE9w79e9uLNRvMwaXl++8lTxXNDlMx8Kdw7dN7ugZTyyT1MVmnaqbHtzhEOOSgZRIKlgORY6z/+FQJKAlkBiyEM0PLBehZRzg+6g= Original-Received: by 10.82.152.16 with SMTP id z16mr1880463bud.1168037075632; Fri, 05 Jan 2007 14:44:35 -0800 (PST) Original-Received: by 10.82.147.2 with HTTP; Fri, 5 Jan 2007 14:44:35 -0800 (PST) Original-To: "Chris Moore" In-Reply-To: Content-Disposition: inline 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:64838 Archived-At: On 1/5/07, Chris Moore wrote: > 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... That's a reason no to auto-detect images, not a reason to use `magic-mode-alist' after `auto-mode-alist'. > But when the file contains an image file, Emacs > is happy to just display it without any kind of prompt or warning, > even when the file has a .c extension? You're right. In my previous message in this tread, I already suggested to deactivate auto-detection of images. > In short, .c files should be opened in cc-mode, no matter what they > contain, at least not without checking with the user first. "The > file's extension indicates that this is C source code, but the file > contains an image in PNG format. Display the image? (y/n)" That's more-or-less easy even now: (defun image-auto-detect-y-or-n-p () (let ((type (image-type-auto-detected-p))) (and type (y-or-n-p (format "File \"%s\" contains a `%s' image; display it " (file-name-nondirectory buffer-file-name) (image-type-from-buffer)))))) (setcar (rassq 'image-mode magic-mode-alist) 'image-auto-detect-y-or-n-p) /L/e/k/t/u