[Sciviews-commits] r548 - in pkg: svKomodo svKomodo/R svKomodo/inst svMisc svMisc/R svMisc/man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Mar 2 08:06:56 CET 2014


Author: phgrosjean
Date: 2014-03-02 08:06:51 +0100 (Sun, 02 Mar 2014)
New Revision: 548

Modified:
   pkg/svKomodo/NAMESPACE
   pkg/svKomodo/NEWS
   pkg/svKomodo/R/svKomodo-internal.R
   pkg/svKomodo/inst/NEWS.Rd
   pkg/svMisc/DESCRIPTION
   pkg/svMisc/NEWS
   pkg/svMisc/R/completion.R
   pkg/svMisc/R/descFun.R
   pkg/svMisc/R/isHelp.R
   pkg/svMisc/R/pkgMan.R
   pkg/svMisc/man/svMisc-package.Rd
Log:
svMisc reworked to eliminate use of :::. IN svKomodo, utils::rc.settings() set on attaching and reset when unloading

Modified: pkg/svKomodo/NAMESPACE
===================================================================
--- pkg/svKomodo/NAMESPACE	2014-03-01 21:01:00 UTC (rev 547)
+++ pkg/svKomodo/NAMESPACE	2014-03-02 07:06:51 UTC (rev 548)
@@ -1,4 +1,4 @@
-importFrom(utils, capture.output)
+importFrom(utils, capture.output, rc.settings)
 import(svMisc)
 
 export(koInstall,

Modified: pkg/svKomodo/NEWS
===================================================================
--- pkg/svKomodo/NEWS	2014-03-01 21:01:00 UTC (rev 547)
+++ pkg/svKomodo/NEWS	2014-03-02 07:06:51 UTC (rev 548)
@@ -6,7 +6,9 @@
 
 * .onAttach() reworked to eliminate ::: (not allowed by CRAN)
 
+* utils::rc.settings are adjusted in .onAttach() and restored in .onUnload()
 
+
 == Changes in svKomodo 0.9-61
 
 * Simplification of internal code to get Komodo location. It does not require

Modified: pkg/svKomodo/R/svKomodo-internal.R
===================================================================
--- pkg/svKomodo/R/svKomodo-internal.R	2014-03-01 21:01:00 UTC (rev 547)
+++ pkg/svKomodo/R/svKomodo-internal.R	2014-03-02 07:06:51 UTC (rev 548)
@@ -114,6 +114,10 @@
 	## Make sure config is OK
 	.loadSvOptions()
 	
+	## Check that usually inactivated rc.settings are set
+	assignTemp(".old.rc.settings", rc.settings())
+	rc.settings(ipck = TRUE)
+	
 	## Create our SciViews task callback manager
 	## Should eliminate this???
 	## PhG: inactivated for now, because it makes problems in R!!!
@@ -466,6 +470,11 @@
 	## Remove the SciViews task callback manager
 	try(removeTaskCallback("SV-taskCallbackManager"), silent = TRUE)
 	try(rmTemp(".svTaskCallbackManager"), silent = TRUE)
+	
+	## Restore rc.settings
+	settings <- getTemp(".old.rc.settings", rc.settings())
+	do.call("rc.settings", as.list(settings))
+	rmTemp(".old.rc.settings")
 }
 
 .packageName <- "svKomodo"

Modified: pkg/svKomodo/inst/NEWS.Rd
===================================================================
--- pkg/svKomodo/inst/NEWS.Rd	2014-03-01 21:01:00 UTC (rev 547)
+++ pkg/svKomodo/inst/NEWS.Rd	2014-03-02 07:06:51 UTC (rev 548)
@@ -5,6 +5,8 @@
   \itemize{
     \item{ Author field rebuild in DESCRIPTION file }
     \item{ \code{.onAttach()} reworked to eliminate \code{:::} (not allowed by CRAN) }
+	\item{ \code{utils::rc.settings} are adjusted in \code{.onAttach()} and
+	  restored in \code{.onUnload()} }
   }
 }
 

