1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-22 07:09:47 +00:00

org-cite-list-bibliography-files: Preserve relative bibliography paths

* lisp/oc.el (org-cite-list-bibliography-files): When the bibliography
path is relative to the exported file location, keep the path
relative.  Resolve relative paths for bibliographies from SETUPFILE as
well.

* testing/lisp/test-oc.el (test-org-cite/list-bibliography-files):
* testing/examples/sub-bib/include-relative-bib.org:
* testing/examples/sub-bib/include-global-bib.org: New test.

Link: https://orgmode.org/list/CAO48Bk_upR4h-xd0YL+FxeKtWvDoqH+Eju6F_Vzds_m6oxBKcg@mail.gmail.com
This commit is contained in:
Ihor Radchenko 2023-03-29 16:13:29 +02:00
parent e58bbded5c
commit 5ec364a1ae
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
4 changed files with 27 additions and 2 deletions

View File

@ -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)))

View File

@ -0,0 +1 @@
#+bibliography: /foo.bib

View File

@ -0,0 +1 @@
#+bibliography: ./foo.bib

View File

@ -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