update packages
This commit is contained in:
@@ -44,18 +44,35 @@
|
||||
}
|
||||
}
|
||||
|
||||
.ess.getHelpAliases <- function(){
|
||||
readrds <-
|
||||
if(.ess.Rversion >= '2.13.0') readRDS
|
||||
else .readRDS
|
||||
rds.files <- paste(searchpaths(), "/help/aliases.rds", sep = "")
|
||||
unlist(lapply(rds.files,
|
||||
function(f){
|
||||
if( file.exists(f) )
|
||||
try(names(readrds(f)))
|
||||
}),
|
||||
use.names = FALSE)
|
||||
}
|
||||
.ess.getHelpAliases <- local({
|
||||
readrds <- if (.ess.Rversion >= '2.13.0') readRDS else .readRDS
|
||||
aliasesCache <- new.env()
|
||||
|
||||
getAliases <- function(file) {
|
||||
cached <- aliasesCache[[file]]
|
||||
if (!is.null(cached))
|
||||
return(cached)
|
||||
|
||||
aliases <- tryCatch(
|
||||
error = function(...) NULL,
|
||||
if (file.exists(file))
|
||||
names(readrds(file))
|
||||
else
|
||||
NULL
|
||||
)
|
||||
|
||||
aliasesCache[[file]] <- aliases
|
||||
aliases
|
||||
}
|
||||
|
||||
function(reset = FALSE) {
|
||||
if (reset)
|
||||
aliasesCache <<- new.env()
|
||||
|
||||
rdsFiles <- paste(searchpaths(), "/help/aliases.rds", sep = "")
|
||||
unlist(lapply(rdsFiles, getAliases), use.names = FALSE)
|
||||
}
|
||||
})
|
||||
|
||||
### SOURCING
|
||||
.ess.eval <- function(string, visibly = TRUE, output = FALSE,
|
||||
@@ -132,3 +149,45 @@ if(.ess.Rversion < "1.8")
|
||||
|
||||
unquote(substitute(expr))
|
||||
}
|
||||
|
||||
.ess.command <- function(expr, sentinel) {
|
||||
## It is possible that the REPL is marked as non-busy when the
|
||||
## output is sinked because prompts are not sinked. In that case,
|
||||
## redirect the sinked output temporarily to ESS.
|
||||
sinked <- sink.number() != 0
|
||||
if (sinked)
|
||||
sink(.ess.stdout)
|
||||
|
||||
on.exit({
|
||||
writeLines(paste0(sentinel, "-END"))
|
||||
if (sinked)
|
||||
sink(NULL)
|
||||
})
|
||||
|
||||
writeLines(paste0(sentinel, "-START"))
|
||||
|
||||
## Don't interrupt `browser()` sessions (#1081)
|
||||
restart <- function(...) {
|
||||
if (!is.null(findRestart("browser")))
|
||||
invokeRestart("browser")
|
||||
}
|
||||
|
||||
out <- withCallingHandlers(
|
||||
interrupt = restart,
|
||||
withVisible(expr)
|
||||
)
|
||||
|
||||
## Print result manually because we can't rely on auto-print
|
||||
## without changing the last value
|
||||
if (out$visible)
|
||||
print(out$value)
|
||||
|
||||
## Keep `.Last.value` stable
|
||||
invisible(.Last.value)
|
||||
}
|
||||
|
||||
## stdout() always returns the current file where output is sinked to.
|
||||
## If there is any sink, it returns that file rather than connection 1.
|
||||
## Since we can't get the default stdout connection when a sink is
|
||||
## active we save it here.
|
||||
.ess.stdout <- stdout()
|
||||
|
||||
Reference in New Issue
Block a user