citar icon indicating copy to clipboard operation
citar copied to clipboard

Force citar to use citar-bibliography (not citar-latex-local-bib-files) for PDFs and notes

Open rdiaz02 opened this issue 10 months ago • 6 comments

Is your feature request related to a problem? Please describe. When I write papers, I initially have the bib file be a symlink to my full bib file. Before the final submission, I prepare a .bib file that contains only the entries with the required fields (e.g., bibexport -o paper.bib paper.aux). In that bib file, the file field disappears (as it should).

But if I now want to see the PDFs (citar-open-files) I often can't, as citar will often use first the new bib, not the global one I specify via citar-bibliography in my init.el (both bib files have the same keys).

Describe the solution you'd like Search PDFs and notes in the global citar-bibliography file.

Describe alternatives you've considered I think I could set to nil or remove, from citar-major-mode-functions the entry for local-bib-files. I can also redefine citar-latex-local-bib-files to return nil; this I've tested adding advice in my init.el and it seems to work.

  (advice-add 'citar-latex-local-bib-files :override
		(lambda (&rest _) nil))

But I am not sure if this is a good idea. If it is, well, I am done and happy with the solution :smiley: .

Additional context

While searching for similar issues, I found these to be somewhat related:

  • https://github.com/emacs-citar/citar/pull/831 and
  • https://github.com/emacs-citar/citar/pull/800 and
  • https://github.com/emacs-citar/citar/issues/695

though I think citar-local-bibliography was not finally added?

rdiaz02 avatar Feb 17 '25 17:02 rdiaz02

Is this related?

https://github.com/emacs-citar/citar/issues/852

Not sure about the advice, but I suppose if it results in the behavior you want, no problem?

bdarcus avatar Feb 17 '25 17:02 bdarcus

Currently when Citar is using multiple bibliographies, entries in higher-priority bibliographies (the local ones) completely override entries in global bibliographies with the same key. For most bibliography fields, I think this is the right thing to do since it wouldn't make sense to mix and match fields from different entries. But for the file field, perhaps it would make more sense to merge the contents of the fields?

roshanshariff avatar Feb 17 '25 19:02 roshanshariff

Not sure about the advice, but I suppose if it results in the behavior you want, no problem?

Perfect!

Is this related?

#852

Yes, sorry, forgot to mention that one. What @christophe-gouel wanted was slightly different, though (https://github.com/emacs-citar/citar/issues/852#issuecomment-2585275652)

(...) I would like to have the same behavior as with RefTeX: Use only the local file if defined Use the global file in the absence of a local file

But his comment

What is tricky here is that, contrary to RefTeX, citar is not just for inserting citations, but also for opening them. One may want a different behavior for citations (local only) and for exploration (global).

I think raises what I think is the actual cause of the of the issue (which might be addressable with what @roshanshariff suggests?)

rdiaz02 avatar Feb 17 '25 21:02 rdiaz02

Currently when Citar is using multiple bibliographies, entries in higher-priority bibliographies (the local ones) completely override entries in global bibliographies with the same key.

Would it be worth saying this explicitly in the README? Maybe in section https://github.com/emacs-citar/citar#reftex-and-local-bibliographic-files-in-latex , and possibly also mentioning the consequence of not opening PDFs? (Or maybe this ought to be a wiki entry?). I can make pull requests if deemed appropriate.

For most bibliography fields, I think this is the right thing to do since it wouldn't make sense to mix and match fields from different entries.

Yes, absolutely.

But for the file field, perhaps it would make more sense to merge the contents of the fields?

That would be great.

But then, maybe this is not really worth the effort? At least in my case, I can easily solve it via the advice (and since the final bib is a strict subset of the large one with pdfs, and the keys do not change, that solution will always work in my case).

So maybe this issue should be closed.

rdiaz02 avatar Feb 17 '25 22:02 rdiaz02

Would it be worth saying this explicitly in the README? Maybe in section https://github.com/emacs-citar/citar#reftex-and-local-bibliographic-files-in-latex , and possibly also mentioning the consequence of not opening PDFs? (Or maybe this ought to be a wiki entry?). I can make pull requests if deemed appropriate.

I think it makes sense in the README, since it should only take a sentence or two.

A PR would be welcome.

Gracias!

bdarcus avatar Feb 18 '25 14:02 bdarcus

Done: https://github.com/emacs-citar/citar/pull/860

Gracias a ti!

rdiaz02 avatar Feb 19 '25 16:02 rdiaz02