Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Add envsetup::other #9

Open
nicholas-masel opened this issue Oct 11, 2022 · 0 comments
Open

Feature Request: Add envsetup::other #9

nicholas-masel opened this issue Oct 11, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@nicholas-masel
Copy link
Collaborator

Feature Idea

'rprofile()` should store other objects defined in the config somewhere. Currently it discards anything not defined within paths and autos

Relevant Input

No response

Relevant Output

No response

Reproducible Example/Pseudo Code

rprofile <- function(config) {
  if ("envsetup:paths" %in% search()) {
    detach("envsetup:paths", character.only = TRUE)
  }
  
  if ("envsetup:other" %in% search()) {
    detach("envsetup:other", character.only = TRUE)
  }
  
  # remove autos and pass everything else to "envsetup:paths"
  config_minus_autos_paths <- config
  config_minus_autos_paths$autos <- NULL
  config_minus_autos_paths$paths <- NULL
  
  # attach after package to allow functions from package to be used in config
  if (any(search() == "package:envsetup")) {
    pos <- which(search() == "package:envsetup") + 1
  } else {
    (pos <- 2L)
  }
  
  attach(config$paths,
         name = "envsetup:paths",
         pos = pos
  )
  
  attach(config_minus_autos_paths,
         name = "envsetup:other",
         pos = pos
  )
  
  set_autos(config$autos)
}
@nicholas-masel nicholas-masel added the enhancement New feature or request label Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant