[Sciviews-commits] r264 - in komodo: . SciViews-K/content SciViews-K/content/js SciViews-K/defaults

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon May 3 15:35:34 CEST 2010


Author: phgrosjean
Date: 2010-05-03 15:35:33 +0200 (Mon, 03 May 2010)
New Revision: 264

Added:
   komodo/SciViews-K/defaults/print.help_files_with_topic210.R
   komodo/SciViews-K/defaults/print.help_files_with_topic211.R
Removed:
   komodo/SciViews-K/defaults/print.help_files_with_topic.R
Modified:
   komodo/SciViews-K/content/js/commands.js
   komodo/SciViews-K/content/js/pref-R.js
   komodo/SciViews-K/content/js/r.js
   komodo/SciViews-K/content/overlayMain.xul
   komodo/SciViews-K/content/pref-R.xul
   komodo/SciViews-K/defaults/.DS_Store
   komodo/SciViews-K/defaults/SciViews-K (0.9.15).kpz
   komodo/SciViews-K/defaults/svStart.R
   komodo/TODO
Log:
SciViews-K is made compatible with R 2.11 + rework of the R interpreter definition (preferences)
Some more web links in the SciViews-K toolbox

Modified: komodo/SciViews-K/content/js/commands.js
===================================================================
--- komodo/SciViews-K/content/js/commands.js	2010-05-02 16:15:34 UTC (rev 263)
+++ komodo/SciViews-K/content/js/commands.js	2010-05-03 13:35:33 UTC (rev 264)
@@ -99,8 +99,6 @@
 
 // Start R
 this.startR = function () {
-	var os = Components.classes['@activestate.com/koOs;1']
-	.getService(Components.interfaces.koIOs);
 	var cwd = sv.tools.file.path("ProfD", "extensions",
 	"sciviewsk at sciviews.org", "defaults");
 	var cmd = sv.prefs.getString("svRApplication");
@@ -120,12 +118,16 @@
 	    return;
 	}
 
-	path = os.path.dirname(path);
-	if (path) path += os.sep;
+	// PhG: %Path% has changed: it is now the full application path, like "/usr/bin/R"!
+	// So, the following code should be eliminated!
+	//var os = Components.classes['@activestate.com/koOs;1']
+	//.getService(Components.interfaces.koIOs);
+	//path = os.path.dirname(path);
+	//if (path) path += os.sep;
 	var Quiet = " ";
 	if (sv.prefs.getString("svRQuiet")) Quiet = "--quiet ";
 	cmd = cmd.replace("%Path%", path).replace("%cwd%", cwd)
-		.replace("%title%", "SciViews-K").replace("%quiet%", Quiet);
+		.replace("%title%", "SciViews-R").replace("%quiet%", Quiet);
 
 	var id = sv.prefs.getString("svRApplicationId");
 
@@ -235,7 +237,9 @@
 		if (running != sv.r.running) {
 			sv.r.running = !!running;
 			//xtk.domutils.fireEvent(window, 'r_app_started_closed');
-			window.updateCommands('r_app_started_closed');
+			// PhG: these events are disabled for now, because menus are
+			//      sometimes disabled when they shouldn't be!!! Very ennoying!
+			//window.updateCommands('r_app_started_closed');
 			sv.log.debug("R status updated: " + (running? "" : "not ") + "running" );
 		}
 	}
@@ -462,12 +466,14 @@
 			}
 		}
 
-		_setCommandCtrl1(cmdsIfRRunning, _isRRunning, "sv_");
-		_setCommandCtrl1(cmdsIfRNotRunning, function() {
-			return !_isRRunning()}, "sv_");
-		_setCommandCtrl1(cmdsIfIsRView, _RControl_supported, "sv_R");
-		_setCommandCtrl1(cmdsIfIsRViewAndSelection,
-			_RControlSelection_supported, "sv_R");
+// PhG: currently, all menu items remain enabled, because this feature
+//      does not work well, and menus are sometimes disabled when they shouldn't be!
+		//_setCommandCtrl1(cmdsIfRRunning, _isRRunning, "sv_");
+		//_setCommandCtrl1(cmdsIfRNotRunning, function() {
+		//	return !_isRRunning()}, "sv_");
+		//_setCommandCtrl1(cmdsIfIsRView, _RControl_supported, "sv_R");
+		//_setCommandCtrl1(cmdsIfIsRViewAndSelection,
+		//	_RControlSelection_supported, "sv_R");
 
 		vmProto.do_cmd_sv_quit_R = function () {
 			sv.r.quit();

Modified: komodo/SciViews-K/content/js/pref-R.js
===================================================================
--- komodo/SciViews-K/content/js/pref-R.js	2010-05-02 16:15:34 UTC (rev 263)
+++ komodo/SciViews-K/content/js/pref-R.js	2010-05-03 13:35:33 UTC (rev 264)
@@ -89,6 +89,9 @@
 	var p = parent;
 	while (p.opener && (p = p.opener) && !sv) if (p.sv) sv = p.sv;
 
+	var os = Components.classes['@activestate.com/koOs;1']
+			.getService(Components.interfaces.koIOs);
+
 	var prefExecutable;
 	var prefset = parent.hPrefWindow.prefset;
 	var prefName = 'svRDefaultInterpreter';
@@ -98,16 +101,22 @@
 		prefExecutable = sv.tools.file.whereIs("R");
 		prefset.setStringPref(prefName, prefExecutable);
 	}
