Christophe Weblog Wiki Code Publications Music
alternative printing for the REPL
[swankr.git] / swank.R
diff --git a/swank.R b/swank.R
index 99f508bc153379b56c4586b6f61e7ee0db6b6c93..0a309ef7da9b22576d945c26984874f6aa58ef88 100644 (file)
--- a/swank.R
+++ b/swank.R
@@ -247,7 +247,11 @@ writeSexpToString <- function(obj) {
 
 printToString <- function(val) {
   f <- fifo("")
-  tryCatch({ sink(f); print(val); sink(); readLines(f) },
+  sink(f)
+  tryCatch({
+    tryCatch(str(val, indent.str="", list.len=5, max.level=2),
+             finally=sink())
+    readLines(f) },
            finally=close(f))
 }