Christophe Weblog Wiki Code Publications Music
don't print out "locals" from the global environment
[swankr.git] / swank.R
diff --git a/swank.R b/swank.R
index f0c0d15373ff150a29f291f56d89b23f9050c276..c50114a1a65769edbf5ffe856e2f8f13d5d29bb9 100644 (file)
--- a/swank.R
+++ b/swank.R
@@ -423,9 +423,17 @@ computeRestartsForEmacs <- function (sldbState) {
 `swank:frame-locals-and-catch-tags` <- function(slimeConnection, sldbState, index) {
   frame <- sldbState$frames[[1+index]]
   objs <- ls(envir=frame)
+  if(identical(frame, globalenv())) {
+    objs <- c()
+  }
   list(lapply(objs, function(name) { list(quote(`:name`), name,
                                           quote(`:id`), 0,
-                                          quote(`:value`), printToString(eval(parse(text=name), envir=frame))) }),
+                                          quote(`:value`),
+                                          tryCatch({
+                                            printToString(eval(parse(text=name), envir=frame))
+                                          }, error=function(c) {
+                                            sprintf("error printing object")
+                                          }))}),
        list())
 }
 
@@ -514,7 +522,7 @@ withRetryRestart <- function(description, expr) {
                                                               envir=globalenv()))) })
   output <- paste(output, sep="", collapse="\n")
   if(tmp$visible) {
-    list(output, prin1ToString(value))
+    list(output, prin1ToString(tmp$value))
   } else {
     list(output, "# invisible value")
   }
@@ -524,7 +532,7 @@ withRetryRestart <- function(description, expr) {
   withRetryRestart("retry SLIME interactive evaluation request",
                    tmp <- withVisible(eval(parse(text=string), envir=globalenv())))
   if(tmp$visible) {
-    prin1ToString(value)
+    prin1ToString(tmp$value)
   } else {
     "# invisible value"
   }