+	prefExecutable = sv.prefs.getString("svRDefaultInterpreter")
 	PrefR_setRAppMenu(document.getElementById("svRApplication"));
+	PrefR_menulistSetValue(document.getElementById("svRApplication"),
+		os.path.basename(prefExecutable), "app",  "R");
+	document.getElementById("svRDefaultInterpreter").value = prefExecutable;
+	
 	if (!PrefR_UpdateCranMirrors(true))
 		PrefR_UpdateCranMirrors(false);
 	
 	menuListSetValues();
+	PrefR_svRApplicationUpdate(null);
 	parent.hPrefWindow.onpageload();
 }
 
 function OnPreferencePageLoading(prefset) {
-	PrefR_svRApplicationOnSelect(null);
+	//PrefR_svRApplicationOnSelect(null);
 }
 
 function OnPreferencePageOK(prefset) {
@@ -143,18 +152,45 @@
 	var data = sel.getAttribute(prefattribute);
 	var app = sel.hasAttribute("app")? sel.getAttribute("app") : "R";
 
-	var os = Components.classes['@activestate.com/koOs;1']
-		.getService(Components.interfaces.koIOs);
+	// PhG: this does not work well. For instance, on Mac OS X, we must
+	//      switch from R in /usr/bin to R.app in /Applications and vice versa
+	// So, we must start with a reasonable default directory for the application
+	// as it can be defined automatically...
+	// And even, for some applications, one cannot change it (disable 'Browse')!	
+	//var os = Components.classes['@activestate.com/koOs;1']
+	//	.getService(Components.interfaces.koIOs);
+	//var path = os.path.normpath(os.path.dirname(
+	//		document.getElementById("svRDefaultInterpreter").value));
+	//if (path) path +=  os.sep;
+	//var svRDefaultInterpreter = path + app;
 
-	var path = os.path.normpath(os.path.dirname(
-			document.getElementById("svRDefaultInterpreter").value));
-	if (path) path +=  os.sep;
-
-	var svRDefaultInterpreter = path + app;
-
+	// PhG: this is the alternative I propose to always get a good starting value
+	var svRDefaultInterpreter = PrefR_locateApp(app);
 	document.getElementById("svRDefaultInterpreter").value
 		= svRDefaultInterpreter;
 
+	// Deleguate to PrefR_svRApplicationUpdate()
+	return PrefR_svRApplicationUpdate(event);
+}
+
+function PrefR_svRApplicationUpdate(event) {
+	var el = document.getElementById("svRApplication");
+	var prefattribute = el.getAttribute("prefattribute");
+	var sel = el.selectedItem;
+	var data = sel.getAttribute(prefattribute);
+	var cmdfield = document.getElementById('R_command');
+	
+	var svRDefaultInterpreter = document
+		.getElementById("svRDefaultInterpreter").value;
+	
+	// Check if svRDefaultInterpreter exists on disk
+	if (!sv.tools.file.exists(svRDefaultInterpreter)) {
+		// Indicate the problem in the command...
+		cmdfield.value = "??? R interpreter '" + svRDefaultInterpreter +
+			"' not found!";
+		return false;
+	}
+	
 	var Quiet = " ";
 	if (document.getElementById("svRQuiet")
 		.getAttribute("checked") == "true") Quiet = "--quiet ";
@@ -162,10 +198,12 @@
 	var cwd = sv.tools.file.path("ProfD", "extensions",
 		"sciviewsk at sciviews.org", "defaults");
 	
-	data = data.replace("%Path%", path).replace("%title%", "SciViews-K")
-		.replace("%cwd%", cwd).replace("%quiet%", Quiet);
+	// PhG: note that the path here is now the full path, application included!
+	data = data.replace("%Path%", svRDefaultInterpreter)
+		.replace("%title%", "SciViews-R").replace("%cwd%", cwd)
+		.replace("%quiet%", Quiet);
 
-	document.getElementById('R_command').value = data;
+	cmdfield.value = data;
 	return true;
 }
 
@@ -175,15 +213,40 @@
 			.getService(Components.interfaces.koIOs);
 
 		path = document.getElementById("svRDefaultInterpreter").value;
