[TxMt] Re: Tree structure bundle?
Rob Shearer
textmate at v.cx
Mon Feb 12 04:08:42 UTC 2007
> Michael Gregoire <mgee at ...> writes:
>> Hi everyone... I catalog my external media using the 'tree' command
>> and this generates a file such as the one attached.
>> Does anyone know of a bundle developed to allow folding for this?
>>
>> .
>> |-- a
>> | |-- AC_DC
>> | | |-- AC_DC - Highway to Hell.mp3
>> | | `-- AC_DC - You Shook Me All Night Long.mp3
>> | |-- Alan Parsons Project - Games People Play.mp3
>> | |-- Alt & The Lost Civilisation - Tequila.mp3
>> | `-- Archies - Sugar Sugar.mp3
>
> Hmm, I don't think this is possible given the current folding
> architecture.
> Hopefully it will be possible with the new parser features being
> added for 2.0.
To figure out whether a line should actually start a folding you
really need to be able to look ahead to the next line, and I think
you can't do that in TM. (yet?)
But if your actual data is a bunch of directories of MP3 files, a
simple little language which sets
foldingStartMarker = '^(\| )*\|-- .*(?<!.mp3)$';
foldingStopMarker = '^(\| )*`--';
does more or less the right thing. The "negative lookbehind" is the
hacky heuristic to decide whether a line starts a folding or not: it
will break if there are empty directories, if any file name doesn't
end with .mp3, or if any directory name does. Giving the -F flag to
`tree` will disambiguate the naming things (use "/$" instead of "(?
<!.mp3)$", but won't fix the problem with empty directories.
One of the things I really like about TextMate is that such
customizations are quick enough to be economic even for grotty single-
use "languages" like this one.
-rob
More information about the textmate
mailing list