1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-24 07:20:37 +00:00

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.
This commit is contained in:
Arash Esbati 2024-05-07 15:50:03 +02:00
parent 4b31074f5f
commit ead7252353
2 changed files with 27 additions and 2 deletions

View 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))

View File

@ -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'.