writeSexpToStringLoop(obj)
}
-withOutputToString <- function(expr) {
- call <- substitute(expr)
- f <- fifo("")
- sink(f)
- tryCatch({ tryCatch(eval.parent(call), finally=sink())
- readLines(f) },
- finally=close(f))
+prin1ToString <- function(val) {
+ paste(deparse(val, backtick=TRUE, control=c("delayPromises", "keepNA")),
+ sep="", collapse="\n")
}
printToString <- function(val) {
- withOutputToString(str(val, indent.str="", list.len=5, max.level=2))
+ paste(capture.output(print(val)), sep="", collapse="\n")
}
`swank:connection-info` <- function (slimeConnection, sldbState) {
makeReplResult <- function(value) {
string <- printToString(value)
- list(quote(`:write-string`), paste(string, collapse="\n"),
+ list(quote(`:write-string`), string,
quote(`:repl-result`))
}
objs <- ls(envir=frame)
list(lapply(objs, function(name) { list(quote(`:name`), name,
quote(`:id`), 0,
- quote(`:value`), paste(printToString(eval(parse(text=name), envir=frame)), sep="", collapse="\n")) }),
+ quote(`:value`), printToString(eval(parse(text=name), envir=frame))) }),
list())
}
`swank:interactive-eval` <- function(slimeConnection, sldbState, string) {
withRetryRestart("retry SLIME interactive evaluation request",
value <- eval(parse(text=string), envir=globalenv()))
- printToString(value)
+ prin1ToString(value)
}
`swank:eval-and-grab-output` <- function(slimeConnection, sldbState, string) {
withRetryRestart("retry SLIME interactive evaluation request",
{ output <-
- withOutputToString(value <- eval(parse(text=string),
- envir=globalenv())) })
- list(output, printToString(value))
+ capture.output(value <- eval(parse(text=string),
+ envir=globalenv())) })
+ output <- paste(output, sep="", collapse="\n")
+ list(output, prin1ToString(value))
}
`swank:find-definitions-for-emacs` <- function(slimeConnection, sldbState, string) {
valuePart <- function(istate, object, string) {
list(quote(`:value`),
- if(is.null(string)) paste(printToString(object),collapse=" ") else string,
+ if(is.null(string)) printToString(object) else string,
assignIndexInParts(object, istate))
}