Christophe Weblog Wiki Code Publications Music
implement swank:inspector-eval
authorChristophe Rhodes <csr21@cantab.net>
Sat, 11 Sep 2010 09:58:10 +0000 (10:58 +0100)
committerChristophe Rhodes <csr21@cantab.net>
Sat, 11 Sep 2010 09:58:10 +0000 (10:58 +0100)
It took me quite some time to remember that parse returns a list of
expressions rather than just a single expression...

swank.R

diff --git a/swank.R b/swank.R
index ce85b6997a5b20e08937aaa9d6fb04af9ed7af12..3ab65ee02f1228d8b2c3423b41d33647f0fe4457 100644 (file)
--- a/swank.R
+++ b/swank.R
@@ -576,3 +576,14 @@ emacsInspect.numeric <- function(numeric) {
     FALSE
   }
 }
+
+`swank:inspector-eval` <- function(slimeConnection, sldbState, string) {
+  expr <- parse(text=string)[[1]]
+  object <- slimeConnection$istate$object
+  if(inherits(object, "list")|inherits(object, "environment")) {
+    substituted <- substituteDirect(expr, object)
+    eval(substituted, envir=globalenv())
+  } else {
+    eval(expr, envir=globalenv())
+  }
+}