4

Note: I'm using org-cite, not org-ref.

As I'm writing, I sometimes add a new citation to my references.bib file. But org-mode can't always find it. Instead, org highlights the new citation as an error, and if I click on it says "Cannot find citation key".

However if I restart Emacs, it can find it.

Is there a function I can call to rebuild or refresh org-mode's understanding of the .bib file without having to restart Emacs?

3
  • Try M-: (org-cite-basic--all-keys), There may be other, better supported ways, but this should parse the bibliography file again and remake the hash table. No guarantees though: my understanding of how citation works in Org mode is extremely rudimentary.
    – NickD
    Dec 7, 2022 at 4:53
  • That function isn't defined in my version of emacs (28.1) and/or org (9.6). Maybe I need to upgrade... Dec 7, 2022 at 13:29
  • It is in 9.6: maybe oc-basic is not loaded?
    – NickD
    Dec 7, 2022 at 13:30

1 Answer 1

1

I learned from this post about the variable org-cite-global-bibliography.

Setting this to point at my bibliography file AND removing the #+BIBLIOGRAPHY: path/to/my.bib from the org-mode buffer seems to fix my issue.

My suspicious is that the keyword-based bibliography information is cached but the org-cite-global-bibliography variable is not, which allows changes to either the .bib or .org file to be updated in the .org document with a call to revert-buffer.

In summary, my old method included this line inside each org-mode file:

#+BIBLIOGRAPHY: path/to/my.bib

My new method adds the following to my .emacs config file:

(setq org-cite-global-bibliography path/to/my.bib)

And omits the #+BIBLIOGRAPHY: line from the .org files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.