R/addins.R

Defines functions source_decoratees_addin

source_decoratees_addin <- function() {
  if (!requireNamespace('rstudioapi')) {
    stop('please install the rstudioapi package', call. = FALSE)
  }

  active <- tryCatch(
    rstudioapi::getSourceEditorContext(),
    error = function(e) {
      list(
        id = '',
        path = '',
        contents = ''
      )
    })

  if (active$path != '') {
    cmd <- paste0('source_decoratees("', active$path, '")')
    rstudioapi::sendToConsole(cmd)
  }
}

Try the tinsel package in your browser

Any scripts or data that you put into this service are public.

tinsel documentation built on May 2, 2019, 1:30 p.m.