From: Arash Esbati Date: Tue, 7 May 2024 13:50:03 +0000 (+0200) Subject: Support biblatex field in `reftex-cite-format' X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7b63533746e115500ffffebda9c2adae84fd5717;p=emacs.git 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. (cherry picked from commit ead7252353290d030b2f66d4bc46535122c7e447) --- 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'.