summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArash Esbati <arash@gnu.org>2024-05-07 15:50:03 +0200
committerArash Esbati <arash@gnu.org>2024-05-07 15:50:03 +0200
commitead7252353290d030b2f66d4bc46535122c7e447 (patch)
tree8828a2b4bc10ab532986acfa0baaa6350d1e859c
parent4b31074f5f49898ba0499a2b617cad425750eafa (diff)
downloademacs-ead7252353290d030b2f66d4bc46535122c7e447.tar.gz
Support biblatex field in `reftex-cite-format'
* lisp/textmodes/reftex-cite.el (reftex-format-citation): Recognize the alternative "journaltitle" field which is preferred by biblatex. (bug#38762) * test/lisp/textmodes/reftex-tests.el (reftex-format-citation-test): Adjust test.
-rw-r--r--lisp/textmodes/reftex-cite.el9
-rw-r--r--test/lisp/textmodes/reftex-tests.el20
2 files changed, 27 insertions, 2 deletions
diff --git a/lisp/textmodes/reftex-cite.el b/lisp/textmodes/reftex-cite.el
index 34f40ba689f..397b449a9c8 100644
--- a/lisp/textmodes/reftex-cite.el
+++ b/lisp/textmodes/reftex-cite.el
@@ -1048,7 +1048,14 @@ in order to only add another reference in the same cite command."
((= l ?E) (car (reftex-get-bib-names "editor" entry)))
((= l ?h) (reftex-get-bib-field "howpublished" entry))
((= l ?i) (reftex-get-bib-field "institution" entry))
- ((= l ?j) (reftex-get-bib-field "journal" entry))
+ ((= l ?j) (let ((jr (reftex-get-bib-field "journal" entry)))
+ (if (string-empty-p jr)
+ ;; Biblatex prefers the alternative
+ ;; journaltitle field, so check if that
+ ;; exists in case journal is empty
+ (reftex-get-bib-field "journaltitle" entry)
+ ;; Standard BibTeX
+ jr)))
((= l ?k) (reftex-get-bib-field "key" entry))
((= l ?m) (reftex-get-bib-field "month" entry))
((= l ?n) (reftex-get-bib-field "number" entry))
diff --git a/test/lisp/textmodes/reftex-tests.el b/test/lisp/textmodes/reftex-tests.el
index 456ee458865..eed00cbbbc3 100644
--- a/test/lisp/textmodes/reftex-tests.el
+++ b/test/lisp/textmodes/reftex-tests.el
@@ -197,10 +197,28 @@
journal = {Some Journal},
year = 2013,
pages = {1--333}
+}"))
+ (entry2 (reftex-parse-bibtex-entry "\
+@article{Abels:slice,
+author = {Abels, H.},
+title = {Parallelizability of proper actions, global
+ {$K$}-slices and maximal compact subgroups},
+journaltitle = {Math. Ann.},
+year = 1974,
+volume = 212,
+pages = {1--19}
}")))
(should (string= (reftex-format-citation entry nil) "\\cite{Foo13}"))
(should (string= (reftex-format-citation entry "%l:%A:%y:%t %j %P %a")
- "Foo13:Jane Roe:2013:Some Article Some Journal 1 Jane Roe, John Doe \\& Jane Taxpayer"))))
+ "Foo13:Jane Roe:2013:Some Article Some Journal 1 Jane Roe, John Doe \\& Jane Taxpayer"))
+ ;; Test for biblatex field journaltitle (bug#38762):
+ (should (string=
+ (reftex-format-citation entry2
+ "[%4a, \\textit{%t}, \
+%b %e, %u, %r %h %j \\textbf{%v} (%y), %p %<]")
+ "[Abels, \\textit{Parallelizability of proper actions, \
+global {$K$}-slices and maximal compact subgroups}, \
+Math. Ann. \\textbf{212} (1974), 1--19]"))))
(ert-deftest reftex-all-used-citation-keys ()
"Test `reftex-all-used-citation-keys'.