From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.help Subject: Re: "Text is read-only"... except it isn't... or shouldn't be Date: Thu, 16 May 2013 00:27:16 -0600 Message-ID: References: <5190B6C2.3060801@mousecar.com> <83y5bi97sp.fsf@gnu.org> <51911A2B.6070100@mousecar.com> <83r4ha959c.fsf@gnu.org> <5191A2BA.7080108@mousecar.com> <83bo8e83ef.fsf@gnu.org> <6DBF2725-3120-4A0D-A23B-C1C16CA8AF22@Web.DE> <51922C68.1030700@mousecar.com> <8338tp8yuu.fsf@gnu.org> <5192A11F.1080003@mousecar.com> <51937603.1050304@mousecar.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1368685639 3250 80.91.229.3 (16 May 2013 06:27:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 16 May 2013 06:27:19 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu May 16 08:27:17 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Ucrem-0001OX-9d for geh-help-gnu-emacs@m.gmane.org; Thu, 16 May 2013 08:27:16 +0200 Original-Received: from localhost ([::1]:39925 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ucrel-0004wX-Sa for geh-help-gnu-emacs@m.gmane.org; Thu, 16 May 2013 02:27:15 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:44911) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UcreU-0004vm-Ei for help-gnu-emacs@gnu.org; Thu, 16 May 2013 02:27:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UcreN-0008PU-Ug for help-gnu-emacs@gnu.org; Thu, 16 May 2013 02:26:58 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:43683) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UcreN-0008P0-Le for help-gnu-emacs@gnu.org; Thu, 16 May 2013 02:26:51 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UcreM-00016g-Fa for help-gnu-emacs@gnu.org; Thu, 16 May 2013 08:26:50 +0200 Original-Received: from 71-215-72-36.hlrn.qwest.net ([71.215.72.36]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 16 May 2013 08:26:50 +0200 Original-Received: from kevin.d.rodgers by 71-215-72-36.hlrn.qwest.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 16 May 2013 08:26:50 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 76 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 71-215-72-36.hlrn.qwest.net User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.28) Gecko/20120306 Thunderbird/3.1.20 In-Reply-To: <51937603.1050304@mousecar.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:90835 Archived-At: On 5/15/13 5:48 AM, ken wrote: > On 05/15/2013 01:17 AM Kevin Rodgers wrote: >> On 5/14/13 2:39 PM, ken wrote: >>> On 05/14/2013 09:39 AM Eli Zaretskii wrote: >>>> Emacs does look at the magic signature, see magic-mode-alist. >>> >>> They why didn't it see that my file was (obviously) a text file and >>> not an image >>> file? >> >> 1. Because the default value of magic-mode-alist is nil. > > If you mean this functionality was turned off in this version I recently > installed, then, yes, that agrees with what I said earlier in this thread: emacs > no longer determines a file's magic upon visiting a file. No, you misunderstand. After file local variables and interpreter-mode-alist, magic-mode-alist is merely the first relevant option that is consulted when automatically setting the major mode. Then auto-mode-alist (which matches the file name), then magic-fallback-mode-alist (which matches the file contents, like magic-mode-alist, but which is not nil by default). That is why I suggested you actually read the "Choosing Modes" section of the Emacs manual. Any part of that algorithm might have changed between your unnamed previous version and the current Emacs version, probably in response to specific bug reports and after review by the maintainers. > The more comprehensive > fix, then, would be to set magic-mode-alist to t, yes? If so, what elisp > statement(s) do you think would best accomplish that? No, t is not a valid alist. You could remove the ".gif" entry from auto-mode-alist, and add an entry to magic-fallback-mode-alist. According to my /usr/share/file/magic, the regexp should be "\\`GIF8". Here is my guess at the lisp: (setq auto-mode-alist (remove '("\\.gif\\'" . image-mode) auto-mode-alist)) (setq magic-fallback-mode-alist (cons '("\\`GIF8" . image-mode) magic-fallback-mode-alist)) >> 2. Because the default value of auto-mode-alist matches the ".gif" >> extension. > > The documentation suggests that magic-mode-alist, if turned on, will override > auto-mode-alist. More precisely: If there is an entry in magic-mode-alist that matches the filecontents, it has precedence over auto-mode-alist. >> 3. Because it is not obvious what the signature is for a text file -- >> perhaps >> something like "\\`[[:print:]\t\f\r\n]", which is so general that it >> would >> prevent most of the existing automatic method from working. > > Yes, the damned humans with their writing so random and the different languages > characters and syntaxes and punctuation etc. make such evaluation nigh > impossible. Probably for this reason, magic mode adopts a different strategy. > The linux "file" utility, referred to earlier in this thread, probably does this > also, as it makes fairly reliable evaluations of files' contents. Yes: Instead of trying to detect text files by their content, detect all the other kinds of files by their content or name (and then default to Fundamental mode). -- Kevin Rodgers Denver, Colorado, USA