[Sciviews-commits] r53 - in komodo: . SciViews-K SciViews-K/content/js SciViews-K/templates

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Sep 3 00:27:10 CEST 2008


Author: phgrosjean
Date: 2008-09-03 00:27:09 +0200 (Wed, 03 Sep 2008)
New Revision: 53

Modified:
   komodo/SciViews-K/content/js/r.js
   komodo/SciViews-K/sciviewsk-0.6.4-ko.xpi
   komodo/SciViews-K/templates/.Rprofile
   komodo/SciViews-K/templates/SciViews-K.kpz
   komodo/TODO
Log:
R statup reworking (uses customized params now)

Modified: komodo/SciViews-K/content/js/r.js
===================================================================
--- komodo/SciViews-K/content/js/r.js	2008-09-01 10:54:03 UTC (rev 52)
+++ komodo/SciViews-K/content/js/r.js	2008-09-02 22:27:09 UTC (rev 53)
@@ -138,6 +138,9 @@
 			res = sv.r.eval('.odir <- setwd("' +
 				kv.document.file.dirName.replace(/\\/g, "//") + '")');
 		}
+	} else if (ask == "session") {
+		// Switch back to the session directory defined in 'R.initdir' option
+		res = sv.r.eval('.odir <- setwd(getOption("R.initdir"))');
 	} else if (ask == "previous") {
 		// Produce an error in R if .odir is not defined, but it is fine!
 		res = sv.r.eval('if (exists(".odir")) .odir <- setwd(.odir); getwd()');
@@ -531,7 +534,7 @@
   if (typeof(save) == "undefined") {
 	// Ask for saving or not
 	var response = ko.dialogs.customButtons("Do you want to save the workspace (.RData) " +
-	  "and the command history (.Rhistory) in the current directory first?",
+	  "and the command history (.Rhistory) in the session directory first?",
 	  ["Yes", "No", "Cancel"], // buttons
 	  "No", // default response
 	  null, // text

Modified: komodo/SciViews-K/sciviewsk-0.6.4-ko.xpi
===================================================================
(Binary files differ)

Modified: komodo/SciViews-K/templates/.Rprofile
===================================================================
--- komodo/SciViews-K/templates/.Rprofile	2008-09-01 10:54:03 UTC (rev 52)
+++ komodo/SciViews-K/templates/.Rprofile	2008-09-02 22:27:09 UTC (rev 53)
@@ -1,46 +1,100 @@
 ### SciViews install begin ###
 # SciViews-R installation and startup for running R with Komodo/SciViews-K
-# Version 0.6.4, 2008-08-18 Ph. Grosjean (phgrosjean at sciviews.org)
+# Version 0.6.6, 2008-09-02 Ph. Grosjean (phgrosjean at sciviews.org)
 
 # Make sure we don't process this twice in case of duplicate items in .Rprofile
 if (!exists(".SciViewsReady", envir = .GlobalEnv)) {
 	.SciViewsReady <- FALSE
-	minVersion <- c(R = "2.7.0", svMisc = "0.9-44", svSocket = "0.9-41", svGUI = "0.9-42")
+	minVersion <- c(R = "2.6.0", svMisc = "0.9-45", svSocket = "0.9-42", svGUI = "0.9-43")
 
-	# Get environment variables
-	args <- commandArgs()
+	# First of all, check R version... redefine compareVersion() because it is
+	# not defined in very old R versions... and thus we don't get an explicit
+	# error message in that particular case
+	checkVersion <- function (a, b) {
+		a <- as.integer(strsplit(a, "[\\.-]")[[1]])
+		b <- as.integer(strsplit(b, "[\\.-]")[[1]])
+		for (k in 1:length(a)) {
+			if (k <= length(b)) {
+				if (a[k] > b[k]) return(1)
+				else if (a[k] < b[k]) return(-1)
+			} else return(1)
+		}
+		if (length(b) > length(a)) return(-1) else return(0)
+	}
+	res <- checkVersion(paste(R.Version()$major, R.Version()$minor, sep = "."),
+		minVersion["R"])
+	rm(checkVersion)
+	if (res < 0) {
+		res <- FALSE
+		cat("R is too old for this version of SciViews (R >=",
+			minVersion["R"], "is needed), please, upgrade it\n")
+	} else res <- TRUE
 
-	## TODO: also check environment variables like:
-	#par <- Sys.getenv("ko.serve") (returns "" if not set)
-	# Configure socket client/server
-	par <- args[grep("^--ko.serve=", args)]
-	if (length(par) == 0) par <- 8888 else par <- as.integer(sub("^--ko.serve=", "", par))
-	options(ko.serve = par)			# Port used by the R socket server
-	par <- args[grep("^--ko.host=", args)]
-	if (length(par) == 0) par <- "localhost" else par <- sub("^--ko.host=", "", par)
-	options(ko.host = par)			# Machine where Komodo is running (local only for the moment)
-	par <- args[grep("^--ko.port=", args)]
-	if (length(par) == 0) par <- 7052 else par <- as.integer(sub("^--ko.port=", "", par))
-	options(ko.port = par)			# Port used by the Komodo socket server
-	par <- args[grep("^--ko.id=", args)]
-	if (length(par) == 0) par <- "R" else par <- sub("^--ko.id=", "", par)
-	options(ko.id = par)			# The id used for this R kernel in Komodo
-	rm(par)
-
-### If started --quiet, display a simplified message
-
 	# Load main R packages
-	res <- require(methods, quietly = TRUE)
+	if (res) res <- require(methods, quietly = TRUE)
 	if (res) res <- require(datasets, quietly = TRUE)
 	if (res) res <- require(utils, quietly = TRUE)
 	if (res) res <- require(grDevices, quietly = TRUE)
 	if (res) res <- require(graphics, quietly = TRUE)
 	if (res) res <- require(stats, quietly = TRUE)
+
+	# Get environment variables
 	if (res) {
+		args <- commandArgs()
+		# If started --quiet, display a simplified message
+		# but not if started -q, so that the user can still make it fully quiet!
+		par <- args[grep("^--quiet$", args)]
+		if (length(par) > 0) cat(R.version.string, "\n", sep = "")
+
+		# Collect SciViews socket client/server config from command line or vars
+		par <- args[grep("^--ko.serve=", args)]
+		if (length(par) == 0) par <- as.integer(Sys.getenv("koServe")) else
+			par <- as.integer(sub("^--ko.serve=", "", par))
+		if (is.na(par)) par <- 8888
+		options(ko.serve = par)		# Port used by the R socket server
+		par <- args[grep("^--ko.host=", args)]
+		if (length(par) == 0) par <- as.character(Sys.getenv("koHost")) else
+			par <- sub("^--ko.host=", "", par)
+		if (par == "") par <- "localhost"
+		options(ko.host = par)		# Machine where Komodo is running
+		par <- args[grep("^--ko.port=", args)]
+		if (length(par) == 0) par <- as.integer(Sys.getenv("koPort")) else
+			par <- as.integer(sub("^--ko.port=", "", par))
+		if (is.na(par)) par <- 7052
+		options(ko.port = par)		# Port used by the Komodo socket server
+		par <- args[grep("^--ko.id=", args)]
+		if (length(par) == 0) par <- as.character(Sys.getenv("koId")) else
+			par <- sub("^--ko.id=", "", par)
+		if (par == "") par <- "SciViewsK"
+		options(ko.id = par)		# The id used by Komodo
+		par <- args[grep("^--ko.activate=", args)]
+		if (length(par) == 0) par <- as.character(Sys.getenv("koActivate")) else
+			par <- sub("^--ko.activate=", "", par)
+		if (par == "") par <- "FALSE"
+		par <- (par[1] == "TRUE")
+		options(ko.activate = par)	# Do we reactivate Komodo?
+		par <- args[grep("^--R.id=", args)]
+		if (length(par) == 0) par <- as.character(Sys.getenv("Rid")) else
+			par <- sub("^--R.id=", "", par)
+		if (par == "") par <- "R"
+ 		options(R.id = par)			# The id used for this R kernel in Komodo
+		par <- args[grep("^--R.initdir=", args)]
+		if (length(par) == 0) par <- as.character(Sys.getenv("Rinitdir")) else
+			par <- sub("^--R.initdir=", "", par)
+		# If the initial directory is "", or it does not exist or it is not a dir
+		# we use the default home directory instead!
+		if (par == "" || !file.exists(par) || !file.info(par)$isdir) par <- "~"
+		options(R.initdir = par)	# The initial directory to use for R
+		# Note: the initial directory is used to load/save workspace and history
+		rm(par)
+	}
+
+	# Load tcltk package
+	if (res) {
 		if (capabilities("tcltk")) {
 			# Make sure tcltk can start: on Mac OS X < 10.5 only,
 			# that is, darwin < 9, we need to check that X11 is installed
-			# (optional!) and started!
+			# (optional component!) and started!
 			if (regexpr("^darwin[5-8]", R.Version()$os) > -1) {
 				# First, is the DISPLAY environment variable defined?
 				dis <- Sys.getenv("DISPLAY")
@@ -59,7 +113,9 @@
 						cat("'open-x11' not found. Make sure you installed X11\n")
 						cat("(see http://developer.apple.com/opensource/tools/runningx11.html\n")
 						res <- FALSE
-					} else {	# Make sure X11 is started (trick: we try opening a non X11 prog)
+					} else {	# Make sure X11 is started
+						# trick: we try opening a non X11 prog,
+						# effect is starting X11 alone
 						system("open-x11 more", intern = TRUE)
 					}
 				}
@@ -73,188 +129,231 @@
 					cat("and svGUI installed, restart R or type require(svGUI)\n")
 				}
 			}
-		} else cat("Tcl/Tk is required by SciViews, but it is not supported by this R installation\n")
+		} else cat("Tcl/Tk is required by SciViews,\nbut it is not supported by this R installation\n")
 	} else cat("Problem loading standard R packages, check R installation\n")
 
 	if (res) {
-		# Check for R version
-		res <- compareVersion(paste(R.Version()$major, R.Version()$minor,
-			sep = "."), minVersion["R"])
-		if (res < 0) {
-			cat("R is too old for this version of SciViews, please, upgrade it\n")
-		} else {
-			# Load packages svMisc, svSocket & svGUI (possibly after installing
-			# or upgrading them). User is supposed to agree with this install
-			# from the moment he tries to start and configure R from Komodo Edit
-			ext <- switch(.Platform$pkgType,
-				mac.binary = "\\.tgz",
-				win.binary = "\\.zip",
-				"\\.tar.gz")
+		# Load packages svMisc, svSocket & svGUI (possibly after installing
+		# or upgrading them). User is supposed to agree with this install
+		# from the moment he tries to start and configure R from Komodo Edit
+		ext <- switch(.Platform$pkgType,
+			mac.binary = "\\.tgz",
+			win.binary = "\\.zip",
+			"\\.tar.gz")
 
-			## svMisc
-			file <- dir(pattern = paste("svMisc", ext, sep = ".+"))
-			file <- sort(file)[length(file)]	# Keep oldest one
-			desc <- system.file("DESCRIPTION", package = "svMisc")
-			if (desc == "") {
-				cat("Installing missing package 'svMisc'\n")
+		## svMisc
+		file <- dir(pattern = paste("svMisc", ext, sep = ".+"))
+		file <- sort(file)[length(file)]	# Keep newest one found
+		desc <- system.file("DESCRIPTION", package = "svMisc")
+		if (desc == "") {
+			cat("Installing missing package 'svMisc'\n")
+			if (length(file)) {
+				install.packages(file, repos = NULL) # or use "http://R-Forge.R-project.org"
+				res <- require(svMisc, quietly = TRUE)
+			} else res <- FALSE
+		} else { # Check version
+			if ((compareVersion(packageDescription("svMisc", fields = "Version"),
+				minVersion["svMisc"]) < 0)) {
+				cat("Updating package 'svMisc'\n")
 				if (length(file)) {
-					install.packages(file, repos = NULL) # or use "http://R-Forge.R-project.org"
+					install.packages(file, repos = NULL)
 					res <- require(svMisc, quietly = TRUE)
 				} else res <- FALSE
-			} else { # Check version
-				if ((compareVersion(packageDescription("svMisc", fields = "Version"),
-					minVersion["svMisc"]) < 0)) {
-					cat("Updating package 'svMisc'\n")
-					if (length(file)) {
-						install.packages(file, repos = NULL)
-						res <- require(svMisc, quietly = TRUE)
-					} else res <- FALSE
-				} else res <- require(svMisc, quietly = TRUE)
-			}
+			} else res <- require(svMisc, quietly = TRUE)
+		}
 
-			## svSocket
-			file <- dir(pattern = paste("svSocket", ext, sep = ".+"))
-			file <- sort(file)[length(file)]	# Keep oldest one
-			desc <- system.file("DESCRIPTION", package = "svSocket")
-			if (desc == "") {
-				cat("Installing missing package 'svSocket'\n")
+		## svSocket
+		file <- dir(pattern = paste("svSocket", ext, sep = ".+"))
+		file <- sort(file)[length(file)]	# Keep newest one
+		desc <- system.file("DESCRIPTION", package = "svSocket")
+		if (desc == "") {
+			cat("Installing missing package 'svSocket'\n")
+			if (length(file)) {
+				install.packages(file, repos = NULL)
+				res[2] <- require(svSocket, quietly = TRUE)
+			} else res[2] <- FALSE
+		} else { # Check version
+			if ((compareVersion(packageDescription("svSocket", fields = "Version"),
+				minVersion["svSocket"]) < 0)) {
+				cat("Updating package 'svSocket'\n")
 				if (length(file)) {
 					install.packages(file, repos = NULL)
 					res[2] <- require(svSocket, quietly = TRUE)
 				} else res[2] <- FALSE
-			} else { # Check version
-				if ((compareVersion(packageDescription("svSocket", fields = "Version"),
-					minVersion["svSocket"]) < 0)) {
-					cat("Updating package 'svSocket'\n")
-					if (length(file)) {
-						install.packages(file, repos = NULL)
-						res[2] <- require(svSocket, quietly = TRUE)
-					} else res[2] <- FALSE
-				} else res[2] <- require(svSocket, quietly = TRUE)
-			}
+			} else res[2] <- require(svSocket, quietly = TRUE)
+		}
 
-			## svGUI
-			file <- dir(pattern = paste("svGUI", ext, sep = ".+"))
-			file <- sort(file)[length(file)]	# Keep oldest one
-			desc <- system.file("DESCRIPTION", package = "svGUI")
-			res[3] <- TRUE
-			if (desc == "") {
-				cat("Installing missing package 'svGUI'\n")
+		## svGUI
+		file <- dir(pattern = paste("svGUI", ext, sep = ".+"))
+		file <- sort(file)[length(file)]	# Keep newest one
+		desc <- system.file("DESCRIPTION", package = "svGUI")
+		res[3] <- TRUE
+		if (desc == "") {
+			cat("Installing missing package 'svGUI'\n")
+			if (length(file)) {
+				install.packages(file, repos = NULL)
+			} else res[3] <- FALSE
+		} else { # Check version
+			if ((compareVersion(packageDescription("svGUI", fields = "Version"),
+				minVersion["svGUI"]) < 0)) {
+				cat("Updating package 'svGUI'\n")
 				if (length(file)) {
 					install.packages(file, repos = NULL)
 				} else res[3] <- FALSE
-			} else { # Check version
-				if ((compareVersion(packageDescription("svGUI", fields = "Version"),
-					minVersion["svGUI"]) < 0)) {
-					cat("Updating package 'svGUI'\n")
-					if (length(file)) {
-						install.packages(file, repos = NULL)
-					} else res[3] <- FALSE
-				}
 			}
-			rm(desc, ext, file)
+		}
+		rm(desc, ext, file)
+		# Try starting the R socket server now
+		if (inherits(try(startSocketServer(port = getOption("ko.serve")),
+			silent = TRUE), "try-error")) {
+			cat("Impossible to start the SciViews R socket server\n(socket",
+				getOption("ko.serve"), "already in use?)\n")
+			cat("Solve the problem, then type: require(svGUI)\n")
+			cat("or choose a different port for the server in Komodo\n")
+		} else {
+			# Finally, load svGUI
+			if (res[3]) res[3] <- require(svGUI, quietly = TRUE)
 
-			# Try starting the R socket server
-			if (inherits(try(startSocketServer(port = getOption("ko.serve")),
-				silent = TRUE), "try-error")) {
-				cat("Impossible to start the SciViews R socket server\n(socket",
-					getOption("ko.serve"), "already in use?)\n")
-				cat("Solve the problem, then type: require(svGUI)\n")
+			if (all(res)) {
+				cat("R is SciViews ready!\n")
+				.SciViewsReady <- TRUE
+
+				# Indicate what we have as default packages
+				options(defaultPackages = c("datasets", "utils", "grDevices",
+					"graphics", "stats", "methods", "tcltk", "svMisc",
+					"svSocket", "svGUI"))
 			} else {
-				# Finally, load svGUI
-				if (res[3]) res[3] <- require(svGUI, quietly = TRUE)
-
-				if (all(res)) {
-					cat("R is SciViews ready!\n")
-					.SciViewsReady <- TRUE
-				} else {
-					cat("R is not SciViews ready, install latest svMisc, svSocket & svGUI packages\n")
-				}
+				cat("R is not SciViews ready, install latest svMisc, svSocket & svGUI packages\n")
 			}
 		}
 	}
+	res <- all(res)
 
-	# Make sure Komodo is started now
-	# Note: in Mac OS X, you have to create the symbolic link manually as explained
-	# in the Komodo Help with:
-	# sudo ln -s "/Applications/Komodo Edit.app/Contents/MacOS/komodo" /usr/local/bin/komodo
-	# You must issue something similar too under Linux (see Komodo installation guide)
-	# Or the script will complain.
+	if (res) {
+		# Make sure Komodo is started now
+		# Note: in Mac OS X, you have to create the symbolic link manually
+		# as explained in the Komodo Help with:
+		# sudo ln -s "/Applications/Komodo Edit.app/Contents/MacOS/komodo" /usr/local/bin/komodo
+		# You must issue something similar too under Linux
+		# (see Komodo installation guide) or the script will complain.
 
-	## Don't need this here, since R is supposed to be started from within Komodo!
-	#system("komodo", wait = FALSE)
+		# A custom pager consists in displaying the file in Komodo
+		svPager <- function (files, header, title, delete.file) {
+			# Note: header and title are NOT used here!
+			# Create full path for files in current directory
+			nodir <- dirname(files) == "."
+			files[nodir] <- file.path(getwd(), files[nodir])
+			# Make sure that files exists
+			if (!all(file.exists(files)))
+				warning("One or more files are not found on the disk!")
+			# We display those files using options(editor) settings
+			cmds <- paste(getOption("editor"), files)
+			for (cmd in cmds) {
+				res <- try(system(cmd), silent = TRUE)
+				if (inherits(res, "try-error"))
+					warning("Error running ", cmd)
+			}
+			# Do we delete these files?
+			# FIXME: if we delete the file, Komodo will not be able to read it
+			# so, currently, we don't delete the file (but need something else!)
+			#if (delete.file) unlink(files)
+		}
 
-	# Look if and where komodo is installed
-	if (.Platform$OS.type == "unix") {
-		Komodo <- "/usr/local/bin/komodo"
-		# Check that this file exists
-		if (!file.exists(Komodo)) {
-			# File not found, display a message with missing link
-			Komodo <- NULL
-			# TODO: look why I can't find Komodo on Linux Ubuntu
-			#cat("Komodo is not found by R. Please, follow instructions at\n",
-			#	"http://www.sciviews.org/SciViews-K to install it correctly.\n",
-			#	"In particular, you must create a symbolic link in /user/local/bin:\n",
-			#	"sudo ln -s <KomodoBinLocation>/komodo /usr/local/bin/komodo\n",
-			#	"otherwise, R cannot find it!\n")
+		# Look if and where komodo is installed
+		if (.Platform$OS.type == "unix") {
+			Komodo <- "/usr/local/bin/komodo"	# Link should be created!
+			# Check that this file exists
+			if (!file.exists(Komodo)) {
+				# File not found, display a message with missing link
+				Komodo <- NULL
+				cat("Komodo is not found by R. Please, follow instructions at\n",
+					"http://www.sciviews.org/SciViews-K to install it correctly.\n",
+					"In particular, you must create a symbolic link in /user/local/bin:\n",
+					"sudo ln -s <KomodoBinLocation>/komodo /usr/local/bin/komodo\n",
+					"otherwise, R cannot find it!\n")
+			} else {
+				# Change the editor and the pager to Komodo
+				options(editor = Komodo)
+				options(pager = svPager)
+			}
 		} else {
-			# Change the editor and the pager to Komodo
-			options(editor = Komodo)
-			#TODO: we need something else here: options(pager = Komodo)
+			Komodo <- "komodo"	# On Windows, 'komodo' should be enough
+			# But for reasons that escape me, komodo seems to stip off its own
+			# directory from the path variable. So, I have to restore it from
+			# the Windows registry :-(
+			Ret <- tclRequire("registry", warn = TRUE)
+			Path <- tclvalue(.Tcl("registry get {HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment} {Path}"))
+			if (!is.null(Path) && !is.na(Path) && Path != "")
+				Sys.setenv(path = Path)
+			rm(Ret, Path)
+			owarn <- getOption("warn")
+			options(warn = -1)
+			# Try to run Komodo now
+			res <- try(system(Komodo, wait = FALSE), silent = TRUE)
+			if (res == -1) {
+				Komodo <- NULL
+				cat("R cannot find Komodo. Please, make sure you install it correctly\n",
+					"You can find it at http://www.activestate.com/Products/komodo_edit.\n")
+			} else {
+				# Change the editor and the pager to Komodo
+				options(editor = Komodo)
+				options(pager = svPager)
+			}
+			options(warn = owarn)
+			rm(owarn)
 		}
-	} else {
-		# TODO: this does not seem to work, becasue the path with spaces is not recognized?
-		Komodo <- "komodo"	# On Windows, 'komodo' should be enough
-		owarn <- getOption("warn")
-		options(warn = -1)
-		res <- try(system(Komodo, wait = FALSE), silent = TRUE)
-		if (res == -1) {
-			Komodo <- NULL
-		#	cat("R cannot find Komodo. Please, make sure you install it correctly\n",
-		#		"You can find it at http://www.activestate.com/Products/komodo_edit.\n")
-		} else {
-			# Change the editor and the pager to Komodo
-			options(editor = Komodo)
-			#TODO: we need something else here: options(pager = Komodo)
-		}
-		options(warn = owarn)
-		rm(owarn)
-	}
-	rm(minVersion, res)
+		rm(minVersion, res, svPager)
 
-	# Change the working directory to the users working dir (by default) or to
-	# the directory that is specified in --dir=
-	dir <- args[grep("^--dir=", args)]
-	if (length(dir) == 0) {
-		dir <- "~"	# Use home directory as default one
-	} else dir <- sub("^--dir=", "", dir)
-	setwd(dir)
+		# Make sure we use HTML help (required for Shift-F1 and Alt-Shift-F1)
+		# to display R help in Komodo Edit (in Windows, chmhelp is the default)
+		if (.Platform$OS.type == "windows") options(chmhelp = FALSE)
+		options(htmlhelp = TRUE)
 
-	# Do we load .RData and .Rhistory?
-	if (!"--no-restore" %in% args && !"--no.restore-data" %in% args)
-		if (file.exists(".RData")) load(".RData")
-	if (!"--no-restore" %in% args && !"--no.restore-history" %in% args)
-		if (file.exists(".Rhistory")) loadhistory()
+		# Change the working directory to the provided directory
+		setwd(getOption("R.initdir"))
 
-	# Do we reactivate Komodo now?
-	koact <- getOption("ko.activate")
-	if (is.null(koact)) {
-		koact <- "--ko-activate" %in% args
-		options(ko.activate = koact)
-	}
-	if (.SciViewsReady && isTRUE(koact)) {
-		if ((.Platform$pkgType == "mac.binary")) {
-			system("osascript -e 'tell application \"Komodo\" to activate'",
-				intern = TRUE)
-		} else if (!is.null(Komodo)) {
-			# TODO: The following start komodo if not started yet, but does not activate it!
-			system(Komodo, wait = FALSE)
+		# Create a .Last.sys function that clears some variables in .GlobalEnv
+		# and then, switch to R.initdir before closing R. The function is stored
+		# in TempEnv()
+		assignTemp(".Last.sys", function () {
+			# Eliminate some known hidden variables from .GlobalEnv to prevent
+			# saving them in the .RData file
+			if (exists(".required", envir = .GlobalEnv, inherits = FALSE))
+				rm(.required, envir = .GlobalEnv, inherits = FALSE)
+			if (exists(".SciViewsReady", envir = .GlobalEnv, inherits = FALSE))
+				rm(.SciViewsReady, envir = .GlobalEnv, inherits = FALSE)
+			# If a R.initdir is defined, make sure to switch to it, so that
+			# the session's workspace and command history are written at the
+			# right place (in case of error, no change is made!)
+			try(setwd(getOption("R.initdir")), silent = TRUE)
+		})
+
+		# Do we load .RData and .Rhistory now?
+		if (!"--vanilla" %in% args && !"--no-restore" %in% args &&
+			!"--no.restore-data" %in% args)
+				if (file.exists(".RData")) load(".RData")
+		if (!"--vanilla" %in% args && !"--no-restore" %in% args &&
+			!"--no.restore-history" %in% args)
+				if (file.exists(".Rhistory")) loadhistory()
+
+		# Do we reactivate Komodo now?
+		koact <- getOption("ko.activate")
+		if (.SciViewsReady && isTRUE(koact)) {
+			if ((.Platform$pkgType == "mac.binary")) {
+				system("osascript -e 'tell application \"Komodo\" to activate'",
+					wait = FALSE)
+			} else if (!is.null(Komodo)) {
+				# TODO: The following starts komodo if not started yet, but does not activate it!
+				system(Komodo, wait = FALSE)
+			}
+			# Indicate to Komodo that R is ready
+			# And test also communication from R to Komodo!
+			koCmd('ko.statusBar.AddMessage("<<<data>>>", "R", 10000, true);',
+				data = paste("'", getOption("R.id"), "' (R ", R.Version()$major, ".",
+				R.Version()$minor, ") connected. Initial dir: ",
+				path.expand(getOption("R.initdir")), sep = ""))
 		}
-		# Indicate to Komodo that R is ready
-		koCmd('ko.statusBar.AddMessage("<<<data>>>", "R", 10000, true);',
-			data = paste("'", getOption("ko.id"), "' (R ", R.Version()$major, ".",
-			R.Version()$minor, ") connected", sep = ""))
+		rm(koact, Komodo, args)
 	}
-	rm(koact, Komodo, args, dir)
 }
 ### SciViews install end ###
\ No newline at end of file

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

Modified: komodo/TODO
===================================================================
--- komodo/TODO	2008-09-01 10:54:03 UTC (rev 52)
+++ komodo/TODO	2008-09-02 22:27:09 UTC (rev 53)
@@ -1,5 +1,14 @@
 = SciViews-K To Do
 
+* There is a bug with the abbrev expansion that prevents correct detection of
+abbrev when the file is not saved or saved with a different extension than .R
+
+* Files with .R extension are recognized as REBOL files!
+
+* Pager currently display the file in a buffer and does not use title or
+delete.file (file not deleted!). Try using a web browser instead, with
+correct title and look for a method to allow deleting the file
+
 * Object explorer: refresh content, tooltip, menu, changer fonction refresh
 
 * svIO and svViews in relation to objects explorer
@@ -8,6 +17,8 @@
 
 * A more convenient Help page + rework R Help/R Help Search (external)
 
+* Add R language entry in Help menu
+
 * GUI for vignettes and demos
 
 * doBraceMatch()
@@ -26,8 +37,6 @@
 
 * Configuration of R when started from .RData files.
 
-* Button for loading/saving workspace and history
-
 * R reference cards
 
 * R completion
@@ -38,8 +47,10 @@
 
 * Make ESS functions + the ESS GUI
 
-* Make R and Rd syntax highlighting; sweave later on
+* Make Rd syntax highlighting; sweave later on
 
+* R Linter
+
 * Projects in packages (developments and binaries) + SciViews-K Unit features
 
 * Make the User's and Developer's manuals



More information about the Sciviews-commits mailing list