-		path = ko.filepicker.openExeFile(path);
+		// Special treatment for the .app items: open the parent directory!
+		var defpath = path;
+		if (path.match(/\.app$/) == ".app") defpath = os.path.dirname(path); 
+		path = ko.filepicker.openExeFile(defpath);
 	}
 
 	PrefR_menulistSetValue(document.getElementById("svRApplication"),
 		os.path.basename(path), "app",  "R");
 	document.getElementById("svRDefaultInterpreter").value = os.path.abspath(path);
-	PrefR_svRApplicationOnSelect(null);
+	PrefR_svRApplicationUpdate(null);
 }
 
+// PhG: I use this to get a first guess of the application location
+function PrefR_locateApp(appName) {
+	// 1) Look if app is an existing file
+	if (sv.tools.file.exists(appName)) {
+		return(appName);
+	}
+	// 2) Try to locate the application
+	var appPath = sv.tools.file.whereIs(appName)
+	if (appPath != null) {
+		return(appPath);
+	}
+	// 3) For R.app and the like on the Macintosh, I should really look at the
+	// /Applications directory
+	appName = "/Applications/" + appName;
+	if (sv.tools.file.exists(appName)) {
+		return(appName);
+	} else {
+		// Not found? What else can I do?
+		return("?");
+	}
+}
+
 function PrefR_setRAppMenu(menuList) {
 	var isLinux = navigator.platform.toLowerCase().indexOf("linux") > -1;
 	var isMac = navigator.platform.toLowerCase().indexOf("mac") > -1;

Modified: komodo/SciViews-K/content/js/r.js
===================================================================
--- komodo/SciViews-K/content/js/r.js	2010-05-02 16:15:34 UTC (rev 263)
+++ komodo/SciViews-K/content/js/r.js	2010-05-03 13:35:33 UTC (rev 264)
@@ -163,7 +163,8 @@
 				}
 			}
 			//xtk.domutils.fireEvent(window, 'r_app_started_closed');
-			window.updateCommands('r_app_started_closed');
+			// PhG: currentky disabled: all menus enabled all the time!
+			//window.updateCommands('r_app_started_closed');
 			sv.log.debug("R state changed: " + wasRRunning + "->" + isRRunning);
 		}
 	}
@@ -189,7 +190,7 @@
 	// Store the current R command
 	if (sv.socket.prompt == ":> ") {
 		// Special case for q() and quit() => use sv.r.quit() instead
-		if (cmd.search(/^q(?:uit)?\s*\(\s*\)$/) > -1) return(sv.r.quit());
+		if (cmd.search(/^(?:base::)?q(?:uit)?\s*\(\s*\)$/) > -1) return(sv.r.quit());
 		// This is a new command
 		sv.socket.cmd = cmd;
 	} else {
@@ -1435,7 +1436,9 @@
 		response = save? "yes" : "no";
 	}
 	// Quit R
-	sv.r.eval('q("' + response.toLowerCase() + '")');
+	// PhG: in R 2.11, R.app 1.33 q() is not usable any more... one has to
+	// be more explicit with base::q()
+	sv.r.eval('base::q("' + response.toLowerCase() + '")');
 	// Clear the R-relative statusbar message
 	sv.cmdout.message("");
 	// Clear the objects browser

Modified: komodo/SciViews-K/content/overlayMain.xul
===================================================================
--- komodo/SciViews-K/content/overlayMain.xul	2010-05-02 16:15:34 UTC (rev 263)
+++ komodo/SciViews-K/content/overlayMain.xul	2010-05-03 13:35:33 UTC (rev 264)
@@ -70,9 +70,10 @@
 	<broadcasterset id="broadcasterset_global">
 		<broadcaster id="sv_r_is_running" disabled="false"/>
 	</broadcasterset>
-
+<!-- PhG: commands updating disabled because it does not always work
+          => sometimes, required commands remain disabled!!!! -->
 	<commandset id="allcommands">
-		<commandset id="cmdset_rApp" commandupdater="true"
+		<commandset id="cmdset_rApp" commandupdater="false"
 			oncommandupdate="ko.commands.updateCommandset(this);"
 			events="r_app_started_closed">
 			<command id="cmd_sv_start_R" key="key_cmd_sv_start_R"
@@ -82,7 +83,7 @@
 				oncommand="ko.commands.doCommand('cmd_sv_quit_R');"
 				desc="R: &QuitR;" label="&QuitR;" accesskey="&QuitR.key;"/>
 			<command id="cmd_sv_OpenPkgManager" key="key_cmd_sv_OpenPkgManager"
-				oncommand="sv.command.openPkgManager();" disabled="true"
+				oncommand="sv.command.openPkgManager();" disabled="false"
 				desc="R: &pkgMgr;" label="&pkgMgr;" accesskey="&pkgMgr.key;"/>
 			<command id="cmd_sv_OpenHelp" key="key_cmd_sv_OpenHelp"
 				oncommand="sv.command.openHelp();"
