emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [patch] add :url and :doi optional entries for export to BiBTeX
@ 2021-06-28 12:42 Eric S Fraga
  2021-06-28 12:59 ` Eric S Fraga
  0 siblings, 1 reply; 6+ messages in thread
From: Eric S Fraga @ 2021-06-28 12:42 UTC (permalink / raw)
  To: Emacs Org mode mailing list

[-- Attachment #1: Type: text/plain, Size: 525 bytes --]

Hello all,

increasingly, I need URL and DOI BiBTeX entries to cite particular types
of publications.  Some BiBTeX styles now recognise these but the current
BiBTeX exporter in org does not export these.  I have added :url and
:doi entries to the list of optional entries to export when present to a
selection of the publication types.

I think this is not a breaking change but who knows...

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4.6-571-gc591be
: Latest paper written in org: https://arxiv.org/abs/2106.05096

[-- Attachment #2: 0001-ol-bibtex-Added-url-and-doi-as-optional-entries-for-.patch --]
[-- Type: text/x-diff, Size: 7803 bytes --]

From ddad85139bd508a06db6e98ddef0131f7cc9946e Mon Sep 17 00:00:00 2001
From: Eric S Fraga <e.fraga@ucl.ac.uk>
Date: Mon, 28 Jun 2021 13:35:34 +0100
Subject: [PATCH] ol-bibtex: Added url and doi as optional entries for BiBTeX
 export

* lisp/ol-bibtex.el: :doi and :url entries added to optional list of
entries to export to BiBTeX when present in the properties.

* etc/ORG-NEWS: added news item noting this change.
---
 etc/ORG-NEWS      |  3 +++
 lisp/ol-bibtex.el | 31 +++++++++++++++++--------------
 2 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 956f1cf19..3f3971961 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -349,6 +349,9 @@ argument is present.  You can also set =:async no= to force it off
 Async evaluation is disabled during export.
 
 ** Miscellaneous
+*** =org-bibtex= includes =doi= and =url= entries when exporting to BiBTeX
+=doi= and =url= entries have been made optional for some publication
+types and will be exported if present for those types.
 *** Missing or empty placeholders in "eval" macros are now =nil=
 They used to be the empty string.
 *** =org-goto-first-child= now works before first heading
diff --git a/lisp/ol-bibtex.el b/lisp/ol-bibtex.el
index 57b240d92..bad4c7e54 100644
--- a/lisp/ol-bibtex.el
+++ b/lisp/ol-bibtex.el
@@ -145,59 +145,59 @@
   '((:article
      (:description . "An article from a journal or magazine")
      (:required :author :title :journal :year)
-     (:optional :volume :number :pages :month :note))
+     (:optional :volume :number :pages :month :note :doi))
     (:book
      (:description . "A book with an explicit publisher")
      (:required (:editor :author) :title :publisher :year)
-     (:optional (:volume :number) :series :address :edition :month :note))
+     (:optional (:volume :number) :series :address :edition :month :note :doi))
     (:booklet
      (:description . "A work that is printed and bound, but without a named publisher or sponsoring institution.")
      (:required :title)
-     (:optional :author :howpublished :address :month :year :note))
+     (:optional :author :howpublished :address :month :year :note :doi :url))
     (:conference
      (:description . "")
      (:required :author :title :booktitle :year)
-     (:optional :editor :pages :organization :publisher :address :month :note))
+     (:optional :editor :pages :organization :publisher :address :month :note :doi :url))
     (:inbook
      (:description . "A part of a book, which may be a chapter (or section or whatever) and/or a range of pages.")
      (:required (:author :editor) :title (:chapter :pages) :publisher :year)
-     (:optional :crossref (:volume :number) :series :type :address :edition :month :note))
+     (:optional :crossref (:volume :number) :series :type :address :edition :month :note :doi))
     (:incollection
      (:description . "A part of a book having its own title.")
      (:required :author :title :booktitle :publisher :year)
-     (:optional :crossref :editor (:volume :number) :series :type :chapter :pages :address :edition :month :note))
+     (:optional :crossref :editor (:volume :number) :series :type :chapter :pages :address :edition :month :note :doi))
     (:inproceedings
      (:description . "An article in a conference proceedings")
      (:required :author :title :booktitle :year)
-     (:optional :crossref :editor (:volume :number) :series :pages :address :month :organization :publisher :note))
+     (:optional :crossref :editor (:volume :number) :series :pages :address :month :organization :publisher :note :doi))
     (:manual
      (:description . "Technical documentation.")
      (:required :title)
-     (:optional :author :organization :address :edition :month :year :note))
+     (:optional :author :organization :address :edition :month :year :note :doi :url))
     (:mastersthesis
      (:description . "A Master’s thesis.")
      (:required :author :title :school :year)
-     (:optional :type :address :month :note))
+     (:optional :type :address :month :note :doi :url))
     (:misc
      (:description . "Use this type when nothing else fits.")
      (:required)
-     (:optional :author :title :howpublished :month :year :note))
+     (:optional :author :title :howpublished :month :year :note :doi :url))
     (:phdthesis
      (:description . "A PhD thesis.")
      (:required :author :title :school :year)
-     (:optional :type :address :month :note))
+     (:optional :type :address :month :note :doi :url))
     (:proceedings
      (:description . "The proceedings of a conference.")
      (:required :title :year)
-     (:optional :editor (:volume :number) :series :address :month :organization :publisher :note))
+     (:optional :editor (:volume :number) :series :address :month :organization :publisher :note :doi))
     (:techreport
      (:description . "A report published by a school or other institution.")
      (:required :author :title :institution :year)
-     (:optional :type :address :month :note))
+     (:optional :type :address :month :note :doi :url))
     (:unpublished
      (:description . "A document having an author and title, but not formally published.")
      (:required :author :title :note)
-     (:optional :month :year)))
+     (:optional :month :yeae :doi :url)))
   "Bibtex entry types with required and optional parameters.")
 
 (defvar org-bibtex-fields
@@ -207,6 +207,7 @@
     (:booktitle    . "Title of a book, part of which is being cited.  See the LaTeX book for how to type titles.  For book entries, use the title field instead.")
     (:chapter      . "A chapter (or section or whatever) number.")
     (:crossref     . "The database key of the entry being cross referenced.")
+    (:doi          . "The digital object identifier.")
     (:edition      . "The edition of a book for example, 'Second'.  This should be an ordinal, and should have the first letter capitalized, as shown here; the standard styles convert to lower case when necessary.")
     (:editor       . "Name(s) of editor(s), typed as indicated in the LaTeX book.  If there is also an author field, then the editor field gives the editor of the book or collection in which the reference appears.")
     (:howpublished . "How something strange has been published.  The first word should be capitalized.")
@@ -223,6 +224,7 @@
     (:series       . "The name of a series or set of books.  When citing an entire book, the title field gives its title and an optional series field gives the name of a series or multi-volume set in which the book is published.")
     (:title        . "The work’s title, typed as explained in the LaTeX book.")
     (:type         . "The type of a technical report for example, 'Research Note'.")
+    (:url          . "Uniform resource locator.")
     (:volume       . "The volume of a journal or multi-volume book.")
     (:year         . "The year of publication or, for an unpublished work, the year it was written.  Generally it should consist of four numerals, such as 1984, although the standard styles can handle any year whose last four nonpunctuation characters are numerals, such as '(about 1984)'"))
   "Bibtex fields with descriptions.")
@@ -507,6 +509,7 @@ ARG, when non-nil, is a universal prefix argument.  See
       (org-link-store-props
        :key (cdr (assoc "=key=" entry))
        :author (or (cdr (assoc "author" entry)) "[no author]")
+       :doi (or (cdr (assoc "doi" entry)) "[no doi]")
        :editor (or (cdr (assoc "editor" entry)) "[no editor]")
        :title (or (cdr (assoc "title" entry)) "[no title]")
        :booktitle (or (cdr (assoc "booktitle" entry)) "[no booktitle]")
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [patch] add :url and :doi optional entries for export to BiBTeX
  2021-06-28 12:42 [patch] add :url and :doi optional entries for export to BiBTeX Eric S Fraga
@ 2021-06-28 12:59 ` Eric S Fraga
  2021-07-01 14:23   ` Timothy
  0 siblings, 1 reply; 6+ messages in thread
From: Eric S Fraga @ 2021-06-28 12:59 UTC (permalink / raw)
  To: Org Mode List

[-- Attachment #1: Type: text/plain, Size: 216 bytes --]

I introduced an error in the previous patch.  Please use this one.
Thank you,
eric

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4.6-571-gc591be
: Latest paper written in org: https://arxiv.org/abs/2106.05096

[-- Attachment #2: 0001-ol-bibtex-Added-url-and-doi-as-optional-entries-for-.patch --]
[-- Type: text/x-diff, Size: 7803 bytes --]

From ddad85139bd508a06db6e98ddef0131f7cc9946e Mon Sep 17 00:00:00 2001
From: Eric S Fraga <e.fraga@ucl.ac.uk>
Date: Mon, 28 Jun 2021 13:35:34 +0100
Subject: [PATCH] ol-bibtex: Added url and doi as optional entries for BiBTeX
 export

* lisp/ol-bibtex.el: :doi and :url entries added to optional list of
entries to export to BiBTeX when present in the properties.

* etc/ORG-NEWS: added news item noting this change.
---
 etc/ORG-NEWS      |  3 +++
 lisp/ol-bibtex.el | 31 +++++++++++++++++--------------
 2 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 956f1cf19..3f3971961 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -349,6 +349,9 @@ argument is present.  You can also set =:async no= to force it off
 Async evaluation is disabled during export.
 
 ** Miscellaneous
+*** =org-bibtex= includes =doi= and =url= entries when exporting to BiBTeX
+=doi= and =url= entries have been made optional for some publication
+types and will be exported if present for those types.
 *** Missing or empty placeholders in "eval" macros are now =nil=
 They used to be the empty string.
 *** =org-goto-first-child= now works before first heading
diff --git a/lisp/ol-bibtex.el b/lisp/ol-bibtex.el
index 57b240d92..bad4c7e54 100644
--- a/lisp/ol-bibtex.el
+++ b/lisp/ol-bibtex.el
@@ -145,59 +145,59 @@
   '((:article
      (:description . "An article from a journal or magazine")
      (:required :author :title :journal :year)
-     (:optional :volume :number :pages :month :note))
+     (:optional :volume :number :pages :month :note :doi))
     (:book
      (:description . "A book with an explicit publisher")
      (:required (:editor :author) :title :publisher :year)
-     (:optional (:volume :number) :series :address :edition :month :note))
+     (:optional (:volume :number) :series :address :edition :month :note :doi))
     (:booklet
      (:description . "A work that is printed and bound, but without a named publisher or sponsoring institution.")
      (:required :title)
-     (:optional :author :howpublished :address :month :year :note))
+     (:optional :author :howpublished :address :month :year :note :doi :url))
     (:conference
      (:description . "")
      (:required :author :title :booktitle :year)
-     (:optional :editor :pages :organization :publisher :address :month :note))
+     (:optional :editor :pages :organization :publisher :address :month :note :doi :url))
     (:inbook
      (:description . "A part of a book, which may be a chapter (or section or whatever) and/or a range of pages.")
      (:required (:author :editor) :title (:chapter :pages) :publisher :year)
-     (:optional :crossref (:volume :number) :series :type :address :edition :month :note))
+     (:optional :crossref (:volume :number) :series :type :address :edition :month :note :doi))
     (:incollection
      (:description . "A part of a book having its own title.")
      (:required :author :title :booktitle :publisher :year)
-     (:optional :crossref :editor (:volume :number) :series :type :chapter :pages :address :edition :month :note))
+     (:optional :crossref :editor (:volume :number) :series :type :chapter :pages :address :edition :month :note :doi))
     (:inproceedings
      (:description . "An article in a conference proceedings")
      (:required :author :title :booktitle :year)
-     (:optional :crossref :editor (:volume :number) :series :pages :address :month :organization :publisher :note))
+     (:optional :crossref :editor (:volume :number) :series :pages :address :month :organization :publisher :note :doi))
     (:manual
      (:description . "Technical documentation.")
      (:required :title)
-     (:optional :author :organization :address :edition :month :year :note))
+     (:optional :author :organization :address :edition :month :year :note :doi :url))
     (:mastersthesis
      (:description . "A Master’s thesis.")
      (:required :author :title :school :year)
-     (:optional :type :address :month :note))
+     (:optional :type :address :month :note :doi :url))
     (:misc
      (:description . "Use this type when nothing else fits.")
      (:required)
-     (:optional :author :title :howpublished :month :year :note))
+     (:optional :author :title :howpublished :month :year :note :doi :url))
     (:phdthesis
      (:description . "A PhD thesis.")
      (:required :author :title :school :year)
-     (:optional :type :address :month :note))
+     (:optional :type :address :month :note :doi :url))
     (:proceedings
      (:description . "The proceedings of a conference.")
      (:required :title :year)
-     (:optional :editor (:volume :number) :series :address :month :organization :publisher :note))
+     (:optional :editor (:volume :number) :series :address :month :organization :publisher :note :doi))
     (:techreport
      (:description . "A report published by a school or other institution.")
      (:required :author :title :institution :year)
-     (:optional :type :address :month :note))
+     (:optional :type :address :month :note :doi :url))
     (:unpublished
      (:description . "A document having an author and title, but not formally published.")
      (:required :author :title :note)
-     (:optional :month :year)))
+     (:optional :month :year :doi :url)))
   "Bibtex entry types with required and optional parameters.")
 
 (defvar org-bibtex-fields
@@ -207,6 +207,7 @@
     (:booktitle    . "Title of a book, part of which is being cited.  See the LaTeX book for how to type titles.  For book entries, use the title field instead.")
     (:chapter      . "A chapter (or section or whatever) number.")
     (:crossref     . "The database key of the entry being cross referenced.")
+    (:doi          . "The digital object identifier.")
     (:edition      . "The edition of a book for example, 'Second'.  This should be an ordinal, and should have the first letter capitalized, as shown here; the standard styles convert to lower case when necessary.")
     (:editor       . "Name(s) of editor(s), typed as indicated in the LaTeX book.  If there is also an author field, then the editor field gives the editor of the book or collection in which the reference appears.")
     (:howpublished . "How something strange has been published.  The first word should be capitalized.")
@@ -223,6 +224,7 @@
     (:series       . "The name of a series or set of books.  When citing an entire book, the title field gives its title and an optional series field gives the name of a series or multi-volume set in which the book is published.")
     (:title        . "The work’s title, typed as explained in the LaTeX book.")
     (:type         . "The type of a technical report for example, 'Research Note'.")
+    (:url          . "Uniform resource locator.")
     (:volume       . "The volume of a journal or multi-volume book.")
     (:year         . "The year of publication or, for an unpublished work, the year it was written.  Generally it should consist of four numerals, such as 1984, although the standard styles can handle any year whose last four nonpunctuation characters are numerals, such as '(about 1984)'"))
   "Bibtex fields with descriptions.")
@@ -507,6 +509,7 @@ ARG, when non-nil, is a universal prefix argument.  See
       (org-link-store-props
        :key (cdr (assoc "=key=" entry))
        :author (or (cdr (assoc "author" entry)) "[no author]")
+       :doi (or (cdr (assoc "doi" entry)) "[no doi]")
        :editor (or (cdr (assoc "editor" entry)) "[no editor]")
        :title (or (cdr (assoc "title" entry)) "[no title]")
        :booktitle (or (cdr (assoc "booktitle" entry)) "[no booktitle]")
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [patch] add :url and :doi optional entries for export to BiBTeX
  2021-06-28 12:59 ` Eric S Fraga
