[TxMt] QuickOpen included files
Juan Falgueras
jfalgueras at uma.es
Thu Apr 19 15:51:56 UTC 2007
The current method the command Quick Open of the C bundle does use
is look for the file in several funny directories that not always are
then same c/c++ are looking into.
Is not easy to know where the cpp preprocessor look for the included
files. The only method I have found is from Andrew Tomazos and is a
small Perl script that makes c++ have mistakes and then shows us the
real places where it is looking into.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc-stdinc-1.0.tar.gz
Type: application/x-gzip
Size: 800 bytes
Desc: not available
URL: <http://lists.macromates.com/textmate/attachments/20070419/7e8fd9be/attachment.gz>
-------------- next part --------------
Running it once is enough, I think, and then pick up the directories
for a script to quick opening included files.
I would like to know who is the C bundle maintainer for to share this
things with him.
I also find a bit complicated the current way of making changes (yet
small changes) and then you will be out of updates of the official
bundle since yours will be always loaded before the official one.
Tx.
#!/usr/bin/env perl
$line=$ENV{'TM_CURRENT_LINE'};
$header=$ENV{'TM_SELECTED_TEXT'};
if (!$header) {
$line =~ /#\s*include\s*([<"])(.*?)[">]/;
$local = $1;
$header = $2;
}
if ($local eq '"') {
$t = $ENV{'TM_DIRECTORY'};
if (-f "$t/$header" ) {
print "$t/$header";
system("mate -r \"$t/$header\"");
exit 0;
}
}
@incs = qw(
/usr/include/c++/4.0.0
/usr/include/c++/4.0.0/powerpc-apple-darwin8
/usr/include/c++/4.0.0/backward
/usr/local/include
/usr/lib/gcc/powerpc-apple-darwin8/4.0.1/include
/usr/include
/System/Library/Frameworks
/Library/Frameworks
);
foreach $t (@incs) {
if (-f "$t/$header") {
print "$t/$header";
system("mate -r \"$t/$header\"");
exit 0;
}
}
print "";
exit 1;
More information about the textmate
mailing list