paleolimbot / rbbt

R Interface to the Better BiBTex Zotero Connector
145 stars 26 forks source link

Add `bbt_update_bib()` function to save time and keystrokes #26

Closed Robinlovelace closed 3 years ago

Robinlovelace commented 3 years ago

Common scenario in my writing, I write a non-evaluated code chunk that I use to update citations every now and then, e.g.:

# set-up code
library(rbbt)
bbt_write_bib("references.bib", bbt_detect_citations("README.Rmd"), overwrite = TRUE)

I've written this many times now but never remember, always referring back to the README (of which I wrote the relevant bit!). A function like this works and would save me, and I guess others, time:

bbt_update_bib <- function(path_bib, path_rmd) {
  bbt_write_bib(
    path = path_bib,
    keys = bbt_detect_citations(path_rmd),
    overwrite = TRUE)
}
bbt_update_bib("references.bib", "README.Rmd")

Do you like the idea @paleolimbot ? Happy to put in a PR if so!

paleolimbot commented 3 years ago

It sounds like a great feature! I'd be happy to accept a PR as long as it has tests!

Would an addin also be relevant? You could detect the bib path from the rmd path by looking at the bib field in the header yaml.

paleolimbot commented 3 years ago

FWIW I'd reverse the arguments (put path_rmd first).

Robinlovelace commented 3 years ago

Looking at this now...

paleolimbot commented 3 years ago

Fixed in #27!