Modified: pkg/svMisc/DESCRIPTION
===================================================================
--- pkg/svMisc/DESCRIPTION	2014-03-01 21:01:00 UTC (rev 547)
+++ pkg/svMisc/DESCRIPTION	2014-03-02 07:06:51 UTC (rev 548)
@@ -1,7 +1,7 @@
 Package: svMisc
 Type: Package
 Version: 0.9-70
-Date: 2013-11-30
+Date: 2014-03-01
 Title: SciViews GUI API - Miscellaneous functions
 Authors at R: c(person("Philippe", "Grosjean", role = c("aut", "cre"),
   email = "phgrosjean at sciviews.org"),

Modified: pkg/svMisc/NEWS
===================================================================
--- pkg/svMisc/NEWS	2014-03-01 21:01:00 UTC (rev 547)
+++ pkg/svMisc/NEWS	2014-03-02 07:06:51 UTC (rev 548)
@@ -8,7 +8,9 @@
   
 * Function pkg() is renamed package().
 
+* Reworked code that was using :::.
 
+
 == Changes in svMisc 0.9-69
 
 * On Mac OS X >= 10.7, the package could not load because of a warning

Modified: pkg/svMisc/R/completion.R
===================================================================
--- pkg/svMisc/R/completion.R	2014-03-01 21:01:00 UTC (rev 547)
+++ pkg/svMisc/R/completion.R	2014-03-02 07:06:51 UTC (rev 548)
@@ -1,4 +1,3 @@
-## TODO: activate rc.settings(ipck = TRUE) and rc.settings(files = TRUE)
 completion <- function (code, pos = nchar(code), min.length = 2,
 print = FALSE, types = c("default", "scintilla"), addition = FALSE, sort = TRUE,
 what = c("arguments", "functions", "packages"), description = FALSE,
@@ -40,8 +39,7 @@
 
 			## Deal with argument completions (ending with " = ")
 			if (length(test.arg <- grep(" = ", completions))) {
-				## TODO: avoid using ::: here!
-				fun <- utils:::.CompletionEnv[["fguess"]]
+				fun <- getNamespace("utils")$.CompletionEnv[["fguess"]]
 				ret[test.arg, "context"] <- fun
 				ret[test.arg, "desc"] <- descArgs(fun,
 					sub(" = $", "", completions[test.arg]))	
@@ -126,10 +124,8 @@
 					ret$context, sep = field.sep), sep = sep)
 			}
 			if (sep != "\n") cat("\n")
-			return(invisible(ret))
-		} else {
-			return(ret)
-		}
+			invisible(ret)
+		} else ret
 	}
 
 	## Do we return the type of the entry, and if yes, in which format?
@@ -172,8 +168,8 @@
 	} else dblBrackets <- FALSE
 	
 	## Save funarg.suffix and use " = " locally