@@ -95,7 +96,7 @@
 				desc="R: &svOpenSessMgr;" label="&svOpenSessMgr;" accesskey="&svOpenSessMgr.key;"/>
 		</commandset>
 
-		<commandset id="cmdset_r_control" commandupdater="true"
+		<commandset id="cmdset_r_control" commandupdater="false"
 		  events="current_view_language_changed,r_app_started_closed"
 		  oncommandupdate="ko.commands.updateCommandset(this);">
 			<command id="cmd_sv_RRunAll" key="key_cmd_sv_RRunAll"
@@ -133,7 +134,8 @@
 				oncommand="ko.commands.doCommand('cmd_sv_RSourceLineOrSelection')"
 				desc="R: &rSrcLineOrSelection;" label="&rSrcLineOrSelection;"
 				accesskey="&rSrcLineOrSelection.key;"/>
-			<commandset id="cmdset_r_control" commandupdater="true" events="select"
+			
+			<commandset id="cmdset_r_control" commandupdater="false" events="select"
 				oncommandupdate="ko.commands.updateCommandset(this);">
 				<command id="cmd_sv_RRunSelection" key="key_cmd_sv_RRunSelection"
 					oncommand="ko.commands.doCommand('cmd_sv_RRunSelection')"
@@ -180,8 +182,6 @@
 					class="menuitem-iconic r-run-command-icon"/>
 				<menuitem id="r_quit_console_menu" observes="cmd_sv_quit_R"
 					class="menuitem-iconic r-quit-command-icon"/>
-				<!--<menuitem id="r_update_charset" observes="cmd_sv_update_charset"
-					class="menuitem"/>-->
 				<menuitem id="r_start_pkg_manager" observes="cmd_sv_OpenPkgManager"
 					class="menuitem-iconic r-pkg-manager"/>
 				<menuitem id="r_start_help" observes="cmd_sv_OpenHelp"

Modified: komodo/SciViews-K/content/pref-R.xul
===================================================================
--- komodo/SciViews-K/content/pref-R.xul	2010-05-02 16:15:34 UTC (rev 263)
+++ komodo/SciViews-K/content/pref-R.xul	2010-05-03 13:35:33 UTC (rev 264)
@@ -80,42 +80,42 @@
 					<menuitem id="r-none" label=""
 						value="" app="?" which="" platform="Linux,Mac,Win"/>
 					<menuitem id="r-terminal" label="in default terminal"
-						value="&quot;%Path%R&quot; %quiet%" which="R"
-						platform="Linux,Mac"/>
+						value="&quot;%Path%&quot; %quiet%" app="R"
+						which="R" platform="Linux,Mac"/>
 					<menuitem id="r-terminal" label="in console window"
-						value="&quot;%Path%R.exe&quot; %quiet%" app="R.exe"
+						value="&quot;%Path%&quot; %quiet%" app="R.exe"
 						which="R" platform="Win"/>
-					<menuitem id="r-gnome-term" label="in Gnome terminal"
-						value="gnome-terminal --hide-menubar --title=%title% -x &quot;%Path%R&quot; %quiet%"
+					<menuitem id="r-gnome-term" label="in Gnome terminal" app="R"
+						value="gnome-terminal --hide-menubar --title=%title% -x &quot;%Path%&quot; %quiet%"
 						which="gnome-terminal,R" platform="Linux"/>
-					<menuitem id="r-kde-term" label="in Konsole"
-						value="konsole --workdir &quot;%cwd%&quot; --title %title% -e &quot;%Path%R&quot; %quiet%"
+					<menuitem id="r-kde-term" label="in Konsole" app="R"
+						value="konsole --workdir &quot;%cwd%&quot; --title %title% -e &quot;%Path%&quot; %quiet%"
 						which="konsole,R" platform="Linux"/>
-					<menuitem id="r-xfce4-term" label="in XFCE terminal"
-						value="xfce4-terminal --title &quot;%title%&quot; -x &quot;%Path%R&quot; %quiet%"
+					<menuitem id="r-xfce4-term" label="in XFCE terminal" app="R"
+						value="xfce4-terminal --title &quot;%title%&quot; -x &quot;%Path%&quot; %quiet%"
 						which="xfce4-terminal,R" platform="Linux"/>
 					<menuitem id="r-app" label="R app"
-						value="open -a &quot;/Applications/R.app&quot; &quot;%cwd%&quot;"
+						value="open -a &quot;%Path%&quot; &quot;%cwd%&quot;"
 						app="R.app"
 						which="/Applications/R.app" platform="Mac"/>
 					<menuitem id="r64-app" label="R64 app"
