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: recognizing a file by scanning it Date: Mon, 28 Apr 2008 10:52:40 -0400 Message-ID: References: <87od7vr0kt.fsf@ambire.localdomain> <87abjfxb19.fsf@uwakimon.sk.tsukuba.ac.jp> <87lk2y65sa.fsf@ambire.localdomain> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1209394376 18952 80.91.229.12 (28 Apr 2008 14:52:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 28 Apr 2008 14:52:56 +0000 (UTC) Cc: "Stephen J. Turnbull" , emacs-devel@gnu.org To: Thien-Thi Nguyen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Apr 28 16:53:31 2008 connect(): Connection refused 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 1JqUjS-0003Te-Mj for ged-emacs-devel@m.gmane.org; Mon, 28 Apr 2008 16:53:30 +0200 Original-Received: from localhost ([127.0.0.1]:35679 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JqUim-0003mi-A2 for ged-emacs-devel@m.gmane.org; Mon, 28 Apr 2008 10:52:48 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JqUih-0003mK-Pc for emacs-devel@gnu.org; Mon, 28 Apr 2008 10:52:43 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JqUif-0003m0-E3 for emacs-devel@gnu.org; Mon, 28 Apr 2008 10:52:43 -0400 Original-Received: from [199.232.76.173] (port=60652 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JqUif-0003lx-7A for emacs-devel@gnu.org; Mon, 28 Apr 2008 10:52:41 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JqUie-0007KV-R1 for emacs-devel@gnu.org; Mon, 28 Apr 2008 10:52:40 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aq0DADOBFUjO+JghdGdsb2JhbACBU5AMASeYHQ X-IronPort-AV: E=Sophos;i="4.25,716,1199682000"; d="scan'208";a="19530327" Original-Received: from smtp.pppoe.ca (HELO smtp.teksavvy.com) ([65.39.196.238]) by ironport2-out.teksavvy.com with ESMTP; 28 Apr 2008 10:52:40 -0400 Original-Received: from pastel.home ([206.248.152.33]) by smtp.teksavvy.com (Internet Mail Server v1.0) with ESMTP id ISC40640; Mon, 28 Apr 2008 10:52:40 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 0FFFF8008; Mon, 28 Apr 2008 10:52:40 -0400 (EDT) In-Reply-To: <87lk2y65sa.fsf@ambire.localdomain> (Thien-Thi Nguyen's message of "Mon, 28 Apr 2008 05:02:13 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. 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:96063 Archived-At: > file(1) contains a rather complete set of such heuristics and > has been stable for a long time. AFAIK libmagic is free and > GPL-compatible. > Yes, i believe so. My concern w/ using libmagic would be > portability, and handling the case where libmagic is not > available. I envision the feature to be non-optional. Would could like we do for `ls': use libmagic if it's available and fallback on an Elisp replacement if not. The Elisp replacement would need to work even in the absence of /etc/magic. The higher-level functionality also needs adjusting: we want to bring magic-mode-alist and auto-mode-alist to the same level (rather than give absolute priority to one of the two). Basically, try them both, each one can return a set/list of potential modes, then try and figure out which mode to use (I've done something similar in doc-view-mode). Hopefully this can be used to disambiguate the .arc archives from the .arc Lisp files as well. > Also, it might be nice if you could call this facility from > coding systems (after all, what else is a BOM but file magic?) > This kind of thing really doesn't need to be in Lisp, and might > benefit from being in C. > Certainly, in C it can be much faster. If it's used just to choose the major-mode, speed is a non-issue. Stefan