You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A mechanism for package author to register some options for autocomplete in RStudio IDE #8702
Currently, the IDE will allow autocompletion of options in options() only for the option which has been already set.
As some of our package relies on options for configurations, it would be nice to have a way to quickly access all the option available for a package using autocompletion, the same way we can access all available function using pkg:: then tabulation.
Context about the need
This comes again from blogdown development where we use a lot of options that the user could use to configure the behavior. This is definitely not the only package.
Usually, these options can be found in documentation (like with ?future::future.options), NEWS, README or other. It can also be found by reading the code of the function on github.
Having a way to access by autocompletion some options that a package developer would like its users to discover would be great.
For blogdown, @yihui added a trick of initializing all the options so that the IDE would know about it. This led to initialize them to NA and have a specific wrapper get_option so that if it was NA it should be considered unset (like NULL) - this is because setting an option to NULL is like unsetting them so the IDE does not see it.
See what we have done in rstudio/blogdown@baeca2f
You can see the effet in RStudio
Open RStudio
try options(blog then Tab for completion
Load blogdown - library(blogdown)
Redo the options(blog and see the difference.
About what could be offered.
To be flexible and extensible this could require a mechanism for a package author to register some options for its package to be found. This could also require a convention like 'pkg.` to be respected and a mechanism to register the option. Or maybe a convention of a function / object or file that if present in the package would contain the option to use for autocompletion.
Thanks for considering.
Reacted by Yihui Xie, Dan Chaltiel and Garrick Aden-Buie
I think such a mechanism exists in the IDE, and we just need a way to let users register the option names somewhere. For example, the IDE can autocomplete knitr chunk options:
This is because knitr:::opts_chunk_attr has provided the candidates. Other packages (e.g. blogdown) could also provide this list of candidates, and the IDE can use this list to autocomplete options().
Activity
yihui commentedon Jan 8, 2021
I think such a mechanism exists in the IDE, and we just need a way to let users register the option names somewhere. For example, the IDE can autocomplete knitr chunk options:
This is because
knitr:::opts_chunk_attrhas provided the candidates. Other packages (e.g. blogdown) could also provide this list of candidates, and the IDE can use this list to autocompleteoptions().fix #605: use blogdown:::get_option() instead of getOption() because …
olivroy commentedon Sep 6, 2023
For reference, I use the opt package to do this. Works well! https://github.com/moodymudskipper/opt