@ 2021-07-01 14:23   ` Timothy
  2021-07-01 15:54     ` Eric S Fraga
  0 siblings, 1 reply; 6+ messages in thread
From: Timothy @ 2021-07-01 14:23 UTC (permalink / raw)
  To: Eric S Fraga; +Cc: emacs-orgmode


Hi Eric,

I've not used Org for exporting to BibTeX, so I don't really know what
I'm on about, but is there any particular reason why only some entries
have :url ? Other than that, this seems like a fairly straightforward
patch.

--
Timothy

Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> I introduced an error in the previous patch.  Please use this one.
> Thank you,
> eric


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch] add :url and :doi optional entries for export to BiBTeX
  2021-07-01 14:23   ` Timothy
@ 2021-07-01 15:54     ` Eric S Fraga
  2021-07-01 21:16       ` Nicolas Goaziou
  0 siblings, 1 reply; 6+ messages in thread
From: Eric S Fraga @ 2021-07-01 15:54 UTC (permalink / raw)
  To: Timothy; +Cc: emacs-orgmode

On Thursday,  1 Jul 2021 at 22:23, Timothy wrote:
> I've not used Org for exporting to BibTeX, so I don't really know what
> I'm on about, but is there any particular reason why only some entries
> have :url ? Other than that, this seems like a fairly straightforward
> patch.

First of all, it's an optional entry so only exported if present.  What I did was consider which types of publications would tend to have a URL instead of other bibliographic information and only include for those where it would likely necessary.  For instance, journal articles will be given a DOI so a URL is less useful; technical reports, however, are likely to be hosted at an institution's web site so a URL is likely useful.

But I must admit that I didn't spend much time thinking about which ones should have it.  I didn't want all of them because I often store the URL for a journal article in the org file just for quick access but I do not want it exported to BiBTeX as it would be messy and superfluous when the paper were cited.

I'm glad the patch seemed straightforward!  Thank you.

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4.6-570-g7666d6
: Latest paper written in org: https://arxiv.org/abs/2106.05096


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch] add :url and :doi optional entries for export to BiBTeX
  2021-07-01 15:54     ` Eric S Fraga
