Christophe Weblog Wiki Code Publications Music
deal with 0 or multiple expressions at the repl
authorChristophe Rhodes <csr21@cantab.net>
Sat, 10 Sep 2011 22:58:36 +0000 (23:58 +0100)
committerChristophe Rhodes <csr21@cantab.net>
Sat, 10 Sep 2011 22:58:36 +0000 (23:58 +0100)
It's easy really; just iterate over expressions.  Resolves bug #10.

BUGS.org
swank.R

index 0088e9045d532ce5bda93fd94243b64f09cf510d..916641ca15f389bd2ff68c1ff580048f09a37f7d 100644 (file)
--- a/BUGS.org
+++ b/BUGS.org
@@ -31,7 +31,7 @@
 * OPEN #9 help and ? to produce help buffers                       :WISHLIST:
   Not like ESS, though: that works by looking at the user's input with
   a regexp.  Use slime-media?
-* OPEN #10 0 or more than 1 exprs at REPL                             :MINOR:
+* RESOLVED #10 0 or more than 1 exprs at REPL                   :MINOR:FIXED:
   Entering 0 exprs (whitespace or the empty string) at the REPL gives
   an error from `swank:listener-eval`, which subscripts the parse tree
   with index 1.  (Entering more than one simply ignores all after the
diff --git a/swank.R b/swank.R
index cf64daaaa81b8ad7341284a67dd67423058c922f..b5c79c78204695667f421bbceb3b3e83664971c1 100644 (file)
--- a/swank.R
+++ b/swank.R
@@ -324,12 +324,14 @@ sendReplResultFunction <- sendReplResult
 `swank:listener-eval` <- function(slimeConnection, sldbState, string) {
   ## O how ugly
   string <- gsub("#\\.\\(swank:lookup-presented-object-or-lose([^)]*)\\)", ".(`swank:lookup-presented-object-or-lose`(slimeConnection, sldbState,\\1))", string)
-  expr <- parse(text=string)[[1]]
-  ## O maybe this is even uglier
-  lookedup <- do.call("bquote", list(expr))
-  tmp <- withVisible(eval(lookedup, envir = globalenv()))
-  if(tmp$visible) {
-    sendReplResultFunction(slimeConnection, tmp$value)
+  for(expr in parse(text=string)) {
+    expr <- expr
+    ## O maybe this is even uglier
+    lookedup <- do.call("bquote", list(expr))
+    tmp <- withVisible(eval(lookedup, envir = globalenv()))
+    if(tmp$visible) {
+      sendReplResultFunction(slimeConnection, tmp$value)
+    }
   }
   list()
 }