From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: using libmagic in Emacs? Date: Fri, 21 Aug 2009 21:42:35 +0300 Message-ID: <837hwxgg9w.fsf@gnu.org> References: <83k50xh1m8.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1250880332 26510 80.91.229.12 (21 Aug 2009 18:45:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 21 Aug 2009 18:45:32 +0000 (UTC) Cc: schwab@linux-m68k.org, monnier@iro.umontreal.ca, emacs-devel@gnu.org To: joakim@verona.se Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Aug 21 20:45:24 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 1MeZ76-0003Za-4T for ged-emacs-devel@m.gmane.org; Fri, 21 Aug 2009 20:45:24 +0200 Original-Received: from localhost ([127.0.0.1]:59683 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MeZ75-0000nu-GE for ged-emacs-devel@m.gmane.org; Fri, 21 Aug 2009 14:45:23 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MeZ70-0000ln-3k for emacs-devel@gnu.org; Fri, 21 Aug 2009 14:45:18 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MeZ6z-0000lC-FP for emacs-devel@gnu.org; Fri, 21 Aug 2009 14:45:17 -0400 Original-Received: from [199.232.76.173] (port=35022 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MeZ6z-0000ks-6n for emacs-devel@gnu.org; Fri, 21 Aug 2009 14:45:17 -0400 Original-Received: from mtaout6.012.net.il ([84.95.2.16]:32758) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MeZ6y-0005ih-Ha for emacs-devel@gnu.org; Fri, 21 Aug 2009 14:45:16 -0400 Original-Received: from conversion-daemon.i-mtaout6.012.net.il by i-mtaout6.012.net.il (HyperSendmail v2007.08) id <0KOQ00G00P0F8U00@i-mtaout6.012.net.il> for emacs-devel@gnu.org; Fri, 21 Aug 2009 21:44:33 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([84.228.180.85]) by i-mtaout6.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0KOQ00HP2PE8UI00@i-mtaout6.012.net.il>; Fri, 21 Aug 2009 21:44:33 +0300 (IDT) In-reply-to: X-012-Sender: halo1@inter.net.il X-detected-operating-system: by monty-python.gnu.org: Solaris 10 (1203?) 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:114486 Archived-At: > From: joakim@verona.se > Cc: schwab@linux-m68k.org, monnier@iro.umontreal.ca, emacs-devel@gnu.org > Date: Fri, 21 Aug 2009 19:38:15 +0200 > > Renamed entry point to libmagic-file-internal since its meant to be > of internal usage for a lisp wrapper, yet to be written. Should that be > a new file BTW? files.el sounds good enough to me. > I'm habing trouble remembering not to use c99. Is there some convenient > compiler flag to force lower versions? I think -std=c89 should do what you want (assuming you use GCC). > I described a bit more in the doc string. Ok? I suggest the following variation of it: doc: /* Return a list describing the argument FILE-OR-BUFFER. If FILE-OR-BUFFER is a file name, return information about that file. If FILE-OR-BUFFER is a buffer, return information about the buffer's file. The return value is a list of the form (MIME-TYPE MIME-ENCODING DESCRIPTION) MIME-TYPE and MIME-ENCODING are the MIME type and encoding suitable for the file's contents, as determined by libmagic. DESCRIPTION is the human readable descripton of the file type offered by libmagic. The function throws a file-error if libmagic cannot determine one of the elements of the above list. The default libmagic database is used, and the quality of information given depends on your version of that database. Often the MIME type is less exact than the description. */) Two more comments: . I am not sure you need to push the file-or-buffer dichotomy to the C level. It is easy enough to do that in Lisp, or even in the application, for that matter. Why complicate a primitive to do such a simple job? . You didn't say in the doc string whether MIME-ENCODING is guaranteed to be a valid Emacs coding-system. I think a user will be desperate to know that. Thanks for working on this.