@ 2021-07-01 21:16       ` Nicolas Goaziou
  2021-07-02  7:59         ` Eric S Fraga
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2021-07-01 21:16 UTC (permalink / raw)
  To: Org Mode List

Hello,

Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> On Thursday,  1 Jul 2021 at 22:23, Timothy wrote:
>> I've not used Org for exporting to BibTeX, so I don't really know what
>> I'm on about, but is there any particular reason why only some entries
>> have :url ? Other than that, this seems like a fairly straightforward
>> patch.
>
> First of all, it's an optional entry so only exported if present. What
> I did was consider which types of publications would tend to have
> a URL instead of other bibliographic information and only include for
> those where it would likely necessary. For instance, journal articles
> will be given a DOI so a URL is less useful; technical reports,
> however, are likely to be hosted at an institution's web site so a URL
> is likely useful.
>
> But I must admit that I didn't spend much time thinking about which
> ones should have it. I didn't want all of them because I often store
> the URL for a journal article in the org file just for quick access
> but I do not want it exported to BiBTeX as it would be messy and
> superfluous when the paper were cited.
>
> I'm glad the patch seemed straightforward!  Thank you.

Applied. Thanks to both of you.

Regards,
-- 
Nicolas Goaziou


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch] add :url and :doi optional entries for export to BiBTeX
  2021-07-01 21:16       ` Nicolas Goaziou
@ 2021-07-02  7:59         ` Eric S Fraga
  0 siblings, 0 replies; 6+ messages in thread
From: Eric S Fraga @ 2021-07-02  7:59 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode List

On Thursday,  1 Jul 2021 at 23:16, Nicolas Goaziou wrote:
> Applied. Thanks to both of you.

Thank you!

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4.6-570-g7666d6
: Latest paper written in org: https://arxiv.org/abs/2106.05096


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-07-02  8:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-28 12:42 [patch] add :url and :doi optional entries for export to BiBTeX Eric S Fraga
2021-06-28 12:59 ` Eric S Fraga
2021-07-01 14:23   ` Timothy
2021-07-01 15:54     ` Eric S Fraga
2021-07-01 21:16       ` Nicolas Goaziou
2021-07-02  7:59         ` Eric S Fraga

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).