diff --git a/lisp/oc.el b/lisp/oc.el index 4b1420271..69b5cff7a 100644 --- a/lisp/oc.el +++ b/lisp/oc.el @@ -602,7 +602,18 @@ to (adaptive outside after)." (append (mapcar (lambda (value) (pcase value (`(,f . ,d) - (expand-file-name (org-strip-quotes f) d)))) + (setq f (org-strip-quotes f)) + (if (or (file-name-absolute-p f) + (file-remote-p f) + (equal d default-directory)) + ;; Keep absolute paths, remote paths, and + ;; local relative paths. + f + ;; Adjust relative bibliography path for + ;; #+SETUP files located in other directory. + ;; Also, see `org-export--update-included-link'. + (file-relative-name + (expand-file-name f d) default-directory))))) (pcase (org-collect-keywords '("BIBLIOGRAPHY") nil '("BIBLIOGRAPHY")) (`(("BIBLIOGRAPHY" . ,pairs)) pairs))) diff --git a/testing/examples/sub-bib/include-global-bib.org b/testing/examples/sub-bib/include-global-bib.org new file mode 100644 index 000000000..e7a4ffb79 --- /dev/null +++ b/testing/examples/sub-bib/include-global-bib.org @@ -0,0 +1 @@ +#+bibliography: /foo.bib diff --git a/testing/examples/sub-bib/include-relative-bib.org b/testing/examples/sub-bib/include-relative-bib.org new file mode 100644 index 000000000..9fae85005 --- /dev/null +++ b/testing/examples/sub-bib/include-relative-bib.org @@ -0,0 +1 @@ +#+bibliography: ./foo.bib diff --git a/testing/lisp/test-oc.el b/testing/lisp/test-oc.el index 4a39874a8..b1db742d7 100644 --- a/testing/lisp/test-oc.el +++ b/testing/lisp/test-oc.el @@ -482,8 +482,20 @@ (let ((org-cite-global-bibliography '("/other-bibliography"))) (org-cite-list-bibliography-files))))) (should - (equal '(t) + (equal '("./bibliography") (org-test-with-temp-text "#+bibliography: ./bibliography" + (let ((org-cite-global-bibliography nil)) + (org-cite-list-bibliography-files))))) + (should + (equal '("/foo.bib") + (org-test-with-temp-text + (format "#+SETUPFILE: \"%s/examples/sub-bib/include-global-bib.org\"" org-test-dir) + (let ((org-cite-global-bibliography nil)) + (org-cite-list-bibliography-files))))) + (should + (equal '(nil) + (org-test-with-temp-text + (format "#+SETUPFILE: \"%s/examples/sub-bib/include-relative-bib.org\"" org-test-dir) (let ((org-cite-global-bibliography nil)) (mapcar #'file-name-absolute-p (org-cite-list-bibliography-files)))))) (should