From dc22b346c159268666cdf0ccdafd740222ef861a Mon Sep 17 00:00:00 2001 From: Christophe Rhodes Date: Sat, 10 Sep 2011 23:58:36 +0100 Subject: [PATCH] deal with 0 or multiple expressions at the repl It's easy really; just iterate over expressions. Resolves bug #10. --- BUGS.org | 2 +- swank.R | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/BUGS.org b/BUGS.org index 0088e90..916641c 100644 --- 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 cf64daa..b5c79c7 100644 --- 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() } -- 2.39.5