-						value="open -a &quot;/Applications/R64.app&quot; &quot;%cwd%&quot;"
+						value="open -a &quot;%Path%&quot; &quot;%cwd%&quot;"
 						app="R64.app"
 						which="/Applications/R64.app" platform="Mac"/>
 					<menuitem id="svr-app" label="SciViews R app"
-						value="open -a &quot;/Applications/SciViews R.app&quot; &quot;%cwd%&quot;"
+						value="open -a &quot;%Path%&quot; &quot;%cwd%&quot;"
 						app="SciViews R.app"
 						which="/Applications/SciViews R.app" platform="Mac"/>
 					<menuitem id="svr64-app" label="SciViews R64 app"
-						value="open -a &quot;/Applications/SciViews R64.app&quot; &quot;%cwd%&quot;"
+						value="open -a &quot;%Path%&quot; &quot;%cwd%&quot;"
 						app="SciViews R64.app"
 						which="/Applications/SciViews R64.app" platform="Mac"/>
 					<menuitem id="r-gui" label="R GUI"
 						app="Rgui.exe"
-						value="&quot;%Path%Rgui.exe&quot; --sdi %quiet%"
+						value="&quot;%Path%&quot; --sdi %quiet%"
 						which="Rgui" platform="Win"/>
 					<menuitem id="r-tk" label="R Tk GUI"
-						value="&quot;%Path%R&quot; --interactive --gui=Tk %quiet%"
+						value="&quot;%Path%&quot; --interactive --gui=Tk %quiet%" app="R"
 						which="R" platform="Linux,Mac"/>
 				</menupopup>
 			</menulist>
@@ -124,12 +124,12 @@
 		<hbox>
 			<textbox id="svRDefaultInterpreter" pref="true"
 				emptytext="No R installation found on the system!"
-				oninput="PrefR_svRApplicationOnSelect(event);"
+				oninput="PrefR_svRApplicationUpdate(event);"
 				editable="false" flex="1"/>
 			<button label="Browse..." oncommand="PrefR_setExecutable();"/>
 		</hbox>
 		<hbox align="center">
-			<checkbox id="svRQuiet" oninput="PrefR_svRApplicationOnSelect(event);"/>
+			<checkbox id="svRQuiet" oncommand="PrefR_svRApplicationUpdate(event);"/>
 			<label value="Run R quietly (no initial messages)"
 				control="svRQuiet" pref="false" />
 		</hbox>
@@ -138,7 +138,7 @@
 			<label class="label" control="R_command" crop="end"
 				value="This command will be used to start R (R -> Start R):"/>
 			<textbox id="R_command" value="" class="plain"
-				style="background: none; padding-top: 1px !important; margin-left: 10px !important;" />
+				style="background: none; padding-top: 1px !important; margin-left: 10px !important; color: rgb(184, 38, 25)" />
 		</vbox>
 	</groupbox>
 	

Modified: komodo/SciViews-K/defaults/.DS_Store
===================================================================
(Binary files differ)

Modified: komodo/SciViews-K/defaults/SciViews-K (0.9.15).kpz
===================================================================
(Binary files differ)

