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:
parent
e58bbded5c
commit
5ec364a1ae
13
lisp/oc.el
13
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)))
|
||||
|
1
testing/examples/sub-bib/include-global-bib.org
Normal file
1
testing/examples/sub-bib/include-global-bib.org
Normal file
@ -0,0 +1 @@
|
||||
#+bibliography: /foo.bib
|
1
testing/examples/sub-bib/include-relative-bib.org
Normal file
1
testing/examples/sub-bib/include-relative-bib.org
Normal file
@ -0,0 +1 @@
|
||||
#+bibliography: ./foo.bib
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user