Re-activate breadcrumbs messages on error.

reactivate_breadcrumbs()

Details

Breadcrumbs messages are activated by default when the modulr package is loaded. This is done by binding a wrapper function to the error option. The function wraps any other previously binded function and the get_breadcrumbs function together. Since IDEs like RStudio are likely to reset this option during the lifetime of an R session, reactivate_breadcrumbs can be useful to re-install the wrapper function.

Examples

#> [2017-06-21T21:58:30 UTC] Resetting modulr state ... OK
options(error = browser) reactivate_breadcrumbs()
#> (function (...) #> { #> if (!interactive()) { #> if (exists("function_list", where = parent.frame(2L))) #> return(list(...)[[1L]]) #> } #> else { #> if (exists(".__name__", where = parent.frame(1L))) { #> module_name <- get(".__name__", pos = parent.frame(1L)) #> if (module_name != "__main__") #> get_breadcrumbs(NULL, verbose = TRUE) #> } #> if (exists("function_list", where = parent.frame(2L))) { #> message("Use ", sQuote("."), " to get the left-hand side value of the pipe.") #> function_list_ <- get("function_list", pos = parent.frame(2L)) #> i_ <- get("i", pos = parent.frame(2L)) #> k_ <- get("k", pos = parent.frame(2L)) #> message(paste(unlist(c(if (i_ %in% 1L:2L) list("> .") else if (i_ > #> 2L) list("> ..."), lapply(function_list_[max(1L, #> i_ - 1L):min(i_ + 1L, k_)], prompt_), if (i_ < #> k_ - 1L) list("> ..."))), collapse = " %>% \n")) #> args <- increment_skipCalls_(list(...), 8L) #> deparse.max.lines.bak <- options(deparse.max.lines = max(getOption("modulr.deparse.max.lines.in.pipes"), #> getOption("deparse.max.lines"))) #> on.exit({ #> options(deparse.max.lines.bak) #> return(args[[1L]]) #> }) #> do.call(base::browser, args = utils::tail(args, -1L), #> envir = parent.frame(1L)) #> } #> else { #> args <- increment_skipCalls_(list(...), 2L) #> do.call(base::browser, args = args, envir = parent.frame(1L)) #> } #> } #> })()
define("foo", NULL, function() function() stop("error in 'foo'"))
#> [2017-06-21T21:58:30 UTC] Defining 'foo' ... OK
define("bar", list(foo = "foo"), function(foo) function() foo())
#> [2017-06-21T21:58:30 UTC] Defining 'bar' ... OK
define("foobar", list(bar = "bar"), function(bar) bar())
#> [2017-06-21T21:58:30 UTC] Defining 'foobar' ... OK
## Not run: make()