[R-SIG-Mac] Using TextMate to develop R packages
Byron Ellis
ellis at stat.harvard.edu
Sat Aug 12 02:33:36 CEST 2006
Lately I've been using TextMate more and more for development so I
thought I'd share a simple modification I've made to TextMate's R
Bundle for actually building packages.
The first is the addition of the "Build As Package" command (I bound
it to Shift-Cmd-B), set to return HTML
cd $TM_DIRECTORY
while [ `pwd` != "/" -a ! -e DESCRIPTION ]; do cd ..; done
if [ -e DESCRIPTION ]; then
export R_PACKAGE=`pwd`
cd ..
R CMD INSTALL $R_PACKAGE 2>&1 | "$TM_BUNDLE_SUPPORT/format_install.pl"
else
echo "<h1>No package to build</h1>"
fi
Basically, it looks at the current file. Searches up the tree until
it finds the DESCRIPTION file and uses that as the root for the R
package build.
format_install.pl is just a really really simple script to highlight
compiler errors and warnings for myself,
#!/usr/bin/perl
my($dir) = $ENV{R_PACKAGE};
my(@dirs) = split(/\//,$dir);
my($package) = pop(@dirs);
print "<html><title>Building $package</title><body><h1>Building
$package...</h1>";
while(<>) {
chomp;
my($color) = "black";
$color = "goldenrod" if(/warning:/);
$color = "red" if(/error:/);
s|^([^:]+):(\d+):(.*)|<a style="color: $color;" href="txmt://open?
url=file://$dir/src/$1&line=$2">$1:$2: $3</a>|;
print "<p>$_</p>\n";
}
print"</body></html>"
---
Byron Ellis (ellis at stat.harvard.edu)
"Oook" -- The Librarian
More information about the R-SIG-Mac
mailing list