From 82f1cecaf5c011506c6cc57cb3835b6f8eba0f6d Mon Sep 17 00:00:00 2001 From: "Pedro A. Aranda" Date: Wed, 17 Apr 2024 08:19:22 +0200 Subject: [PATCH 1/2] Allow explicit style= in cite_export options lisp/oc-biblatex.el: Allow explicit style= in biblatex cite-export doc/org-manual.org: Clarify documentation regarding biblatex cite-export --- doc/org-manual.org | 10 +++++++++- lisp/oc-biblatex.el | 31 +++++++++++++++++-------------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/doc/org-manual.org b/doc/org-manual.org index 6c699ae1e..2de5df3af 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -17614,7 +17614,15 @@ style and the =bibtex= backend. Always define the style first and then the rest of load-time options for the =biblatex= package. Alternatively, use the ~org-cite-biblatex-options~ variable in your Emacs configuration. It will only export to PDF, since it -relies on the ~biblatex~ processor of your LaTeX installation; +relies on the ~biblatex~ processor of your LaTeX installation. + +The previous example assumes the first element in the options is a +style. Alternatively you can specify ~style=~ explicitly anywhere in +the options string (as you would when setting the +~org-cite-biblatex-options~ variable in your Emacs configuration): + +: #+cite_export: biblatex backend=bibtex,style=numeric + ** Bibliography printing diff --git a/lisp/oc-biblatex.el b/lisp/oc-biblatex.el index 36c0ee7e5..13e160ac1 100644 --- a/lisp/oc-biblatex.el +++ b/lisp/oc-biblatex.el @@ -190,20 +190,23 @@ INITIAL is an initial style of comma-separated options, as a string or nil. STYLE is the style definition as a string or nil. Return a string." - (let ((options-no-style - (and initial - (let ((re (rx string-start (or "bibstyle" "citestyle" "style")))) - (seq-filter - (lambda (option) (not (string-match re option))) - (split-string (org-unbracket-string "[" "]" initial) - "," t " \t"))))) - (style-options - (cond - ((null style) nil) - ((not (string-match "/" style)) (list (concat "style=" style))) - (t - (list (concat "bibstyle=" (substring style nil (match-beginning 0))) - (concat "citestyle=" (substring style (match-end 0)))))))) + (let* ((options-no-style + (and initial + (let ((re (rx string-start (or "bibstyle" "citestyle" "style")))) + (seq-filter + (lambda (option) (not (string-match re option))) + (split-string (org-unbracket-string "[" "]" initial) + "," t " \t"))))) + ;; Did we state the style as style= in the options? + (explicit-style (string-match-p "\\(\\`s\\|,s\\)tyle=" style)) + (style-options + (cond + ((null style) nil) + ;; prepend style= if not already in options + ((not (string-match "/" style)) (list (if explicit-style style (concat "style=" style)))) + (t + (list (concat "bibstyle=" (substring style nil (match-beginning 0))) + (concat "citestyle=" (substring style (match-end 0)))))))) (if (or options-no-style style-options) (format "[%s]" (mapconcat #'identity -- 2.34.1