[TxMt] Filename Extensions
Allan Odgaard
throw-away-2 at macromates.com
Fri Apr 25 05:33:46 UTC 2008
On 24 Apr 2008, at 21:46, Steve King wrote:
> In another thread Allan Odgaard wrote:
>> TextMate will not search binary files, granted it knows that the
>> file type is binary. So right-click a file (using the extension you
>> want to exclude) in the project drawer and select to treat it as
>> binary.
>
> That helps, but isn't perfect. For one thing, it can't handle files
> without an extension, such as executables.
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.
> There's another quirk related to filename extensions that drives me
> nuts. For various reasons, I have a lot of files with the extension
> "*.txt" [...]
I am sorry, but from my POV using the same extension for different
types is wrong, and “supporting” that is not exactly a priority.
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.
> [...]
> What would be even better would be for TextMate to examine the
> contents of the file as well as the filename to determine what
> language it is. If the extension is ambiguous, check the first few
> bytes for a shell shebang line, or an emacs-style modeline, or some
> other clue as to the type. And I would absolutely swoon if the
> language definition itself contained a way to specify what to look
> for, letting TextMate try each language in turn until it found a
> match.
The grammars have a ‘firstLineMatch’ regexp to look for shebang and
similar.
More information about the textmate
mailing list