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: using libmagic in Emacs? Date: Thu, 20 Aug 2009 09:57:41 -0400 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1250776943 20389 80.91.229.12 (20 Aug 2009 14:02:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 20 Aug 2009 14:02:23 +0000 (UTC) Cc: Emacs Development To: joakim@verona.se Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Aug 20 16:02:16 2009 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 1Me8DW-0005vE-6C for ged-emacs-devel@m.gmane.org; Thu, 20 Aug 2009 16:02:15 +0200 Original-Received: from localhost ([127.0.0.1]:53144 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Me8DV-0004OV-OY for ged-emacs-devel@m.gmane.org; Thu, 20 Aug 2009 10:02:13 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Me89G-000246-FS for emacs-devel@gnu.org; Thu, 20 Aug 2009 09:57:50 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Me899-0001zs-Tj for emacs-devel@gnu.org; Thu, 20 Aug 2009 09:57:48 -0400 Original-Received: from [199.232.76.173] (port=49317 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Me899-0001zi-Jw for emacs-devel@gnu.org; Thu, 20 Aug 2009 09:57:43 -0400 Original-Received: from ironport2-out.pppoe.ca ([206.248.154.182]:15987 helo=ironport2-out.teksavvy.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Me899-0000SB-0T for emacs-devel@gnu.org; Thu, 20 Aug 2009 09:57:43 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApsEAM/yjEpLd/9W/2dsb2JhbACBU9VshBgF X-IronPort-AV: E=Sophos;i="4.43,414,1246852800"; d="scan'208";a="43854252" Original-Received: from 75-119-255-86.teksavvy.com (HELO pastel.home) ([75.119.255.86]) by ironport2-out.teksavvy.com with ESMTP; 20 Aug 2009 09:57:03 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 6FCD77F36; Thu, 20 Aug 2009 09:57:41 -0400 (EDT) In-Reply-To: (joakim@verona.se's message of "Thu, 20 Aug 2009 00:49:53 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) X-detected-operating-system: 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:114443 Archived-At: >> I think it's a good idea. It may require some non-trivial changes on >> the Lisp side, since libmagic's information is not quite the same as >> what Emacs currently uses: we'll probably want to use libmagic to get >> a MIME-type and then have a table mapping mime-types to major modes or >> some such. > I attach an early draft filemagic patch. > Some notes: > - The mime type info usualy is less granular than the free > text info: We can provide both. I think we'd want 2 functions: one to get the free text info, which just returns a string (or nil), and another to get the MIME info, which returns a cons, whose car is a symbol such as application/octet-stream, and whose cdr is an alist representing the additional optional info. > file --mime /tmp/tst.xcf > /tmp/tst.xcf: application/octet-stream; charset=binary This would look like (application/octet-stream (charset . "binary")) A few more comments: - please follow the GNU coding convention. I.e. put spaces where they need to be (e.g. around parens and operators). - don't bother with a new file. Just put it into fileio.c. - as someone else mentioned, CPP macros in the Makefile.in are things we'd like to get rid of, so please don't put more of them there. Use autoconf's m4 macros instead, thank you. Stefan