Re: [PATCH] oc-natbib: Provide a fallback bibliography style

2023-02-20 Thread Ihor Radchenko
Ihor Radchenko  writes:

> From f27e5b4f66b7e703f9b2fdaa5c1b5d756d38fd33 Mon Sep 17 00:00:00 2001
> Message-Id: 
> 
> From: Ihor Radchenko 
> Date: Wed, 25 Jan 2023 18:02:49 +0300
> Subject: [PATCH] oc-natbib: Provide a fallback bibliography style

Applied, onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=d94f4066e

I did not add default custom options. We can do it later if necessary.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>



Re: [PATCH] oc-natbib: Provide a fallback bibliography style

2023-01-26 Thread Ihor Radchenko
András Simonyi  writes:

>> Also, should we provide some commonly available natbib styles in the
>> defcustom?
>
> What would this look like?

`org-cite-natbib-options' has the following:

:type
  '(set
(const :tag "use round parentheses (default)" round)
(const :tag "use square brackets" square)
(const :tag "use curly braces" curly)
...)

We can provide a list of possible bibliography styles (distributed with
TeXLive) maybe also with a description. However, my TeXLive has >300
.bst files in it. We certainly don't want to list all of them. Maybe
just the most popular. But what are "the most popular"?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [PATCH] oc-natbib: Provide a fallback bibliography style

2023-01-25 Thread András Simonyi
Dear All,

On Wed, 25 Jan 2023 at 16:10, Ihor Radchenko  wrote:

> If we do not specify a bibliography style, LaTeX export will fail.
> With the attached patch, the following simple-minded Org document will
> export without errors:

Thanks, I think that is an important improvement -- when I tried the
natbib exporter I expected it to do
something sensible without specifying a style.

> Also, should we provide some commonly available natbib styles in the
> defcustom?

What would this look like?

best wishes,
András



[PATCH] oc-natbib: Provide a fallback bibliography style

2023-01-25 Thread Ihor Radchenko

If we do not specify a bibliography style, LaTeX export will fail.
With the attached patch, the following simple-minded Org document will
export without errors:

 #+title: Testing org-cite \LaTeX export
 #+latex_header: \usepackage{natbib}
 #+bibliography: bibliography.bib
 #+options: toc:nil
 #+cite_export: natbib

 Hello World! This is a citation: [cite:@citationkey2023]

 #+print_bibliography:

Also, should we provide some commonly available natbib styles in the
defcustom?

>From f27e5b4f66b7e703f9b2fdaa5c1b5d756d38fd33 Mon Sep 17 00:00:00 2001
Message-Id: 
From: Ihor Radchenko 
Date: Wed, 25 Jan 2023 18:02:49 +0300
Subject: [PATCH] oc-natbib: Provide a fallback bibliography style

* lisp/oc-natbib.el (org-cite-natbib-bibliography-style): New custom
option for default bibliography style.
(org-cite-natbib-export-bibliography): Use the new custom option.
* etc/ORG-NEWS (New ~org-cite-natbib-export-bibliography~ option
defining fallback bibliography style): Document the new option.

If we do not specify a bibliography style, LaTeX export will fail.
After the patch, the following simple-minded Org document will export
without errors:

 #+title: Testing org-cite \LaTeX export
 #+latex_header: \usepackage{natbib}
 #+bibliography: bibliography.bib
 #+options: toc:nil
 #+cite_export: natbib

 Hello World! This is a citation: [cite:@citationkey2023]

 #+print_bibliography:
---
 etc/ORG-NEWS  | 10 ++
 lisp/oc-natbib.el | 21 -
 2 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 3ef76ec1a..04f6338a9 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -13,6 +13,16 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org.
 
 * Version 9.7 (not released yet)
 ** New options
+*** New ~org-cite-natbib-export-bibliography~ option defining fallback bibliography style
+
+~natbib~ citation export processor now uses
+~org-cite-natbib-export-bibliography~ (defaults to ~unsrtnat~) as a
+fallback bibliography style if none is specified by user in
+=#+cite_export:= keyword.
+
+Previously, export would fail without explicitly selected bibliography
+style.
+
 *** New options for the "csl" citation export processor's LaTeX output
 
 The ~org-cite-csl-latex-label-separator~ and
diff --git a/lisp/oc-natbib.el b/lisp/oc-natbib.el
index 855be2a5c..9153afd86 100644
--- a/lisp/oc-natbib.el
+++ b/lisp/oc-natbib.el
@@ -77,6 +77,15 @@ (defcustom org-cite-natbib-options nil
 (const :tag "redefine \\thebibliography to issue \\section* instead of \\chapter*" sectionbib)
 (const :tag "keep all the authors' names in a citation on one line" nonamebreak)))
 
+(defcustom org-cite-natbib-bibliography-style 'unsrtnat
+  "Default bibliography style."
+  :group 'org-cite
+  :package-version '(Org . "9.7")
+  :type
+  '(choice
+(const unsrtnat)
+(symbol :tag "Other")))
+
 
 ;;; Internal functions
 (defun org-cite-natbib--style-to-command (style)
@@ -143,11 +152,13 @@ (defun org-cite-natbib-export-bibliography (_keys files style  _)
   "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))
-  (format "\\bibliography{%s}"
-  (mapconcat #'file-name-sans-extension
- files
- ","
+  (concat
+   (format "\\bibliographystyle{%s}\n"
+   (or style org-cite-natbib-bibliography-style))
+   (format "\\bibliography{%s}"
+   (mapconcat #'file-name-sans-extension
+  files
+  ","
 
 (defun org-cite-natbib-export-citation (citation style _ info)
   "Export CITATION object.
-- 
2.39.1


-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>