X-Git-Url: http://christophe.rhodes.io/gitweb/?p=swankr.git;a=blobdiff_plain;f=swank.R;h=18269449e914970f099c240fc916ead34f11c159;hp=05b1c784f6aca534b4361349ba05adb9cc732529;hb=574dfdfecdc1bb179c60e79e680092469303404a;hpb=2b8d4ed472bd7bd4fef2ab2639d056688bd0bb8d diff --git a/swank.R b/swank.R index 05b1c78..1826944 100644 --- a/swank.R +++ b/swank.R @@ -316,3 +316,29 @@ printToString <- function(val) { abort="abort compilation") list(quote(`:compilation-result`), list(), TRUE, times[3]) } + +`swank:interactive-eval` <- function(io, sldbState, string) { + retry <- TRUE + value <- "" + while(retry) { + retry <- FALSE + withRestarts(value <- eval(parse(text=string), envir = globalenv()), + retry=list(description="retry SLIME interactive evaluation request", handler=function() retry <<- TRUE)) + } + printToString(value) +} + +`swank:eval-and-grab-output` <- function(io, sldbState, string) { + retry <- TRUE + value <- "" + output <- NULL + f <- fifo("") + tryCatch({ + sink(f) + while(retry) { + retry <- FALSE + withRestarts(value <- eval(parse(text=string), envir = globalenv()), + retry=list(description="retry SLIME interactive evaluation request", handler=function() retry <<- TRUE))}}, + finally={sink(); output <- readLines(f); close(f)}) + list(output, printToString(value)) +}