From: Christophe Rhodes Date: Fri, 3 Sep 2010 07:10:09 +0000 (+0100) Subject: alternative printing for the REPL X-Git-Url: http://christophe.rhodes.io/gitweb/?p=swankr.git;a=commitdiff_plain;h=f3a32de1015eb3008fbdd254e72927f50819c029 alternative printing for the REPL instead of using print(), use str(). Also, be even more cautious about cleaning up in printToString; previously, errors in printing would lead to a sink to a closed fifo... Printing is still not really right, and I forsee that we will end up writing our own printer to get something more lispy. But at least this approach tends not to dump huge tables into the REPL. --- diff --git a/swank.R b/swank.R index 99f508b..0a309ef 100644 --- 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)) }