Klimi's new dotfiles with stow.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.8 KiB

4 years ago
  1. ## This file is sourced when R starts and `load.ESSR` is called. See
  2. ## inferior-ess-r-load-ESSR--local.
  3. ## Do not use _ in names, nor :: as they cannot be parsed in old R versions
  4. ## load .base.R and all other files into ESSR environment; then attach ESSR
  5. .ess.load.ESSR <- function(dir) {
  6. .source <-
  7. if(any("keep.source" == names(formals(sys.source))))
  8. sys.source
  9. else
  10. function(..., keep.source) sys.source(...)
  11. Rver <- if(exists("getRversion", mode="function")) getRversion()
  12. else paste(R.version$major, R.version$minor, sep=".")
  13. oldR <- Rver <= "1.3.0"
  14. ESSR <-
  15. if(oldR) ## really old library() revert order a bit
  16. attach(NULL, name = "ESSR")
  17. else if(length(nn <- names(formals(new.env))) && any(nn == "parent"))
  18. new.env(parent =
  19. if(Rver >= "1.9.0") getNamespace("utils")
  20. else .BaseNamespaceEnv)
  21. else
  22. new.env()
  23. assign(".ess.Rversion", Rver, envir = ESSR)
  24. ## updated by make !!
  25. VERSION <- "1.5"
  26. assign(".ess.ESSRversion", VERSION, envir = ESSR)
  27. ## .basic.R:
  28. try(.source(paste(dir,'/.basic.R', sep = ""), envir = ESSR, keep.source = FALSE))
  29. ## all others try(*) as it will fail in old R
  30. if(!oldR) # no sense if(oldR)
  31. for( f in dir(dir, pattern='\\.R$', full.names=TRUE) )
  32. try(.source(f, envir = ESSR, keep.source = FALSE))
  33. if(Rver >= "2.4.0")
  34. attach(ESSR)
  35. else if(!oldR) { ## borrow from older library()
  36. e <- attach(NULL, name = "ESSR")
  37. .Internal(lib.fixup(ESSR, e))
  38. } else { ## if(oldR), use as in that old library():
  39. .Internal(lib.fixup(ESSR, .GlobalEnv))
  40. }
  41. ## BUILDESSR needs this:
  42. invisible(ESSR)
  43. }