[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org 5ec364a1ae 2/2: org-cite-list-bibliography-files: P
|
From: |
ELPA Syncer |
|
Subject: |
[elpa] externals/org 5ec364a1ae 2/2: org-cite-list-bibliography-files: Preserve relative bibliography paths |
|
Date: |
Tue, 2 May 2023 08:59:22 -0400 (EDT) |
branch: externals/org
commit 5ec364a1ae327312da6f69766a2bec79bc7691e8
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>
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
---
lisp/oc.el | 13 ++++++++++++-
testing/examples/sub-bib/include-global-bib.org | 1 +
testing/examples/sub-bib/include-relative-bib.org | 1 +
testing/lisp/test-oc.el | 14 +++++++++++++-
4 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/lisp/oc.el b/lisp/oc.el
index 4b1420271d..69b5cff7a1 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 0000000000..e7a4ffb790
--- /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 0000000000..9fae850058
--- /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 4a39874a82..b1db742d74 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