Allan Odgaard wrote:
On 17 Jul 2008, at 14:57, Baluta Cristian wrote:
Can i order the files from drawer alphabeticaly, but fistly the
folders,
then the files? It seems i get lost in the current alphabeticaly
order.
Not possible. There will (most likely) be some sorting options in the
future.
You can do it if you're willing to create a *.tmproj file by hand. I
wrote a Perl script to recurse through an SVN source tree, adding only
files under version control (not object files, or intermediate source
files created by such things as yacc). In addition, it orders the
project with directories first. I've attached the script, hopefully it
will be useful to someone. It could easily be modified to add all files,
rather than only files in SVN. That way it would be almost equivalent to
simply opening a directory in TextMate.
Note: You run this from the terminal, *outside* of TextMate. It finishes
by launching TextMate to open the new project file.
Allan: Future sorting options would be very much appreciated!
--
Steve King
Sr. Software Engineer
Arbor Networks
+1 734 821 1461
www.arbornetworks.com
http://www.arbornetworks.com/
#! /usr/bin/perl -w
################################################################################
##
## tmsvn.pl
##
## Copyright (c) 2008 Arbor Networks, Inc.
## All rights reserved. Proprietary and confidential.
##
## $Id: tmsvn.pl 40 2008-02-07 18:25:45Z sking $
##
################################################################################
use strict;
use File::Spec::Functions qw( :ALL );
use IO::File;
my $VERBOSE = 0;
my $DRYRUN = 0;
################################################################################
##
## main
##
################################################################################
{
my $root = shift(@ARGV) || '.';
my @paths = shell('svn','ls','-R',$root);
my $tree = {};
foreach my $path (@paths) {
next if ($path =~ m-/$-);
my ($vol,$dirs,$file) = splitpath($path);
my @dirs = splitdir(canonpath($dirs));
my $ref = $tree;
foreach my $d (@dirs) {
$ref->{$d} = {} unless($ref->{$d});
$ref = $ref->{$d};
}
$ref->{$file} = $path;
}
my $xml = parseTree($tree);
my ($vol, $dir, undef) = splitpath(canonpath(rel2abs($root)),1);
my @dirs = splitdir($dir);
my $projfile = pop(@dirs) . '.tmproj';
my $projpath = catpath($vol,$dir,$projfile);
my $fh = IO::File->new($projpath, 'w') || die;
print $fh <<EOF;
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>windowFrame</key>
<string>{{204, 4}, {647, 874}}</string>
<key>documents</key>
<array>
$xml
</array>
</dict>
</plist>
EOF
close($fh);
exec('open', $projpath);
}
################################################################################
##
## parseTree
##
################################################################################
sub parseTree
{
my $tree = shift;
my $str = '';
my (@dirs, @files);
foreach my $k (keys %{$tree}) {
if (ref($tree->{$k})) {
push(@dirs, $k);
}
else {
push(@files, $k);
}
}
foreach my $k (sort @dirs) {
$str .= <<EOF;
<dict>
<key>name</key>
<string>$k</string>
<key>children</key>
<array>
EOF
$str .= parseTree($tree->{$k});
$str .= <<EOF;
</array>
</dict>
EOF
}
foreach my $k (sort @files) {
next if ($k =~ /.(gz|tgz|zip|pdf|pcap)$/i);
$str .= <<EOF;
<dict>
<key>filename</key>
<string>$tree->{$k}</string>
</dict>
EOF
}
return $str;
}
################################################################################
##
## shell
##
################################################################################
sub shell
{
my @cmd = @_;
my $cmd = join(' ',@cmd);
my (@output);
print "$cmd\n" if ($VERBOSE);
if (! $DRYRUN) {
my $fh = IO::File->new($cmd . '|');
@output = $fh->getlines();
chomp(@output);
$fh->close();
}
return @output;
}