Skip to content

Commit

Permalink
bind last output to .Last.value
Browse files Browse the repository at this point in the history
  • Loading branch information
randy3k committed Sep 10, 2016
1 parent 45bddc5 commit 69fef4e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions R/execution.r
Expand Up @@ -168,6 +168,7 @@ handle_value = function(obj) {
page(mimebundle)
} else {
log_debug('Sending display_data: %s', paste(capture.output(str(mimebundle$data)), collapse = '\n'))
set_last_value(obj)
send_response('display_data', current_request, 'iopub', mimebundle)
}
},
Expand Down
6 changes: 6 additions & 0 deletions R/utils.r
Expand Up @@ -29,3 +29,9 @@ fromRawJSON <- function(r) {
Encoding(s) <- 'UTF-8'
fromJSON(s)
}

set_last_value <- function(obj) {
unlockBinding(".Last.value", .BaseNamespaceEnv)
assign(".Last.value", obj, .BaseNamespaceEnv)
lockBinding(".Last.value", .BaseNamespaceEnv)
}

0 comments on commit 69fef4e

Please sign in to comment.