HenrikBengtsson / startup

:wrench: R package: startup - Friendly R Startup Configuration
https://henrikbengtsson.github.io/startup/
161 stars 5 forks source link

.gitignore inside .Rprofile.d #131

Open Diego-MX opened 4 months ago

Diego-MX commented 4 months ago

Disclaimer: I just recently started using your package. I find it really great, and I'm still getting the hang of it.

I have setup my local ~/.Rprofile.d And then I added a project one .../my-project/.Rprofile.d

The project profile has:

So the issue is that startup() cannot process .gitignore because it is not an R-profile.
And I have two questions:

Thank you.

HenrikBengtsson commented 4 months ago

Does startup::startup(all=TRUE) provide what you need?

I don't understand the .gitignore part

Diego-MX commented 4 months ago

Thank you for your answer. I'll write in three bullets:

  1. In the vignette, you mention that file ending with *\.(txt|md|~), *\.(Rhistory|RData|DS_Store) or starting with \.\.* are ignored. I'm thinking along the lines of ignoring .gitignore as well.

I'll make a case, with a -hopefully- simple example.

# ~/.Rprofile
print("My local functions, which other developers don't need or even use.")
print("May include fortunes:fortune(), or set local repository")
# my-proj/R-src/.Rprofile.d/0-local.R
source(~/.Rprofile)  
print("I thought to call them here, since I set up my proj profile.")
# my-proj/R-src/.Rprofile.d/1-package.R
proj_function <- function(x) print("Project uses this function.")
# my-proj/R-src/.Rprofile.d/.gitignore
0-local.R 

This last file throws an error as it is in .Rprofile.d

  1. The workaround is to ignore 0-local.R from an outer .gitignore

    # my-proj/R-src/.gitignore
    .Rprofile.d/0-local.R

    This is very close to ideal, so happy to live with that.

  2. Going back to the ideal solution, I didn't find how to make all=TRUE help.
    But partially found the following does: (using magrittr pipes)

    "my-proj/R-src/.Rprofile.d" %>%
    list.files(all.files=TRUE, full.names=TRUE) %>%
    str_subset("/\\.", negate=TRUE) %>%  # Includes /.gitignore and others. 
    rprofile_d(paths=.)

I mean partially, because I can only call rprofile_d like this, but not startup.

So one final question, and one proposal:

i) Is there a parameter to ignore other files (like *.(txt|md|~)?

ii) if you think the .gitignore case is a strong one, I can look into the code and try a Pull Request.

Thank you =D