refactor: Skip missing per-buffer local bibliography files#886
Conversation
…phy-files Two helpers extracted in preparation for refactoring `citar--bibliography-files': - `citar--global-bibliography-files' returns `citar-bibliography' after validating it is a list of existing files (signals an error otherwise). - `citar--local-bibliography-files' returns the per-buffer local bibliography files declared via `local-bib-files' in `citar-major-mode-functions', without validating existence.
Rewrite `citar--bibliography-files' to delegate global and per-buffer bibliography file collection to the recently added `citar--global-bibliography-files' and `citar--local-bibliography-files' helpers. Local bibliography files that do not exist are now silently filtered out instead of signalling a `user-error'; globals retain the previous strict existence check. This unblocks workflows that declare a project-local bibliography file (e.g. via Org `#+bibliography:') before the file has been materialized — for instance via `citar-export-local-bibtex-file'. `citar-file--normalize-paths' and `citar-file--files-exist-p' had only one caller each (the rewritten `citar--bibliography-files') and have been removed.
Add four tests for `citar--bibliography-files': - existing global is returned; - missing global signals a `user-error'; - missing per-buffer local is silently filtered; - existing per-buffer local is included.
|
I am not sure this is a good idea. The missing files might be due to a typo etc. Silently ignoring the unavailability seems problematic. I think the problem this is trying to solve can be worked around by just commenting out the line for the bibliography. |
Fair point on typo masking. I based the idea of ignoring on LaTeX's compilation process, which will produce an output even if the bibliography file does not exist. But to be fair to my initial idea, even LaTeX's compilation produces warnings and errors in stderr and log files. Would you consider this change if I added a
The comment-out workaround misses the use case driving this PR (a follow-up to #885). I want |
Summary
citar--bibliography-filesnow treats missing per-buffer local bibliography files as a soft case (silently filtered) instead of an error. Globals (citar-bibliography) retain the previous strict existence check.Motivation
The pre-flight existence check (introduced in #765) conflates two cases:
citar-bibliographyare user-configured up front. A missing global typically indicates a typo and should fail fast.#+bibliography:or TeX\bibliography{}. These may legitimately point to files that haven't been written yet — e.g. a project-local bib materialized after writing citations viacitar-export-local-bibtex-file.Treating both equally meant inserting a citation into an Org buffer with
#+bibliography: project.biberrored out beforeproject.bibexisted, blocking the natural pre-export workflow.Changes
citar--global-bibliography-files(validates) andcitar--local-bibliography-files(does not validate).citar--bibliography-filesto use them.citar-file--normalize-pathsandcitar-file--files-exist-p(no longer used).Backwards compatibility