X-Git-Url: http://christophe.rhodes.io/gitweb/?p=swankr.git;a=blobdiff_plain;f=swank.R;h=1c1633d77ad8c7aa7fa8a709eb3a3bcd02e57e10;hp=ca1eff93665ed4b1625e4509a06178355d44a275;hb=5035036a7da09e17a5a70ea7ea15657d671e9c52;hpb=081a80aba6b863a9ae5aafd16e12a114e4a5c339 diff --git a/swank.R b/swank.R index ca1eff9..1c1633d 100644 --- a/swank.R +++ b/swank.R @@ -64,11 +64,13 @@ makeSldbState <- function(condition, level, id) { } sldbLoop <- function(io, sldbState, id) { - sendToEmacs(io, c(list(quote(`:debug`), id, sldbState$level), debuggerInfoForEmacs(sldbState))) - sendToEmacs(io, list(quote(`:debug-activate`), id, sldbState$level, FALSE)) - while(TRUE) { - dispatch(io, readPacket(io), sldbState) - } + tryCatch({ + sendToEmacs(io, c(list(quote(`:debug`), id, sldbState$level), debuggerInfoForEmacs(sldbState))) + sendToEmacs(io, list(quote(`:debug-activate`), id, sldbState$level, FALSE)) + while(TRUE) { + dispatch(io, readPacket(io), sldbState) + } + }, finally=sendToEmacs(io, c(list(quote(`:debug-return`), id, sldbState$level, FALSE)))) } debuggerInfoForEmacs <- function(sldbState, from=0, to=NULL) { @@ -260,6 +262,10 @@ printToString <- function(val) { "No Arglist Information" } +`swank:operator-arglist` <- function(io, sldbState, op, package) { + list() +} + `swank:throw-to-toplevel` <- function(io, sldbState) { condition <- simpleCondition("Throw to toplevel") class(condition) <- c("swankTopLevel", class(condition)) @@ -289,3 +295,26 @@ printToString <- function(val) { quote(`:value`), paste(printToString(eval(parse(text=name), envir=frame)), sep="", collapse="\n")) }), list()) } + +`swank:simple-completions` <- function(io, sldbState, prefix, package) { + ## fails multiply if prefix contains regexp metacharacters + matches <- apropos(sprintf("^%s", prefix), ignore.case=FALSE) + nmatches <- length(matches) + if(nmatches == 0) { + list(list(), "") + } else { + longest <- matches[order(nchar(matches))][1] + while(length(grep(sprintf("^%s", longest), matches)) < nmatches) { + longest <- substr(longest, 1, nchar(longest)-1) + } + list(as.list(matches), longest) + } +} + +`swank:compile-string-for-emacs` <- function(io, sldbState, string, buffer, position, filename, policy) { + # FIXME: I think in parse() here we can use srcref to associate + # buffer/filename/position to the objects. Or something. + withRestarts({ times <- system.time(eval(parse(text=string), envir = globalenv())) }, + abort="abort compilation") + list(quote(`:compilation-result`), list(), TRUE, times[3]) +}