[Sciviews-commits] r527 - komodo/SciViews-K/defaults pkg/svKomodo pkg/svKomodo/R pkg/svKomodo/inst pkg/svKomodo/man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Feb 11 22:07:56 CET 2013
Author: phgrosjean
Date: 2013-02-11 22:07:56 +0100 (Mon, 11 Feb 2013)
New Revision: 527
Modified:
komodo/SciViews-K/defaults/svStart.R
pkg/svKomodo/DESCRIPTION
pkg/svKomodo/NEWS
pkg/svKomodo/R/svKomodo-internal.R
pkg/svKomodo/inst/NEWS.Rd
pkg/svKomodo/man/svKomodo-package.Rd
Log:
svStart() and .onAttach() in svKomodo adapted for better handling of locate in Mac OS X
Modified: komodo/SciViews-K/defaults/svStart.R
===================================================================
--- komodo/SciViews-K/defaults/svStart.R 2013-01-30 15:02:47 UTC (rev 526)
+++ komodo/SciViews-K/defaults/svStart.R 2013-02-11 21:07:56 UTC (rev 527)
@@ -8,6 +8,7 @@
## Version 0.9.25, 2011-12-28 modified by Ph. Grosjean
## Version 0.9.27, 2012-04-22 modified by Ph. Grosjean
## Version 0.9.28, 2012-12-17 modified by Ph. Grosjean
+## Version 0.9.29, 2013-02-08 modified by Ph. Grosjean (don't use locate on the Mac)
## TODO: also use value in koDebug to debug server from within R!
## TODO: use the mechanism of startHttpServer() to retrieve default config
@@ -441,11 +442,22 @@
debugMsg("which", "returned", Komodo)
}
+ isMac <- function () (grepl("^mac", .Platform$pkgType))
if (length(Komodo) == 0 || Komodo == "") {
- Komodo <- system(paste("locate --basename -e --regex ^komodo$",
- "| grep -vF 'INSTALLDIR' | grep -F 'bin/komodo'",
- "| tail --lines=1"), intern = TRUE, ignore.stderr = TRUE)
- debugMsg("locate komodo", "returned", Komodo)
+ if (!isMac()) {
+ isLocate <- suppressWarnings(length(system('which locate',
+ intern = TRUE)) > 0)
+ if (!isLocate) { # locate is not there
+ Komodo <- NULL
+ } else {
+ Komodo <- try(suppressWarnings(system(paste(
+ "locate --basename -e --regex ^komodo$",
+ "| grep -vF 'INSTALLDIR' | grep -F 'bin/komodo'",
+ "| tail --lines=1"), intern = TRUE, ignore.stderr = TRUE)),
+ silent = TRUE)
+ debugMsg("locate komodo", "returned", Komodo)
+ }
+ } else Komodo <- NULL
}
} else { # Windows
@@ -468,7 +480,7 @@
key <- "Applications\\komodo.exe\\shell\\open\\command"
Komodo <-
tryCatch(readRegistry(key, hive = "HCR")[["(Default)"]],
- error = err.null)
+ error = err.null)
if (!is.null(Komodo))
Komodo <- sub(" *\\\"%[1-9\\*].*$", "", Komodo)
}
@@ -493,34 +505,59 @@
debugMsg("Komodo path is:", Komodo)
}
- if (!is.null(Komodo) && Komodo != "" && file.exists(Komodo)) {
+ if (length(Komodo) && Komodo != "" && file.exists(Komodo)) {
## Change the editor and the pager to Komodo
+ options(pager2 = getOption("pager"))
## A custom pager consists in displaying the file in Komodo
svPager <- function (files, header, title, delete.file) {
require(svKomodo)
files <- gsub("\\", "\\\\", files[1], fixed = TRUE)
- koCmd(sprintf('sv.r.pager("%s", "%s")', files, title))
- if (delete.file) {
- cmd <- paste('window.setTimeout("try { ',
- 'sv.tools.file.getfile(\\"%s\\").remove(false); } ',
- 'catch(e) {}", 10000);', sep = "")
- koCmd(sprintf(cmd, files));
+ res <- tryCatch(koCmd(sprintf('sv.r.pager("%s", "%s")', files, title)),
+ error = function (e) return(FALSE))
+ if (res == FALSE) {
+ ## Try using pager2 instead
+ pager2 <- getOption("pager2")
+ if (is.null(pager2)) {
+ stop("You must start Komodo Edit for displaying this file!")
+ } else if (is.function(pager2)) {
+ pager2(files = files, header = header, title = title,
+ delete.file = delete.file)
+ } else {
+ ## Replacement for the following line of code to avoid
+ ## using .Internal()
+ #.Internal(file.show(files, header, title, delete.file, pager2))
+ file.show(files, header = header, title = title,
+ delete.file = delete.file, pager = pager2)
+ }
+ } else {
+ if (delete.file) {
+ cmd <- paste('window.setTimeout("try { ',
+ 'sv.tools.file.getfile(\\"%s\\").remove(false); } ',
+ 'catch(e) {}", 10000);', sep = "")
+ koCmd(sprintf(cmd, files))
+ }
}
}
+ options(browser2 = getOption("browser"))
svBrowser <- function (url) {
require(svKomodo)
url <- gsub("\\", "\\\\", url, fixed = TRUE)
## If the URL starts with '/', I could safely assume a file path
## on Unix or Mac and prepend 'file://'
url <- sub("^/", "file:///", url)
- koCmd(sprintf("sv.command.openHelp(\"%s\")", url))
+ res <- tryCatch(koCmd(sprintf("sv.command.openHelp(\"%s\")", url)),
+ error = function (e) return(FALSE))
+ if (res == FALSE) {
+ ## Try using browser2 instead
+ browser2 <- getOption("browser2")
+ if (is.null(browser2)) {
+ stop("You must start Komodo Edit for browsing files")
+ } else browseURL(url, browser = browser2)
+ }
}
- ## The current SciViews-K help window in Komodo is buggy
- ## it let's Komodo crash on closing, and probably causes
- ## other problems => for now, just use the default browser!
- #options(editor = Komodo, browser = svBrowser, pager = svPager)
- options(editor = Komodo)
+ option(editor2 = getOption("editor"))
+ options(editor = Komodo, browser = svBrowser, pager = svPager)
} else {
Komodo <- NULL
cat("R cannot find Komodo.", file = stderr())
@@ -590,7 +627,7 @@
}
## Change the working directory to the provided directory
- setwd(getOption("R.initdir"))
+ try(setwd(getOption("R.initdir")), silent = TRUE)
## Create a .Last.sys function that clears some variables in .GlobalEnv
## and then, switch to R.initdir before closing R. The function is
@@ -621,7 +658,7 @@
if (!"--vanilla" %in% args && !"--no-restore" %in% args &&
!"--no.restore-data" %in% args) {
if (file.exists(".RData")) {
- load(".RData")
+ load(".RData", envir = .GlobalEnv)
msg2 <- append(msg2, "data loaded")
} else {
msg2 <- append(msg2, "no data")
@@ -644,7 +681,7 @@
msg2 <- append(msg2, "data and history not loaded")
}
- cat(msg, " (", paste(msg2, collapse=", "), ")", "\n",
+ cat(msg, " (", paste(msg2, collapse = ", "), ")", "\n",
sep = "", file = stderr())
## Do we reactivate Komodo now?
Modified: pkg/svKomodo/DESCRIPTION
===================================================================
--- pkg/svKomodo/DESCRIPTION 2013-01-30 15:02:47 UTC (rev 526)
+++ pkg/svKomodo/DESCRIPTION 2013-02-11 21:07:56 UTC (rev 527)
@@ -1,7 +1,7 @@
Package: svKomodo
Type: Package
-Version: 0.9-59
-Date: 2013-01-27
+Version: 0.9-60
+Date: 2013-02-11
Title: SciViews GUI API - Functions to interface with Komodo Edit/IDE
Authors at R: c(person("Philippe", "Grosjean", role = c("aut", "cre"),
email = "phgrosjean at sciviews.org"))
Modified: pkg/svKomodo/NEWS
===================================================================
--- pkg/svKomodo/NEWS 2013-01-30 15:02:47 UTC (rev 526)
+++ pkg/svKomodo/NEWS 2013-02-11 21:07:56 UTC (rev 527)
@@ -1,7 +1,12 @@
= svKomodo News
-== Change in svKomodo 0.9-59
+== Changes in svKomodo 0.9-60
+* .onAttach() is reworked for not issuing warning messages in Mac OS X.
+
+
+== Changes in svKomodo 0.9-59
+
* R is now configured to be used with SciViews Komodo (Komodo Edit + SciViews-K)
when the package is attached. It was previously configured when it was loaded.
Modified: pkg/svKomodo/R/svKomodo-internal.R
===================================================================
--- pkg/svKomodo/R/svKomodo-internal.R 2013-01-30 15:02:47 UTC (rev 526)
+++ pkg/svKomodo/R/svKomodo-internal.R 2013-02-11 21:07:56 UTC (rev 527)
@@ -158,17 +158,19 @@
}
if (length(Komodo) == 0 || Komodo == "") {
- isLocate <- suppressWarnings(length(system('which locate',
- intern = TRUE)) > 0)
- if (!isLocate || isMac()) { # locate is not there or Mac OS X
- Komodo <- NULL
- } else {
- Komodo <- try(suppressWarnings(system(
- "locate --basename -e --regex ^komodo$ | grep -vF 'INSTALLDIR' | grep -F 'bin/komodo' | tail --lines=1",
- intern = TRUE, ignore.stderr = TRUE)), silent = TRUE)
- if (inherits(Komodo, "try-error")) Komodo <- NULL
- #debugMsg("locate komodo", "returned", Komodo)
- }
+ if (!isMac()) {
+ isLocate <- suppressWarnings(length(system('which locate',
+ intern = TRUE)) > 0)
+ if (!isLocate) { # locate is not there
+ Komodo <- NULL
+ } else {
+ Komodo <- try(suppressWarnings(system(
+ "locate --basename -e --regex ^komodo$ | grep -vF 'INSTALLDIR' | grep -F 'bin/komodo' | tail --lines=1",
+ intern = TRUE, ignore.stderr = TRUE)), silent = TRUE)
+ if (inherits(Komodo, "try-error")) Komodo <- NULL
+ #debugMsg("locate komodo", "returned", Komodo)
+ }
+ } else Komodo <- NULL
}
## Just to avoid warnings while compiling outside of Windows...
readRegistry <- function() return()
Modified: pkg/svKomodo/inst/NEWS.Rd
===================================================================
--- pkg/svKomodo/inst/NEWS.Rd 2013-01-30 15:02:47 UTC (rev 526)
+++ pkg/svKomodo/inst/NEWS.Rd 2013-02-11 21:07:56 UTC (rev 527)
@@ -1,8 +1,14 @@
\name{NEWS}
\title{NEWS file for the svKomodo package}
+\section{Changes in version 0.9-60}{
+ \itemize{
+ \item{ You must start Komodo Edit for browsing files. }
+ }
+}
+
\section{Changes in version 0.9-59}{
- \itemize{
+ \itemize{
\item{ R is now configured to be used with SciViews Komodo (Komodo Edit +
SciViews-K) when the package is attached. It was previously configured
when it was loaded. }
@@ -15,21 +21,21 @@
}
\section{Changes in version 0.9-58}{
- \itemize{
+ \itemize{
\item{ The package was not loading correctly when not on \code{.libPaths}. Fixed. }
}
}
\section{Changes in version 0.9-57}{
- \itemize{
+ \itemize{
\item{ svKomodo creates now at loading a \code{.Last.sys()} function in
- \code{SciViews:TempEnv} indicating to Komodo Edit that R has quit. This
- is required to update R menus there. }
+ \code{SciViews:TempEnv} indicating to Komodo Edit that R has quit. This
+ is required to update R menus there. }
- \item{ The SciViews-K configuration file is not saved from here anymore
- (CRAN now does not accept packages that write files elsewhere than in R
- temp dir). This configuration file is now created by the SciViews-K Komodo
- plugin, in \preformatted{svStart.R}. }
+ \item{ The SciViews-K configuration file is not saved from here anymore
+ (CRAN now does not accept packages that write files elsewhere than in R
+ temp dir). This configuration file is now created by the SciViews-K Komodo
+ plugin, in \preformatted{svStart.R}. }
}
}
Modified: pkg/svKomodo/man/svKomodo-package.Rd
===================================================================
--- pkg/svKomodo/man/svKomodo-package.Rd 2013-01-30 15:02:47 UTC (rev 526)
+++ pkg/svKomodo/man/svKomodo-package.Rd 2013-02-11 21:07:56 UTC (rev 527)
@@ -13,8 +13,8 @@
\tabular{ll}{
Package: \tab svKomodo\cr
Type: \tab Package\cr
- Version: \tab 0.9-58\cr
- Date: \tab 2012-06-22\cr
+ Version: \tab 0.9-60\cr
+ Date: \tab 2013-02-11\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