## KH's personal ~/.R/Rprofile.
## Last updated on 2022-10-17.

local({
    repos <- c(CRAN = "file:///data/Repositories/CRAN")

    ## Try to infer the "right" BioC repository.
    ## Alternatively, we could hard-wire the BioC versions here.
    BioC_names <- c("BioCsoft", "BioCann", "BioCexp")
    BioC_paths <- c("bioc", "data/annotation", "data/experiment")
    BioC_mirror <- "http://bioconductor.statistik.tu-dortmund.de"
    BioC_version <-
        if(exists(".BioC_version_associated_with_R_version",
                  asNamespace("utils")))
            utils:::.BioC_version_associated_with_R_version()
        else
            tools:::.BioC_version_associated_with_R_version()
    dirs <- file.path(sprintf("/data/Repositories/Bioconductor/%s",
                              BioC_version),
                      BioC_paths)
    repos <-
        c(repos,
          structure(ifelse(file.exists(file.path(dirs, "src", "contrib",
                                                 "PACKAGES")),
                           sprintf("file://%s", dirs),
                           sprintf("%s/packages/%s/%s",
                                   BioC_mirror, BioC_version,
                                   BioC_paths)),
                    names = BioC_names))

    ## <NOTE>
    ## Argh.  Using these keeps causing trouble for the CRAN incoming
    ## checking (most notably for Matrix and lme4).  Hence, for now let
    ## us not use the R-Forge repository ...
    ##     repos <- if(file.exists("/data/Repositories/R-Forge"))
    ##         c(repos, "R-Forge" = "file:///data/Repositories/R-Forge")
    ##     else
    ##         c(repos, "R-Forge" = "http://R-Forge.R-project.org/")
    ## </NOTE>

    options(repos = repos)
})

options(prompt = "R> ",
        editor = "emacsclient",
        browser = "firefox",
        pdfviewer = "evince",
        printcmd = "a2ps -2 -q",
        dvipscmd = "a2ps -2 -q",
        menu.graphics = FALSE,
        save.defaults = list(ascii = FALSE, compress = TRUE))

setHook(packageEvent("grDevices", "onLoad"),
        function(...) {
            grDevices::ps.options(horizontal = FALSE, pointsize = 14, 
                                  height = 6, width = 7)
            grDevices::X11.options(type = "cairo")
        })

setHook(packageEvent("rJava", "onLoad"),
        function(...) {
            ## StanfordCoreNLPjars needs -Xmx3g, but should provide this
            ## via its own .onLoad() (assuming that it is the one to
            ## start the JVM, of course).
            ## <FIXME>
            ##   Adding "-Xss8m" suggested by Tomas Kalibera to overcome
            ##   stack protection problems on Linux.  Remove eventually?
            options(java.parameters =
                        c(getOption("java.parameters"),
                          c("-Xrs", "-Xss8m"),
                          ## Also avoid MTJ warning madness:
                          "-Dcom.github.fommil.netlib.BLAS=com.github.fommil.netlib.F2jBLAS",
              
                          "-Dcom.github.fommil.netlib.LAPACK=com.github.fommil.netlib.F2jLAPACK",
                          "-Dcom.github.fommil.netlib.ARPACK=com.github.fommil.netlib.F2jARPACK"
                          ))
            ## </FIXME>
        })

options(showErrorCalls = TRUE,
        showWarnCalls = TRUE,
        warn = 1)

## When moving towards avoiding partial matching && friends:
options(warnPartialMatchArgs = TRUE,
        warnPartialMatchAttr = TRUE,
        warnPartialMatchDollar = TRUE)

## Ensure CRAN versions where available.
options(available_packages_filters =
            c("R_version", "OS_type", "subarch", "CRAN", "duplicates"))

### Local Variables: ***
### mode: R ***
### End: ***