[prev in list] [next in list] [prev in thread] [next in thread] 

List:       r-sig-mac
Subject:    [R-SIG-Mac] Using TextMate to develop R packages
From:       Byron Ellis <ellis () stat ! harvard ! edu>
Date:       2006-08-12 0:33:36
Message-ID: 185DB629-2499-474B-A9F9-6CE701C9216B () stat ! harvard ! edu
[Download RAW message or body]

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@stat.harvard.edu)
"Oook" -- The Librarian


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic