Skip to content

Commit

Permalink
Improve R help searching
Browse files Browse the repository at this point in the history
took care for help.search(topic) and ??topic cases
fix search() so that it works with and without quotation marks:
search(ls) and search("ls")
help.start() now opens R help pages in an external browser
  • Loading branch information
Valentin Georgiev committed Aug 15, 2012
1 parent af88108 commit e3703f7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Expand Up @@ -431,8 +431,12 @@ public String eval(String command) {
cmdDefMirror.append(", repos=\"http://cran.us.r-project.org\")");
command = cmdDefMirror.toString();
}
if (command.startsWith("?"))
returnVal = help(command.substring(1));
if (command.startsWith("?") && !command.contains("??"))
returnVal = help(command);
if (command.contains("help.search") || command.contains("??"))
returnVal = "help.search() and ?? searching is currently not supported in Bioclipse-R!";
else if (command.startsWith("help") && !command.contains("help.start"))
returnVal = help(command);
else if (command.contains("quartz"))
returnVal = "quartz() is currently disabled for stability reasons" + NEWLINE + "Please use X11 for plotting!";
else if (command.contains("chooseCRANmirror") && OS.startsWith("Mac"))
Expand Down Expand Up @@ -469,7 +473,17 @@ public String ls() {
* Opens help in browser
*/
private String help(String command) {
String url = eval("getHelpAddress(help("+ command +", help_type=\"html\"))");
String url = null;
if (command.startsWith("?")) {
command = command.substring(1);
} else {
if (command.contains("(\"")) {
command = command.substring(command.indexOf("(\"") + 2, command.length() - 3);
} else {
command = command.substring(command.indexOf("(") + 1, command.length() - 2);
}
}
url = eval("getHelpAddress(help("+ command +", help_type=\"html\"))");
url = url.substring(5, url.length()-1);
logger.debug("URL is " + url);

Expand Down
Expand Up @@ -53,7 +53,7 @@ public void run() {
protected String executeCommand( String command ) {
String returnVal = null;
command = RunUtil.parseCommand(command);
if (command.contains("?") || command.contains("install.packages"))
if (command.contains("?") || command.contains("help") || command.contains("install.packages"))
returnVal = evalCommand(command, false);
else
returnVal = evalCommand(command, true);
Expand Down

0 comments on commit e3703f7

Please sign in to comment.