]> git.eshelyaron.com Git - emacs.git/commitdiff
Support biblatex field in `reftex-cite-format'
authorArash Esbati <arash@gnu.org>
Tue, 7 May 2024 13:50:03 +0000 (15:50 +0200)
committerEshel Yaron <me@eshelyaron.com>
Wed, 8 May 2024 16:52:46 +0000 (18:52 +0200)
* 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)

lisp/textmodes/reftex-cite.el
test/lisp/textmodes/reftex-tests.el

index 34f40ba689ffe250b0eb308bdc51ed5a8e57dbe5..397b449a9c879071851ced813a328d31409abb72 100644 (file)
@@ -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))
index 456ee45886572243cc416f16579c04bc803157b9..eed00cbbbc34a2174e0c3a2a9b12e0f8a5f50e53 100644 (file)
   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'.