Deleted: komodo/SciViews-K/defaults/print.help_files_with_topic.R
===================================================================
--- komodo/SciViews-K/defaults/print.help_files_with_topic.R	2010-05-02 16:15:34 UTC (rev 263)
+++ komodo/SciViews-K/defaults/print.help_files_with_topic.R	2010-05-03 13:35:33 UTC (rev 264)
@@ -1,184 +0,0 @@
-# print method of object returned by help() is very unflexible for R.app and
-# does not allow in any way to use anything else than the R.app internal
-# browser for help!!!
-# That makes me very unhappy! Hey guys, I would like to use SciViews help
-# browser here! So, no other solution than to be even harsher, and to force
-# rewriting of the print function in base environment!!!
-# (problem emailed to Simon Urbanek on 03/11/2009... I hope he will propose
-# a work-around for this in R 2.10.1!!!)
-unlockBinding("print.help_files_with_topic", env = baseenv())
-assign("print.help_files_with_topic",
-function (x, ...)
-{
-    browser <- getOption("browser")
-    topic <- attr(x, "topic")
-    type <- attr(x, "type")
-	# This is the problematic code!
-    #if (.Platform$GUI == "AQUA" && type == "html") {
-    #    browser <- function(x, ...) {
-    #        .Internal(aqua.custom.print("help-files", x))
-    #        return(invisible(x))
-    #    }
-    #}
-    paths <- as.character(x)
-    if (!length(paths)) {
-        writeLines(c(gettextf("No documentation for '%s' in specified packages and libraries:",
-            topic), gettextf("you could try '??%s'", topic)))
-        return(invisible(x))
-    }
-    if (type == "html")
-        if (tools:::httpdPort == 0L)
-            tools::startDynamicHelp()
-    if (attr(x, "tried_all_packages")) {
-        paths <- unique(dirname(dirname(paths)))
-        msg <- gettextf("Help for topic '%s' is not in any loaded package but can be found in the following packages:",
-            topic)
-        if (type == "html" && tools:::httpdPort > 0L) {
-            path <- file.path(tempdir(), ".R/doc/html")
-            dir.create(path, recursive = TRUE, showWarnings = FALSE)
-            out <- paste("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n",
-                "<html><head><title>R: help</title>\n", "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=\"UTF-8\">\n",
-                "<link rel=\"stylesheet\" type=\"text/css\" href=\"/doc/html/R.css\">\n",
-                "</head><body>\n\n<hr>\n", sep = "")
-            out <- c(out, "<p>", msg, "</p><br>")
-            out <- c(out, "<table width=\"100%\" summary=\"R Package list\">\n",
-                "<tr align=\"left\" valign=\"top\">\n", "<td width=\"25%\">Package</td><td>Library</td></tr>\n")
-            pkgs <- basename(paths)
-            links <- paste("<a href=\"http://127.0.0.1:", tools:::httpdPort,
-                "/library/", pkgs, "/help/", topic, "\">", pkgs,
-                "</a>", sep = "")
-            out <- c(out, paste("<tr align=\"left\" valign=\"top\">\n",
-                "<td>", links, "</td><td>", dirname(paths), "</td></tr>\n",
-                sep = ""))
-            out <- c(out, "</table>\n</p>\n<hr>\n</body></html>")
-            writeLines(out, file.path(path, "all.available.html"))
-            browseURL(paste("http://127.0.0.1:", tools:::httpdPort,
-                "/doc/html/all.available.html", sep = ""), browser)
-        }
-        else {
-            writeLines(c(strwrap(msg), "", paste(" ", formatDL(c(gettext("Package"),
-                basename(paths)), c(gettext("Library"), dirname(paths)),
-                indent = 22))))
-        }
-    }
-    else {
-        if (length(paths) > 1L) {
-            if (type == "html" && tools:::httpdPort > 0L) {
-                browseURL(paste("http://127.0.0.1:", tools:::httpdPort,
-                  "/library/NULL/help/", topic, sep = ""), browser)
-                return(invisible(x))
-            }
-            file <- paths[1L]
-            p <- paths
-            msg <- gettextf("Help on topic '%s' was found in the following packages:",
-                topic)
-            paths <- dirname(dirname(paths))
-            txt <- formatDL(c("Package", basename(paths)), c("Library",
-                dirname(paths)), indent = 22L)
-            writeLines(c(strwrap(msg), "", paste(" ", txt), ""))
-            if (interactive()) {
-                fp <- file.path(paths, "Meta", "Rd.rds")
-                tp <- basename(p)
-                titles <- tp
-                if (type == "html" || type == "latex")
-                  tp <- tools::file_path_sans_ext(tp)
-                for (i in seq_along(fp)) {
-                  tmp <- try(.readRDS(fp[i]))
-                  titles[i] <- if (inherits(tmp, "try-error"))
-                    "unknown title"
-                  else tmp[tools::file_path_sans_ext(tmp$File) ==
-                    tp[i], "Title"]
-                }
-                txt <- paste(titles, " {", basename(paths), "}",
-                  sep = "")
-                res <- menu(txt, title = gettext("Choose one"),
-                  graphics = getOption("menu.graphics"))
-                if (res > 0)
-                  file <- p[res]
-            }
-            else {
-                writeLines(gettext("\nUsing the first match ..."))
-            }
-        }
-        else file <- paths
-        if (type == "html") {
-            if (tools:::httpdPort > 0L) {
-                path <- dirname(file)
-                dirpath <- dirname(path)
-                pkgname <- basename(dirpath)
-                browseURL(paste("http://127.0.0.1:", tools:::httpdPort,
-                  "/library/", pkgname, "/html/", basename(file),
-                  sep = ""), browser)
-            }
-            else {
-                warning("HTML help is unavailable", call. = FALSE)
-                att <- attributes(x)
-                xx <- sub("/html/([^/]*)\\.html$", "/help/\\1",
-                  x)
-                attributes(xx) <- att
-                attr(xx, "type") <- "text"
-                print(xx)
-            }
-        }
-        else if (type == "text") {
-            path <- dirname(file)
-            dirpath <- dirname(path)
-            pkgname <- basename(dirpath)
-            RdDB <- file.path(path, pkgname)
-            if (file.exists(paste(RdDB, "rdx", sep = "."))) {
-                temp <- tools::Rd2txt(tools:::fetchRdDB(RdDB,
-                  basename(file)), out = tempfile("Rtxt"), package = pkgname)
-                file.show(temp, title = gettextf("R Help on '%s'",
-                  topic), delete.file = TRUE)
-            }
-            else {
-                zfile <- zip.file.extract(file, "Rhelp.zip")
-                if (file.exists(zfile)) {
-                  first <- readLines(zfile, n = 1L)
-                  enc <- if (length(grep("\\(.*\\)$", first)))
-                    sub("[^(]*\\((.*)\\)$", "\\1", first)
-                  else ""
-                  if (enc == "utf8")
-                    enc <- "UTF-8"
-                  if (.Platform$OS.type == "windows"
-					  && enc == ""
-					  && l10n_info()$codepage < 1000)
-                    enc <- "CP1252"
-                  file.show(zfile, title = gettextf("R Help on '%s'",
-                    topic), delete.file = (zfile != file), encoding = enc)
-                }
-                else stop(gettextf("No text help for '%s' is available:\ncorresponding file is missing",
-                  topic), domain = NA)
-            }
-        }
-        else if (type %in% c("ps", "postscript", "pdf")) {
-            ok <- FALSE
-            zfile <- zip.file.extract(file, "Rhelp.zip")
-            if (zfile != file)
-                on.exit(unlink(zfile))
-            if (file.exists(zfile)) {
-                .show_help_on_topic_offline(zfile, topic, type)
-                ok <- TRUE
-            }
-            else {
-                path <- dirname(file)
-                dirpath <- dirname(path)
-                pkgname <- basename(dirpath)
-                RdDB <- file.path(dirpath, "help", pkgname)
-                if (file.exists(paste(RdDB, "rdx", sep = "."))) {
-                  key <- sub("\\.tex$", "", basename(file))
-                  tf2 <- tempfile("Rlatex")
-                  tools::Rd2latex(tools:::fetchRdDB(RdDB, key),
-                    tf2)
-                  .show_help_on_topic_offline(tf2, topic, type)
-                  ok <- TRUE
-                }
-            }
-            if (!ok)
-                stop(gettextf("No offline help for '%s' is available:\ncorresponding file is missing",
-                  topic), domain = NA)
-        }
-    }
-    invisible(x)
-}, envir = baseenv())
-lockBinding("print.help_files_with_topic", env = baseenv())
\ No newline at end of file

