Christophe Weblog Wiki Code Publications Music
use srcfile$wd when going to source for an sldb frame
[swankr.git] / swank.R
diff --git a/swank.R b/swank.R
index e6e78c7e15996168ad9db03c1ab154c3d2dd9b9e..13164853c32efb8a4c0c4086229a7431c6d99516 100644 (file)
--- a/swank.R
+++ b/swank.R
@@ -272,10 +272,22 @@ printToString <- function(val) {
   list("R", "R")
 }
 
+sendReplResult <- function(slimeConnection, value) {
+  string <- printToString(value)
+  sendToEmacs(slimeConnection,
+              list(quote(`:write-string`),
+                   paste(string, collapse="\n"),
+                   quote(`:repl-result`)))
+}
+
+sendReplResultFunction <- sendReplResult
+
 `swank:listener-eval` <- function(slimeConnection, sldbState, string) {
-  val <- eval(parse(text=string), envir = globalenv())
-  string <- printToString(val)
-  sendToEmacs(slimeConnection, list(quote(`:write-string`), paste(string, collapse="\n"), quote(`:repl-result`)))
+  string <- gsub("#\\.\\(swank:lookup-presented-object-or-lose([^)]*)\\)", ".(`swank:lookup-presented-object-or-lose`(slimeConnection, sldbState,\\1))", string)
+  expr <- parse(text=string)[[1]]
+  lookedup <- do.call("bquote", list(expr))
+  value <- eval(lookedup, envir = globalenv())
+  sendReplResultFunction(slimeConnection, value)
   list()
 }
 
@@ -337,9 +349,8 @@ computeRestartsForEmacs <- function (sldbState) {
   if(is.null(srcfile)) {
     list(quote(`:error`), "no srcfile")
   } else {
-    filename <- get("filename", srcfile)
     list(quote(`:location`),
-         list(quote(`:file`), filename),
+         list(quote(`:file`), sprintf("%s/%s", srcfile$wd, srcfile$filename)),
          list(quote(`:line`), srcref[[1]], srcref[[2]]-1),
          FALSE)
   }