Hi Ihor,

Ihor Radchenko <[email protected]> writes:
> It would be nice to expand about possible values in the docstring.

> You can also add :tag to other values briefly describing what they do.

Okay, I've added some additional documentation and :tag info.

>> +  :safe #'stringp)
>
> Yet, the default value is a symbol, which is confusing.

I've corrected the values to strings.  However, after thinking more
about :safe I believe this variable should be considered unsafe. A
malicious actor could simply set "plain}\MalliciousCode" to insert any
TeX code.  I've removed the :safe declaration.

> Also, please document the new customization in etc/ORG-NEWS and possibly
> in the manual.

Done, thanks!
--
Thomas Ingram
https://taingram.org/

>From 021e4b606409912e6404f04a743db0edeb8ea1c6 Mon Sep 17 00:00:00 2001
From: Thomas Ingram <[email protected]>
Date: Sat, 13 Dec 2025 17:44:00 -0500
Subject: [PATCH] lisp/oc-bibtex.el: Add default bibliography style variable

* oc-bibtex.el (org-cite-bibtex-export-bibliography): Add
`org-cite-bibtex-bibliography-style' variable to provide a fallback
bibliography style if none is provided.

To render a bibliography bibtex requires a "\bibliographystyle{}" to
be set, omitting a style will create latex documents that fail to
compile.  This variable provides a fallback bibliography style for
when none is provided in the #+CITE_EXPORT options.
---
 etc/ORG-NEWS      |  6 ++++++
 lisp/oc-bibtex.el | 30 +++++++++++++++++++++++++++++-
 2 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index f4ff44d29..feac28cea 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -425,6 +425,12 @@ This option makes ~org-cite~'s ~basic~ insert processor use
 It can also be set to dynamically compute ~crm-separator~ so that the
 separator does not appear in completion candidates.
 
+*** New option ~org-cite-bibtex-bibliography-style~
+
+This option adds a fallback bibliography style for BibTeX when none is
+provided in the =#+CITE_EXPORT= options.  The default style is
+"plain".
+
 *** New Option ~org-md-link-org-files-as-md~
 
 This option makes it possible to disable mapping of linked org files
diff --git a/lisp/oc-bibtex.el b/lisp/oc-bibtex.el
index 1d44b10d0..804d96dc7 100644
--- a/lisp/oc-bibtex.el
+++ b/lisp/oc-bibtex.el
@@ -45,13 +45,41 @@
 
 (declare-function org-export-data "ox" (data info))
 
+(defcustom org-cite-bibtex-bibliography-style "plain"
+  "Default BibTeX bibliography style.
+
+BibTeX provides the following default styles:
+
+  \"plain\"   Sorted numbered entries
+  \"abbrv\"   Sorted numbered entries with abbreviated author name
+  \"unsrt\"   Unsorted numbered entries
+  \"alpha\"   Alphabetized entries with unique short id
+  \"acm\"     ACM Transactions
+  \"apalike\" APA-like
+  \"ieeetr\"  IEEE Transactions
+  \"siam\"    SIAM"
+  :group 'org-cite
+  :package-version '(Org . "9.8")
+  :type
+  '(choice
+    (const :tag "Plain" "plain")
+    (const :tag "Abbreviated" "abbrv")
+    (const :tag "Unsorted" "unsrt")
+    (const :tag "Alphabetic" "alpha")
+    (const :tag "ACM" "acm")
+    (const :tag "APA-like" "apalike")
+    (const :tag "IEEE" "ieeetr")
+    (const :tag "SIAM" "siam")
+    (string :tag "Other")))
+
 
 ;;; Export capability
 (defun org-cite-bibtex-export-bibliography (_keys files style &rest _)
   "Print references from bibliography FILES.
 FILES is a list of absolute file names.  STYLE is the bibliography style, as
 a string or nil."
-  (concat (and style (format "\\bibliographystyle{%s}\n" style))
+  (concat (format "\\bibliographystyle{%s}\n"
+                  (or style org-cite-bibtex-bibliography-style))
           (format "\\bibliography{%s}"
                   (mapconcat #'file-name-sans-extension
                              files
-- 
2.47.3

Reply via email to