Added: komodo/SciViews-K/defaults/print.help_files_with_topic210.R
===================================================================
--- komodo/SciViews-K/defaults/print.help_files_with_topic210.R	                        (rev 0)
+++ komodo/SciViews-K/defaults/print.help_files_with_topic210.R	2010-05-03 13:35:33 UTC (rev 264)
@@ -0,0 +1,184 @@
+# print method of object returned by help() is very unflexible for R.app and
+# does not allow in any way to use anything else than the R.app internal
+# browser for help!!!
+# That makes me very unhappy! Hey guys, I would like to use SciViews help
+# browser here! So, no other solution than to be even harsher, and to force
+# rewriting of the print function in base environment!!!
+# (problem emailed to Simon Urbanek on 03/11/2009... I hope he will propose
+# a work-around for this in R 2.11!!!)
+unlockBinding("print.help_files_with_topic", env = baseenv())
+assign("print.help_files_with_topic",
+function (x, ...)
+{
+    browser <- getOption("browser")
+    topic <- attr(x, "topic")
+    type <- attr(x, "type")
+	# This is the problematic code!
+    #if (.Platform$GUI == "AQUA" && type == "html") {
+    #    browser <- function(x, ...) {
+    #        .Internal(aqua.custom.print("help-files", x))
+    #        return(invisible(x))
+    #    }
+    #}
+    paths <- as.character(x)
+    if (!length(paths)) {
+        writeLines(c(gettextf("No documentation for '%s' in specified packages and libraries:",
+            topic), gettextf("you could try '??%s'", topic)))
+        return(invisible(x))
+    }
+    if (type == "html")
+        if (tools:::httpdPort == 0L)
+            tools::startDynamicHelp()
+    if (attr(x, "tried_all_packages")) {
+        paths <- unique(dirname(dirname(paths)))
+        msg <- gettextf("Help for topic '%s' is not in any loaded package but can be found in the following packages:",
+            topic)
+        if (type == "html" && tools:::httpdPort > 0L) {
+            path <- file.path(tempdir(), ".R/doc/html")
+            dir.create(path, recursive = TRUE, showWarnings = FALSE)
+            out <- paste("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n",
+                "<html><head><title>R: help</title>\n", "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=\"UTF-8\">\n",
+                "<link rel=\"stylesheet\" type=\"text/css\" href=\"/doc/html/R.css\">\n",
+                "</head><body>\n\n<hr>\n", sep = "")
+            out <- c(out, "<p>", msg, "</p><br>")
+            out <- c(out, "<table width=\"100%\" summary=\"R Package list\">\n",
+                "<tr align=\"left\" valign=\"top\">\n", "<td width=\"25%\">Package</td><td>Library</td></tr>\n")
+            pkgs <- basename(paths)
+            links <- paste("<a href=\"http://127.0.0.1:", tools:::httpdPort,
+                "/library/", pkgs, "/help/", topic, "\">", pkgs,
+                "</a>", sep = "")
+            out <- c(out, paste("<tr align=\"left\" valign=\"top\">\n",
+                "<td>", links, "</td><td>", dirname(paths), "</td></tr>\n",
+                sep = ""))
+            out <- c(out, "</table>\n</p>\n<hr>\n</body></html>")
+            writeLines(out, file.path(path, "all.available.html"))
+            browseURL(paste("http://127.0.0.1:", tools:::httpdPort,
+                "/doc/html/all.available.html", sep = ""), browser)
+        }
+        else {
+            writeLines(c(strwrap(msg), "", paste(" ", formatDL(c(gettext("Package"),
+                basename(paths)), c(gettext("Library"), dirname(paths)),
+                indent = 22))))
+        }
+    }
+    else {
+        if (length(paths) > 1L) {
+            if (type == "html" && tools:::httpdPort > 0L) {
+                browseURL(paste("http://127.0.0.1:", tools:::httpdPort,
+                  "/library/NULL/help/", topic, sep = ""), browser)
+                return(invisible(x))
+            }
+            file <- paths[1L]
+            p <- paths
+            msg <- gettextf("Help on topic '%s' was found in the following packages:",
+                topic)
+            paths <- dirname(dirname(paths))
+            txt <- formatDL(c("Package", basename(paths)), c("Library",
+                dirname(paths)), indent = 22L)
+            writeLines(c(strwrap(msg), "", paste(" ", txt), ""))
+            if (interactive()) {
+                fp <- file.path(paths, "Meta", "Rd.rds")
+                tp <- basename(p)
+                titles <- tp
+                if (type == "html" || type == "latex")
+                  tp <- tools::file_path_sans_ext(tp)
+                for (i in seq_along(fp)) {
+                  tmp <- try(.readRDS(fp[i]))
+                  titles[i] <- if (inherits(tmp, "try-error"))
+                    "unknown title"
+                  else tmp[tools::file_path_sans_ext(tmp$File) ==
+                    tp[i], "Title"]
+                }
+                txt <- paste(titles, " {", basename(paths), "}",
+                  sep = "")
+                res <- menu(txt, title = gettext("Choose one"),
+                  graphics = getOption("menu.graphics"))
+                if (res > 0)
+                  file <- p[res]
+            }
+            else {
+                writeLines(gettext("\nUsing the first match ..."))
+            }
+        }
+        else file <- paths
+        if (type == "html") {
+            if (tools:::httpdPort > 0L) {
+                path <- dirname(file)
+                dirpath <- dirname(path)
+                pkgname <- basename(dirpath)
+                browseURL(paste("http://127.0.0.1:", tools:::httpdPort,
+                  "/library/", pkgname, "/html/", basename(file),
+                  sep = ""), browser)
+            }
+            else {
+                warning("HTML help is unavailable", call. = FALSE)
+                att <- attributes(x)
+                xx <- sub("/html/([^/]*)\\.html$", "/help/\\1",
+                  x)
+                attributes(xx) <- att
+                attr(xx, "type") <- "text"
+                print(xx)
+            }
+        }
+        else if (type == "text") {
+            path <- dirname(file)
+            dirpath <- dirname(path)
+            pkgname <- basename(dirpath)
+            RdDB <- file.path(path, pkgname)
+            if (file.exists(paste(RdDB, "rdx", sep = "."))) {
+                temp <- tools::Rd2txt(tools:::fetchRdDB(RdDB,
+                  basename(file)), out = tempfile("Rtxt"), package = pkgname)
+                file.show(temp, title = gettextf("R Help on '%s'",
+                  topic), delete.file = TRUE)
+            }
+            else {
+                zfile <- zip.file.extract(file, "Rhelp.zip")
+                if (file.exists(zfile)) {
+                  first <- readLines(zfile, n = 1L)
+                  enc <- if (length(grep("\\(.*\\)$", first)))
+                    sub("[^(]*\\((.*)\\)$", "\\1", first)
+                  else ""
+                  if (enc == "utf8")
+                    enc <- "UTF-8"
+                  if (.Platform$OS.type == "windows"
+					  && enc == ""
+					  && l10n_info()$codepage < 1000)
+                    enc <- "CP1252"
+                  file.show(zfile, title = gettextf("R Help on '%s'",
+                    topic), delete.file = (zfile != file), encoding = enc)
+                }
+                else stop(gettextf("No text help for '%s' is available:\ncorresponding file is missing",
+                  topic), domain = NA)
+            }
+        }
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/sciviews -r 264


More information about the Sciviews-commits mailing list