Christophe Weblog Wiki Code Publications Music
new makeReplResultFunction hook
[swankr.git] / swank.R
diff --git a/swank.R b/swank.R
index e9674bc7f175276229aec93e08d386a2375e4664..c0adff899a9a8b895f06cf692d53a21cf0b9c6ed 100644 (file)
--- a/swank.R
+++ b/swank.R
@@ -280,12 +280,17 @@ printToString <- function(val) {
   list("R", "R")
 }
 
-sendReplResult <- function(slimeConnection, value) {
+makeReplResult <- function(value) {
   string <- printToString(value)
-  sendToEmacs(slimeConnection,
-              list(quote(`:write-string`),
-                   paste(string, collapse="\n"),
-                   quote(`:repl-result`)))
+  list(quote(`:write-string`), paste(string, collapse="\n"),
+       quote(`:repl-result`))
+}
+
+makeReplResultFunction <- makeReplResult
+
+sendReplResult <- function(slimeConnection, value) {
+  result <- makeReplResultFunction(value)
+  sendToEmacs(slimeConnection, result)
 }
 
 sendReplResultFunction <- sendReplResult
@@ -368,6 +373,13 @@ computeRestartsForEmacs <- function (sldbState) {
   FALSE
 }
 
+`swank:eval-string-in-frame` <- function(slimeConnection, sldbState, string, index) {
+  frame <- sldbState$frames[[1+index]]
+  withRetryRestart("retry SLIME interactive evaluation request",
+                   value <- eval(parse(text=string), envir=frame))
+  printToString(value)
+}
+
 `swank:frame-locals-and-catch-tags` <- function(slimeConnection, sldbState, index) {
   str(sldbState$frames)
   frame <- sldbState$frames[[1+index]]