help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: automatically turn on hexl-mode


From: Benjamin Riefenstahl
Subject: Re: automatically turn on hexl-mode
Date: Thu, 05 Jun 2003 17:27:38 +0200
User-agent: Gnus/5.1001 (Gnus v5.10.1) Emacs/21.3.50 (gnu/linux)

Hi Kin,


Kin Cho <address@hidden> writes:
> In my find-file-hooks function, I want to turn on hexl-mode
> automatically based on content.  I.e.,
>
> (and (buffer-content-looks-binary) (hexl-mode))
>
> What's a reasonable implementation of buffer-content-looks-binary?

<philosophical>
It's not easy to define formally what "binary" is.  Is an MS Word
document binary?  An UTF-16 document?  A gzipped text file?  And all
of these can be shown in Emacs, even though some of them need external
helpers.  Also for some purposes the actual question behind "is it
binary?" may be different than for others.  E.g. what CVS actually
needs to know is "Can I change the line ends and expand RCS keywords?"
</philosophical>

I recently had to find all binary files in a development project, a
collection of 13186 files.  Several methods said that there were 897
binary files in between.  The simplest and still reliable criterium
was to just look for a NUL byte in the first 1K of the file.


Hope this helps, benny


reply via email to

[Prev in Thread] Current Thread [Next in Thread]