From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Richard Stallman Newsgroups: gmane.emacs.devel Subject: Re: using libmagic in Emacs? Date: Sun, 23 Aug 2009 20:07:18 -0400 Message-ID: References: <87ocqco7fi.fsf@mail.jurta.org> <87y6pb8lqh.fsf@mail.jurta.org> Reply-To: rms@gnu.org NNTP-Posting-Host: lo.gmane.org Content-Type: text/plain; charset=ISO-8859-15 X-Trace: ger.gmane.org 1251072459 32670 80.91.229.12 (24 Aug 2009 00:07:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 24 Aug 2009 00:07:39 +0000 (UTC) Cc: monnier@IRO.UMontreal.CA, joakim@verona.se, emacs-devel@gnu.org To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 24 02:07:32 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 1MfN5v-0007Ui-99 for ged-emacs-devel@m.gmane.org; Mon, 24 Aug 2009 02:07:31 +0200 Original-Received: from localhost ([127.0.0.1]:37458 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MfN5u-0004qW-9d for ged-emacs-devel@m.gmane.org; Sun, 23 Aug 2009 20:07:30 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MfN5o-0004oV-R9 for emacs-devel@gnu.org; Sun, 23 Aug 2009 20:07:24 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MfN5j-0004iV-VF for emacs-devel@gnu.org; Sun, 23 Aug 2009 20:07:24 -0400 Original-Received: from [199.232.76.173] (port=57573 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MfN5j-0004iQ-QZ for emacs-devel@gnu.org; Sun, 23 Aug 2009 20:07:19 -0400 Original-Received: from fencepost.gnu.org ([140.186.70.10]:36654) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MfN5j-00020K-56 for emacs-devel@gnu.org; Sun, 23 Aug 2009 20:07:19 -0400 Original-Received: from rms by fencepost.gnu.org with local (Exim 4.67) (envelope-from ) id 1MfN5i-0006qY-5N; Sun, 23 Aug 2009 20:07:18 -0400 In-reply-to: <87y6pb8lqh.fsf@mail.jurta.org> (message from Juri Linkov on Sun, 23 Aug 2009 02:36:22 +0300) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) 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:114541 Archived-At: The problem is that `image-jpeg-p' in image.el refuses to accept non-JFIF JPEG image files whereas Emacs can correctly display them when tests in `image-jpeg-p' are ignored. Using libmagic means looking only for 2 bytes 0xffd8 (a magic number of JPEG files) as described by the magic number file: 0 beshort 0xffd8 JPEG image data It seems this is enough to determine JPEG files. But I'm not confident about removing additional tests from `image-jpeg-p'. We could keep the current rules in image.el as a fall-back when libmagic is not available. Whatever we do with the function `image-jpeg-p', we could easily make Emacs test these two bytes. It makes no sense to install code to link with libmagic just to handle that and a few other similar things. Meanwhile, for operations less common and important than visiting a file, running `file' is easy to do. Combining those two approaches seems much better than adding code to link with libmagic.