[TxMt] Filename Extensions

Steve King sking at arbor.net
Fri Apr 25 13:26:40 UTC 2008


Allan Odgaard wrote:
> There is nothing there to indicate, that the file is what you refer to 
> as binary. TextMate uses a heuristic where it scans the first 4 KB or 
> similar, and if it looks like text, it is treated as text. But if you 
> do not use extensions, you can’t expect programs to figure out what 
> the type of the file is.

I'm not asking the application to determine it, just a way to manually 
tell the app "this particular file is binary".  As opposed to "all files 
with this extension are binary".

(Although I should note that whatever heuristic Perl uses to determine 
whether a file is text or binary seems to work in the huge majority of 
cases, so it's at least possible for the app to make an educated guess.)

> You can however use double-extensions, like ‘file.real-type.txt’ and 
> then update the language grammar of real-type to claim the 
> ‘real-type.txt’ extension.

Alas, I can't go back and change years worth of file names.  Again, this 
is where I'd like a feature to say "this PARTICULAR file is 
such-and-such" without saying "any file with this extension is 
such-and-such".  Or even a way to say "treat this particular file as a 
different type for the duration of this session, but DON'T change the 
type associated with the extension". I don't care if the temporary 
association to an individual file is preserved across sessions.

> The grammars have a ‘firstLineMatch’ regexp to look for shebang and 
> similar.

Ah, I didn't know that!  Is that a new behavior, or just something I've 
missed seeing?  Is there any way to extend it to a multiline match so it 
could find something like an emacs modeline or vim config line elsewhere 
in the file?  (The vim guys like to put it at the end of the file.)

-- 
Steve King
Sr. Software Engineer
Arbor Networks
+1 734 821 1461
www.arbornetworks.com <http://www.arbornetworks.com/>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20080425/20846182/attachment.html>


More information about the textmate mailing list