-	## TODO: do not use ::: here!
-	ComplEnv <- utils:::.CompletionEnv
+	utilsNS <- getNamespace("utils")
+	ComplEnv <- utilsNS$.CompletionEnv
 	opts <- ComplEnv$options
 	funarg.suffix <- opts$funarg.suffix
 	on.exit({
@@ -184,14 +180,12 @@
 	ComplEnv$options <- opts
 
 	## Calculate completion with standard R completion tools
-	## TODO: do not use ::: here!
-	utils:::.assignLinebuffer(code)
-	utils:::.assignEnd(pos)
-	utils:::.guessTokenFromLine()
+	utilsNS$.assignLinebuffer(code)
+	utilsNS$.assignEnd(pos)
+	utilsNS$.guessTokenFromLine()
 	## The standard utils:::.completeToken() is replaced by our own version:
 	.completeTokenExt()
-	## TODO: do not use ::: here!
-	completions <- utils:::.retrieveCompletions()
+	completions <- utilsNS$.retrieveCompletions()
 	triggerPos <- pos - ComplEnv[["start"]]
 	token <- ComplEnv[["token"]]
 
@@ -274,11 +268,13 @@
 ## (checked equivalent with R 2.11.1)
 ## Only difference: it also gets current arguments list (if applicable).
 ## They are assigned to utils:::.CompletionEnv$funargs
-## TODO: avoid using ::: in the code of a package!
 .inFunctionExt <-
-function (line = utils:::.CompletionEnv[["linebuffer"]],
-cursor = utils:::.CompletionEnv[["start"]])
+function (line, cursor)
 {
+	utilsNS <- getNamespace("utils")
+	if (missing(line)) line <- utilsNS$.CompletionEnv[["linebuffer"]]
+	if (missing(cursor)) cursor <- utilsNS$.CompletionEnv[["start"]]
+		
 	parens <- sapply(c("(", ")"), function(s)
 		gregexpr(s, substr(line, 1L, cursor), fixed = TRUE)[[1L]],
 		simplify = FALSE)
@@ -295,7 +291,7 @@
 		suffix <- substr(line, index + 1L, cursor + 1L)
 		if ((length(grep("=", suffix, fixed = TRUE)) == 0L) &&
 			(length(grep(",", suffix, fixed = TRUE)) == 0L))
-			utils:::setIsFirstArg(v = TRUE)
+			utilsNS$setIsFirstArg(v = TRUE)
 		if ((length(grep("=", suffix, fixed = TRUE))) && (length(grep(",",
 			substr(suffix, tail(gregexpr("=", suffix, fixed = TRUE)[[1L]],
 			1L), 1000000L), fixed = TRUE)) == 0L)) {
@@ -314,13 +310,13 @@
 			}
 			funargs <- strsplit(funargs, "\\s*,\\s*", perl=TRUE)[[1]]
 			funargs <- unname(sapply(funargs, sub, pattern = "\\s*=.*$",
-				replacement = utils:::.CompletionEnv$options$funarg.suffix,
+				replacement = utilsNS$.CompletionEnv$options$funarg.suffix,
 					perl=TRUE))
-			assign("funargs", funargs, utils:::.CompletionEnv)
+			assign("funargs", funargs, utilsNS$.CompletionEnv)
 			## TODO: how to take non named arguments into account too?
 			## ... addition ends here
 
-			possible <- suppressWarnings(strsplit(prefix, utils:::breakRE,
+			possible <- suppressWarnings(strsplit(prefix, utilsNS$breakRE,
 				perl = TRUE))[[1L]]
 			possible <- possible[possible != ""]
 			if (length(possible)) {
@@ -339,24 +335,25 @@
 ## Main difference is that calls .inFunctionExt instead of utils:::inFunction
 ## and it also makes sure completion is for Complete in 'Complete("anova(", )'!
 .completeTokenExt <- function () {
-	ComplEnv <- utils:::.CompletionEnv
+	utilsNS <- getNamespace("utils")
+	ComplEnv <- utilsNS$.CompletionEnv
 	text <- ComplEnv$token
 	linebuffer <- ComplEnv$linebuffer
 	st <- ComplEnv$start
 
-	if (utils:::isInsideQuotes()) {
+	if (utilsNS$isInsideQuotes()) {
 		probablyNotFilename <- (st > 2L &&
 			(substr(linebuffer, st - 1L, st - 1L) %in% c("[", ":", "$")))
 		if (ComplEnv$settings[["files"]]) {
 			if (probablyNotFilename) {
 				ComplEnv[["comps"]] <- character(0L)
 			} else {
-				ComplEnv[["comps"]] <- utils:::fileCompletions(text)
+				ComplEnv[["comps"]] <- utilsNS$fileCompletions(text)
 			}
-			utils:::.setFileComp(FALSE)
+			utilsNS$.setFileComp(FALSE)
 		} else {
 			ComplEnv[["comps"]] <- character(0L)
-			utils:::.setFileComp(TRUE)
+			utilsNS$.setFileComp(TRUE)
 		}
 	} else {
 
@@ -375,8 +372,8 @@
 		}
 		## ... additions until here
 
-		utils:::.setFileComp(FALSE)
-		utils:::setIsFirstArg(FALSE)
+		utilsNS$.setFileComp(FALSE)
+		utilsNS$setIsFirstArg(FALSE)
 		guessedFunction <- ""
 		if (ComplEnv$settings[["args"]]) {
 			## Call of .inFunctionExt() instead of utils:::inFunction()
@@ -386,9 +383,9 @@
 		}
 
 		assign("fguess", guessedFunction, ComplEnv)
-		fargComps <- utils:::functionArgs(guessedFunction, text)
+		fargComps <- utilsNS$functionArgs(guessedFunction, text)
 
-		if (utils:::getIsFirstArg() && length(guessedFunction) &&
+		if (utilsNS$getIsFirstArg() && length(guessedFunction) &&
 			guessedFunction %in% c("library", "require", "data")) {
 			assign("comps", fargComps, ComplEnv)
 			return()
@@ -398,15 +395,15 @@
 			prefix <- substr(text, 1L, lastArithOp)
 			text <- substr(text, lastArithOp + 1L, 1000000L)
 		}
-		spl <- utils:::specialOpLocs(text)
+		spl <- utilsNS$specialOpLocs(text)
 		if (length(spl)) {
-			comps <- utils:::specialCompletions(text, spl)
+			comps <- utilsNS$specialCompletions(text, spl)
 		} else {
 			appendFunctionSuffix <- !any(guessedFunction %in%
 				c("help", "args", "formals", "example", "do.call",
 				"environment", "page", "apply", "sapply", "lapply",
 				"tapply", "mapply", "methods", "fix", "edit"))
-			comps <- utils:::normalCompletions(text,
+			comps <- utilsNS$normalCompletions(text,
 				check.mode = appendFunctionSuffix)
 		}
 		if (haveArithOp && length(comps))

Modified: pkg/svMisc/R/descFun.R
===================================================================
--- pkg/svMisc/R/descFun.R	2014-03-01 21:01:00 UTC (rev 547)
+++ pkg/svMisc/R/descFun.R	2014-03-02 07:06:51 UTC (rev 548)
@@ -20,8 +20,7 @@
 		file <- as.character(file)
 		if (length(file) > 0) {
 			## Read the Rd file and get the title section out of it
-			## TODO: avoid this!
-			Rdoc <- utils:::.getHelpFile(file[1L])
+			Rdoc <- getNamespace("utils")$.getHelpFile(file[1L])
 			## Look for the \title tag
 			j <- 0
 			for (j in seq_along(Rdoc))
@@ -54,8 +53,7 @@
     if (!file.exists(paste(RdDB, "rdx", sep=".")))
     	return(character(length(args)))
     
-    ## TODO: avoid this!
-	rd <- tools:::fetchRdDB(RdDB, basename(file))
+	rd <- getNamespace("tools")$fetchRdDB(RdDB, basename(file))
     
     ## This is not exported from tools
     RdTags <- function (Rd) {

Modified: pkg/svMisc/R/isHelp.R
===================================================================
--- pkg/svMisc/R/isHelp.R	2014-03-01 21:01:00 UTC (rev 547)
+++ pkg/svMisc/R/isHelp.R	2014-03-02 07:06:51 UTC (rev 548)
@@ -5,8 +5,8 @@
     if (!is.character(topic))  topic <- deparse(topic)[1L]
     
 	pkgpaths <- find.package(package, lib.loc, verbose = FALSE)
-    ## TODO: avoid using :::
-	file <- utils:::index.search(topic, pkgpaths, TRUE)
+	utilsNS <- getNamespace("utils")
+	file <- utilsNS$index.search(topic, pkgpaths, TRUE)
     if (!length(file)) return(c(help = FALSE, example = FALSE))
     
 	packagePath <- dirname(dirname(file))
@@ -16,8 +16,7 @@
     tf <- tempfile("Rex")
 	on.exit(unlink(tf))
     encoding <- "UTF-8"
-    ## TODO: avoid using :::
-	tools::Rd2ex(utils:::.getHelpFile(file), tf)
+	tools::Rd2ex(utilsNS$.getHelpFile(file), tf)
     if (!file.exists(tf)) {
         c(help = TRUE, example = FALSE)
     } else c(help = TRUE, example = TRUE)

Modified: pkg/svMisc/R/pkgMan.R
===================================================================
--- pkg/svMisc/R/pkgMan.R	2014-03-01 21:01:00 UTC (rev 547)
+++ pkg/svMisc/R/pkgMan.R	2014-03-02 07:06:51 UTC (rev 548)
@@ -23,8 +23,8 @@
 	if (isTRUE(print.it)) {
 		write.dcf(as.data.frame.list(desc[!sapply(desc, is.na)],
 			optional = TRUE), width = Inf)
-		return(invisible(desc))
-	} else return(desc)
+		invisible(desc)
+	} else desc
 }
 
 pkgManGetMirrors <- function ()
@@ -93,7 +93,6 @@
 		imax <- nrow(avpkg.list)
 		idx <- seq(imax)
 	}
-	#browser()
 	assignTemp('avpkg.pattern', pattern)
 
 	if (page == "next") {
@@ -133,8 +132,7 @@
 
 pkgManInstall <- function (pkgs, install.deps = FALSE, ask = TRUE)
 {
-	## TODO: avoid using ::: !
-	dep <- suppressMessages(utils:::getDependencies(pkgs,
+	dep <- suppressMessages(getNamespace("utils")$getDependencies(pkgs,
 		available = getTemp('avpkg.list')))
 	msg <- status <- ""
 	if (!isTRUE(ask) && (isTRUE(install.deps) || all(dep %in% pkgs))) {
@@ -147,10 +145,8 @@
 			"This will install packages: %s and %s.",
 		), paste(sQuote(dep[-l]), collapse = ", "), sQuote(dep[l]))
 		status <- "question"
-
 	}
-	return(list(packages = dep, message = msg, status = status))
-	#return(invisible(dep))
+	list(packages = dep, message = msg, status = status)
 }
 
 pkgManRemove <- function (pkgName)
@@ -170,10 +166,10 @@
 		pkglib <- normalizePath(file.path(pkgpath, ".."))
 		if (file.access(pkglib, 2) == 0) {
 			remove.packages(pkgName, lib = pkglib)
-			return(TRUE)
+			TRUE
 		} else {
 			#warning("No sufficient access rights to library", sQuote(pkglib))
-			return(FALSE)
+			FALSE
 		}
 	}, simplify = FALSE)
 }
@@ -192,7 +188,7 @@
 			if (packSearchName %in% search())
 				detach(packSearchName, character.only = TRUE, unload = TRUE)
 			if(pkgName %in% loadedNamespaces()) unloadNamespace(pkgName)
-			return(TRUE)
+			TRUE
 		}, error = function(e) { conditionMessage(e) })
 	}, simplify = FALSE)
 }

Modified: pkg/svMisc/man/svMisc-package.Rd
===================================================================
--- pkg/svMisc/man/svMisc-package.Rd	2014-03-01 21:01:00 UTC (rev 547)
+++ pkg/svMisc/man/svMisc-package.Rd	2014-03-02 07:06:51 UTC (rev 548)
@@ -13,7 +13,7 @@
     Package: \tab svMisc\cr
     Type: \tab Package\cr
     Version: \tab 0.9-70\cr
-    Date: \tab 2013-11-30\cr
+    Date: \tab 2014-03-01\cr
     License: \tab GPL 2 or above, at your convenience\cr
   }
   % TODO: add description of main functions here. Also add examples



More information about the Sciviews-commits mailing list