]> git.bundesbrandschatzamt.de Git - emacsconfig.git/commitdiff
update org-ref
authorAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Wed, 24 Dec 2025 12:51:26 +0000 (13:51 +0100)
committerAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Wed, 24 Dec 2025 13:55:19 +0000 (14:55 +0100)
91 files changed:
elpa/org-ref-20241124.2012/citeproc/csl-locales/locales-en-US.xml [deleted file]
elpa/org-ref-20241124.2012/citeproc/csl-styles/apa-5th-edition.csl [deleted file]
elpa/org-ref-20241124.2012/citeproc/csl-styles/apa-numeric-superscript-brackets.csl [deleted file]
elpa/org-ref-20241124.2012/citeproc/csl-styles/chicago-author-date-16th-edition.csl [deleted file]
elpa/org-ref-20241124.2012/citeproc/csl-styles/elsevier-harvard.csl [deleted file]
elpa/org-ref-20241124.2012/citeproc/csl-styles/elsevier-with-titles.csl [deleted file]
elpa/org-ref-20241124.2012/contrib.el [deleted file]
elpa/org-ref-20241124.2012/doi-utils.el [deleted file]
elpa/org-ref-20241124.2012/nist-webbook.el [deleted file]
elpa/org-ref-20241124.2012/openalex.el [deleted file]
elpa/org-ref-20241124.2012/org-ref-arxiv.el [deleted file]
elpa/org-ref-20241124.2012/org-ref-autoloads.el [deleted file]
elpa/org-ref-20241124.2012/org-ref-bibliography-links.el [deleted file]
elpa/org-ref-20241124.2012/org-ref-bibtex.el [deleted file]
elpa/org-ref-20241124.2012/org-ref-citation-links.el [deleted file]
elpa/org-ref-20241124.2012/org-ref-compat.el [deleted file]
elpa/org-ref-20241124.2012/org-ref-core.el [deleted file]
elpa/org-ref-20241124.2012/org-ref-export.el [deleted file]
elpa/org-ref-20241124.2012/org-ref-extract.el [deleted file]
elpa/org-ref-20241124.2012/org-ref-glossary.el [deleted file]
elpa/org-ref-20241124.2012/org-ref-helm.el [deleted file]
elpa/org-ref-20241124.2012/org-ref-isbn.el [deleted file]
elpa/org-ref-20241124.2012/org-ref-ivy.el [deleted file]
elpa/org-ref-20241124.2012/org-ref-label-link.el [deleted file]
elpa/org-ref-20241124.2012/org-ref-latex.el [deleted file]
elpa/org-ref-20241124.2012/org-ref-misc-links.el [deleted file]
elpa/org-ref-20241124.2012/org-ref-natbib-bbl-citeproc.el [deleted file]
elpa/org-ref-20241124.2012/org-ref-pdf.el [deleted file]
elpa/org-ref-20241124.2012/org-ref-pgk.el [deleted file]
elpa/org-ref-20241124.2012/org-ref-pkg.el [deleted file]
elpa/org-ref-20241124.2012/org-ref-publish.el [deleted file]
elpa/org-ref-20241124.2012/org-ref-pubmed.el [deleted file]
elpa/org-ref-20241124.2012/org-ref-ref-links.el [deleted file]
elpa/org-ref-20241124.2012/org-ref-refproc.el [deleted file]
elpa/org-ref-20241124.2012/org-ref-sci-id.el [deleted file]
elpa/org-ref-20241124.2012/org-ref-scifinder.el [deleted file]
elpa/org-ref-20241124.2012/org-ref-scopus.el [deleted file]
elpa/org-ref-20241124.2012/org-ref-url-utils.el [deleted file]
elpa/org-ref-20241124.2012/org-ref-utils.el [deleted file]
elpa/org-ref-20241124.2012/org-ref-worldcat.el [deleted file]
elpa/org-ref-20241124.2012/org-ref-wos.el [deleted file]
elpa/org-ref-20241124.2012/org-ref.bib [deleted file]
elpa/org-ref-20241124.2012/org-ref.el [deleted file]
elpa/org-ref-20241124.2012/org-ref.org [deleted file]
elpa/org-ref-20241124.2012/x2bib.el [deleted file]
elpa/org-ref-20251206.1422/citeproc/csl-locales/locales-en-US.xml [new file with mode: 0644]
elpa/org-ref-20251206.1422/citeproc/csl-styles/apa-5th-edition.csl [new file with mode: 0644]
elpa/org-ref-20251206.1422/citeproc/csl-styles/apa-numeric-superscript-brackets.csl [new file with mode: 0644]
elpa/org-ref-20251206.1422/citeproc/csl-styles/chicago-author-date-16th-edition.csl [new file with mode: 0644]
elpa/org-ref-20251206.1422/citeproc/csl-styles/chicago-fullnote-bibliography-16th-edition.csl [new file with mode: 0644]
elpa/org-ref-20251206.1422/citeproc/csl-styles/elsevier-harvard.csl [new file with mode: 0644]
elpa/org-ref-20251206.1422/citeproc/csl-styles/elsevier-with-titles.csl [new file with mode: 0644]
elpa/org-ref-20251206.1422/contrib.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/doi-utils.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/nist-webbook.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/openalex.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref-arxiv.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref-autoloads.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref-bibliography-links.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref-bibtex.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref-citation-links.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref-compat.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref-core.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref-export.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref-extract.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref-glossary.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref-helm.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref-isbn.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref-ivy.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref-label-link.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref-latex.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref-misc-links.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref-natbib-bbl-citeproc.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref-pdf.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref-pgk.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref-pkg.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref-publish.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref-pubmed.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref-ref-links.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref-refproc.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref-sci-id.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref-scifinder.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref-scopus.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref-url-utils.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref-utils.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref-worldcat.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref-wos.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref.bib [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref.el [new file with mode: 0644]
elpa/org-ref-20251206.1422/org-ref.org [new file with mode: 0644]
elpa/org-ref-20251206.1422/x2bib.el [new file with mode: 0644]

diff --git a/elpa/org-ref-20241124.2012/citeproc/csl-locales/locales-en-US.xml b/elpa/org-ref-20241124.2012/citeproc/csl-locales/locales-en-US.xml
deleted file mode 100644 (file)
index be78c5e..0000000
+++ /dev/null
@@ -1,357 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<locale xmlns="http://purl.org/net/xbiblio/csl" version="1.0" xml:lang="en-US">
-  <info>
-    <translator>
-      <name>Andrew Dunning</name>
-    </translator>
-    <translator>
-      <name>Sebastian Karcher</name>
-    </translator>
-    <translator>
-      <name>Rintze M. Zelle</name>
-    </translator>
-    <rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
-    <updated>2015-10-10T23:31:02+00:00</updated>
-  </info>
-  <style-options punctuation-in-quote="true"/>
-  <date form="text">
-    <date-part name="month" suffix=" "/>
-    <date-part name="day" suffix=", "/>
-    <date-part name="year"/>
-  </date>
-  <date form="numeric">
-    <date-part name="month" form="numeric-leading-zeros" suffix="/"/>
-    <date-part name="day" form="numeric-leading-zeros" suffix="/"/>
-    <date-part name="year"/>
-  </date>
-  <terms>
-    <term name="accessed">accessed</term>
-    <term name="and">and</term>
-    <term name="and others">and others</term>
-    <term name="anonymous">anonymous</term>
-    <term name="anonymous" form="short">anon.</term>
-    <term name="at">at</term>
-    <term name="available at">available at</term>
-    <term name="by">by</term>
-    <term name="circa">circa</term>
-    <term name="circa" form="short">c.</term>
-    <term name="cited">cited</term>
-    <term name="edition">
-      <single>edition</single>
-      <multiple>editions</multiple>
-    </term>
-    <term name="edition" form="short">ed.</term>
-    <term name="et-al">et al.</term>
-    <term name="forthcoming">forthcoming</term>
-    <term name="from">from</term>
-    <term name="ibid">ibid.</term>
-    <term name="in">in</term>
-    <term name="in press">in press</term>
-    <term name="internet">internet</term>
-    <term name="interview">interview</term>
-    <term name="letter">letter</term>
-    <term name="no date">no date</term>
-    <term name="no date" form="short">n.d.</term>
-    <term name="online">online</term>
-    <term name="presented at">presented at the</term>
-    <term name="reference">
-      <single>reference</single>
-      <multiple>references</multiple>
-    </term>
-    <term name="reference" form="short">
-      <single>ref.</single>
-      <multiple>refs.</multiple>
-    </term>
-    <term name="retrieved">retrieved</term>
-    <term name="scale">scale</term>
-    <term name="version">version</term>
-
-    <!-- ANNO DOMINI; BEFORE CHRIST -->
-    <term name="ad">AD</term>
-    <term name="bc">BC</term>
-
-    <!-- PUNCTUATION -->
-    <term name="open-quote">“</term>
-    <term name="close-quote">”</term>
-    <term name="open-inner-quote">‘</term>
-    <term name="close-inner-quote">’</term>
-    <term name="page-range-delimiter">–</term>
-
-    <!-- ORDINALS -->
-    <term name="ordinal">th</term>
-    <term name="ordinal-01">st</term>
-    <term name="ordinal-02">nd</term>
-    <term name="ordinal-03">rd</term>
-    <term name="ordinal-11">th</term>
-    <term name="ordinal-12">th</term>
-    <term name="ordinal-13">th</term>
-
-    <!-- LONG ORDINALS -->
-    <term name="long-ordinal-01">first</term>
-    <term name="long-ordinal-02">second</term>
-    <term name="long-ordinal-03">third</term>
-    <term name="long-ordinal-04">fourth</term>
-    <term name="long-ordinal-05">fifth</term>
-    <term name="long-ordinal-06">sixth</term>
-    <term name="long-ordinal-07">seventh</term>
-    <term name="long-ordinal-08">eighth</term>
-    <term name="long-ordinal-09">ninth</term>
-    <term name="long-ordinal-10">tenth</term>
-
-    <!-- LONG LOCATOR FORMS -->
-    <term name="book">
-      <single>book</single>
-      <multiple>books</multiple>
-    </term>
-    <term name="chapter">
-      <single>chapter</single>
-      <multiple>chapters</multiple>
-    </term>
-    <term name="column">
-      <single>column</single>
-      <multiple>columns</multiple>
-    </term>
-    <term name="figure">
-      <single>figure</single>
-      <multiple>figures</multiple>
-    </term>
-    <term name="folio">
-      <single>folio</single>
-      <multiple>folios</multiple>
-    </term>
-    <term name="issue">
-      <single>number</single>
-      <multiple>numbers</multiple>
-    </term>
-    <term name="line">
-      <single>line</single>
-      <multiple>lines</multiple>
-    </term>
-    <term name="note">
-      <single>note</single>
-      <multiple>notes</multiple>
-    </term>
-    <term name="opus">
-      <single>opus</single>
-      <multiple>opera</multiple>
-    </term>
-    <term name="page">
-      <single>page</single>
-      <multiple>pages</multiple>
-    </term>
-    <term name="number-of-pages">
-      <single>page</single>
-      <multiple>pages</multiple>
-    </term>
-    <term name="paragraph">
-      <single>paragraph</single>
-      <multiple>paragraphs</multiple>
-    </term>
-    <term name="part">
-      <single>part</single>
-      <multiple>parts</multiple>
-    </term>
-    <term name="section">
-      <single>section</single>
-      <multiple>sections</multiple>
-    </term>
-    <term name="sub verbo">
-      <single>sub verbo</single>
-      <multiple>sub verbis</multiple>
-    </term>
-    <term name="verse">
-      <single>verse</single>
-      <multiple>verses</multiple>
-    </term>
-    <term name="volume">
-      <single>volume</single>
-      <multiple>volumes</multiple>
-    </term>
-
-    <!-- SHORT LOCATOR FORMS -->
-    <term name="book" form="short">
-      <single>bk.</single>
-      <multiple>bks.</multiple>
-    </term>
-    <term name="chapter" form="short">
-      <single>chap.</single>
-      <multiple>chaps.</multiple>
-    </term>
-    <term name="column" form="short">
-      <single>col.</single>
-      <multiple>cols.</multiple>
-    </term>
-    <term name="figure" form="short">
-      <single>fig.</single>
-      <multiple>figs.</multiple>
-    </term>
-    <term name="folio" form="short">
-      <single>fol.</single>
-      <multiple>fols.</multiple>
-    </term>
-    <term name="issue" form="short">
-      <single>no.</single>
-      <multiple>nos.</multiple>
-    </term>
-    <term name="line" form="short">
-      <single>l.</single>
-      <multiple>ll.</multiple>
-    </term>
-    <term name="note" form="short">
-      <single>n.</single>
-      <multiple>nn.</multiple>
-    </term>
-    <term name="opus" form="short">
-      <single>op.</single>
-      <multiple>opp.</multiple>
-    </term>
-    <term name="page" form="short">
-      <single>p.</single>
-      <multiple>pp.</multiple>
-    </term>
-    <term name="number-of-pages" form="short">
-      <single>p.</single>
-      <multiple>pp.</multiple>
-    </term>
-    <term name="paragraph" form="short">
-      <single>para.</single>
-      <multiple>paras.</multiple>
-    </term>
-    <term name="part" form="short">
-      <single>pt.</single>
-      <multiple>pts.</multiple>
-    </term>
-    <term name="section" form="short">
-      <single>sec.</single>
-      <multiple>secs.</multiple>
-    </term>
-    <term name="sub verbo" form="short">
-      <single>s.v.</single>
-      <multiple>s.vv.</multiple>
-    </term>
-    <term name="verse" form="short">
-      <single>v.</single>
-      <multiple>vv.</multiple>
-    </term>
-    <term name="volume" form="short">
-      <single>vol.</single>
-      <multiple>vols.</multiple>
-    </term>
-
-    <!-- SYMBOL LOCATOR FORMS -->
-    <term name="paragraph" form="symbol">
-      <single>¶</single>
-      <multiple>¶¶</multiple>
-    </term>
-    <term name="section" form="symbol">
-      <single>§</single>
-      <multiple>§§</multiple>
-    </term>
-
-    <!-- LONG ROLE FORMS -->
-    <term name="director">
-      <single>director</single>
-      <multiple>directors</multiple>
-    </term>
-    <term name="editor">
-      <single>editor</single>
-      <multiple>editors</multiple>
-    </term>
-    <term name="editorial-director">
-      <single>editor</single>
-      <multiple>editors</multiple>
-    </term>
-    <term name="illustrator">
-      <single>illustrator</single>
-      <multiple>illustrators</multiple>
-    </term>
-    <term name="translator">
-      <single>translator</single>
-      <multiple>translators</multiple>
-    </term>
-    <term name="editortranslator">
-      <single>editor &amp; translator</single>
-      <multiple>editors &amp; translators</multiple>
-    </term>
-
-    <!-- SHORT ROLE FORMS -->
-    <term name="director" form="short">
-      <single>dir.</single>
-      <multiple>dirs.</multiple>
-    </term>
-    <term name="editor" form="short">
-      <single>ed.</single>
-      <multiple>eds.</multiple>
-    </term>
-    <term name="editorial-director" form="short">
-      <single>ed.</single>
-      <multiple>eds.</multiple>
-    </term>
-    <term name="illustrator" form="short">
-      <single>ill.</single>
-      <multiple>ills.</multiple>
-    </term>
-    <term name="translator" form="short">
-      <single>tran.</single>
-      <multiple>trans.</multiple>
-    </term>
-    <term name="editortranslator" form="short">
-      <single>ed. &amp; tran.</single>
-      <multiple>eds. &amp; trans.</multiple>
-    </term>
-
-    <!-- VERB ROLE FORMS -->
-    <term name="container-author" form="verb">by</term>
-    <term name="director" form="verb">directed by</term>
-    <term name="editor" form="verb">edited by</term>
-    <term name="editorial-director" form="verb">edited by</term>
-    <term name="illustrator" form="verb">illustrated by</term>
-    <term name="interviewer" form="verb">interview by</term>
-    <term name="recipient" form="verb">to</term>
-    <term name="reviewed-author" form="verb">by</term>
-    <term name="translator" form="verb">translated by</term>
-    <term name="editortranslator" form="verb">edited &amp; translated by</term>
-
-    <!-- SHORT VERB ROLE FORMS -->
-    <term name="director" form="verb-short">dir. by</term>
-    <term name="editor" form="verb-short">ed. by</term>
-    <term name="editorial-director" form="verb-short">ed. by</term>
-    <term name="illustrator" form="verb-short">illus. by</term>
-    <term name="translator" form="verb-short">trans. by</term>
-    <term name="editortranslator" form="verb-short">ed. &amp; trans. by</term>
-
-    <!-- LONG MONTH FORMS -->
-    <term name="month-01">January</term>
-    <term name="month-02">February</term>
-    <term name="month-03">March</term>
-    <term name="month-04">April</term>
-    <term name="month-05">May</term>
-    <term name="month-06">June</term>
-    <term name="month-07">July</term>
-    <term name="month-08">August</term>
-    <term name="month-09">September</term>
-    <term name="month-10">October</term>
-    <term name="month-11">November</term>
-    <term name="month-12">December</term>
-
-    <!-- SHORT MONTH FORMS -->
-    <term name="month-01" form="short">Jan.</term>
-    <term name="month-02" form="short">Feb.</term>
-    <term name="month-03" form="short">Mar.</term>
-    <term name="month-04" form="short">Apr.</term>
-    <term name="month-05" form="short">May</term>
-    <term name="month-06" form="short">Jun.</term>
-    <term name="month-07" form="short">Jul.</term>
-    <term name="month-08" form="short">Aug.</term>
-    <term name="month-09" form="short">Sep.</term>
-    <term name="month-10" form="short">Oct.</term>
-    <term name="month-11" form="short">Nov.</term>
-    <term name="month-12" form="short">Dec.</term>
-
-    <!-- SEASONS -->
-    <term name="season-01">Spring</term>
-    <term name="season-02">Summer</term>
-    <term name="season-03">Autumn</term>
-    <term name="season-04">Winter</term>
-  </terms>
-</locale>
diff --git a/elpa/org-ref-20241124.2012/citeproc/csl-styles/apa-5th-edition.csl b/elpa/org-ref-20241124.2012/citeproc/csl-styles/apa-5th-edition.csl
deleted file mode 100644 (file)
index 186557d..0000000
+++ /dev/null
@@ -1,341 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="sort-only">
-  <info>
-    <title>American Psychological Association 5th edition</title>
-    <title-short>APA (5th ed.)</title-short>
-    <id>http://www.zotero.org/styles/apa-5th-edition</id>
-    <link href="http://www.zotero.org/styles/apa-5th-edition" rel="self"/>
-    <link href="http://rdc.libguides.com/content.php?pid=63487" rel="documentation"/>
-    <author>
-      <name>Simon Kornblith</name>
-      <email>simonNOSPAMsimonster.com</email>
-    </author>
-    <contributor>
-      <name>Bruce D'Arcus</name>
-    </contributor>
-    <contributor>
-      <name>Curtis M. Humphrey</name>
-    </contributor>
-    <contributor>
-      <name>Richard Karnesky</name>
-      <email>karnesky+zoteroNOSPAMgmail.com</email>
-      <uri>http://arc.nucapt.northwestern.edu/Richard_Karnesky</uri>
-    </contributor>
-    <contributor>
-      <name>Sebastian Karcher</name>
-    </contributor>
-    <category citation-format="author-date"/>
-    <category field="psychology"/>
-    <category field="generic-base"/>
-    <updated>2020-03-23T14:28:18+00:00</updated>
-    <rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
-  </info>
-  <locale xml:lang="fr">
-    <terms>
-      <term name="editor" form="short">
-        <single>éd.</single>
-        <multiple>éds.</multiple>
-      </term>
-    </terms>
-  </locale>
-  <macro name="container-contributors">
-    <choose>
-      <if type="chapter paper-conference" match="any">
-        <text term="in" text-case="capitalize-first" suffix=" "/>
-        <names variable="editor" delimiter=", " suffix=", ">
-          <name and="symbol" initialize-with=". " delimiter=", "/>
-          <label form="short" prefix=" (" text-case="capitalize-first" suffix=")"/>
-          <substitute>
-            <names variable="translator"/>
-          </substitute>
-        </names>
-      </if>
-    </choose>
-  </macro>
-  <macro name="secondary-contributors">
-    <choose>
-      <if type="chapter paper-conference" match="none">
-        <names variable="translator" delimiter=", " prefix=" (" suffix=")">
-          <name and="symbol" initialize-with=". " delimiter=", "/>
-          <label form="short" prefix=", " text-case="capitalize-first"/>
-          <substitute>
-            <names variable="editor"/>
-          </substitute>
-        </names>
-      </if>
-    </choose>
-  </macro>
-  <macro name="author">
-    <names variable="author">
-      <name name-as-sort-order="all" and="symbol" sort-separator=", " initialize-with=". " delimiter=", " delimiter-precedes-last="always"/>
-      <label form="short" prefix=" (" suffix=")" text-case="capitalize-first"/>
-      <substitute>
-        <names variable="editor"/>
-        <names variable="translator"/>
-        <text macro="title"/>
-      </substitute>
-    </names>
-  </macro>
-  <macro name="author-short">
-    <names variable="author">
-      <name form="short" and="symbol" delimiter=", " initialize-with=". "/>
-      <substitute>
-        <names variable="editor"/>
-        <names variable="translator"/>
-        <choose>
-          <if type="bill book graphic legal_case legislation motion_picture report song" match="any">
-            <text variable="title" form="short" font-style="italic"/>
-          </if>
-          <else>
-            <text variable="title" form="short" quotes="true"/>
-          </else>
-        </choose>
-      </substitute>
-    </names>
-  </macro>
-  <macro name="access">
-    <choose>
-      <if type="thesis">
-        <choose>
-          <if variable="archive" match="any">
-            <group>
-              <text term="retrieved" text-case="capitalize-first" suffix=" "/>
-              <text term="from" suffix=" "/>
-              <text variable="archive" suffix="."/>
-              <text variable="archive_location" prefix=" (" suffix=")"/>
-            </group>
-          </if>
-          <else>
-            <group>
-              <text term="retrieved" text-case="capitalize-first" suffix=" "/>
-              <date variable="accessed" suffix=", ">
-                <date-part name="month" suffix=" "/>
-                <date-part name="day" suffix=", "/>
-                <date-part name="year"/>
-              </date>
-              <text term="from" suffix=" "/>
-              <text variable="URL"/>
-            </group>
-          </else>
-        </choose>
-      </if>
-      <else>
-        <choose>
-          <if variable="URL">
-            <choose>
-              <if variable="archive">
-                <group>
-                  <text term="retrieved" text-case="capitalize-first" suffix=" "/>
-                  <text term="from" suffix=" "/>
-                  <text variable="archive" suffix="."/>
-                </group>
-              </if>
-              <else>
-                <group>
-                  <text term="retrieved" text-case="capitalize-first" suffix=" "/>
-                  <date variable="accessed" suffix=", ">
-                    <date-part name="month" suffix=" "/>
-                    <date-part name="day" suffix=", "/>
-                    <date-part name="year"/>
-                  </date>
-                  <group>
-                    <text term="from" suffix=" "/>
-                    <text variable="URL"/>
-                  </group>
-                </group>
-              </else>
-            </choose>
-          </if>
-        </choose>
-      </else>
-    </choose>
-  </macro>
-  <macro name="title">
-    <choose>
-      <if type="report thesis" match="any">
-        <text variable="title" font-style="italic"/>
-        <group prefix=" (" suffix=")">
-          <text variable="genre"/>
-          <text variable="number" prefix=" No. "/>
-        </group>
-      </if>
-      <else-if type="bill book graphic legal_case legislation manuscript motion_picture report song speech" match="any">
-        <text variable="title" font-style="italic"/>
-      </else-if>
-      <else>
-        <text variable="title"/>
-      </else>
-    </choose>
-  </macro>
-  <macro name="publisher">
-    <choose>
-      <if type="report" match="any">
-        <group delimiter=": ">
-          <text variable="publisher-place"/>
-          <text variable="publisher"/>
-        </group>
-      </if>
-      <else-if type="thesis" match="any">
-        <group delimiter=", ">
-          <text variable="publisher"/>
-          <text variable="publisher-place"/>
-        </group>
-      </else-if>
-      <else>
-        <choose>
-          <if variable="event" match="none">
-            <text variable="genre" suffix=", "/>
-          </if>
-        </choose>
-        <group delimiter=": ">
-          <text variable="publisher-place"/>
-          <text variable="publisher"/>
-        </group>
-      </else>
-    </choose>
-  </macro>
-  <macro name="event">
-    <choose>
-      <if variable="event">
-        <choose>
-          <if variable="genre" match="none">
-            <text term="presented at" text-case="capitalize-first" suffix=" "/>
-            <text variable="event"/>
-          </if>
-          <else>
-            <group delimiter=" ">
-              <text variable="genre" text-case="capitalize-first"/>
-              <text term="presented at"/>
-              <text variable="event"/>
-            </group>
-          </else>
-        </choose>
-      </if>
-    </choose>
-  </macro>
-  <macro name="issued">
-    <choose>
-      <if variable="issued">
-        <group prefix=" (" suffix=").">
-          <date variable="issued">
-            <date-part name="year"/>
-          </date>
-          <choose>
-            <if type="article-journal bill book chapter graphic legal_case legislation motion_picture paper-conference report song" match="none">
-              <date variable="issued">
-                <date-part prefix=", " name="month"/>
-                <date-part prefix=" " name="day"/>
-              </date>
-            </if>
-          </choose>
-        </group>
-      </if>
-      <else>
-        <text prefix=" (" term="no date" suffix=")." form="short"/>
-      </else>
-    </choose>
-  </macro>
-  <macro name="issued-year">
-    <choose>
-      <if variable="issued">
-        <date variable="issued">
-          <date-part name="year"/>
-        </date>
-      </if>
-      <else>
-        <text term="no date" form="short"/>
-      </else>
-    </choose>
-  </macro>
-  <macro name="edition">
-    <choose>
-      <if is-numeric="edition">
-        <group delimiter=" ">
-          <number variable="edition" form="ordinal"/>
-          <text term="edition" form="short"/>
-        </group>
-      </if>
-      <else>
-        <text variable="edition" suffix="."/>
-      </else>
-    </choose>
-  </macro>
-  <macro name="locators">
-    <choose>
-      <if type="article-journal article-magazine article-newspaper" match="any">
-        <group prefix=", " delimiter=", ">
-          <group>
-            <text variable="volume" font-style="italic"/>
-            <text variable="issue" prefix="(" suffix=")"/>
-          </group>
-          <text variable="page"/>
-        </group>
-      </if>
-      <else-if type="bill book chapter graphic legal_case legislation motion_picture paper-conference report song" match="any">
-        <group prefix=" (" suffix=")" delimiter=", ">
-          <text macro="edition"/>
-          <group>
-            <text term="volume" form="short" plural="true" text-case="capitalize-first" suffix=" "/>
-            <number variable="number-of-volumes" form="numeric" prefix="1-"/>
-          </group>
-          <group>
-            <text term="volume" form="short" text-case="capitalize-first" suffix=" "/>
-            <number variable="volume" form="numeric"/>
-          </group>
-          <group>
-            <label variable="page" form="short" suffix=" "/>
-            <text variable="page"/>
-          </group>
-        </group>
-      </else-if>
-    </choose>
-  </macro>
-  <macro name="citation-locator">
-    <group>
-      <label variable="locator" form="short"/>
-      <text variable="locator" prefix=" "/>
-    </group>
-  </macro>
-  <citation et-al-min="6" et-al-use-first="1" et-al-subsequent-min="3" et-al-subsequent-use-first="1" disambiguate-add-year-suffix="true" disambiguate-add-names="true" disambiguate-add-givenname="true" givenname-disambiguation-rule="primary-name" collapse="year">
-    <sort>
-      <key macro="author"/>
-      <key macro="issued-year"/>
-    </sort>
-    <layout prefix="(" suffix=")" delimiter="; ">
-      <group delimiter=", ">
-        <text macro="author-short"/>
-        <text macro="issued-year"/>
-        <text macro="citation-locator"/>
-      </group>
-    </layout>
-  </citation>
-  <bibliography hanging-indent="true" et-al-min="8" et-al-use-first="7" entry-spacing="0" line-spacing="2">
-    <sort>
-      <key macro="author"/>
-      <key macro="issued-year" sort="ascending"/>
-    </sort>
-    <layout>
-      <group suffix=".">
-        <text macro="author" suffix="."/>
-        <text macro="issued" suffix=" "/>
-        <group delimiter=". ">
-          <text macro="title"/>
-          <group>
-            <text macro="container-contributors"/>
-            <text macro="secondary-contributors"/>
-            <group delimiter=", ">
-              <text variable="container-title" font-style="italic"/>
-              <text variable="collection-title"/>
-            </group>
-          </group>
-        </group>
-        <text macro="locators"/>
-        <group delimiter=", " prefix=". ">
-          <text macro="event"/>
-          <text macro="publisher"/>
-        </group>
-      </group>
-      <text macro="access" prefix=". "/>
-    </layout>
-  </bibliography>
-</style>
diff --git a/elpa/org-ref-20241124.2012/citeproc/csl-styles/apa-numeric-superscript-brackets.csl b/elpa/org-ref-20241124.2012/citeproc/csl-styles/apa-numeric-superscript-brackets.csl
deleted file mode 100644 (file)
index e1a2a18..0000000
+++ /dev/null
@@ -1,1711 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="never" page-range-format="expanded">
-  <info>
-    <title>American Psychological Association 7th edition (numeric, brackets)</title>
-    <title-short>APA (numeric, superscript, brackets)</title-short>
-    <id>http://www.zotero.org/styles/apa-numeric-superscript-brackets</id>
-    <link href="http://www.zotero.org/styles/apa-numeric-superscript-brackets" rel="self"/>
-    <link href="http://www.zotero.org/styles/apa" rel="template"/>
-    <link href="https://apastyle.apa.org/style-grammar-guidelines/references/examples" rel="documentation"/>
-    <author>
-      <name>Brenton M. Wiernik</name>
-      <email>zoteroNOSPAMwiernik.org</email>
-    </author>
-    <category citation-format="numeric"/>
-    <category field="psychology"/>
-    <category field="generic-base"/>
-    <summary>APA style, with numeric in-text citations in brackets</summary>
-    <updated>2021-03-11T05:11:56+00:00</updated>
-    <rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
-  </info>
-  <locale xml:lang="en">
-    <terms>
-      <term name="editortranslator" form="short">
-        <single>ed. &amp; trans.</single>
-        <multiple>eds. &amp; trans.</multiple>
-      </term>
-      <term name="translator" form="short">trans.</term>
-      <term name="interviewer" form="short">
-        <single>interviewer</single>
-        <multiple>interviewers</multiple>
-      </term>
-      <term name="collection-editor" form="short">
-        <single>ed.</single>
-        <multiple>eds.</multiple>
-      </term>
-      <term name="circa" form="short">ca.</term>
-      <term name="bc"> B.C.E.</term>
-      <term name="ad"> C.E.</term>
-      <term name="letter">personal communication</term>
-      <term name="letter" form="short">letter</term>
-      <term name="issue" form="long">
-        <single>issue</single>
-        <multiple>issues</multiple>
-      </term>
-    </terms>
-  </locale>
-  <locale xml:lang="af">
-    <terms>
-      <term name="letter">persoonlike kommunikasie</term>
-      <term name="letter" form="short">brief</term>
-    </terms>
-  </locale>
-  <locale xml:lang="ar">
-    <terms>
-      <term name="letter">اتصال شخصي</term>
-      <term name="letter" form="short">خطاب</term>
-    </terms>
-  </locale>
-  <locale xml:lang="da">
-    <terms>
-      <term name="et-al">et al.</term>
-      <term name="letter">personlig kommunikation</term>
-      <term name="letter" form="short">brev</term>
-    </terms>
-  </locale>
-  <locale xml:lang="de">
-    <terms>
-      <term name="et-al">et al.</term>
-      <term name="letter">persönliche Kommunikation</term>
-      <term name="letter" form="short">Brief</term>
-    </terms>
-  </locale>
-  <locale xml:lang="es">
-    <terms>
-      <term name="from">de</term>
-      <term name="letter">comunicación personal</term>
-      <term name="letter" form="short">carta</term>
-    </terms>
-  </locale>
-  <locale xml:lang="fr">
-    <terms>
-      <term name="letter">communication personnelle</term>
-      <term name="letter" form="short">lettre</term>
-      <term name="editor" form="short">
-        <single>éd.</single>
-        <multiple>éds.</multiple>
-      </term>
-    </terms>
-  </locale>
-  <locale xml:lang="nb">
-    <terms>
-      <term name="et-al">et al.</term>
-      <term name="letter">personlig kommunikasjon</term>
-      <term name="letter" form="short">brev</term>
-    </terms>
-  </locale>
-  <locale xml:lang="nl">
-    <terms>
-      <term name="et-al">et al.</term>
-      <term name="letter">persoonlijke communicatie</term>
-      <term name="letter" form="short">brief</term>
-    </terms>
-  </locale>
-  <locale xml:lang="nn">
-    <terms>
-      <term name="et-al">et al.</term>
-      <term name="letter">personlig kommunikasjon</term>
-      <term name="letter" form="short">brev</term>
-    </terms>
-  </locale>
-  <locale xml:lang="ru">
-    <terms>
-      <term name="letter">личная переписка</term>
-      <term name="letter" form="short">письмо</term>
-    </terms>
-  </locale>
-  <locale xml:lang="tr">
-    <terms>
-      <term name="letter">kişisel iletişim</term>
-      <term name="letter" form="short">mektup</term>
-    </terms>
-  </locale>
-  <!-- General categories of item types:
-       Periodical: article-journal article-magazine article-newspaper post-weblog review review-book
-       Periodical or Booklike: paper-conference
-       Booklike: article book broadcast chapter dataset entry entry-dictionary entry-encyclopedia figure 
-                 graphic interview manuscript map motion_picture musical_score pamphlet patent 
-                 personal_communication report song speech thesis post webpage
-       Legal: bill legal_case legislation treaty
-  -->
-  <!-- APA references contain four parts: author, date, title, source -->
-  <macro name="author-bib">
-    <names variable="composer" delimiter=", ">
-      <name name-as-sort-order="all" and="symbol" sort-separator=", " initialize-with=". " delimiter=", " delimiter-precedes-last="always"/>
-      <substitute>
-        <names variable="author"/>
-        <names variable="illustrator"/>
-        <names variable="director">
-          <name name-as-sort-order="all" and="symbol" sort-separator=", " initialize-with=". " delimiter=", " delimiter-precedes-last="always"/>
-          <label form="long" prefix=" (" suffix=")" text-case="title"/>
-        </names>
-        <choose>
-          <if variable="container-title">
-            <choose>
-              <if type="book entry entry-dictionary entry-encyclopedia" match="any">
-                <choose>
-                  <if variable="title">
-                    <group delimiter=" ">
-                      <text macro="title"/>
-                      <text macro="parenthetical"/>
-                    </group>
-                  </if>
-                  <else>
-                    <text macro="title-and-descriptions"/>
-                  </else>
-                </choose>
-              </if>
-            </choose>
-          </if>
-        </choose>
-        <!-- Test for editortranslator and put that first as that becomes available -->
-        <names variable="editor" delimiter=", ">
-          <name name-as-sort-order="all" and="symbol" sort-separator=", " initialize-with=". " delimiter=", " delimiter-precedes-last="always"/>
-          <label form="short" prefix=" (" suffix=")" text-case="title"/>
-        </names>
-        <names variable="editorial-director">
-          <name name-as-sort-order="all" and="symbol" sort-separator=", " initialize-with=". " delimiter=", " delimiter-precedes-last="always"/>
-          <label form="short" prefix=" (" suffix=")" text-case="title"/>
-        </names>
-        <names variable="collection-editor">
-          <name name-as-sort-order="all" and="symbol" sort-separator=", " initialize-with=". " delimiter=", " delimiter-precedes-last="always"/>
-          <label form="short" prefix=" (" suffix=")" text-case="title"/>
-        </names>
-        <choose>
-          <if variable="title">
-            <group delimiter=" ">
-              <text macro="title"/>
-              <text macro="parenthetical"/>
-            </group>
-          </if>
-          <else>
-            <text macro="title-and-descriptions"/>
-          </else>
-        </choose>
-      </substitute>
-    </names>
-  </macro>
-  <macro name="author-intext">
-    <choose>
-      <if type="bill legal_case legislation treaty" match="any">
-        <text macro="title-intext"/>
-      </if>
-      <else-if type="interview personal_communication" match="any">
-        <choose>
-          <!-- These variables indicate that the letter is retrievable by the reader. 
-                If not, then use the APA in-text-only personal communication format -->
-          <if variable="archive container-title DOI publisher URL" match="none">
-            <group delimiter=", ">
-              <names variable="author">
-                <name and="symbol" delimiter=", " initialize-with=". "/>
-                <substitute>
-                  <text macro="title-intext"/>
-                </substitute>
-              </names>
-              <!-- Replace with term="personal-communication" if that becomes available -->
-              <text term="letter"/>
-            </group>
-          </if>
-          <else>
-            <names variable="author" delimiter=", ">
-              <name form="short" and="symbol" delimiter=", " initialize-with=". "/>
-              <substitute>
-                <text macro="title-intext"/>
-              </substitute>
-            </names>
-          </else>
-        </choose>
-      </else-if>
-      <else>
-        <names variable="composer" delimiter=", ">
-          <name form="short" and="symbol" delimiter=", " initialize-with=". "/>
-          <substitute>
-            <names variable="author"/>
-            <names variable="illustrator"/>
-            <names variable="director"/>
-            <choose>
-              <if variable="container-title">
-                <choose>
-                  <if type="book entry entry-dictionary entry-encyclopedia" match="any">
-                    <text macro="title-intext"/>
-                  </if>
-                </choose>
-              </if>
-            </choose>
-            <names variable="editor"/>
-            <names variable="editorial-director"/>
-            <text macro="title-intext"/>
-          </substitute>
-        </names>
-      </else>
-    </choose>
-  </macro>
-  <macro name="date-bib">
-    <group delimiter=" " prefix="(" suffix=")">
-      <choose>
-        <if is-uncertain-date="issued">
-          <text term="circa" form="short"/>
-        </if>
-      </choose>
-      <group>
-        <choose>
-          <if variable="issued">
-            <date variable="issued">
-              <date-part name="year"/>
-            </date>
-            <text variable="year-suffix"/>
-            <choose>
-              <if type="article-magazine article-newspaper broadcast interview motion_picture pamphlet personal_communication post post-weblog song speech webpage" match="any">
-                <!-- Many video and audio examples in manual give full dates. Err on the side of too much information. -->
-                <date variable="issued">
-                  <date-part prefix=", " name="month"/>
-                  <date-part prefix=" " name="day"/>
-                </date>
-              </if>
-              <else-if type="paper-conference">
-                <!-- Capture 'speech' stored as 'paper-conference' -->
-                <choose>
-                  <if variable="collection-editor editor editorial-director issue page volume" match="none">
-                    <date variable="issued">
-                      <date-part prefix=", " name="month"/>
-                      <date-part prefix=" " name="day"/>
-                    </date>
-                  </if>
-                </choose>
-              </else-if>
-              <!-- Only year: article article-journal book chapter entry entry-dictionary entry-encyclopedia dataset figure graphic 
-                   manuscript map musical_score paper-conference[published] patent report review review-book thesis -->
-            </choose>
-          </if>
-          <else-if variable="status">
-            <group>
-              <text variable="status" text-case="lowercase"/>
-              <text variable="year-suffix" prefix="-"/>
-            </group>
-          </else-if>
-          <else>
-            <group>
-              <text term="no date" form="short"/>
-              <text variable="year-suffix" prefix="-"/>
-            </group>
-          </else>
-        </choose>
-      </group>
-    </group>
-  </macro>
-  <macro name="date-sort-group">
-    <choose>
-      <if variable="issued">
-        <text value="1"/>
-      </if>
-      <else-if variable="status">
-        <text value="2"/>
-      </else-if>
-      <else>
-        <text value="0"/>
-      </else>
-    </choose>
-  </macro>
-  <macro name="date-sort-date">
-    <choose>
-      <if type="article-magazine article-newspaper broadcast interview pamphlet personal_communication post post-weblog speech treaty webpage" match="any">
-        <date variable="issued" form="numeric"/>
-      </if>
-      <else-if type="paper-conference">
-        <!-- Capture 'speech' stored as 'paper-conference' -->
-        <choose>
-          <if variable="collection-editor editor editorial-director issue page volume" match="none">
-            <date variable="issued" form="numeric"/>
-          </if>
-        </choose>
-      </else-if>
-      <else>
-        <date variable="issued" form="numeric"/>
-      </else>
-    </choose>
-  </macro>
-  <macro name="date-intext">
-    <choose>
-      <if variable="issued">
-        <group delimiter="/">
-          <group delimiter=" ">
-            <choose>
-              <if is-uncertain-date="original-date">
-                <text term="circa" form="short"/>
-              </if>
-            </choose>
-            <date variable="original-date">
-              <date-part name="year"/>
-            </date>
-          </group>
-          <group delimiter=" ">
-            <choose>
-              <if is-uncertain-date="issued">
-                <text term="circa" form="short"/>
-              </if>
-            </choose>
-            <group>
-              <choose>
-                <if type="interview personal_communication" match="any">
-                  <choose>
-                    <if variable="archive container-title DOI publisher URL" match="none">
-                      <!-- These variables indicate that the communication is retrievable by the reader. 
-                           If not, then use the in-text-only personal communication format -->
-                      <date variable="issued" form="text"/>
-                    </if>
-                    <else>
-                      <date variable="issued">
-                        <date-part name="year"/>
-                      </date>
-                    </else>
-                  </choose>
-                </if>
-                <else>
-                  <date variable="issued">
-                    <date-part name="year"/>
-                  </date>
-                </else>
-              </choose>
-              <text variable="year-suffix"/>
-            </group>
-          </group>
-        </group>
-      </if>
-      <else-if variable="status">
-        <text variable="status" text-case="lowercase"/>
-        <text variable="year-suffix" prefix="-"/>
-      </else-if>
-      <else>
-        <text term="no date" form="short"/>
-        <text variable="year-suffix" prefix="-"/>
-      </else>
-    </choose>
-  </macro>
-  <!-- APA has two description elements following the title:
-       title (parenthetical) [bracketed]  -->
-  <macro name="title-and-descriptions">
-    <choose>
-      <if variable="title">
-        <group delimiter=" ">
-          <text macro="title"/>
-          <text macro="parenthetical"/>
-          <text macro="bracketed"/>
-        </group>
-      </if>
-      <else>
-        <group delimiter=" ">
-          <text macro="bracketed"/>
-          <text macro="parenthetical"/>
-        </group>
-      </else>
-    </choose>
-  </macro>
-  <macro name="title">
-    <choose>
-      <if type="post webpage" match="any">
-        <!-- Webpages are always italicized -->
-        <text variable="title" font-style="italic"/>
-      </if>
-      <else-if variable="container-title" match="any">
-        <!-- Other types are italicized based on presence of container-title.
-             Assume that review and review-book are published in periodicals/blogs,
-             not just on a web page (ex. 69) -->
-        <text variable="title"/>
-      </else-if>
-      <else>
-        <choose>
-          <if type="article-journal article-magazine article-newspaper post-weblog review review-book" match="any">
-            <text variable="title" font-style="italic"/>
-          </if>
-          <else-if type="paper-conference">
-            <choose>
-              <if variable="collection-editor editor editorial-director" match="any">
-                <group delimiter=": " font-style="italic">
-                  <text variable="title"/>
-                  <!-- Replace with volume-title as that becomes available -->
-                  <choose>
-                    <if is-numeric="volume" match="none">
-                      <group delimiter=" ">
-                        <label variable="volume" form="short" text-case="capitalize-first"/>
-                        <text variable="volume"/>
-                      </group>
-                    </if>
-                  </choose>
-                </group>
-              </if>
-              <else>
-                <text variable="title" font-style="italic"/>
-              </else>
-            </choose>
-          </else-if>
-          <else>
-            <group delimiter=": " font-style="italic">
-              <text variable="title"/>
-              <!-- Replace with volume-title as that becomes available -->
-              <choose>
-                <if is-numeric="volume" match="none">
-                  <group delimiter=" ">
-                    <label variable="volume" form="short" text-case="capitalize-first"/>
-                    <text variable="volume"/>
-                  </group>
-                </if>
-              </choose>
-            </group>
-          </else>
-        </choose>
-      </else>
-    </choose>
-  </macro>
-  <macro name="title-intext">
-    <choose>
-      <if variable="title" match="none">
-        <text macro="bracketed-intext" prefix="[" suffix="]"/>
-      </if>
-      <else-if type="bill">
-        <!-- If a bill has no number or container-title, assume it is a hearing; italic and title case -->
-        <choose>
-          <if variable="number container-title" match="none">
-            <text variable="title" form="short" font-style="italic" text-case="title"/>
-          </if>
-          <else-if variable="title">
-            <text variable="title" form="short"/>
-          </else-if>
-          <else>
-            <group delimiter=" ">
-              <text variable="genre"/>
-              <group delimiter=" ">
-                <choose>
-                  <if variable="chapter-number container-title" match="none">
-                    <!-- Replace with label variable="number" as that becomes available -->
-                    <text term="issue" form="short"/>
-                  </if>
-                </choose>
-                <text variable="number"/>
-              </group>
-            </group>
-          </else>
-        </choose>
-      </else-if>
-      <else-if type="legal_case" match="any">
-        <!-- Cases are italicized -->
-        <text variable="title" font-style="italic"/>
-      </else-if>
-      <else-if type="legislation treaty" match="any">
-        <!-- Legislation and treaties not italicized or quoted -->
-        <text variable="title" form="short"/>
-      </else-if>
-      <else-if type="post webpage" match="any">
-        <!-- Webpages are always italicized -->
-        <text variable="title" form="short" font-style="italic"/>
-      </else-if>
-      <else-if variable="container-title" match="any">
-        <!-- Other types are italicized or quoted based on presence of container-title. As in title macro. -->
-        <text variable="title" form="short" quotes="true"/>
-      </else-if>
-      <else>
-        <text variable="title" form="short" font-style="italic"/>
-      </else>
-    </choose>
-  </macro>
-  <macro name="parenthetical">
-    <!-- (Secondary contributors; Database location; Genre no. 123; Report Series 123, Version, Edition, Volume, Page) -->
-    <group prefix="(" suffix=")">
-      <choose>
-        <if type="patent">
-          <!-- authority: U.S. ; genre: patent ; number: 123,445 -->
-          <group delimiter=" ">
-            <text variable="authority" form="short"/>
-            <choose>
-              <if variable="genre">
-                <text variable="genre" text-case="capitalize-first"/>
-              </if>
-              <else>
-                <!-- This should be localized -->
-                <text value="patent" text-case="capitalize-first"/>
-              </else>
-            </choose>
-            <group delimiter=" ">
-              <!-- Replace with label variable="number" if that becomes available -->
-              <text term="issue" form="short" text-case="capitalize-first"/>
-              <text variable="number"/>
-            </group>
-          </group>
-        </if>
-        <else-if type="post webpage" match="any">
-          <!-- For post webpage, container-title is treated as publisher -->
-          <group delimiter="; ">
-            <text macro="secondary-contributors"/>
-            <text macro="database-location"/>
-            <text macro="number"/>
-            <text macro="locators-booklike"/>
-          </group>
-        </else-if>
-        <else-if variable="container-title">
-          <group delimiter="; ">
-            <text macro="secondary-contributors"/>
-            <choose>
-              <if type="broadcast graphic map motion_picture song" match="any">
-                <!-- For audiovisual media, number information comes after title, not container-title -->
-                <text macro="number"/>
-              </if>
-            </choose>
-          </group>
-        </else-if>
-        <else>
-          <group delimiter="; ">
-            <text macro="secondary-contributors"/>
-            <text macro="database-location"/>
-            <text macro="number"/>
-            <text macro="locators-booklike"/>
-          </group>
-        </else>
-      </choose>
-    </group>
-  </macro>
-  <macro name="parenthetical-container">
-    <choose>
-      <if variable="container-title" match="any">
-        <group prefix="(" suffix=")">
-          <group delimiter="; ">
-            <text macro="database-location"/>
-            <choose>
-              <if type="broadcast graphic map motion_picture song" match="none">
-                <!-- For audiovisual media, number information comes after title, not container-title -->
-                <text macro="number"/>
-              </if>
-            </choose>
-            <text macro="locators-booklike"/>
-          </group>
-        </group>
-      </if>
-    </choose>
-  </macro>
-  <macro name="bracketed">
-    <!-- [Descriptive information] -->
-    <!-- If there is a number, genre is already printed in macro="number" -->
-    <group prefix="[" suffix="]">
-      <choose>
-        <if variable="reviewed-author reviewed-title" type="review review-book" match="any">
-          <!-- Reviewed item -->
-          <group delimiter="; ">
-            <group delimiter=", ">
-              <group delimiter=" ">
-                <!-- Assume that genre is entered as 'Review of the book' or similar -->
-                <choose>
-                  <if variable="number" match="none">
-                    <choose>
-                      <if variable="genre">
-                        <text variable="genre" text-case="capitalize-first"/>
-                      </if>
-                      <else-if variable="medium">
-                        <text variable="medium" text-case="capitalize-first"/>
-                      </else-if>
-                      <else>
-                        <!-- Replace with term="review" as that becomes available -->
-                        <text value="Review of"/>
-                      </else>
-                    </choose>
-                  </if>
-                  <else>
-                    <choose>
-                      <if variable="medium">
-                        <text variable="medium" text-case="capitalize-first"/>
-                      </if>
-                      <else>
-                        <!-- Replace with term="review" as that becomes available -->
-                        <text value="Review of"/>
-                      </else>
-                    </choose>
-                  </else>
-                </choose>
-                <text macro="reviewed-title"/>
-              </group>
-              <names variable="reviewed-author">
-                <label form="verb-short" suffix=" "/>
-                <name and="symbol" initialize-with=". " delimiter=", "/>
-              </names>
-            </group>
-            <choose>
-              <if variable="genre" match="any">
-                <choose>
-                  <if variable="number" match="none">
-                    <text variable="medium" text-case="capitalize-first"/>
-                  </if>
-                </choose>
-              </if>
-            </choose>
-          </group>
-        </if>
-        <else-if type="thesis">
-          <!-- Thesis type and institution -->
-          <group delimiter="; ">
-            <choose>
-              <if variable="number" match="none">
-                <group delimiter=", ">
-                  <text variable="genre" text-case="capitalize-first"/>
-                  <choose>
-                    <if variable="archive DOI URL" match="any">
-                      <!-- Include the university in brackets if thesis is published -->
-                      <text variable="publisher"/>
-                    </if>
-                  </choose>
-                </group>
-              </if>
-            </choose>
-            <text variable="medium" text-case="capitalize-first"/>
-          </group>
-        </else-if>
-        <else-if variable="interviewer" type="interview" match="any">
-          <!-- Interview information -->
-          <choose>
-            <if variable="title">
-              <text macro="format"/>
-            </if>
-            <else-if variable="genre">
-              <group delimiter="; ">
-                <group delimiter=" ">
-                  <text variable="genre" text-case="capitalize-first"/>
-                  <group delimiter=" ">
-                    <text term="author" form="verb"/>
-                    <names variable="interviewer">
-                      <name and="symbol" initialize-with=". " delimiter=", "/>
-                    </names>
-                  </group>
-                </group>
-              </group>
-            </else-if>
-            <else-if variable="interviewer">
-              <group delimiter="; ">
-                <names variable="interviewer">
-                  <label form="verb" suffix=" " text-case="capitalize-first"/>
-                  <name and="symbol" initialize-with=". " delimiter=", "/>
-                </names>
-                <text variable="medium" text-case="capitalize-first"/>
-              </group>
-            </else-if>
-            <else>
-              <text macro="format"/>
-            </else>
-          </choose>
-        </else-if>
-        <else-if type="personal_communication">
-          <!-- Letter information -->
-          <choose>
-            <if variable="recipient">
-              <group delimiter="; ">
-                <group delimiter=" ">
-                  <choose>
-                    <if variable="number" match="none">
-                      <choose>
-                        <if variable="genre">
-                          <text variable="genre" text-case="capitalize-first"/>
-                        </if>
-                        <else-if variable="medium">
-                          <text variable="medium" text-case="capitalize-first"/>
-                        </else-if>
-                        <else>
-                          <text term="letter" form="short" text-case="capitalize-first"/>
-                        </else>
-                      </choose>
-                    </if>
-                    <else>
-                      <choose>
-                        <if variable="medium">
-                          <text variable="medium" text-case="capitalize-first"/>
-                        </if>
-                        <else>
-                          <text term="letter" form="short" text-case="capitalize-first"/>
-                        </else>
-                      </choose>
-                    </else>
-                  </choose>
-                  <names variable="recipient" delimiter=", ">
-                    <label form="verb" suffix=" "/>
-                    <name and="symbol" delimiter=", "/>
-                  </names>
-                </group>
-                <choose>
-                  <if variable="genre" match="any">
-                    <choose>
-                      <if variable="number" match="none">
-                        <text variable="medium" text-case="capitalize-first"/>
-                      </if>
-                    </choose>
-                  </if>
-                </choose>
-              </group>
-            </if>
-            <else>
-              <text macro="format"/>
-            </else>
-          </choose>
-        </else-if>
-        <else-if variable="composer" type="song" match="all">
-          <!-- Performer of classical music works -->
-          <group delimiter="; ">
-            <choose>
-              <if variable="number" match="none">
-                <group delimiter=" ">
-                  <choose>
-                    <if variable="genre">
-                      <text variable="genre" text-case="capitalize-first"/>
-                      <!-- Replace prefix with performer label as that becomes available -->
-                      <names variable="author" prefix="recorded by ">
-                        <name and="symbol" initialize-with=". " delimiter=", "/>
-                      </names>
-                    </if>
-                    <else-if variable="medium">
-                      <text variable="medium" text-case="capitalize-first"/>
-                      <!-- Replace prefix with performer label as that becomes available -->
-                      <names variable="author" prefix="recorded by ">
-                        <name and="symbol" initialize-with=". " delimiter=", "/>
-                      </names>
-                    </else-if>
-                    <else>
-                      <!-- Replace prefix with performer label as that becomes available -->
-                      <names variable="author" prefix="Recorded by ">
-                        <name and="symbol" initialize-with=". " delimiter=", "/>
-                      </names>
-                    </else>
-                  </choose>
-                </group>
-              </if>
-              <else>
-                <group delimiter=" ">
-                  <choose>
-                    <if variable="medium">
-                      <text variable="medium" text-case="capitalize-first"/>
-                      <!-- Replace prefix with performer label as that becomes available -->
-                      <names variable="author" prefix="recorded by ">
-                        <name and="symbol" initialize-with=". " delimiter=", "/>
-                      </names>
-                    </if>
-                    <else>
-                      <!-- Replace prefix with performer label as that becomes available -->
-                      <names variable="author" prefix="Recorded by ">
-                        <name and="symbol" initialize-with=". " delimiter=", "/>
-                      </names>
-                    </else>
-                  </choose>
-                </group>
-              </else>
-            </choose>
-            <choose>
-              <if variable="genre" match="any">
-                <choose>
-                  <if variable="number" match="none">
-                    <text variable="medium" text-case="capitalize-first"/>
-                  </if>
-                </choose>
-              </if>
-            </choose>
-          </group>
-        </else-if>
-        <else-if variable="container-title" match="none">
-          <!-- Other description -->
-          <text macro="format"/>
-        </else-if>
-        <else>
-          <!-- For conference presentations, chapters in reports, software, place bracketed after the container title -->
-          <choose>
-            <if type="paper-conference speech" match="any">
-              <choose>
-                <if variable="collection-editor editor editorial-director issue page volume" match="any">
-                  <text macro="format"/>
-                </if>
-              </choose>
-            </if>
-            <else-if type="book">
-              <choose>
-                <if variable="version" match="none">
-                  <text macro="format"/>
-                </if>
-              </choose>
-            </else-if>
-            <else-if type="report" match="none">
-              <text macro="format"/>
-            </else-if>
-          </choose>
-        </else>
-      </choose>
-    </group>
-  </macro>
-  <macro name="bracketed-intext">
-    <group prefix="[" suffix="]">
-      <choose>
-        <if variable="reviewed-author reviewed-title" type="review review-book" match="any">
-          <!-- This should be localized -->
-          <text macro="reviewed-title-intext" prefix="Review of "/>
-        </if>
-        <else-if variable="interviewer" type="interview" match="any">
-          <names variable="interviewer">
-            <label form="verb" suffix=" " text-case="capitalize-first"/>
-            <name and="symbol" initialize-with=". " delimiter=", "/>
-            <substitute>
-              <text macro="format-intext"/>
-            </substitute>
-          </names>
-        </else-if>
-        <else-if type="personal_communication">
-          <!-- Letter information -->
-          <choose>
-            <if variable="recipient">
-              <group delimiter=" ">
-                <choose>
-                  <if variable="number" match="none">
-                    <text variable="genre" text-case="capitalize-first"/>
-                  </if>
-                  <else>
-                    <text term="letter" form="short" text-case="capitalize-first"/>
-                  </else>
-                </choose>
-                <names variable="recipient" delimiter=", ">
-                  <label form="verb" suffix=" "/>
-                  <name and="symbol" delimiter=", "/>
-                </names>
-              </group>
-            </if>
-            <else>
-              <text macro="format-intext"/>
-            </else>
-          </choose>
-        </else-if>
-        <else>
-          <text macro="format-intext"/>
-        </else>
-      </choose>
-    </group>
-  </macro>
-  <macro name="bracketed-container">
-    <group prefix="[" suffix="]">
-      <choose>
-        <if type="paper-conference speech" match="any">
-          <!-- Conference presentations should describe the session [container] in bracketed unless published in a proceedings -->
-          <choose>
-            <if variable="collection-editor editor editorial-director issue page volume" match="none">
-              <text macro="format"/>
-            </if>
-          </choose>
-        </if>
-        <else-if type="book" variable="version" match="all">
-          <!-- For entries in mobile app reference works, place bracketed after the container-title -->
-          <text macro="format"/>
-        </else-if>
-        <else-if type="report">
-          <!-- For chapters in reports, place bracketed after the container title -->
-          <text macro="format"/>
-        </else-if>
-      </choose>
-    </group>
-  </macro>
-  <macro name="secondary-contributors">
-    <choose>
-      <if type="article-journal article-magazine article-newspaper post-weblog review review-book" match="any">
-        <text macro="secondary-contributors-periodical"/>
-      </if>
-      <else-if type="paper-conference">
-        <choose>
-          <if variable="collection-editor editor editorial-director" match="any">
-            <text macro="secondary-contributors-booklike"/>
-          </if>
-          <else>
-            <text macro="secondary-contributors-periodical"/>
-          </else>
-        </choose>
-      </else-if>
-      <else>
-        <text macro="secondary-contributors-booklike"/>
-      </else>
-    </choose>
-  </macro>
-  <macro name="secondary-contributors-periodical">
-    <group delimiter="; ">
-      <choose>
-        <if variable="title">
-          <names variable="interviewer" delimiter="; ">
-            <name and="symbol" initialize-with=". " delimiter=", "/>
-            <label form="short" prefix=", " text-case="title"/>
-          </names>
-        </if>
-      </choose>
-      <names variable="translator" delimiter="; ">
-        <name and="symbol" initialize-with=". " delimiter=", "/>
-        <label form="short" prefix=", " text-case="title"/>
-      </names>
-    </group>
-  </macro>
-  <macro name="secondary-contributors-booklike">
-    <group delimiter="; ">
-      <choose>
-        <if variable="title">
-          <names variable="interviewer">
-            <name and="symbol" initialize-with=". " delimiter=", "/>
-            <label form="short" prefix=", " text-case="title"/>
-          </names>
-        </if>
-      </choose>
-      <!-- When editortranslator becomes available, add a test: variable="editortranslator" match="none"; then print translator -->
-      <choose>
-        <if type="post webpage" match="none">
-          <!-- Webpages treat container-title like publisher -->
-          <choose>
-            <if variable="container-title" match="none">
-              <group delimiter="; ">
-                <names variable="container-author">
-                  <label form="verb-short" suffix=" " text-case="title"/>
-                  <name and="symbol" initialize-with=". " delimiter=", "/>
-                </names>
-                <names variable="editor translator" delimiter="; ">
-                  <name and="symbol" initialize-with=". " delimiter=", "/>
-                  <label form="short" prefix=", " text-case="title"/>
-                </names>
-              </group>
-            </if>
-          </choose>
-        </if>
-        <else>
-          <group delimiter="; ">
-            <names variable="container-author">
-              <label form="verb-short" suffix=" " text-case="title"/>
-              <name and="symbol" initialize-with=". " delimiter=", "/>
-            </names>
-            <names variable="editor translator" delimiter="; ">
-              <name and="symbol" initialize-with=". " delimiter=", "/>
-              <label form="short" prefix=", " text-case="title"/>
-            </names>
-          </group>
-        </else>
-      </choose>
-    </group>
-  </macro>
-  <macro name="database-location">
-    <choose>
-      <if variable="archive-place" match="none">
-        <!-- With `archive-place`: physical archives. Without: online archives. -->
-        <!-- Add archive_collection as that becomes available -->
-        <text variable="archive_location"/>
-      </if>
-    </choose>
-  </macro>
-  <macro name="number">
-    <choose>
-      <if variable="number">
-        <group delimiter=", ">
-          <group delimiter=" ">
-            <text variable="genre" text-case="title"/>
-            <choose>
-              <if is-numeric="number">
-                <!-- Replace with label variable="number" if that becomes available -->
-                <text term="issue" form="short" text-case="capitalize-first"/>
-                <text variable="number"/>
-              </if>
-              <else>
-                <text variable="number"/>
-              </else>
-            </choose>
-          </group>
-          <choose>
-            <if type="thesis">
-              <choose>
-                <!-- Include the university in brackets if thesis is published -->
-                <if variable="archive DOI URL" match="any">
-                  <text variable="publisher"/>
-                </if>
-              </choose>
-            </if>
-          </choose>
-        </group>
-      </if>
-    </choose>
-  </macro>
-  <macro name="locators-booklike">
-    <choose>
-      <if type="article-journal article-magazine article-newspaper broadcast interview patent post post-weblog review review-book speech webpage" match="any"/>
-      <else-if type="paper-conference">
-        <choose>
-          <if variable="collection-editor editor editorial-director" match="any">
-            <group delimiter=", ">
-              <text macro="version"/>
-              <text macro="edition"/>
-              <text macro="volume-booklike"/>
-            </group>
-          </if>
-        </choose>
-      </else-if>
-      <else>
-        <group delimiter=", ">
-          <text macro="version"/>
-          <text macro="edition"/>
-          <text macro="volume-booklike"/>
-        </group>
-      </else>
-    </choose>
-  </macro>
-  <macro name="version">
-    <choose>
-      <if is-numeric="version">
-        <group delimiter=" ">
-          <!-- replace with label variable="version" if that becomes available -->
-          <text term="version" text-case="capitalize-first"/>
-          <text variable="version"/>
-        </group>
-      </if>
-      <else>
-        <text variable="version"/>
-      </else>
-    </choose>
-  </macro>
-  <macro name="edition">
-    <choose>
-      <if is-numeric="edition">
-        <group delimiter=" ">
-          <number variable="edition" form="ordinal"/>
-          <label variable="edition" form="short"/>
-        </group>
-      </if>
-      <else>
-        <text variable="edition"/>
-      </else>
-    </choose>
-  </macro>
-  <macro name="volume-booklike">
-    <group delimiter=", ">
-      <!-- Report series [ex. 52] -->
-      <choose>
-        <if type="report">
-          <group delimiter=" ">
-            <text variable="collection-title" text-case="title"/>
-            <text variable="collection-number"/>
-          </group>
-        </if>
-      </choose>
-      <choose>
-        <if variable="volume" match="any">
-          <choose>
-            <!-- Non-numeric volumes are already printed as part of the book title -->
-            <if is-numeric="volume" match="none"/>
-            <else>
-              <group delimiter=" ">
-                <label variable="volume" form="short" text-case="capitalize-first"/>
-                <number variable="volume" form="numeric"/>
-              </group>
-            </else>
-          </choose>
-        </if>
-        <else>
-          <group>
-            <!-- Replace with label variable="number-of-volumes" if that becomes available -->
-            <text term="volume" form="short" text-case="capitalize-first" suffix=" "/>
-            <text term="page-range-delimiter" prefix="1"/>
-            <number variable="number-of-volumes" form="numeric"/>
-          </group>
-        </else>
-      </choose>
-      <group delimiter=" ">
-        <label variable="issue" text-case="capitalize-first"/>
-        <text variable="issue"/>
-      </group>
-      <group delimiter=" ">
-        <label variable="page" form="short" suffix=" "/>
-        <text variable="page"/>
-      </group>
-    </group>
-  </macro>
-  <macro name="reviewed-title">
-    <choose>
-      <if variable="reviewed-title">
-        <!-- Not possible to distinguish TV series episode from other reviewed 
-              works [Ex. 69] -->
-        <text variable="reviewed-title" font-style="italic"/>
-      </if>
-      <else>
-        <!-- Assume title is title of reviewed work -->
-        <text variable="title" font-style="italic"/>
-      </else>
-    </choose>
-  </macro>
-  <macro name="reviewed-title-intext">
-    <choose>
-      <if variable="reviewed-title">
-        <!-- Not possible to distinguish TV series episode from other reviewed works [Ex. 69] -->
-        <text variable="reviewed-title" form="short" font-style="italic"/>
-      </if>
-      <else>
-        <!-- Assume title is title of reviewed work -->
-        <text variable="title" form="short" font-style="italic"/>
-      </else>
-    </choose>
-  </macro>
-  <macro name="format">
-    <choose>
-      <if variable="genre medium" match="any">
-        <group delimiter="; ">
-          <choose>
-            <if variable="number" match="none">
-              <text variable="genre" text-case="capitalize-first"/>
-            </if>
-          </choose>
-          <text variable="medium" text-case="capitalize-first"/>
-        </group>
-      </if>
-      <!-- Generic labels for specific types -->
-      <!-- These should be localized when possible -->
-      <else-if type="dataset">
-        <text value="Data set"/>
-      </else-if>
-      <else-if type="book" variable="version" match="all">
-        <!-- Replace with type="software" and term="software" as that becomes available -->
-        <text value="Computer software"/>
-      </else-if>
-      <else-if type="interview personal_communication" match="any">
-        <choose>
-          <if variable="archive container-title DOI publisher URL" match="none">
-            <text term="letter" text-case="capitalize-first"/>
-          </if>
-          <else-if type="interview">
-            <text term="interview" text-case="capitalize-first"/>
-          </else-if>
-        </choose>
-      </else-if>
-      <else-if type="map">
-        <text value="Map"/>
-      </else-if>
-    </choose>
-  </macro>
-  <macro name="format-intext">
-    <choose>
-      <if variable="genre" match="any">
-        <text variable="genre" text-case="capitalize-first"/>
-      </if>
-      <else-if variable="medium">
-        <text variable="medium" text-case="capitalize-first"/>
-      </else-if>
-      <!-- Generic labels for specific types -->
-      <!-- These should be localized when possible -->
-      <else-if type="dataset">
-        <text value="Data set"/>
-      </else-if>
-      <else-if type="book" variable="version" match="all">
-        <!-- Replace with type="software" and term="software" as that becomes available -->
-        <text value="Computer software"/>
-      </else-if>
-      <else-if type="interview personal_communication" match="any">
-        <choose>
-          <if variable="archive container-title DOI publisher URL" match="none">
-            <text term="letter" text-case="capitalize-first"/>
-          </if>
-          <else-if type="interview">
-            <text term="interview" text-case="capitalize-first"/>
-          </else-if>
-        </choose>
-      </else-if>
-      <else-if type="map">
-        <text value="Map"/>
-      </else-if>
-    </choose>
-  </macro>
-  <!-- APA 'source' element contains four parts:
-       container, event, publisher, access -->
-  <macro name="container">
-    <choose>
-      <if type="article-journal article-magazine article-newspaper post-weblog review review-book" match="any">
-        <!-- Periodical items -->
-        <text macro="container-periodical"/>
-      </if>
-      <else-if type="paper-conference">
-        <!-- Determine if paper-conference is a periodical or booklike -->
-        <choose>
-          <if variable="editor editorial-director collection-editor container-author" match="any">
-            <text macro="container-booklike"/>
-          </if>
-          <else>
-            <text macro="container-periodical"/>
-          </else>
-        </choose>
-      </else-if>
-      <else-if type="post webpage" match="none">
-        <!-- post and webpage treat container-title like publisher -->
-        <text macro="container-booklike"/>
-      </else-if>
-    </choose>
-  </macro>
-  <macro name="container-periodical">
-    <group delimiter=". ">
-      <group delimiter=", ">
-        <text variable="container-title" font-style="italic" text-case="title"/>
-        <choose>
-          <if variable="volume">
-            <group>
-              <text variable="volume" font-style="italic"/>
-              <text variable="issue" prefix="(" suffix=")"/>
-            </group>
-          </if>
-          <else>
-            <text variable="issue" font-style="italic"/>
-          </else>
-        </choose>
-        <choose>
-          <if variable="page">
-            <text variable="page"/>
-          </if>
-          <else>
-            <!-- Ex. 6: Journal article with article number or eLocator -->
-            <!-- This should be localized -->
-            <text variable="number" prefix="Article "/>
-          </else>
-        </choose>
-      </group>
-      <choose>
-        <if variable="issued">
-          <choose>
-            <if variable="issue page volume" match="none">
-              <text variable="status" text-case="capitalize-first"/>
-            </if>
-          </choose>
-        </if>
-      </choose>
-    </group>
-  </macro>
-  <macro name="container-booklike">
-    <choose>
-      <if variable="container-title" match="any">
-        <group delimiter=" ">
-          <text term="in" text-case="capitalize-first"/>
-          <group delimiter=", ">
-            <names variable="editor translator" delimiter=", &amp; ">
-              <!-- Change to editortranslator and move editor to substitute as that becomes available -->
-              <name and="symbol" initialize-with=". " delimiter=", "/>
-              <label form="short" text-case="title" prefix=" (" suffix=")"/>
-              <substitute>
-                <names variable="editorial-director"/>
-                <names variable="collection-editor"/>
-                <names variable="container-author"/>
-              </substitute>
-            </names>
-            <group delimiter=": " font-style="italic">
-              <text variable="container-title"/>
-              <!-- Replace with volume-title as that becomes available -->
-              <choose>
-                <if is-numeric="volume" match="none">
-                  <group delimiter=" ">
-                    <label variable="volume" form="short" text-case="capitalize-first"/>
-                    <text variable="volume"/>
-                  </group>
-                </if>
-              </choose>
-            </group>
-          </group>
-          <text macro="parenthetical-container"/>
-          <text macro="bracketed-container"/>
-        </group>
-      </if>
-    </choose>
-  </macro>
-  <macro name="publisher">
-    <group delimiter="; ">
-      <choose>
-        <if type="thesis">
-          <choose>
-            <if variable="archive DOI URL" match="none">
-              <text variable="publisher"/>
-            </if>
-          </choose>
-        </if>
-        <else-if type="post webpage" match="any">
-          <!-- For websites, treat container title like publisher -->
-          <group delimiter="; ">
-            <text variable="container-title" text-case="title"/>
-            <text variable="publisher"/>
-          </group>
-        </else-if>
-        <else-if type="paper-conference">
-          <!-- For paper-conference, don't print publisher if in a journal-like proceedings -->
-          <choose>
-            <if variable="collection-editor editor editorial-director" match="any">
-              <text variable="publisher"/>
-            </if>
-          </choose>
-        </else-if>
-        <else-if type="article-journal article-magazine article-newspaper post-weblog" match="none">
-          <text variable="publisher"/>
-        </else-if>
-      </choose>
-      <group delimiter=", ">
-        <choose>
-          <if variable="archive-place">
-            <!-- With `archive-place`: physical archives. Without: online archives. -->
-            <!-- For physical archives, print the location before the archive name.
-                For electronic archives, these are printed in macro="description". -->
-            <!-- Split "archive_location" into "archive_collection" and "archive_location" as that becomes available -->
-            <!-- Must test for archive_collection:
-                With collection: archive_collection (archive_location), archive, archive-place
-                No collection: archive (archive_location), archive-place
-            -->
-            <text variable="archive_location"/>
-          </if>
-        </choose>
-        <text variable="archive"/>
-        <text variable="archive-place"/>
-      </group>
-    </group>
-  </macro>
-  <macro name="access">
-    <choose>
-      <if variable="DOI" match="any">
-        <text variable="DOI" prefix="https://doi.org/"/>
-      </if>
-      <else-if variable="URL">
-        <group delimiter=" ">
-          <choose>
-            <if variable="issued status" match="none">
-              <group delimiter=" ">
-                <text term="retrieved" text-case="capitalize-first"/>
-                <date variable="accessed" form="text" suffix=","/>
-                <text term="from"/>
-              </group>
-            </if>
-          </choose>
-          <text variable="URL"/>
-        </group>
-      </else-if>
-    </choose>
-  </macro>
-  <macro name="event">
-    <choose>
-      <if variable="event">
-        <!-- To prevent Zotero from printing event-place due to its double-mapping of all 'place' to
-             both publisher-place and event-place. Remove this 'choose' when that is changed. -->
-        <choose>
-          <if variable="collection-editor editor editorial-director issue page volume" match="none">
-            <!-- Don't print event info if published in a proceedings -->
-            <group delimiter=", ">
-              <text variable="event"/>
-              <text variable="event-place"/>
-            </group>
-          </if>
-        </choose>
-      </if>
-    </choose>
-  </macro>
-  <!-- After 'source', APA also prints publication history (original publication, reprint info, retraction info) -->
-  <macro name="publication-history">
-    <choose>
-      <if type="patent" match="none">
-        <group prefix="(" suffix=")">
-          <choose>
-            <if variable="references">
-              <!-- This provides the option for more elaborate description 
-                   of publication history, such as full "reprinted" references
-                   (examples 11, 43, 44) or retracted references -->
-              <text variable="references"/>
-            </if>
-            <else>
-              <group delimiter=" ">
-                <text value="Original work published"/>
-                <choose>
-                  <if is-uncertain-date="original-date">
-                    <text term="circa" form="short"/>
-                  </if>
-                </choose>
-                <date variable="original-date">
-                  <date-part name="year"/>
-                </date>
-              </group>
-            </else>
-          </choose>
-        </group>
-      </if>
-      <else>
-        <text variable="references" prefix="(" suffix=")"/>
-      </else>
-    </choose>
-  </macro>
-  <!-- Legal citations have their own rules -->
-  <macro name="legal-cites">
-    <choose>
-      <if type="legal_case">
-        <group delimiter=". ">
-          <group delimiter=", ">
-            <text variable="title"/>
-            <group delimiter=" ">
-              <text macro="container-legal"/>
-              <text macro="date-legal"/>
-            </group>
-            <text variable="references"/>
-          </group>
-          <text macro="access"/>
-        </group>
-      </if>
-      <else-if type="bill">
-        <!-- Currently designed to handle bills, resolutions, hearings, rederal reports. -->
-        <group delimiter=". ">
-          <group delimiter=", ">
-            <choose>
-              <if variable="number container-title" match="none">
-                <!-- If no number or container-title, then assume it is a hearing -->
-                <text variable="title" font-style="italic"/>
-              </if>
-              <else>
-                <text variable="title"/>
-              </else>
-            </choose>
-            <group delimiter=" ">
-              <text macro="container-legal"/>
-              <text macro="date-legal"/>
-              <choose>
-                <if variable="number container-title" match="none">
-                  <!-- If no number or container-title, then assume it is a hearing -->
-                  <names variable="author" prefix="(testimony of " suffix=")">
-                    <name and="symbol" delimiter=", "/>
-                  </names>
-                </if>
-                <else>
-                  <text variable="status" prefix="(" suffix=")"/>
-                </else>
-              </choose>
-            </group>
-            <text variable="references"/>
-          </group>
-          <text macro="access"/>
-        </group>
-      </else-if>
-      <else-if type="legislation">
-        <!-- Currently designed to handle statutes, codified regulations, executive orders.
-             For uncodified regulations, assume future code section is in status. -->
-        <group delimiter=". ">
-          <group delimiter=", ">
-            <text variable="title"/>
-            <group delimiter=" ">
-              <text macro="container-legal"/>
-              <text macro="date-legal"/>
-              <text variable="status" prefix="(" suffix=")"/>
-            </group>
-            <text variable="references"/>
-          </group>
-          <text macro="access"/>
-        </group>
-      </else-if>
-      <else-if type="treaty">
-        <!-- APA generally defers to Bluebook for legal citations, but diverges without
-             explanation for treaty items. The Bluebook format that was used in APA 6th
-             ed. is used here. -->
-        <group delimiter=", ">
-          <text variable="title" text-case="title"/>
-          <names variable="author">
-            <name initialize-with="." form="short" delimiter="-"/>
-          </names>
-          <text macro="date-legal"/>
-          <text macro="container-legal"/>
-          <text macro="access"/>
-        </group>
-      </else-if>
-    </choose>
-  </macro>
-  <macro name="date-legal">
-    <choose>
-      <if type="legal_case">
-        <group prefix="(" suffix=")" delimiter=" ">
-          <text variable="authority"/>
-          <choose>
-            <if variable="container-title" match="any">
-              <!-- Print only year for cases published in reporters-->
-              <date variable="issued" form="numeric" date-parts="year"/>
-            </if>
-            <else>
-              <date variable="issued" form="text"/>
-            </else>
-          </choose>
-        </group>
-      </if>
-      <else-if type="bill legislation" match="any">
-        <group prefix="(" suffix=")" delimiter=" ">
-          <group delimiter=" ">
-            <date variable="original-date">
-              <date-part name="year"/>
-            </date>
-            <text term="and" form="symbol"/>
-          </group>
-          <date variable="issued">
-            <date-part name="year"/>
-          </date>
-        </group>
-      </else-if>
-      <else-if type="treaty">
-        <date variable="issued" form="text"/>
-      </else-if>
-    </choose>
-  </macro>
-  <macro name="container-legal">
-    <!-- Expect legal item container-titles to be stored in short form -->
-    <choose>
-      <if type="legal_case">
-        <group delimiter=" ">
-          <choose>
-            <if variable="container-title">
-              <group delimiter=" ">
-                <text variable="volume"/>
-                <text variable="container-title"/>
-                <group delimiter=" ">
-                  <!-- Change to label variable="section" as that becomes available -->
-                  <text term="section" form="symbol"/>
-                  <text variable="section"/>
-                </group>
-                <choose>
-                  <if variable="page page-first" match="any">
-                    <text variable="page-first"/>
-                  </if>
-                  <else>
-                    <text value="___"/>
-                  </else>
-                </choose>
-              </group>
-            </if>
-            <else>
-              <group delimiter=" ">
-                <choose>
-                  <if is-numeric="number">
-                    <!-- Replace with label variable="number" if that becomes available -->
-                    <text term="issue" form="short" text-case="capitalize-first"/>
-                  </if>
-                </choose>
-                <text variable="number"/>
-              </group>
-            </else>
-          </choose>
-        </group>
-      </if>
-      <else-if type="bill">
-        <group delimiter=", ">
-          <group delimiter=" ">
-            <text variable="genre"/>
-            <group delimiter=" ">
-              <choose>
-                <if variable="chapter-number container-title" match="none">
-                  <!-- Replace with label variable="number" as that becomes available -->
-                  <text term="issue" form="short"/>
-                </if>
-              </choose>
-              <text variable="number"/>
-            </group>
-          </group>
-          <text variable="authority"/>
-          <text variable="chapter-number"/>
-          <group delimiter=" ">
-            <text variable="volume"/>
-            <text variable="container-title"/>
-            <text variable="page-first"/>
-          </group>
-        </group>
-      </else-if>
-      <else-if type="legislation">
-        <choose>
-          <if variable="number">
-            <!--There's a public law number-->
-            <group delimiter=", ">
-              <text variable="number" prefix="Pub. L. No. "/>
-              <group delimiter=" ">
-                <text variable="volume"/>
-                <text variable="container-title"/>
-                <text variable="page-first"/>
-              </group>
-            </group>
-          </if>
-          <else>
-            <group delimiter=" ">
-              <text variable="volume"/>
-              <text variable="container-title"/>
-              <choose>
-                <if variable="section">
-                  <group delimiter=" ">
-                    <!-- Change to label variable="section" as that becomes available -->
-                    <text term="section" form="symbol"/>
-                    <text variable="section"/>
-                  </group>
-                </if>
-                <else>
-                  <text variable="page-first"/>
-                </else>
-              </choose>
-            </group>
-          </else>
-        </choose>
-      </else-if>
-      <else-if type="treaty">
-        <group delimiter=" ">
-          <number variable="volume"/>
-          <text variable="container-title"/>
-          <choose>
-            <if variable="page page-first" match="any">
-              <text variable="page-first"/>
-            </if>
-            <else>
-              <group delimiter=" ">
-                <!-- Replace with label variable="number" if that becomes available -->
-                <text term="issue" form="short" text-case="capitalize-first"/>
-                <text variable="number"/>
-              </group>
-            </else>
-          </choose>
-        </group>
-      </else-if>
-    </choose>
-  </macro>
-  <macro name="citation-locator">
-    <group delimiter=" ">
-      <choose>
-        <if locator="chapter">
-          <label variable="locator" text-case="capitalize-first"/>
-        </if>
-        <else>
-          <label variable="locator" form="short"/>
-        </else>
-      </choose>
-      <text variable="locator"/>
-    </group>
-  </macro>
-  <citation collapse="citation-number">
-    <sort>
-      <key variable="citation-number"/>
-    </sort>
-    <layout delimiter="," prefix="[" suffix="]" vertical-align="sup">
-      <group>
-        <text variable="citation-number"/>
-        <text macro="citation-locator" prefix="(" suffix=")"/>
-      </group>
-    </layout>
-  </citation>
-  <bibliography hanging-indent="true" et-al-min="21" et-al-use-first="19" et-al-use-last="true" entry-spacing="0" line-spacing="2">
-    <layout>
-      <group delimiter=". ">
-        <text variable="citation-number"/>
-        <choose>
-          <if type="bill legal_case legislation treaty" match="any">
-            <!-- Legal items have different orders and delimiters -->
-            <choose>
-              <if variable="DOI URL" match="any">
-                <text macro="legal-cites"/>
-              </if>
-              <else>
-                <text macro="legal-cites" suffix="."/>
-              </else>
-            </choose>
-          </if>
-          <else>
-            <group delimiter=" ">
-              <group delimiter=". " suffix=".">
-                <text macro="author-bib"/>
-                <text macro="date-bib"/>
-                <text macro="title-and-descriptions"/>
-                <text macro="container"/>
-                <text macro="event"/>
-                <text macro="publisher"/>
-              </group>
-              <text macro="access"/>
-              <text macro="publication-history"/>
-            </group>
-          </else>
-        </choose>
-      </group>
-    </layout>
-  </bibliography>
-</style>
diff --git a/elpa/org-ref-20241124.2012/citeproc/csl-styles/chicago-author-date-16th-edition.csl b/elpa/org-ref-20241124.2012/citeproc/csl-styles/chicago-author-date-16th-edition.csl
deleted file mode 100644 (file)
index 6ff1f0b..0000000
+++ /dev/null
@@ -1,657 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="display-and-sort" page-range-format="chicago">
-  <info>
-    <title>Chicago Manual of Style 16th edition (author-date)</title>
-    <id>http://www.zotero.org/styles/chicago-author-date-16th-edition</id>
-    <link href="http://www.zotero.org/styles/chicago-author-date-16th-edition" rel="self"/>
-    <link href="http://www.chicagomanualofstyle.org/tools_citationguide.html" rel="documentation"/>
-    <author>
-      <name>Julian Onions</name>
-      <email>julian.onionsNOSPAMgmail.com</email>
-    </author>
-    <contributor>
-      <name>Sebastian Karcher</name>
-    </contributor>
-    <contributor>
-      <name>Richard Karnesky</name>
-      <email>karnesky+zoteroNOSPAMgmail.com</email>
-      <uri>http://arc.nucapt.northwestern.edu/Richard_Karnesky</uri>
-    </contributor>
-    <contributor>
-      <name>Andrew Dunning</name>
-      <email>andrew.dunningNOSPAMutoronto.ca</email>
-    </contributor>
-    <contributor>
-      <name>Brenton M. Wiernik</name>
-    </contributor>
-    <category citation-format="author-date"/>
-    <category field="generic-base"/>
-    <summary>The author-date variant of the Chicago style</summary>
-    <updated>2020-04-26T18:22:50+00:00</updated>
-    <rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
-  </info>
-  <locale xml:lang="en">
-    <terms>
-      <term name="editor" form="verb-short">ed.</term>
-      <term name="container-author" form="verb">by</term>
-      <term name="translator" form="verb-short">trans.</term>
-      <term name="editortranslator" form="verb">edited and translated by</term>
-      <term name="translator" form="short">trans.</term>
-    </terms>
-  </locale>
-  <macro name="secondary-contributors">
-    <choose>
-      <if type="chapter entry-dictionary entry-encyclopedia paper-conference" match="none">
-        <group delimiter=". ">
-          <names variable="editor translator" delimiter=". ">
-            <label form="verb" text-case="capitalize-first" suffix=" "/>
-            <name and="text" delimiter=", "/>
-          </names>
-          <names variable="director" delimiter=". ">
-            <label form="verb" text-case="capitalize-first" suffix=" "/>
-            <name and="text" delimiter=", "/>
-          </names>
-        </group>
-      </if>
-    </choose>
-  </macro>
-  <macro name="container-contributors">
-    <choose>
-      <if type="chapter entry-dictionary entry-encyclopedia paper-conference" match="any">
-        <group prefix=", " delimiter=", ">
-          <names variable="container-author" delimiter=", ">
-            <label form="verb" suffix=" "/>
-            <name and="text" delimiter=", "/>
-          </names>
-          <names variable="editor translator" delimiter=", ">
-            <label form="verb" suffix=" "/>
-            <name and="text" delimiter=", "/>
-          </names>
-        </group>
-      </if>
-    </choose>
-  </macro>
-  <macro name="editor">
-    <names variable="editor">
-      <name name-as-sort-order="first" and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/>
-      <label form="short" prefix=", "/>
-    </names>
-  </macro>
-  <macro name="translator">
-    <names variable="translator">
-      <name name-as-sort-order="first" and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/>
-      <label form="short" prefix=", "/>
-    </names>
-  </macro>
-  <macro name="recipient">
-    <choose>
-      <if type="personal_communication">
-        <choose>
-          <if variable="genre">
-            <text variable="genre" text-case="capitalize-first"/>
-          </if>
-          <else>
-            <text term="letter" text-case="capitalize-first"/>
-          </else>
-        </choose>
-      </if>
-    </choose>
-    <names variable="recipient" delimiter=", ">
-      <label form="verb" prefix=" " text-case="lowercase" suffix=" "/>
-      <name and="text" delimiter=", "/>
-    </names>
-  </macro>
-  <macro name="substitute-title">
-    <choose>
-      <if type="article-magazine article-newspaper review review-book" match="any">
-        <text macro="container-title"/>
-      </if>
-    </choose>
-  </macro>
-  <macro name="contributors">
-    <group delimiter=". ">
-      <names variable="author">
-        <name and="text" name-as-sort-order="first" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/>
-        <label form="short" prefix=", "/>
-        <substitute>
-          <names variable="editor"/>
-          <names variable="translator"/>
-          <names variable="director"/>
-          <text macro="substitute-title"/>
-          <text macro="title"/>
-        </substitute>
-      </names>
-      <text macro="recipient"/>
-    </group>
-  </macro>
-  <macro name="contributors-short">
-    <names variable="author">
-      <name form="short" and="text" delimiter=", " initialize-with=". "/>
-      <substitute>
-        <names variable="editor"/>
-        <names variable="translator"/>
-        <names variable="director"/>
-        <text macro="substitute-title"/>
-        <text macro="title"/>
-      </substitute>
-    </names>
-  </macro>
-  <macro name="interviewer">
-    <names variable="interviewer" delimiter=", ">
-      <label form="verb" prefix=" " text-case="capitalize-first" suffix=" "/>
-      <name and="text" delimiter=", "/>
-    </names>
-  </macro>
-  <macro name="archive">
-    <group delimiter=". ">
-      <text variable="archive_location" text-case="capitalize-first"/>
-      <text variable="archive"/>
-      <text variable="archive-place"/>
-    </group>
-  </macro>
-  <macro name="access">
-    <group delimiter=". ">
-      <choose>
-        <if type="graphic report" match="any">
-          <text macro="archive"/>
-        </if>
-        <else-if type="article-journal bill book chapter legal_case legislation motion_picture paper-conference" match="none">
-          <text macro="archive"/>
-        </else-if>
-      </choose>
-      <choose>
-        <if type="webpage post-weblog" match="any">
-          <date variable="issued" delimiter=" ">
-            <date-part name="month"/>
-            <date-part name="day"/>
-          </date>
-        </if>
-      </choose>
-      <choose>
-        <if variable="issued" match="none">
-          <group delimiter=" ">
-            <text term="accessed" text-case="capitalize-first"/>
-            <date variable="accessed" delimiter=" ">
-              <date-part name="month"/>
-              <date-part name="day"/>
-            </date>
-          </group>
-        </if>
-      </choose>
-      <choose>
-        <if type="legal_case" match="none">
-          <choose>
-            <if variable="DOI">
-              <text variable="DOI" prefix="doi:"/>
-            </if>
-            <else>
-              <text variable="URL"/>
-            </else>
-          </choose>
-        </if>
-      </choose>
-    </group>
-  </macro>
-  <macro name="title">
-    <choose>
-      <if variable="title" match="none">
-        <choose>
-          <if type="personal_communication" match="none">
-            <text variable="genre" text-case="capitalize-first"/>
-          </if>
-        </choose>
-      </if>
-      <else-if type="bill book graphic legislation motion_picture song" match="any">
-        <text variable="title" text-case="title" font-style="italic"/>
-        <group prefix=" (" suffix=")" delimiter=" ">
-          <text term="version"/>
-          <text variable="version"/>
-        </group>
-      </else-if>
-      <else-if variable="reviewed-author">
-        <choose>
-          <if variable="reviewed-title">
-            <group delimiter=". ">
-              <text variable="title" text-case="title" quotes="true"/>
-              <group delimiter=", ">
-                <text variable="reviewed-title" text-case="title" font-style="italic" prefix="Review of "/>
-                <names variable="reviewed-author">
-                  <label form="verb-short" text-case="lowercase" suffix=" "/>
-                  <name and="text" delimiter=", "/>
-                </names>
-              </group>
-            </group>
-          </if>
-          <else>
-            <group delimiter=", ">
-              <text variable="title" text-case="title" font-style="italic" prefix="Review of "/>
-              <names variable="reviewed-author">
-                <label form="verb-short" text-case="lowercase" suffix=" "/>
-                <name and="text" delimiter=", "/>
-              </names>
-            </group>
-          </else>
-        </choose>
-      </else-if>
-      <else-if type="legal_case interview patent" match="any">
-        <text variable="title"/>
-      </else-if>
-      <else>
-        <text variable="title" text-case="title" quotes="true"/>
-      </else>
-    </choose>
-  </macro>
-  <macro name="edition">
-    <choose>
-      <if type="bill book graphic legal_case legislation motion_picture report song" match="any">
-        <choose>
-          <if is-numeric="edition">
-            <group delimiter=" " prefix=". ">
-              <number variable="edition" form="ordinal"/>
-              <text term="edition" form="short" strip-periods="true"/>
-            </group>
-          </if>
-          <else>
-            <text variable="edition" text-case="capitalize-first" prefix=". "/>
-          </else>
-        </choose>
-      </if>
-      <else-if type="chapter entry-dictionary entry-encyclopedia paper-conference" match="any">
-        <choose>
-          <if is-numeric="edition">
-            <group delimiter=" " prefix=", ">
-              <number variable="edition" form="ordinal"/>
-              <text term="edition" form="short"/>
-            </group>
-          </if>
-          <else>
-            <text variable="edition" prefix=", "/>
-          </else>
-        </choose>
-      </else-if>
-    </choose>
-  </macro>
-  <macro name="locators">
-    <choose>
-      <if type="article-journal">
-        <choose>
-          <if variable="volume">
-            <text variable="volume" prefix=" "/>
-            <group prefix=" (" suffix=")">
-              <choose>
-                <if variable="issue">
-                  <text variable="issue"/>
-                </if>
-                <else>
-                  <date variable="issued">
-                    <date-part name="month"/>
-                  </date>
-                </else>
-              </choose>
-            </group>
-          </if>
-          <else-if variable="issue">
-            <group delimiter=" " prefix=", ">
-              <text term="issue" form="short"/>
-              <text variable="issue"/>
-              <date variable="issued" prefix="(" suffix=")">
-                <date-part name="month"/>
-              </date>
-            </group>
-          </else-if>
-          <else>
-            <date variable="issued" prefix=", ">
-              <date-part name="month"/>
-            </date>
-          </else>
-        </choose>
-      </if>
-      <else-if type="legal_case">
-        <text variable="volume" prefix=", "/>
-        <text variable="container-title" prefix=" "/>
-        <text variable="page" prefix=" "/>
-      </else-if>
-      <else-if type="bill book graphic legal_case legislation motion_picture report song" match="any">
-        <group prefix=". " delimiter=". ">
-          <group>
-            <text term="volume" form="short" text-case="capitalize-first" suffix=" "/>
-            <number variable="volume" form="numeric"/>
-          </group>
-          <group>
-            <number variable="number-of-volumes" form="numeric"/>
-            <text term="volume" form="short" prefix=" " plural="true"/>
-          </group>
-        </group>
-      </else-if>
-      <else-if type="chapter entry-dictionary entry-encyclopedia paper-conference" match="any">
-        <choose>
-          <if variable="page" match="none">
-            <group prefix=". ">
-              <text term="volume" form="short" text-case="capitalize-first" suffix=" "/>
-              <number variable="volume" form="numeric"/>
-            </group>
-          </if>
-        </choose>
-      </else-if>
-    </choose>
-  </macro>
-  <macro name="locators-chapter">
-    <choose>
-      <if type="chapter entry-dictionary entry-encyclopedia paper-conference" match="any">
-        <choose>
-          <if variable="page">
-            <group prefix=", ">
-              <text variable="volume" suffix=":"/>
-              <text variable="page"/>
-            </group>
-          </if>
-        </choose>
-      </if>
-    </choose>
-  </macro>
-  <macro name="locators-article">
-    <choose>
-      <if type="article-newspaper">
-        <group prefix=", " delimiter=", ">
-          <group delimiter=" ">
-            <text variable="edition"/>
-            <text term="edition"/>
-          </group>
-          <group>
-            <text term="section" form="short" suffix=" "/>
-            <text variable="section"/>
-          </group>
-        </group>
-      </if>
-      <else-if type="article-journal">
-        <choose>
-          <if variable="volume issue" match="any">
-            <text variable="page" prefix=": "/>
-          </if>
-          <else>
-            <text variable="page" prefix=", "/>
-          </else>
-        </choose>
-      </else-if>
-    </choose>
-  </macro>
-  <macro name="point-locators">
-    <choose>
-      <if variable="locator">
-        <choose>
-          <if locator="page" match="none">
-            <choose>
-              <if type="bill book graphic legal_case legislation motion_picture report song" match="any">
-                <choose>
-                  <if variable="volume">
-                    <group>
-                      <text term="volume" form="short" suffix=" "/>
-                      <number variable="volume" form="numeric"/>
-                      <label variable="locator" form="short" prefix=", " suffix=" "/>
-                    </group>
-                  </if>
-                  <else>
-                    <label variable="locator" form="short" suffix=" "/>
-                  </else>
-                </choose>
-              </if>
-              <else>
-                <label variable="locator" form="short" suffix=" "/>
-              </else>
-            </choose>
-          </if>
-          <else-if type="bill book graphic legal_case legislation motion_picture report song" match="any">
-            <number variable="volume" form="numeric" suffix=":"/>
-          </else-if>
-        </choose>
-        <text variable="locator"/>
-      </if>
-    </choose>
-  </macro>
-  <macro name="container-prefix">
-    <text term="in" text-case="capitalize-first"/>
-  </macro>
-  <macro name="container-title">
-    <choose>
-      <if type="chapter entry-dictionary entry-encyclopedia paper-conference" match="any">
-        <text macro="container-prefix" suffix=" "/>
-      </if>
-    </choose>
-    <choose>
-      <if type="legal_case" match="none">
-        <text variable="container-title" text-case="title" font-style="italic"/>
-      </if>
-    </choose>
-  </macro>
-  <macro name="publisher">
-    <group delimiter=": ">
-      <text variable="publisher-place"/>
-      <text variable="publisher"/>
-    </group>
-  </macro>
-  <macro name="date">
-    <choose>
-      <if variable="issued">
-        <group delimiter=" ">
-          <date variable="original-date" form="text" date-parts="year" prefix="(" suffix=")"/>
-          <date variable="issued">
-            <date-part name="year"/>
-          </date>
-        </group>
-      </if>
-      <else-if variable="accessed">
-        <date variable="accessed">
-          <date-part name="year"/>
-        </date>
-      </else-if>
-      <else-if variable="status">
-        <text variable="status" text-case="capitalize-first"/>
-      </else-if>
-      <else>
-        <text term="no date" form="short"/>
-      </else>
-    </choose>
-  </macro>
-  <macro name="date-in-text">
-    <choose>
-      <if variable="issued">
-        <group delimiter=" ">
-          <date variable="original-date" form="text" date-parts="year" prefix="[" suffix="]"/>
-          <date variable="issued">
-            <date-part name="year"/>
-          </date>
-        </group>
-      </if>
-      <else-if variable="accessed">
-        <date variable="accessed">
-          <date-part name="year"/>
-        </date>
-      </else-if>
-      <else-if variable="status">
-        <text variable="status"/>
-      </else-if>
-      <else>
-        <text term="no date" form="short"/>
-      </else>
-    </choose>
-  </macro>
-  <macro name="day-month">
-    <date variable="issued">
-      <date-part name="month"/>
-      <date-part name="day" prefix=" "/>
-    </date>
-  </macro>
-  <macro name="collection-title">
-    <choose>
-      <if match="none" type="article-journal">
-        <choose>
-          <if match="none" is-numeric="collection-number">
-            <group delimiter=", ">
-              <text variable="collection-title" text-case="title"/>
-              <text variable="collection-number"/>
-            </group>
-          </if>
-          <else>
-            <group delimiter=" ">
-              <text variable="collection-title" text-case="title"/>
-              <text variable="collection-number"/>
-            </group>
-          </else>
-        </choose>
-      </if>
-    </choose>
-  </macro>
-  <macro name="collection-title-journal">
-    <choose>
-      <if type="article-journal">
-        <group delimiter=" ">
-          <text variable="collection-title"/>
-          <text variable="collection-number"/>
-        </group>
-      </if>
-    </choose>
-  </macro>
-  <macro name="event">
-    <group delimiter=" ">
-      <choose>
-        <if variable="genre">
-          <text term="presented at"/>
-        </if>
-        <else>
-          <text term="presented at" text-case="capitalize-first"/>
-        </else>
-      </choose>
-      <text variable="event"/>
-    </group>
-  </macro>
-  <macro name="description">
-    <choose>
-      <if type="interview">
-        <group delimiter=". ">
-          <text macro="interviewer"/>
-          <text variable="medium" text-case="capitalize-first"/>
-        </group>
-      </if>
-      <else-if type="patent">
-        <group delimiter=" " prefix=". ">
-          <text variable="authority"/>
-          <text variable="number"/>
-        </group>
-      </else-if>
-      <else>
-        <text variable="medium" text-case="capitalize-first" prefix=". "/>
-      </else>
-    </choose>
-    <choose>
-      <if variable="title" match="none"/>
-      <else-if type="thesis personal_communication speech" match="any"/>
-      <else>
-        <group delimiter=" " prefix=". ">
-          <text variable="genre" text-case="capitalize-first"/>
-          <choose>
-            <if type="report">
-              <text variable="number"/>
-            </if>
-          </choose>
-        </group>
-      </else>
-    </choose>
-  </macro>
-  <macro name="issue">
-    <choose>
-      <if type="legal_case">
-        <text variable="authority" prefix=". "/>
-      </if>
-      <else-if type="speech">
-        <group prefix=". " delimiter=", ">
-          <group delimiter=" ">
-            <text variable="genre" text-case="capitalize-first"/>
-            <text macro="event"/>
-          </group>
-          <text variable="event-place"/>
-          <text macro="day-month"/>
-        </group>
-      </else-if>
-      <else-if type="article-newspaper article-magazine personal_communication" match="any">
-        <text macro="day-month" prefix=", "/>
-      </else-if>
-      <else-if type="patent">
-        <group delimiter=", " prefix=", ">
-          <group delimiter=" ">
-            <!--Needs Localization-->
-            <text value="filed"/>
-            <date variable="submitted" form="text"/>
-          </group>
-          <group delimiter=" ">
-            <choose>
-              <if variable="issued submitted" match="all">
-                <text term="and"/>
-              </if>
-            </choose>
-            <!--Needs Localization-->
-            <text value="issued"/>
-            <date variable="issued" form="text"/>
-          </group>
-        </group>
-      </else-if>
-      <else>
-        <group prefix=". " delimiter=", ">
-          <choose>
-            <if type="thesis">
-              <text variable="genre" text-case="capitalize-first"/>
-            </if>
-          </choose>
-          <text macro="publisher"/>
-        </group>
-      </else>
-    </choose>
-  </macro>
-  <citation et-al-min="4" et-al-use-first="1" disambiguate-add-year-suffix="true" disambiguate-add-names="true" disambiguate-add-givenname="true" givenname-disambiguation-rule="primary-name" collapse="year">
-    <layout prefix="(" suffix=")" delimiter="; ">
-      <group delimiter=", ">
-        <choose>
-          <if variable="issued accessed" match="any">
-            <group delimiter=" ">
-              <text macro="contributors-short"/>
-              <text macro="date-in-text"/>
-            </group>
-          </if>
-          <!---comma before forthcoming and n.d.-->
-          <else>
-            <group delimiter=", ">
-              <text macro="contributors-short"/>
-              <text macro="date-in-text"/>
-            </group>
-          </else>
-        </choose>
-        <text macro="point-locators"/>
-      </group>
-    </layout>
-  </citation>
-  <bibliography hanging-indent="true" et-al-min="11" et-al-use-first="7" subsequent-author-substitute="&#8212;&#8212;&#8212;" entry-spacing="0">
-    <sort>
-      <key macro="contributors"/>
-      <key variable="issued"/>
-      <key variable="title"/>
-    </sort>
-    <layout suffix=".">
-      <group delimiter=". ">
-        <text macro="contributors"/>
-        <text macro="date"/>
-        <text macro="title"/>
-      </group>
-      <text macro="description"/>
-      <text macro="secondary-contributors" prefix=". "/>
-      <text macro="container-title" prefix=". "/>
-      <text macro="container-contributors"/>
-      <text macro="edition"/>
-      <text macro="locators-chapter"/>
-      <text macro="collection-title-journal" prefix=", " suffix=", "/>
-      <text macro="locators"/>
-      <text macro="collection-title" prefix=". "/>
-      <text macro="issue"/>
-      <text macro="locators-article"/>
-      <text macro="access" prefix=". "/>
-    </layout>
-  </bibliography>
-</style>
diff --git a/elpa/org-ref-20241124.2012/citeproc/csl-styles/elsevier-harvard.csl b/elpa/org-ref-20241124.2012/citeproc/csl-styles/elsevier-harvard.csl
deleted file mode 100644 (file)
index cc97857..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="never" default-locale="en-US">
-  <info>
-    <title>Elsevier - Harvard (with titles)</title>
-    <id>http://www.zotero.org/styles/elsevier-harvard</id>
-    <link href="http://www.zotero.org/styles/elsevier-harvard" rel="self"/>
-    <link href="http://www.zotero.org/styles/ecology-letters" rel="template"/>
-    <link href="http://www.elsevier.com/journals/biological-conservation/0006-3207/guide-for-authors#68000" rel="documentation"/>
-    <author>
-      <name>David Kaplan</name>
-      <email>david.kaplanNOSPAMird.fr</email>
-    </author>
-    <contributor>
-      <name>Simon Kornblith</name>
-      <email>simonNOSPAMsimonster.com</email>
-    </contributor>
-    <contributor>
-      <name>Bruce D'Arcus</name>
-    </contributor>
-    <contributor>
-      <name>Curtis M. Humphrey</name>
-    </contributor>
-    <contributor>
-      <name>Richard Karnesky</name>
-      <email>karnesky+zoteroNOSPAMgmail.com</email>
-      <uri>http://arc.nucapt.northwestern.edu/Richard_Karnesky</uri>
-    </contributor>
-    <contributor>
-      <name>Sebastian Karcher</name>
-    </contributor>
-    <category citation-format="author-date"/>
-    <category field="biology"/>
-    <category field="generic-base"/>
-    <updated>2014-03-04T00:09:00+00:00</updated>
-    <rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
-  </info>
-  <macro name="container">
-    <choose>
-      <if type="chapter paper-conference" match="any">
-        <text term="in" prefix=", " suffix=": "/>
-        <names variable="editor translator" delimiter=", " suffix=", ">
-          <name name-as-sort-order="all" sort-separator=", " initialize-with="." delimiter=", " delimiter-precedes-last="always"/>
-          <label form="short" text-case="capitalize-first" prefix=" (" suffix=")"/>
-        </names>
-        <group delimiter=", ">
-          <text variable="container-title" text-case="title"/>
-          <text variable="collection-title" text-case="title"/>
-        </group>
-      </if>
-      <else-if type="bill book graphic legal_case legislation motion_picture report song" match="any">
-        <group prefix=", " delimiter=", ">
-          <text variable="container-title"/>
-          <text variable="collection-title"/>
-        </group>
-      </else-if>
-      <else>
-        <group prefix=". " delimiter=", ">
-          <text variable="container-title" form="short"/>
-          <text variable="collection-title"/>
-        </group>
-      </else>
-    </choose>
-  </macro>
-  <macro name="author">
-    <names variable="author">
-      <name name-as-sort-order="all" sort-separator=", " initialize-with="." delimiter=", " delimiter-precedes-last="always"/>
-      <label form="short" prefix=" (" suffix=")" text-case="capitalize-first"/>
-      <substitute>
-        <names variable="editor"/>
-        <names variable="translator"/>
-        <text macro="title"/>
-      </substitute>
-    </names>
-  </macro>
-  <macro name="author-short">
-    <names variable="author">
-      <name form="short" and="text" delimiter=", " initialize-with=". "/>
-      <substitute>
-        <names variable="editor"/>
-        <names variable="translator"/>
-        <choose>
-          <if type="bill book graphic legal_case legislation motion_picture report song" match="any">
-            <text variable="title" form="short" font-style="italic"/>
-          </if>
-          <else>
-            <text variable="title" form="short" quotes="true"/>
-          </else>
-        </choose>
-      </substitute>
-    </names>
-  </macro>
-  <macro name="access">
-    <choose>
-      <if variable="DOI">
-        <text variable="DOI" prefix="https://doi.org/"/>
-      </if>
-      <else-if type="webpage post-weblog" match="any">
-        <group delimiter=" ">
-          <text value="URL"/>
-          <text variable="URL"/>
-          <group prefix="(" suffix=").">
-            <text term="accessed" suffix=" "/>
-            <date variable="accessed">
-              <date-part name="month" form="numeric" suffix="."/>
-              <date-part name="day" suffix="."/>
-              <date-part name="year" form="short"/>
-            </date>
-          </group>
-        </group>
-      </else-if>
-    </choose>
-  </macro>
-  <macro name="title">
-    <choose>
-      <if type="report thesis" match="any">
-        <text variable="title"/>
-        <group prefix=" (" suffix=")" delimiter=" ">
-          <text variable="genre"/>
-          <text variable="number" prefix="No. "/>
-        </group>
-      </if>
-      <else-if type="bill book graphic legal_case legislation motion_picture report song speech" match="any">
-        <text variable="title"/>
-        <text macro="edition" prefix=", "/>
-      </else-if>
-      <else-if type="webpage">
-        <text variable="title"/>
-        <text value="WWW Document" prefix=" [" suffix="]"/>
-      </else-if>
-      <else>
-        <text variable="title"/>
-      </else>
-    </choose>
-  </macro>
-  <macro name="publisher">
-    <group delimiter=", ">
-      <text variable="publisher"/>
-      <text variable="publisher-place"/>
-    </group>
-  </macro>
-  <macro name="event">
-    <choose>
-      <if variable="event">
-        <text term="presented at" text-case="capitalize-first" suffix=" "/>
-        <text variable="event"/>
-      </if>
-    </choose>
-  </macro>
-  <macro name="issued">
-    <choose>
-      <if variable="issued">
-        <date variable="issued">
-          <date-part name="year"/>
-        </date>
-      </if>
-      <else>
-        <text term="no date" form="short"/>
-      </else>
-    </choose>
-  </macro>
-  <macro name="edition">
-    <group delimiter=" ">
-      <choose>
-        <if is-numeric="edition">
-          <number variable="edition" form="ordinal"/>
-        </if>
-        <else>
-          <text variable="edition" suffix="."/>
-        </else>
-      </choose>
-      <text value="ed"/>
-    </group>
-  </macro>
-  <macro name="locators">
-    <choose>
-      <if type="article-journal article-magazine article-newspaper" match="any">
-        <group prefix=" " delimiter=", ">
-          <group>
-            <text variable="volume"/>
-          </group>
-          <text variable="page"/>
-        </group>
-      </if>
-      <else-if type="bill book graphic legal_case legislation motion_picture report song thesis" match="any">
-        <group delimiter=", " prefix=". ">
-          <text macro="event"/>
-          <text macro="publisher"/>
-        </group>
-      </else-if>
-      <else-if type="chapter paper-conference" match="any">
-        <group delimiter=", " prefix=". ">
-          <text macro="event"/>
-          <text macro="publisher"/>
-          <group>
-            <label variable="page" form="short" suffix=" "/>
-            <text variable="page"/>
-          </group>
-        </group>
-      </else-if>
-      <else-if type="patent">
-        <text variable="number" prefix=". "/>
-      </else-if>
-    </choose>
-  </macro>
-  <citation et-al-min="3" et-al-use-first="1" disambiguate-add-givenname="true" disambiguate-add-year-suffix="true" collapse="year" cite-group-delimiter=", ">
-    <sort>
-      <key macro="author"/>
-      <key macro="issued" sort="descending"/>
-    </sort>
-    <layout prefix="(" suffix=")" delimiter="; ">
-      <group delimiter=", ">
-        <text macro="author-short"/>
-        <text macro="issued"/>
-        <group delimiter=" ">
-          <label variable="locator" form="short"/>
-          <text variable="locator"/>
-        </group>
-      </group>
-    </layout>
-  </citation>
-  <bibliography hanging-indent="true" entry-spacing="0" line-spacing="1">
-    <sort>
-      <key macro="author"/>
-      <key macro="issued" sort="descending"/>
-    </sort>
-    <layout>
-      <group suffix=".">
-        <text macro="author" suffix=","/>
-        <text macro="issued" prefix=" "/>
-        <group prefix=". ">
-          <text macro="title"/>
-          <text macro="container"/>
-          <text macro="locators"/>
-        </group>
-      </group>
-      <text macro="access" prefix=". "/>
-    </layout>
-  </bibliography>
-</style>
\ No newline at end of file
diff --git a/elpa/org-ref-20241124.2012/citeproc/csl-styles/elsevier-with-titles.csl b/elpa/org-ref-20241124.2012/citeproc/csl-styles/elsevier-with-titles.csl
deleted file mode 100644 (file)
index 135329d..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="sort-only" default-locale="en-US">
-  <info>
-    <title>Elsevier (numeric, with titles)</title>
-    <id>http://www.zotero.org/styles/elsevier-with-titles</id>
-    <link href="http://www.zotero.org/styles/elsevier-with-titles" rel="self"/>
-    <link href="http://www.zotero.org/styles/elsevier-without-titles" rel="template"/>
-    <link href="http://www.elsevier.com/journals/journal-of-hazardous-materials/0304-3894/guide-for-authors#68001" rel="documentation"/>
-    <author>
-      <name>Richard Karnesky</name>
-      <email>karnesky+zoteroNOSPAMgmail.com</email>
-      <uri>http://arc.nucapt.northwestern.edu/Richard_Karnesky</uri>
-    </author>
-    <contributor>
-      <name>Rintze Zelle</name>
-      <uri>http://twitter.com/rintzezelle</uri>
-    </contributor>
-    <category citation-format="numeric"/>
-    <category field="generic-base"/>
-    <summary>A style for many of Elsevier's journals that includes article titles in the reference list</summary>
-    <updated>2019-10-15T15:14:08+00:00</updated>
-    <rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
-  </info>
-  <macro name="author">
-    <names variable="author">
-      <name initialize-with="." delimiter=", " delimiter-precedes-last="always"/>
-      <label form="short" prefix=", "/>
-      <substitute>
-        <names variable="editor"/>
-        <names variable="translator"/>
-      </substitute>
-    </names>
-  </macro>
-  <macro name="editor">
-    <names variable="editor">
-      <name initialize-with="." delimiter=", " delimiter-precedes-last="always"/>
-      <label form="short" prefix=" (" text-case="capitalize-first" suffix=")"/>
-    </names>
-  </macro>
-  <macro name="year-date">
-    <choose>
-      <if variable="issued">
-        <date variable="issued">
-          <date-part name="year"/>
-        </date>
-      </if>
-      <else>
-        <text term="no date" form="short"/>
-      </else>
-    </choose>
-  </macro>
-  <macro name="publisher">
-    <text variable="publisher" suffix=", "/>
-    <text variable="publisher-place" suffix=", "/>
-    <text macro="year-date"/>
-  </macro>
-  <macro name="edition">
-    <!--TODO: CSL should have low numeric be text (e.g. '3'->'third')-->
-    <choose>
-      <if is-numeric="edition">
-        <group delimiter=" ">
-          <number variable="edition" form="ordinal"/>
-          <text term="edition" form="short"/>
-        </group>
-      </if>
-      <else>
-        <text variable="edition"/>
-      </else>
-    </choose>
-  </macro>
-  <macro name="access">
-    <choose>
-      <if variable="URL">
-        <text variable="URL"/>
-        <group prefix=" (" suffix=")" delimiter=" ">
-          <text term="accessed"/>
-          <date variable="accessed" form="text"/>
-        </group>
-      </if>
-    </choose>
-  </macro>
-  <citation collapse="citation-number">
-    <sort>
-      <key variable="citation-number"/>
-    </sort>
-    <layout prefix="[" suffix="]" delimiter=",">
-      <text variable="citation-number"/>
-    </layout>
-  </citation>
-  <bibliography entry-spacing="0" second-field-align="flush">
-    <layout suffix=".">
-      <text variable="citation-number" prefix="[" suffix="]"/>
-      <text macro="author" suffix=", "/>
-      <choose>
-        <if type="bill book graphic legal_case legislation motion_picture report song" match="any">
-          <group delimiter=", ">
-            <text variable="title"/>
-            <text macro="edition"/>
-            <text macro="publisher"/>
-          </group>
-        </if>
-        <else-if type="chapter paper-conference" match="any">
-          <text variable="title" suffix=", "/>
-          <text term="in" suffix=": "/>
-          <text macro="editor" suffix=", "/>
-          <text variable="container-title" form="short" text-case="title" suffix=", "/>
-          <text macro="edition" suffix=", "/>
-          <text macro="publisher"/>
-          <group delimiter=" ">
-            <label variable="page" form="short" prefix=": "/>
-            <text variable="page"/>
-          </group>
-        </else-if>
-        <else-if type="patent">
-          <group delimiter=", ">
-            <text variable="title"/>
-            <text variable="number"/>
-            <text macro="year-date"/>
-          </group>
-        </else-if>
-        <else-if type="thesis">
-          <group delimiter=", ">
-            <text variable="title"/>
-            <text variable="genre"/>
-            <text variable="publisher"/>
-            <text macro="year-date"/>
-          </group>
-        </else-if>
-        <else>
-          <group delimiter=" ">
-            <text variable="title" suffix=","/>
-            <text variable="container-title" form="short" text-case="title" suffix="."/>
-            <text variable="volume"/>
-            <text macro="year-date" prefix="(" suffix=")"/>
-            <text variable="page" form="short"/>
-          </group>
-        </else>
-      </choose>
-      <choose>
-        <if variable="DOI">
-          <text variable="DOI" prefix=". https://doi.org/"/>
-        </if>
-        <else>
-          <text macro="access" prefix=". "/>
-        </else>
-      </choose>
-    </layout>
-  </bibliography>
-</style>
diff --git a/elpa/org-ref-20241124.2012/contrib.el b/elpa/org-ref-20241124.2012/contrib.el
deleted file mode 100644 (file)
index f726f75..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-;;; contrib.el --- Code contributed by users -*- lexical-binding: t; -*-
-
-;;; Commentary:
-;; 
-
-;;; Code:
-(defvar org-ref-cite-types)
-(declare-function org-element-context "org-element")
-(declare-function org-element-type "org-element")
-(declare-function org-element-property "org-element")
-(declare-function bibtex-completion-apa-format-reference "bibtex-completion")
-(declare-function org-ref-parse-cite-path "org-ref-citation-links")
-
-
-;; * Add messages in minibuffer
-;; Contributed in https://github.com/jkitchin/org-ref/issues/938 by @DiogoFerrari
-
-
-(defun org-ref-get-bibtex-key-under-cursor--display ()
-  "Return key under the cursor in `org-mode'.
-If not on a key, but on a cite, prompt for key."
-  (if-let ((key (get-text-property (point) 'cite-key)))
-      ;; Point is on a key, so we get it directly
-      key
-    ;; point is not on a key, but may still be on a cite link
-    (let ((el (org-element-context))
-         data text
-         keys)
-      (cond
-       ;; on a cite-link type
-       ((and
-        (eq (org-element-type el) 'link)
-        (assoc (org-element-property :type el) org-ref-cite-types))
-
-       (goto-char (org-element-property :begin el))
-       (setq data (org-ref-parse-cite-path (org-element-property :path el))
-             keys (cl-loop for ref in (plist-get data :references)
-                           collect (plist-get ref :key)))
-       (setq text nil)
-       (dolist (key keys)
-         (search-forward key)
-         (goto-char (match-beginning 0))
-         ;; (get-text-property (point) 'cite-key)
-         ;; (message (bibtex-completion-apa-format-reference key))
-         (setq text (concat text "\n" (bibtex-completion-apa-format-reference key))))))))
-  (message (string-trim-left text)))
-
-
-(defvar org-ref-message-timer nil
-  "Stores the idle timer for cite minibuffer messages.")
-
-
-(defcustom org-ref-message-interval 0.5
-  "Time in seconds to wait for the idle timer that displays the cite message."
-  :group 'org-ref
-  :type 'float)
-
-
-(defun org-ref-link-message ()
-  "Display a message in the minibuffer when point is on a cite link."
-  (when (and (eq major-mode 'org-mode) (eq (get-text-property (point) 'help-echo) 'org-ref-cite-tooltip))
-    (save-excursion (org-ref-get-bibtex-key-under-cursor--display))))
-
-
-(defun org-ref-messages-on ()
-  "Turn cite messages to minibuffer on."
-  (interactive)
-  (setq org-ref-message-timer (run-with-idle-timer org-ref-message-interval 0 'org-ref-link-message)))
-
-
-(defun org-ref-messages-off ()
-  "Turn cite messages to minibuffer off."
-  (interactive)
-  (when org-ref-message-timer
-    (cancel-timer org-ref-message-timer)
-    (setq org-ref-message-timer nil)))
-
-
-(provide 'contrib)
-
-;;; contrib.el ends here
diff --git a/elpa/org-ref-20241124.2012/doi-utils.el b/elpa/org-ref-20241124.2012/doi-utils.el
deleted file mode 100644 (file)
index ddde49a..0000000
+++ /dev/null
@@ -1,1694 +0,0 @@
-;;; doi-utils.el --- DOI utilities for making bibtex entries
-
-;; Copyright (C) 2015-2021  John Kitchin
-
-;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
-;; Keywords: convenience
-;; Package-Requires: ((org-ref))
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;; This package provides functionality to download PDFs and bibtex entries from
-;; a DOI, as well as to update a bibtex entry from a DOI.  It depends slightly
-;; on org-ref, to determine where to save pdf files too, and where to insert
-;; bibtex entries in the default bibliography.
-
-;; The principle commands you will use from here are:
-
-;; - doi-utils-get-bibtex-entry-pdf with the cursor in a bibtex entry.
-;; - doi-utils-insert-bibtex-entry-from-doi to insert a bibtex entry at your cursor, clean it and try to get a pdf.
-;; - doi-utils-add-bibtex-entry-from-doi to add an entry to your default bibliography (cleaned with pdf if possible).
-;; - doi-utils-update-bibtex-entry-from-doi with cursor in an entry to update its fields.
-
-;;; Code:
-
-(defvar url-http-end-of-headers)
-(declare-function org-ref-find-bibliography "org-ref-core")
-(declare-function org-ref-clean-bibtex-entry "org-ref-core")
-(declare-function bibtex-completion-edit-notes "bibtex-completion")
-(declare-function org-bibtex-yank "org-bibtex")
-(declare-function org-ref-possible-bibfiles "org-ref-core")
-
-(declare-function f-ext? "f")
-(declare-function f-entries "f")
-(declare-function s-match "s")
-
-(eval-when-compile
-  (require 'cl-lib))
-(require 'bibtex)
-(require 'dash)
-(require 'json)
-(require 'org)                          ; org-add-link-type
-
-(or (require 'ol-bibtex nil t)
-    (require 'org-bibtex)) ; org-bibtex-yank
-
-(require 'url-http)
-(require 'url-handlers)
-(require 'org-ref-utils)
-(require 'hydra)
-
-;;* Customization
-(defgroup doi-utils nil
-  "Customization group for doi-utils."
-  :tag "DOI utils"
-  :group 'doi-utils)
-
-
-(defcustom doi-utils-download-pdf
-  t
-  "Try to download PDFs when adding bibtex entries when non-nil."
-  :type 'boolean
-  :group 'doi-utils)
-
-(defcustom doi-utils-open-pdf-after-download
-  nil
-  "Open PDF after adding bibtex entries."
-  :type 'boolean
-  :group 'doi-utils)
-
-
-(defcustom doi-utils-timestamp-field
-  "DATE_ADDED"
-  "The bibtex field to store the date when an entry has been added."
-  :type 'string
-  :group 'doi-utils)
-
-(defcustom doi-utils-timestamp-format-function
-  'current-time-string
-  "The function to format the timestamp for a bibtex entry.
-Set to a function that returns nil to avoid setting timestamps in the entries.
-e.g. (lambda () nil)"
-  :type 'function
-  :group 'doi-utils)
-
-
-(defcustom doi-utils-dx-doi-org-url
-  "https://doi.org/"
-  "Base url to retrieve doi metadata from. A trailing / is required."
-  :type 'string
-  :group 'doi-utils)
-
-
-(defcustom doi-utils-metadata-function 'doi-utils-get-json-metadata
-  "Function for retrieving json metadata from `doi-utils-dx-doi-org-url'.
-The default is `doi-utils-get-json-metadata', but it sometimes
-fails with a proxy. An alternative is
-`doi-utils-get-json-metadata-curl' which requires an external
-program to use curl."
-  :type 'function
-  :group 'doi-utils)
-
-
-(defcustom doi-utils-async-download t
-  "Use `doi-utils-async-download-pdf' to get pdfs asynchrounously.
-If nil use `doi-utils-get-bibtex-entry-pdf' synchronously."
-  :type 'boolean
-  :group 'doi-utils)
-
-
-;;* Getting pdf files from a DOI
-
-;; The idea here is simple. When you visit http://dx.doi.org/doi or
-;; https://doi.org/doi, you get redirected to the journal site. Once you have
-;; the url for the article, you can usually compute the url to the pdf, or find
-;; it in the page. Then you simply download it.
-
-;; There are some subtleties in doing this that are described here. To get the
-;; redirect, we have to use url-retrieve, and a callback function. The callback
-;; does not return anything, so we communicate through global variables.
-;; url-retrieve is asynchronous, so we have to make sure to wait for it to
-;; finish.
-
-(defvar *doi-utils-waiting* t
-  "Stores waiting state for url retrieval.")
-
-(defvar *doi-utils-redirect* nil
-  "Stores redirect url from a callback function.")
-
-(defun doi-utils-redirect-callback (&optional status)
-  "Callback for `url-retrieve' to set the redirect.
-Optional argument STATUS Unknown why this is optional."
-  (when (plist-get status :error)
-    (signal (car (plist-get status :error)) (cdr(plist-get status :error))))
-  (when (plist-get status :redirect) ;  is nil if there none
-    (setq *doi-utils-redirect* (plist-get status :redirect)))
-  ;; we have done our job, so we are not waiting any more.
-  (setq *doi-utils-waiting* nil))
-
-;; To actually get the redirect we use url-retrieve like this.
-
-(defun doi-utils-get-redirect (doi)
-  "Get redirect url from `doi-utils-dx-doi-org-url'/doi."
-  ;; we are going to wait until the url-retrieve is done
-  (setq *doi-utils-waiting* t)
-  ;; start with no redirect. it will be set in the callback.
-  (setq *doi-utils-redirect* nil)
-  (url-retrieve
-   (format "%s%s" doi-utils-dx-doi-org-url doi)
-   'doi-utils-redirect-callback)
-  ;; I suspect we need to wait here for the asynchronous process to
-  ;; finish. we loop and sleep until the callback says it is done via
-  ;; `*doi-utils-waiting*'. this works as far as i can tell. Before I
-  ;; had to run this a few times to get it to work, which i suspect
-  ;; just gave the first one enough time to finish.
-  (while *doi-utils-waiting* (sleep-for 0.1)))
-
-;; Once we have a redirect for a particular doi, we need to compute the url to
-;; the pdf. We do this with a series of functions. Each function takes a single
-;; argument, the redirect url. If it knows how to compute the pdf url it does,
-;; and returns it. We store the functions in a variable:
-
-(defvar doi-utils-pdf-url-functions nil
-  "Functions that return a url to a pdf from a redirect url.
-Each function takes one argument, the redirect url.  The function
-must return a pdf-url, or nil.")
-
-
-;;** APS journals
-
-(defun aps-pdf-url (*doi-utils-redirect*)
-  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
-  (when (string-match "^http\\(s*\\)://journals.aps.org" *doi-utils-redirect*)
-    (replace-regexp-in-string "/abstract/" "/pdf/" *doi-utils-redirect*)))
-
-
-;;** Science
-
-(defun science-pdf-url (*doi-utils-redirect*)
-  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
-  (when (string-match "^http\\(s?\\)://www.sciencemag.org" *doi-utils-redirect*)
-    (concat *doi-utils-redirect* ".full.pdf")))
-
-
-;;** Nature
-
-(defun nature-pdf-url (*doi-utils-redirect*)
-  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
-  (when (string-match "^http\\(s?\\)://www.nature.com" *doi-utils-redirect*)
-    (concat *doi-utils-redirect* ".pdf")))
-
-
-;;** Elsevier/ScienceDirect
-;; You cannot compute these pdf links; they are embedded in the redirected pages.
-
-(defvar *doi-utils-pdf-url* nil
-  "Stores url to pdf download from a callback function.")
-
-;;** Wiley
-;; Wiley have changed the url structure from
-;; http://onlinelibrary.wiley.com/doi/10.1002/anie.201402680/abstract
-;; http://onlinelibrary.wiley.com/doi/10.1002/anie.201402680/pdf
-;; to
-;; http://onlinelibrary.wiley.com/doi/abs/10.1002/anie.201402680
-;; http://onlinelibrary.wiley.com/doi/pdf/10.1002/anie.201402680
-;; Hence fewer steps are now required.
-
-;; https://onlinelibrary.wiley.com/doi/10.1002/adts.202200926
-;; https://onlinelibrary.wiley.com/doi/epdf/10.1002/adts.202200926
-
-;; (defun wiley-pdf-url (*doi-utils-redirect*)
-;;   "Get url to the pdf from *DOI-UTILS-REDIRECT*."
-;;   (when (string-match "^http\\(s?\\)://onlinelibrary.wiley.com" *doi-utils-redirect*)
-;;     (replace-regexp-in-string "doi/abs" "doi/pdf" *doi-utils-redirect*)))
-
-
-(defun wiley-pdf-url-2 (*doi-utils-redirect*)
-  "Get url to the pdf from *DOI-UTILS-REDIRECT*.
-[2023-04-10 Mon] updated a new rule.
-https://onlinelibrary.wiley.com/doi/pdfdirect/10.1002/anie.201310461?download=true"
-  (when (string-match "^http\\(s?\\)://onlinelibrary.wiley.com" *doi-utils-redirect*)
-    (concat
-     (replace-regexp-in-string "doi/" "doi/pdfdirect/" *doi-utils-redirect*)
-     "?download=true")))
-
-
-(defun agu-pdf-url (*doi-utils-redirect*)
-  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
-  (when (string-match "https://agupubs.onlinelibrary.wiley.com"
-                     *doi-utils-redirect*)
-    (replace-regexp-in-string "/full/" "/pdfdirect/" *doi-utils-redirect*)))
-
-
-;;** Springer
-
-(defun springer-chapter-pdf-url (*doi-utils-redirect*)
-  (when (string-match "^http\\(s?\\)://link.springer.com/chapter/" *doi-utils-redirect*)
-    (replace-regexp-in-string "/chapter" "/content/pdf"
-                             (concat *doi-utils-redirect* ".pdf"))))
-
-
-(defun springer-pdf-url (*doi-utils-redirect*)
-  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
-  (when (string-match "^http\\(s?\\)://link.springer.com" *doi-utils-redirect*)
-    (replace-regexp-in-string "/article/" "/content/pdf/"
-                             (concat *doi-utils-redirect* ".pdf"))))
-
-
-;;** ACS
-;; here is a typical url http://pubs.acs.org/doi/abs/10.1021/nl500037x
-;; the pdf is found at http://pubs.acs.org/doi/pdf/10.1021/nl500037x
-
-;; we just change /abs/ to /pdf/.
-
-(defun acs-pdf-url-1 (*doi-utils-redirect*)
-  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
-  (when (string-match "^http\\(s?\\)://pubs.acs.org/doi/abs/" *doi-utils-redirect*)
-    (replace-regexp-in-string "/abs/" "/pdf/" *doi-utils-redirect*)))
-
-;; 1/20/2016 I noticed this new pattern in pdf urls, where there is no abs in
-;; the url
-(defun acs-pdf-url-2 (*doi-utils-redirect*)
-  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
-  (when (string-match "^http\\(s?\\)://pubs.acs.org/doi/" *doi-utils-redirect*)
-    (replace-regexp-in-string "/doi/" "/doi/pdf/" *doi-utils-redirect*)))
-
-;; 1/18/2019: It looks like they are using https now
-(defun acs-pdf-url-3 (*doi-utils-redirect*)
-  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
-  (when (string-match "^https://pubs.acs.org/doi/" *doi-utils-redirect*)
-    (replace-regexp-in-string "/doi/" "/doi/pdf/" *doi-utils-redirect*)))
-
-
-;;** IOP
-
-(defun iop-pdf-url (*doi-utils-redirect*)
-  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
-  (when (string-match "^http\\(s?\\)://iopscience.iop.org" *doi-utils-redirect*)
-    (concat *doi-utils-redirect* "/pdf")))
-
-;;** JSTOR
-
-(defun jstor-pdf-url (*doi-utils-redirect*)
-  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
-  (when (string-match "^http\\(s?\\)://www.jstor.org" *doi-utils-redirect*)
-    (concat (replace-regexp-in-string "/stable/" "/stable/pdfplus/" *doi-utils-redirect*) ".pdf")))
-
-
-;;** AIP
-
-(defun aip-pdf-url (*doi-utils-redirect*)
-  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
-  (when (string-match "^http\\(s?\\)://scitation.aip.org" *doi-utils-redirect*)
-    ;; get stuff after content
-    (let (p1 p2 s p3)
-      (setq p2 (replace-regexp-in-string
-                "^http\\(s?\\)://scitation.aip.org/" "" *doi-utils-redirect*))
-      (setq s (split-string p2 "/"))
-      (setq p1 (mapconcat 'identity (-remove-at-indices '(0 6) s) "/"))
-      (setq p3 (concat "/" (nth 0 s) (nth 1 s) "/" (nth 2 s) "/" (nth 3 s)))
-      (format "http://scitation.aip.org/deliver/fulltext/%s.pdf?itemId=/%s&mimeType=pdf&containerItemId=%s"
-              p1 p2 p3))))
-
-(defun aip-pdf-url-2 (*doi-utils-redirect*)
-  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
-  ;; [2021-08-28 Sat] Seems like they changed the link a little?
-  ;; https://aip.scitation.org/doi/10.1063/1.5019667
-  ;; to
-  ;; https://aip.scitation.org/doi/pdf/10.1063/1.5019667
-  (when (string-match "^http\\(s?\\)://aip.scitation.org" *doi-utils-redirect*)
-    (concat "https://aip.scitation.org/doi/pdf" (cl-second (split-string *doi-utils-redirect* "doi")))))
-
-;;** Taylor and Francis
-
-(defun tandfonline-pdf-url (*doi-utils-redirect*)
-  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
-  (when (string-match "^http\\(s?\\)://www.tandfonline.com" *doi-utils-redirect*)
-    (replace-regexp-in-string "/abs/\\|/full/" "/pdf/" *doi-utils-redirect*)))
-
-;;** ECS
-
-(defun ecs-pdf-url (*doi-utils-redirect*)
-  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
-  (when (string-match "^http\\(s?\\)://jes.ecsdl.org" *doi-utils-redirect*)
-    (replace-regexp-in-string "\.abstract$" ".full.pdf" *doi-utils-redirect*)))
-
-;; http://ecst.ecsdl.org/content/25/2/2769
-;; http://ecst.ecsdl.org/content/25/2/2769.full.pdf
-
-
-(defun ecst-pdf-url (*doi-utils-redirect*)
-  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
-  (when (string-match "^http\\(s?\\)://ecst.ecsdl.org" *doi-utils-redirect*)
-    (concat *doi-utils-redirect* ".full.pdf")))
-
-
-
-;;** RSC
-
-(defun rsc-pdf-url (*doi-utils-redirect*)
-  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
-  (when (string-match "^http\\(s?\\)://pubs.rsc.org" *doi-utils-redirect*)
-    (let ((url (downcase *doi-utils-redirect*)))
-      (setq url (replace-regexp-in-string "articlelanding" "articlepdf" url))
-      url)))
-
-;;** Science Direct
-
-;; https://www.sciencedirect.com/science/article/pii/S001085452200577X?via%3Dihub
-;; https://www.sciencedirect.com/science/article/pii/S001085452200577X/pdfft?isDTMRedir=true&download=true
-
-(defun science-direct-pdf-url (*doi-utils-redirect*)
-  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
-  (when (string-match "^http\\(s?\\)://www.sciencedirect.com" *doi-utils-redirect*)
-    (replace-string "?via%3Dihub" "/pdfft?isDTMRedir=true&download=true" *doi-utils-redirect*)))
-
-;; (defun doi-utils-get-science-direct-pdf-url (redirect-url)
-;;   "Science direct hides the pdf url in html.  We get it out here.
-;; REDIRECT-URL is where the pdf url will be in."
-;;   (let ((first-url
-;;          (with-current-buffer (url-retrieve-synchronously redirect-url)
-;;            (goto-char (point-min))
-;;            (when (re-search-forward "pdf_url\" content=\"\\([^\"]*\\)\"" nil t)
-;;              (match-string-no-properties 1)))))
-;;     (and first-url
-;;          (with-current-buffer (url-retrieve-synchronously first-url)
-;;            (goto-char (point-min))
-;;            (when (re-search-forward "or click <a href=\"\\([^\"]*\\)\">" nil t)
-;;              (match-string-no-properties 1))))))
-
-;; (defun science-direct-pdf-url (*doi-utils-redirect*)
-;;   "Get url to the pdf from *DOI-UTILS-REDIRECT*."
-;;   (when (string-match "^http\\(s?\\)://www.sciencedirect.com" *doi-utils-redirect*)
-;;     (doi-utils-get-science-direct-pdf-url *doi-utils-redirect*)))
-
-;; sometimes I get
-;; http://linkinghub.elsevier.com/retrieve/pii/S0927025609004558
-;; which actually redirect to
-;; http://www.sciencedirect.com/science/article/pii/S0927025609004558
-
-;; https://www.sciencedirect.com/science/article/pii/S001085452200577X?via%3Dihub
-;; https://www.sciencedirect.com/science/article/pii/S001085452200577X/pdfft?isDTMRedir=true&download=true
-
-;; (defun linkinghub-elsevier-pdf-url (*doi-utils-redirect*)
-;;   "Get url to the pdf from *DOI-UTILS-REDIRECT*."
-;;   (when (string-match
-;;      "^https://linkinghub.elsevier.com/retrieve" *doi-utils-redirect*)
-;;     (science-direct-pdf-url
-;;      (replace-regexp-in-string
-;;       ;; change URL to science direct and use function to get pdf URL
-;;       "https://linkinghub.elsevier.com/retrieve"
-;;       "https://www.sciencedirect.com/science/article"
-;;       *doi-utils-redirect*))))
-
-;; https://www.sciencedirect.com/science/article/pii/S1385894723014973/pdfft?isDTMRedir=true&download=true
-
-(defun linkinghub-elsevier-pdf-url (*doi-utils-redirect*)
-  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
-  (when (string-match
-        "^https://linkinghub.elsevier.com/retrieve" *doi-utils-redirect*)
-    (concat
-     (replace-regexp-in-string
-      ;; change URL to science direct and use function to get pdf URL
-      "https://linkinghub.elsevier.com/retrieve"
-      "https://www.sciencedirect.com/science/article"
-      *doi-utils-redirect*)
-     "/pdfft?isDTMRedir=true")))
-
-;;** PNAS
-;; http://www.pnas.org/content/early/2014/05/08/1319030111
-;; http://www.pnas.org/content/early/2014/05/08/1319030111.full.pdf
-
-;; with supporting info
-;; http://www.pnas.org/content/early/2014/05/08/1319030111.full.pdf+html?with-ds=yes
-
-(defun pnas-pdf-url (*doi-utils-redirect*)
-  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
-  (when (string-match "^http\\(s?\\)://www.pnas.org" *doi-utils-redirect*)
-    (concat *doi-utils-redirect* ".full.pdf?with-ds=yes")))
-
-
-;;** Copernicus Publications
-(defvar copernicus-journal-urls '(
-                                  "^https://www.adv-geosci.net/"
-                                  "^https://www.adv-radio-sci.net/"
-                                  "^https://www.adv-sci-res.net/"
-                                  "^https://www.adv-stat-clim-meteorol-oceanogr.net/"
-                                  "^https://www.ann-geophys.net/"
-                                  "^https://www.arch-anim-breed.net/"
-                                  "^https://www.astra-proc.net/"
-                                  "^https://www.atmos-chem-phys.net/"
-                                  "^https://www.atmos-chem-phys-discuss.net/"
-                                  "^https://www.atmos-meas-tech.net/"
-                                  "^https://www.atmos-meas-tech-discuss.net/"
-                                  "^https://www.biogeosciences.net/"
-                                  "^https://www.biogeosciences-discuss.net/"
-                                  "^https://www.clim-past.net/recent_papers.html"
-                                  "^https://www.clim-past-discuss.net/"
-                                  "^https://www.drink-water-eng-sci.net/"
-                                  "^https://www.drink-water-eng-sci-discuss.net/"
-                                  "^https://www.eg-quaternary-sci-j.net/"
-                                  "^https://www.earth-surf-dynam.net/"
-                                  "^https://www.earth-surf-dynam-discuss.net/"
-                                  "^https://www.earth-syst-dynam.net/"
-                                  "^https://www.earth-syst-dynam-discuss.net/"
-                                  "^https://www.earth-syst-sci-data.net/"
-                                  "^https://www.earth-syst-sci-data-discuss.net/"
-                                  "^https://www.foss-rec.net/"
-                                  "^https://www.geogr-helv.net/"
-                                  "^https://www.geosci-instrum-method-data-syst.net/"
-                                  "^https://www.geosci-instrum-method-data-syst-discuss.net/"
-                                  "^https://www.geosci-model-dev.net/"
-                                  "^https://www.geosci-model-dev-discuss.net/"
-                                  "^https://www.hist-geo-space-sci.net/"
-                                  "^https://www.hydrol-earth-syst-sci.net/"
-                                  "^https://www.hydrol-earth-syst-sci-discuss.net/"
-                                  "^https://www.j-sens-sens-syst.net/"
-                                  "^https://www.mech-sci.net/"
-                                  "^https://www.nat-hazards-earth-syst-sci.net/"
-                                  "^https://www.nonlin-processes-geophys-discuss.net/"
-                                  "^https://www.ocean-sci.net/"
-                                  "^https://www.ocean-sci-discuss.net/"
-                                  "^https://www.primate-biol.net/"
-                                  "^https://www.proc-iahs.net/"
-                                  "^https://www.sci-dril.net/"
-                                  "^https://www.soil-journal.net/"
-                                  "^https://www.soil-discuss.net/"
-                                  "^https://www.solid-earth.net/"
-                                  "^https://www.solid-earth-discuss.net/"
-                                  "^https://www.stephan-mueller-spec-publ-ser.net/"
-                                  "^https://www.the-cryosphere.net/"
-                                  "^https://www.the-cryosphere-discuss.net/"
-                                  "^https://www.web-ecol.net/"
-                                  "^https://www.wind-energ-sci.net/"
-                                  "^https://www.wind-energ-sci-discuss.net/"
-                                  )
-  "List of Copernicus URLs.")
-
-(defun doi-utils-get-copernicus-pdf-url (redirect-url)
-  "Copernicus hides the pdf url in html.  We get it out here.
-REDIRECT-URL is where the pdf url will be in."
-  (setq *doi-utils-waiting* t)
-  (url-retrieve
-   redirect-url
-   (lambda (status)
-     (goto-char (point-min))
-     (re-search-forward "citation_pdf_url\" content=\"\\([^\"]*\\)\"" nil t)
-
-     (setq *doi-utils-pdf-url* (match-string 1)
-          *doi-utils-waiting* nil)))
-  (while *doi-utils-waiting* (sleep-for 0.1))
-  *doi-utils-pdf-url*)
-
-(defun copernicus-pdf-url (*doi-utils-redirect*)
-  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
-
-  (car (cl-loop for copurl in copernicus-journal-urls
-               when (string-match copurl *doi-utils-redirect*)
-               collect
-               (progn (doi-utils-get-copernicus-pdf-url *doi-utils-redirect*)
-                      *doi-utils-pdf-url*))))
-
-
-;;** Sage
-(defun sage-pdf-url (*doi-utils-redirect*)
-  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
-  (when (string-match "^http\\(s?\\)://pss.sagepub.com" *doi-utils-redirect*)
-    (concat *doi-utils-redirect* ".full.pdf")))
-
-
-;;** Journal of Neuroscience
-(defun jneurosci-pdf-url (*doi-utils-redirect*)
-  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
-  (when (string-match "^http\\(s?\\)://www.jneurosci.org" *doi-utils-redirect*)
-    (concat *doi-utils-redirect* ".full.pdf")))
-
-;;** Generic .full.pdf
-(defun generic-full-pdf-url (*doi-utils-redirect*)
-  (let ((pdf (concat *doi-utils-redirect* ".full.pdf")))
-    (when (url-http-file-exists-p pdf)
-      pdf)))
-
-;;** IEEE
-;; 10.1109/re.2014.6912247
-;; http(s)://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=6912247
-;; http(s)://ieeexplore.ieee.org/ielx7/6903646/6912234/06912247.pdf
-;; http(s)://ieeexplore.ieee.org/iel7/6903646/6912234/06912247.pdf?arnumber=6912247
-;; <meta name="citation_pdf_url" content="http(s)://ieeexplore.ieee.org/iel7/6903646/6912234/06912247.pdf?arnumber=6912247">
-;; <frame src="http(s)://ieeexplore.ieee.org/ielx7/6903646/6912234/06912247.pdf?tp=&arnumber=6912247&isnumber=6912234" frameborder=0 />
-(defun ieee-pdf-url (*doi-utils-redirect*)
-  "Get a url to the pdf from *DOI-UTILS-REDIRECT* for IEEE urls."
-  (when (string-match "^https?://ieeexplore.ieee.org" *doi-utils-redirect*)
-    (with-current-buffer (url-retrieve-synchronously *doi-utils-redirect*)
-      (goto-char (point-min))
-      (when (re-search-forward "<meta name=\"citation_pdf_url\" content=\"\\([[:ascii:]]*?\\)\">" nil t)
-       (let ((framed-url (match-string 1)))
-          (with-current-buffer (url-retrieve-synchronously framed-url)
-            (goto-char (point-min))
-            (when (re-search-forward "<frame src=\"\\(http[[:ascii:]]*?\\)\"" nil t)
-              (match-string 1))))))))
-
-;; At least some IEEE papers need the following new pdf-link parsing
-;; Example: 10.1109/35.667413
-(defun ieee2-pdf-url (*doi-utils-redirect*)
-  "Get a url to the pdf from *DOI-UTILS-REDIRECT* for IEEE urls."
-  (when (string-match "^https?://ieeexplore.ieee.org" *doi-utils-redirect*)
-    (with-current-buffer (url-retrieve-synchronously *doi-utils-redirect*)
-      (goto-char (point-min))
-      (when (re-search-forward "\"pdfUrl\":\"\\([[:ascii:]]*?\\)\"" nil t)
-       (let ((framed-url (match-string 1)))
-          (with-current-buffer (url-retrieve-synchronously (concat "http://ieeexplore.ieee.org" framed-url))
-            (goto-char (point-min))
-            (when (re-search-forward "<frame src=\"\\(http[[:ascii:]]*?\\)\"" nil t)
-              (match-string 1))))))))
-
-;; Another try to get the ieee pdf
-;; <iframe src="http(s)://ieeexplore.ieee.org/ielx5/8/4538127/04538164.pdf?tp=&arnumber=4538164&isnumber=4538127" frameborder=0>
-(defun ieee3-pdf-url (*doi-utils-redirect*)
-  "Get a url to the pdf from *DOI-UTILS-REDIRECT* for IEEE urls."
-  (when (string-match "^https?://ieeexplore.ieee.org" *doi-utils-redirect*)
-    (with-current-buffer (url-retrieve-synchronously *doi-utils-redirect*)
-      (goto-char (point-min))
-      (when (re-search-forward "\"pdfUrl\":\"\\([[:ascii:]]*?\\)\"" nil t)
-       (let ((framed-url (match-string 1)))
-          (with-current-buffer (url-retrieve-synchronously (concat "http://ieeexplore.ieee.org" framed-url))
-            (goto-char (point-min))
-            (when (re-search-forward "<iframe src=\"\\(http[[:ascii:]]*?\\)\"" nil t)
-              (match-string 1))))))))
-
-;; ACM Digital Library
-;; https://dl.acm.org/doi/10.1145/1368088.1368132
-(defun acm-pdf-url (*doi-utils-redirect*)
-  "Get a url to the pdf from *DOI-UTILS-REDIRECT* for ACM urls."
-  (when (string-match "^https?://dl.acm.org" *doi-utils-redirect*)
-    (replace-regexp-in-string "doi" "doi/pdf" *doi-utils-redirect* )))
-
-;;** Optical Society of America (OSA)
-(defun osa-pdf-url (*doi-utils-redirect*)
-  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
-  (when (string-match "^https://www.osapublishing.org" *doi-utils-redirect*)
-    (replace-regexp-in-string "abstract.cfm" "viewmedia.cfm" *doi-utils-redirect* )))
-
-
-
-;;** Publishers using Highwire Press metatags
-;; For context and details, see:
-;; https://webmasters.stackexchange.com/questions/72746/where-are-the-complete-set-of-highwire-press-metatags-defined
-
-(defun highwire-pdf-url (*doi-utils-redirect*)
-  "Typical URL:  http://biomechanical.asmedigitalcollection.asme.org/article.aspx?articleid=1427237
-
-On this page the pdf might&nb; /><meta name=\"citation_pdf_url\" content=\"http://biomechanical.asmedigitalcollection.asme.org/data/journals/jbendy/27048/101013_1.pdf\" />
-
-It is in the citation_pdf_url.
-
-It would be better to parse this, but here I just use a regexp.
-"
-
-  (when (or (string-match "^http\\(s?\\)://biomechanical.asmedigitalcollection.asme.org" *doi-utils-redirect*)
-           (string-match "^http\\(s?\\)://ojs.aaai.org" *doi-utils-redirect*)
-           (string-match "^http\\(s?\\)://aclanthology.org" *doi-utils-redirect*))
-    (setq *doi-utils-waiting* 0)
-    (url-retrieve
-     *doi-utils-redirect*
-     (lambda (status)
-       (or (progn (goto-char (point-min))
-                 (re-search-forward "citation_pdf_url\"? content=\"\\(.*\\)\"" nil t))
-          (progn (goto-char (point-min))
-                 (re-search-forward "\"\\([^\"]*\\)\" name=\"?citation_pdf_url" nil t)))
-       ;; (message-box (match-string 1))
-       (setq *doi-utils-pdf-url* (match-string 1)
-            *doi-utils-waiting* nil)))
-    (while (and *doi-utils-waiting* (< *doi-utils-waiting* 5))
-      (setq *doi-utils-waiting* (+ *doi-utils-waiting* 0.1))
-      (sleep-for 0.1))
-    *doi-utils-pdf-url*))
-
-
-;; Society for Industrial and Applied Mathematics (SIAM)
-(defun siam-pdf-url (*doi-utils-redirect*)
-  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
-  (when (string-match "^http\\(s?\\)://epubs.siam.org" *doi-utils-redirect*)
-    (replace-regexp-in-string "/doi/" "/doi/pdf/" *doi-utils-redirect* )))
-
-;; PLOS journals
-;; https://plos.org/
-(defun plos-pdf-url (*doi-utils-redirect*)
-  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
-  (when (string-match "^http\\(s*\\)://journals.plos.org" *doi-utils-redirect*)
-    (concat (replace-regexp-in-string (regexp-quote "/article?id=") "/article/file?id=" *doi-utils-redirect*) "&type=printable")))
-
-
-;; https://www.frontiersin.org/articles/10.3389/fchem.2022.1037997/full
-;; https://www.frontiersin.org/articles/10.3389/fchem.2022.1037997/pdf
-(defun frontiers-pdf-url (*doi-utils-redirect*)
-  (when (string-match "^http\\(s*\\)://www.frontiersin.org" *doi-utils-redirect*)
-    (replace-regexp-in-string "/full" "/pdf" *doi-utils-redirect*)))
-
-
-
-
-;; https://chemistry-europe.onlinelibrary.wiley.com/doi/10.1002/celc.201902035
-;; https://chemistry-europe.onlinelibrary.wiley.com/doi/epdf/10.1002/celc.201902035
-(defun chemistry-europe-pdf-url (*doi-utils-redirect*)
-  (when (string-match "^http\\(s*\\)://chemistry-europe.onlinelibrary.wiley.com" *doi-utils-redirect*)
-    (concat
-     (replace-regexp-in-string "/doi" "/doi/pdfdirect" *doi-utils-redirect*)
-     "?download=true")))
-
-
-;; ** from issue #1081
-
-(defun arxiv-pdf-url (*doi-utils-redirect*)
-  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
-  (when (string-match-p "^https?://arxiv\\.org" *doi-utils-redirect*)
-    (concat (replace-regexp-in-string "/abs/" "/pdf/" *doi-utils-redirect*)
-           ".pdf")))
-
-
-(defun rss-pdf-url (*doi-utils-redirect*)
-  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
-  (when (string-match-p "roboticsproceedings" *doi-utils-redirect*)
-    (concat (replace-regexp-in-string "\\.html" ".pdf" *doi-utils-redirect*))))
-
-
-(defun ieeestamp-pdf-url (*doi-utils-redirect*)
-  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
-  (when (string-match "^https?://ieeexplore\\.ieee\\.org/document/\\([0-9]+\\)"
-                     *doi-utils-redirect*)
-    (concat "https://ieeexplore.ieee.org/stampPDF/getPDF.jsp?tp=&arnumber="
-           (match-string 1 *doi-utils-redirect*))))
-
-
-;;** Add all functions
-
-(setq doi-utils-pdf-url-functions
-      (list
-       'aps-pdf-url
-       'science-pdf-url
-       'nature-pdf-url
-       ;; 'wiley-pdf-url
-       'wiley-pdf-url-2
-       'springer-chapter-pdf-url
-       'springer-pdf-url
-       'acs-pdf-url-1
-       'acs-pdf-url-2
-       'acs-pdf-url-3
-       'iop-pdf-url
-       'jstor-pdf-url
-       'aip-pdf-url
-       'aip-pdf-url-2
-       'science-direct-pdf-url
-       'linkinghub-elsevier-pdf-url
-       'tandfonline-pdf-url
-       'ecs-pdf-url
-       'ecst-pdf-url
-       'rsc-pdf-url
-       'pnas-pdf-url
-       'copernicus-pdf-url
-       'sage-pdf-url
-       'jneurosci-pdf-url
-       'ieee-pdf-url
-       'ieee2-pdf-url
-       'ieee3-pdf-url
-       'acm-pdf-url
-       'osa-pdf-url
-       'highwire-pdf-url
-       'siam-pdf-url
-       'agu-pdf-url
-       'plos-pdf-url
-       'frontiers-pdf-url
-       'chemistry-europe-pdf-url 
-       'generic-full-pdf-url
-       'arxiv-pdf-url
-       'rss-pdf-url
-       'ieeestamp-pdf-url))
-
-;;** Get the pdf url for a doi
-
-(defun doi-utils-get-pdf-url (doi)
-  "Return a url to a pdf for the DOI if one can be calculated.
-Loops through the functions in `doi-utils-pdf-url-functions'
-until one is found."
-  (doi-utils-get-redirect doi)
-
-  (unless *doi-utils-redirect*
-    (error "No redirect found for %s" doi))
-  (catch 'pdf-url
-    (dolist (func doi-utils-pdf-url-functions)
-      (let ((this-pdf-url (funcall func *doi-utils-redirect*)))
-        (when this-pdf-url
-          (throw 'pdf-url this-pdf-url))))))
-
-;;** Finally, download the pdf
-(defvar bibtex-completion-library-path)
-(defvar bibtex-completion-bibliography)
-(declare-function async-start "async")
-
-;;;###autoload
-(defun doi-utils-async-download-pdf ()
-  "Download the PDF for bibtex entry at point asynchronously.
-It is not fully async, only the download is. Fully async is
-harder because you need to run `doi-utils-get-pdf-url' async
-too. "
-  (interactive)
-  (require 'async)
-  (save-excursion
-    (bibtex-beginning-of-entry)
-    (let (;; get doi, removing http://dx.doi.org/ if it is there.
-          (doi (replace-regexp-in-string
-                "https?://\\(dx.\\)?.doi.org/" ""
-                (bibtex-autokey-get-field "doi")))
-          (key (cdr (assoc "=key=" (bibtex-parse-entry))))
-          (pdf-url)
-          (pdf-file))
-
-      (setq pdf-file
-           (concat (cond
-                    ((stringp bibtex-completion-library-path)
-                     bibtex-completion-library-path)
-                    ((= 1 (length bibtex-completion-library-path))
-                     (car bibtex-completion-library-path))
-                    (t
-                     (completing-read "Dir: " bibtex-completion-library-path)))
-                   key ".pdf"))
-
-      (unless doi (error "No DOI found to get a pdf for"))
-
-      (when (file-exists-p pdf-file)
-       (error "%s already exists. Delete to re-download" pdf-file))
-
-      ;; (doi-utils-get-pdf-url "10.1063/1.5019667")
-      ;; If you get here, try getting the pdf file
-      (async-start
-       `(lambda ()
-         (setq package-user-dir ,package-user-dir)
-         (require 'package)
-         (package-initialize)
-         (setq load-path (list ,@load-path))
-         (require 'doi-utils)
-
-         (setq pdf-url (doi-utils-get-pdf-url ,doi))
-         (when pdf-url
-           (url-copy-file pdf-url ,pdf-file t)
-
-           (let* ((header (with-temp-buffer
-                            (set-buffer-multibyte nil)
-                            (insert-file-contents-literally ,pdf-file nil 0 5)
-                            (buffer-string)))
-                  (valid (and (stringp header)
-                              (string-equal (encode-coding-string header 'utf-8) "%PDF-"))))
-             (if valid
-                 (format "%s downloaded" ,pdf-file)
-               (delete-file ,pdf-file)
-               (require 'browse-url)
-               (browse-url pdf-url)
-               (message "Invalid pdf (file deleted). Header = %s" header)))))
-       `(lambda (result)
-         (message "doi-utils-async-download-pdf: %s"  result))))))
-
-
-;;;###autoload
-(defun doi-utils-get-bibtex-entry-pdf (&optional arg)
-  "Download pdf for entry at point if the pdf does not already exist locally.
-The entry must have a doi. The pdf will be saved, by the name
-%s.pdf where %s is the bibtex label. Files will not be
-overwritten. The pdf will be checked to make sure it is a pdf,
-and not some html failure page. You must have permission to
-access the pdf. We open the pdf at the end if
-`doi-utils-open-pdf-after-download' is non-nil.
-
-With one prefix ARG, directly get the pdf from a file (through
-`read-file-name') instead of looking up a DOI. With a double
-prefix ARG, directly get the pdf from an open buffer (through
-`read-buffer-to-switch') instead. These two alternative methods
-work even if the entry has no DOI, and the pdf file is not
-checked."
-  (interactive "P")
-  (save-excursion
-    (bibtex-beginning-of-entry)
-    (let (;; get doi, removing http://dx.doi.org/ if it is there.
-          (doi (replace-regexp-in-string
-                "https?://\\(dx.\\)?.doi.org/" ""
-                (bibtex-autokey-get-field "doi")))
-          (key (cdr (assoc "=key=" (bibtex-parse-entry))))
-          (pdf-url)
-          (pdf-file))
-
-      (setq pdf-file
-           (concat (cond
-                    ((stringp bibtex-completion-library-path)
-                     bibtex-completion-library-path)
-                    ((= 1 (length bibtex-completion-library-path))
-                     (car bibtex-completion-library-path))
-                    (t
-                     (completing-read "Dir: " bibtex-completion-library-path)))
-                   key ".pdf"))
-      ;; now get file if needed.
-      (unless (file-exists-p pdf-file)
-       (cond
-        ((and (not arg)
-              doi
-              (setq pdf-url (doi-utils-get-pdf-url doi)))
-         (url-copy-file pdf-url pdf-file)
-         ;; now check if we got a pdf
-          (if (org-ref-pdf-p pdf-file)
-              (message "%s saved" pdf-file)
-            (delete-file pdf-file)
-            (message "No pdf was downloaded.")
-            (browse-url pdf-url)))
-        ((equal arg '(4))
-         (copy-file (expand-file-name (read-file-name "Pdf file: " nil nil t))
-                    pdf-file))
-        ((equal arg '(16))
-         (with-current-buffer (read-buffer-to-switch "Pdf buffer: ")
-           (write-file pdf-file)))
-        (t
-         (message "We don't have a recipe for this journal.")))
-
-       (when (file-exists-p pdf-file)
-         (bibtex-set-field "file" pdf-file))
-
-       (when (and doi-utils-open-pdf-after-download (file-exists-p pdf-file))
-         (org-open-file pdf-file))))))
-
-;;* Getting bibtex entries from a DOI
-
-;; [[http://homepages.see.leeds.ac.uk/~eeaol/notes/2013/02/doi-metadata/][found]]
-;; you can download metadata about a DOI from http://dx.doi.org. You just have
-;; to construct the right http request to get it. Here is a function that gets
-;; the metadata as a plist in emacs.
-;;
-;;
-(defvar doi-utils-cache nil
-  "Cache variable for storing data we can reuse.
-A-list (doi . data) where doi is doi string, and data is what is
-retrieved from it. This is transient, and disappears when you
-restart Emacs. This mostly exists to prevent
-`doi-utils-update-field' from needing to download the data for
-every field.")
-
-
-(defun doi-utils-clear-cache ()
-  "Clear `doi-utils-cache'."
-  (interactive)
-  (setq doi-utils-cache '()))
-
-
-(defun doi-utils-get-json-metadata (doi)
-  "Try to get json metadata for DOI.  Open the DOI in a browser if we do not get it."
-  (if-let ((data (cdr (assoc doi doi-utils-cache))))
-      ;; We have the data already, so we return it.
-      data
-    (let ((url-request-method "GET")
-          (url-mime-accept-string "application/citeproc+json")
-          (json-object-type 'plist)
-          (json-data)
-         (url (concat doi-utils-dx-doi-org-url doi)))
-      (with-temp-buffer
-       (url-insert
-        (url-retrieve-synchronously url))
-       (setq json-data (buffer-string))
-
-       (when (or (string-match "<title>Error: DOI Not Found</title>" json-data)
-                 (string-match "Resource not found" json-data)
-                 (string-match "Status *406" json-data)
-                 (string-match "400 Bad Request" json-data))
-         (browse-url (concat doi-utils-dx-doi-org-url doi))
-         (error "Something went wrong.  We got this response:
-%s
-
-Opening %s" json-data url))
-
-       (setq data (json-read-from-string json-data))
-       (cl-pushnew (cons doi data) doi-utils-cache)
-       data))))
-
-
-(defun doi-utils-get-json-metadata-curl (doi)
-  "Try to get json metadata for DOI.  Open the DOI in a browser if we do not get it."
-  (let ((json-object-type 'plist)
-        (json-data)
-       (url (concat doi-utils-dx-doi-org-url doi)))
-    (with-temp-buffer
-      (call-process "curl" nil t nil
-                    "--location"
-                    "--silent"
-                    "--header"
-                    "Accept: application/citeproc+json"
-                    url)
-      (setq json-data (buffer-string))
-      (cond
-       ((or (string-match "<title>Error: DOI Not Found</title>" json-data)
-           (string-match "Resource not found" json-data)
-           (string-match "Status *406" json-data)
-           (string-match "400 Bad Request" json-data))
-       (browse-url url)
-       (error "Something went wrong.  We got this response:
-%s
-Opening %s" json-data url))
-       ;; everything seems ok with the data
-       (t
-       (json-read-from-string json-data))))))
-
-;; We can use that data to construct a bibtex entry. We do that by defining a
-;; template, and filling it in. I wrote this template expansion code which
-;; makes it easy to substitute values like %{} in emacs lisp.
-
-
-(defun doi-utils-expand-template (s)
-  "Expand a string template S containing %{} with the eval of its contents."
-  (replace-regexp-in-string "%{\\([^}]+\\)}"
-                           (lambda (arg)
-                             (let ((sexp (substring arg 2 -1)))
-                               (format "%s" (eval (read sexp)))))
-                           s))
-
-
-;; Now we define a function that fills in that template from the metadata.
-
-;; As different bibtex types share common keys, it is advantageous to separate
-;; data extraction from json, and the formatting of the bibtex entry.
-
-;; We use eval-and-compile because we use the three following forms in the
-;; `doi-utils-def-bibtex-type' macro.  Since the macro is expanded at compile
-;; time, we need to ensure these defuns and defvars are evaluated at
-;; compile-time.
-(eval-and-compile
-  (defvar doi-utils-json-metadata-extract
-    '((type       (plist-get results :type))
-      (author     (mapconcat (lambda (x)
-                              (message "%s" x)
-                              (if (plist-get x :name)
-                                  (plist-get x :name)
-                                (concat (plist-get x :given) " " (plist-get x :family))))
-                             (plist-get results :author) " and "))
-      (title      (plist-get results :title))
-      (subtitle   (plist-get results :subtitle))
-      (journal    (plist-get results :container-title))
-      (series     (plist-get results :container-title))
-      (publisher  (plist-get results :publisher))
-      (volume     (plist-get results :volume))
-      (issue      (plist-get results :issue))
-      (number     (plist-get results :issue))
-      (year       (or (elt (elt (plist-get (plist-get results :issued) :date-parts) 0) 0)
-                      (elt (elt (plist-get (plist-get results :approved) :date-parts) 0) 0)
-                      ))
-      ;; Some dates don't have a month in them.
-      (month      (let ((date (elt
-                              (plist-get (plist-get results :issued) :date-parts) 0)))
-                   (if (>= (length date) 2)
-                       (elt date 1)
-                     "-")))
-      (pages      (or (plist-get results :page)
-                     (plist-get results :article-number)))
-      (doi        (plist-get results :DOI))
-      (url        (plist-get results :URL))
-      (booktitle  (plist-get results :container-title))
-      (school     (or (plist-get results :school)
-                      (plist-get (plist-get results :institution) :name)))
-      ;; I am not sure how general this is. This gets the first name.
-      (institution (plist-get (car (plist-get results :institution)) :name))))
-
-  ;; Next, we need to define the different bibtex types. Each type has a bibtex
-  ;; type (for output) and the type as provided in the doi record. Finally, we
-  ;; have to declare the fields we want to output.
-
-  (defvar doi-utils-bibtex-type-generators nil)
-
-  (defun doi-utils-concat-prepare (lst &optional acc)
-    "Minimize the number of args passed to `concat' from LST.
-Given a list LST of strings and other expressions, which are
-intended to be passed to `concat', concat any subsequent strings,
-minimising the number of arguments being passed to `concat'
-without changing the results.  ACC is the list of additional
-expressions."
-    (cond ((null lst) (nreverse acc))
-          ((and (stringp (car lst))
-                (stringp (car acc)))
-           (doi-utils-concat-prepare (cdr lst) (cons (concat (car acc) (car lst))
-                                                     (cdr acc))))
-          (t (doi-utils-concat-prepare (cdr lst) (cons (car lst) acc))))))
-
-(defmacro doi-utils-def-bibtex-type (name matching-types &rest fields)
-  "Define a BibTeX type identified by (symbol) NAME.
-MATCHING-TYPES is a list of strings.  FIELDS are symbols that
-match to retrieval expressions in
-`doi-utils-json-metadata-extract'.  This type will only be used
-when the `:type' parameter in the JSON metadata is contained in
-MATCHING-TYPES."
-  `(push (lambda (type results)
-           (when
-               (or ,@(mapcar
-                      (lambda (match-type)
-                        `(string= type ,match-type)) matching-types))
-             (let ,(mapcar (lambda (field)
-                             (let ((field-expr
-                                    (assoc field doi-utils-json-metadata-extract)))
-                               (if field-expr
-                                   ;; need to convert to string first
-                                   `(,(car field-expr) (format "%s" ,(cadr field-expr)))
-                                 (error "Unknown bibtex field type %s" field))))
-                           fields)
-               (concat
-                ,@(doi-utils-concat-prepare
-                   (-flatten
-                    (list (concat "@" (symbol-name name) "{,\n")
-                          ;; there seems to be some bug with mapcan,
-                          ;; so we fall back to flatten
-                          (mapcar (lambda (field)
-                                    `("  " ,(symbol-name field) " = {" ,field "},\n"))
-                                  fields)
-                          "}\n")))))))
-         doi-utils-bibtex-type-generators))
-
-(doi-utils-def-bibtex-type article ("journal-article" "article-journal" "article")
-                           author title journal year volume number pages doi url)
-
-(doi-utils-def-bibtex-type inproceedings ("proceedings-article" "paper-conference")
-                           author title booktitle year month pages doi url)
-
-(doi-utils-def-bibtex-type book ("book" "edited-book")
-                           author title series publisher year pages doi url)
-
-(doi-utils-def-bibtex-type inbook ("chapter" "book-chapter" "reference-entry")
-                           author title booktitle series publisher year pages doi url)
-
-(doi-utils-def-bibtex-type phdthesis ("phdthesis" "thesis" "dissertation")
-                          author title school publisher year)
-
-(doi-utils-def-bibtex-type techreport ("report")
-                          institution author title publisher year doi url)
-
-;; this is what preprints in chemrxiv look like for now
-(doi-utils-def-bibtex-type misc ("posted-content")
-                          author title year doi url)
-
-
-
-;; With the code generating the bibtex entry in place, we can glue it to the json retrieval code.
-
-(defun doi-utils-doi-to-bibtex-string (doi)
-  "Return a bibtex entry as a string for the DOI.  Not all types are supported yet."
-  (let* ((results (funcall doi-utils-metadata-function doi))
-         (type (plist-get results :type)))
-    ;; (format "%s" results) ; json-data
-    (or (-some (lambda (g) (funcall g type results)) doi-utils-bibtex-type-generators)
-        (message "%s not supported yet\n%S." type results))))
-
-;; That is just the string for the entry. To be useful, we need a function that
-;; inserts the string into a buffer. This function will insert the string at the
-;; cursor, clean the entry, try to get the pdf.
-
-(defun doi-utils-insert-bibtex-entry-from-doi (doi)
-  "Insert and clean bibtex entry from a DOI."
-  (insert (doi-utils-doi-to-bibtex-string doi))
-  (backward-char)
-  ;; set date added for the record
-  (let ((ts (funcall doi-utils-timestamp-format-function)))
-    (when ts
-      (bibtex-set-field doi-utils-timestamp-field
-                       ts)))
-  (org-ref-clean-bibtex-entry)
-  (when (buffer-file-name)
-      (save-buffer)))
-
-
-;;;###autoload
-(defun doi-utils-add-bibtex-entry-from-doi (doi &optional bibfile)
-  "Add DOI entry to end of a file in the current directory.
-Pick the file ending with .bib or in .  If you have an active region that
-starts like a DOI, that will be the initial prompt.  If no region
-is selected and the first entry of the ‘kill-ring’ starts like a
-DOI, then that is the initial prompt.  Otherwise, you have to type
-or paste in a DOI.
-Argument BIBFILE the bibliography to use."
-  (interactive
-   (list (read-string
-          "DOI: "
-          ;; now set initial input
-          (doi-utils-maybe-doi-from-region-or-current-kill))))
-
-  (unless bibfile
-    (setq bibfile (completing-read "Bibfile: " (org-ref-possible-bibfiles))))
-  ;; Wrap in save-window-excursion to restore your window arrangement after this
-  ;; is done.
-  (save-window-excursion
-    (with-current-buffer
-        (find-file-noselect bibfile)
-      ;; Check if the doi already exists
-      (goto-char (point-min))
-      (if (re-search-forward (concat doi "\\_>") nil t)
-          (message "%s is already in this file" doi)
-        (goto-char (point-max))
-
-       (when (not (looking-back "\n\n" (min 3 (point))))
-         (insert "\n\n"))
-
-        (doi-utils-insert-bibtex-entry-from-doi doi)
-        (save-buffer)))))
-
-(defalias 'doi-add-bibtex-entry 'doi-utils-add-bibtex-entry-from-doi
-  "Alias function for convenience.")
-
-(defun doi-utils-maybe-doi-from-region-or-current-kill ()
-  "Try to get a DOI from the active region or current kill."
-  (let* ((the-active-region (if (region-active-p) ;; nil if no active region
-                                (buffer-substring (region-beginning) (region-end))
-                              nil))
-         (the-current-kill (ignore-errors (current-kill 0 t)))  ;; nil if empty kill ring
-         ;; DOI urls
-         ;; Ex: https://doi.org/10.1109/MALWARE.2014.6999410
-         ;; Ex: https://dx.doi.org/10.1007/978-3-319-60876-1_10
-         (doi-url-prefix-regexp "^https?://\\(dx\\.\\)?doi\\.org/")
-         ;; https://www.crossref.org/blog/dois-and-matching-regular-expressions/
-         (doi-regexp "10\\.[0-9]\\{4,9\\}/[-._;()/:A-Z0-9]+$"))
-    (cond
-     ;; Check if a DOI can be found in the active region
-     ;; DOI raw
-     ;; Ex: 10.1109/MALWARE.2014.6999410
-     ((and (stringp the-active-region)
-           (s-match (concat "^" doi-regexp) the-active-region))
-      the-active-region)
-     ;; DOI url
-     ;; Ex: https://doi.org/10.1109/MALWARE.2014.6999410
-     ((and (stringp the-active-region)
-           (s-match (concat doi-url-prefix-regexp doi-regexp) the-active-region))
-      (replace-regexp-in-string doi-url-prefix-regexp "" the-active-region))
-     ;; DOI url as customized
-     ((and (stringp the-active-region)
-           (s-match (regexp-quote doi-utils-dx-doi-org-url) the-active-region))
-      (replace-regexp-in-string (regexp-quote doi-utils-dx-doi-org-url) "" the-active-region))
-     ;; Check if DOI can be found in the current kill
-     ;; DOI raw
-     ;; Ex: 10.1109/MALWARE.2014.6999410
-     ((and (stringp the-current-kill)
-           (s-match (concat "^" doi-regexp) the-current-kill))
-      the-current-kill)
-     ;; DOI url
-     ;; Ex: https://doi.org/10.1109/MALWARE.2014.6999410
-     ((and (stringp the-current-kill)
-           (s-match (concat doi-url-prefix-regexp doi-regexp) the-current-kill))
-      (replace-regexp-in-string doi-url-prefix-regexp "" the-current-kill))
-     ;; DOI url as customized
-     ((and (stringp the-current-kill)
-           (s-match (regexp-quote doi-utils-dx-doi-org-url) the-current-kill))
-      (replace-regexp-in-string (regexp-quote doi-utils-dx-doi-org-url) "" the-current-kill))
-     ;; otherwise, return nil
-     (t
-      nil))))
-
-;;;###autoload
-(defun doi-utils-doi-to-org-bibtex (doi)
-  "Convert a DOI to an ‘org-bibtex’ form and insert it at point."
-  (interactive "sDOI: ")
-  (with-temp-buffer
-    (insert (doi-utils-doi-to-bibtex-string doi))
-    (bibtex-clean-entry)
-    (kill-region (point-min) (point-max)))
-  (org-bibtex-yank)
-  (org-metaright)
-  (org-metaright))
-
-;;* Updating bibtex entries
-
-;; I wrote this code because it is pretty common for me to copy bibtex entries
-;; from ASAP articles that are incomplete, e.g. no page numbers because it is
-;; not in print yet. I wanted a convenient way to update an entry from its DOI.
-;; Basically, we get the metadata, and update the fields in the entry.
-
-;; There is not bibtex set field function, so I wrote this one.
-
-
-;;;###autoload
-(defun bibtex-set-field (field value &optional nodelim)
-  "Set FIELD to VALUE in bibtex file.  create field if it does not exist.
-Optional argument NODELIM see `bibtex-make-field'."
-  (interactive "sfield: \nsvalue: ")
-  (bibtex-beginning-of-entry)
-  (let ((found))
-    (if (setq found (bibtex-search-forward-field field t))
-        ;; we found a field
-        (progn
-          (goto-char (car (cdr found)))
-          (when value
-            (bibtex-kill-field)
-            (bibtex-make-field field nil nil nodelim)
-            (backward-char)
-            (insert value)))
-      ;; make a new field
-      (bibtex-beginning-of-entry)
-      (forward-line) (beginning-of-line)
-      (bibtex-next-field nil)
-      (forward-char)
-      (bibtex-make-field field nil nil nodelim)
-      (backward-char)
-      (insert value))))
-
-
-(defun plist-get-keys (plist)
-  "Return keys in a PLIST."
-  (-slice plist 0 nil 2))
-
-
-;;;###autoload
-(defun doi-utils-update-bibtex-entry-from-doi (doi)
-  "Update fields in a bibtex entry from the DOI.
-Every field will be updated, so previous change will be lost."
-  (interactive (list
-                (or (replace-regexp-in-string
-                     "https?://\\(dx.\\)?doi.org/" ""
-                     (bibtex-autokey-get-field "doi"))
-                    (read-string "DOI: "))))
-  (let* ((results (funcall doi-utils-metadata-function doi))
-         (type (plist-get results :type))
-         (author (mapconcat
-                  (lambda (x)
-                   ;; There are two possible ways an author is named. The most
-                   ;; common is with :given and :family, but sometimes there is
-                   ;; :name instead.
-                   (if (plist-get x :name)
-                       (plist-get x :name)
-                     (concat (plist-get x :given)
-                             " " (plist-get x :family))))
-                  (plist-get results :author) " and "))
-         (title (plist-get results :title))
-         (journal (plist-get results :container-title))
-         (year (format "%s"
-                       (elt
-                        (elt
-                         (plist-get
-                          (plist-get results :issued) :date-parts) 0) 0)))
-         (volume (plist-get results :volume))
-         (number (or (plist-get results :issue) ""))
-         (pages (or (plist-get results :page) ""))
-         (url (or (plist-get results :URL) ""))
-         (doi (plist-get results :DOI))
-         mapping)
-
-    ;; map the json fields to bibtex fields. The code each field is mapped to is
-    ;; evaluated.
-    (setq mapping '((:author . (bibtex-set-field "author" author))
-                    (:title . (bibtex-set-field "title" title))
-                    (:container-title . (bibtex-set-field "journal" journal))
-                    (:issued . (bibtex-set-field "year" year))
-                    (:volume . (bibtex-set-field "volume" volume))
-                    (:issue . (bibtex-set-field "number" number))
-                    (:page . (bibtex-set-field "pages" pages))
-                    (:DOI . (bibtex-set-field "doi" doi))
-                    (:URL . (bibtex-set-field "url" url))))
-
-    ;; now we have code to run for each entry. we map over them and evaluate the code
-    (mapc
-     (lambda (key)
-       (eval (cdr (assoc key mapping))))
-     (plist-get-keys results)))
-
-  (org-ref-clean-bibtex-entry))
-
-
-;; A downside to updating an entry is it overwrites what you have already fixed.
-;; So, we next develop a function to update the field at point.
-
-
-;;;###autoload
-(defun doi-utils-update-field ()
-  "Update the field at point in the bibtex entry.
-Data is retrieved from the doi in the entry."
-  (interactive)
-  (let* ((doi (bibtex-autokey-get-field "doi"))
-         (results (funcall doi-utils-metadata-function doi))
-         (field (car (bibtex-find-text-internal nil nil ","))))
-    (cond
-     ((string= field "volume")
-      (bibtex-set-field field (plist-get results :volume)))
-     ((string= field "number")
-      (bibtex-set-field field (plist-get results :issue)))
-     ((string= field "pages")
-      (bibtex-set-field field (or (plist-get results :page)
-                                  (plist-get results :article-number))))
-     ((string= field "year")
-      (bibtex-set-field field (plist-get results :year)))
-     (t
-      (message "%s not supported yet." field)))))
-
-
-
-;;* DOI functions for WOS
-
-;; I came across this API http://wokinfo.com/media/pdf/OpenURL-guide.pdf to make
-;; links to the things I am interested in here. Based on that document, here are
-;; three links based on a doi:10.1021/jp047349j that take you to different Web
-;; Of Science (WOS) pages.
-
-
-;; 1. go to article in WOS: http://ws.isiknowledge.com/cps/openurl/service?url_ver=Z39.88-2004&rft_id=info:doi/10.1021/jp047349j
-;; 2. citing articles: http://ws.isiknowledge.com/cps/openurl/service?url_ver=Z39.88-2004&rft_id=info%3Adoi%2F10.1021/jp047349j&svc_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Asch_svc&svc.citing=yes
-;; 3. related articles: http://ws.isiknowledge.com/cps/openurl/service?url_ver=Z39.88-2004&rft_id=info%3Adoi%2F10.1021/jp047349j&svc_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Asch_svc&svc.related=yes
-
-;; These are pretty easy to construct, so we can write functions that will
-;; create them and open the url in our browser. There are some other options
-;; that could be considered, but since we usually have a doi, it seems like the
-;; best way to go for creating the links. Here are the functions.
-
-;;;###autoload
-(defun doi-utils-wos (doi)
-  "Open Web of Science entry for DOI."
-  (interactive "sDOI: ")
-  (browse-url
-   (format
-    "http://ws.isiknowledge.com/cps/openurl/service?url_ver=Z39.88-2004&rft_id=info:doi/%s" doi)))
-
-;;;###autoload
-(defun doi-utils-wos-citing (doi)
-  "Open Web of Science citing articles entry for DOI.
-May be empty if none are found."
-  (interactive "sDOI: ")
-  (browse-url
-   (concat
-    "http://ws.isiknowledge.com/cps/openurl/service?url_ver=Z39.88-2004&rft_id=info%3Adoi%2F"
-    doi
-    "&svc_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Asch_svc&svc.citing=yes")))
-
-;;;###autoload
-(defun doi-utils-wos-related (doi)
-  "Open Web of Science related articles page for DOI."
-  (interactive "sDOI: ")
-  (browse-url
-   (concat "http://ws.isiknowledge.com/cps/openurl/service?url_ver=Z39.88-2004&rft_id=info%3Adoi%2F"
-           doi
-           "&svc_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Asch_svc&svc.related=yes")))
-
-
-;;* DOI functions for ADS
-
-;;;###autoload
-(defun doi-utils-ads (doi)
-  "Open ADS entry for DOI"
-  (interactive "sDOI: ")
-  (browse-url
-   (concat
-    "https://ui.adsabs.harvard.edu/abs/" "%22" doi "%22")))
-
-
-;;* A new doi link for org-mode
-;; The idea is to add a menu to the doi link, so rather than just clicking to open the article, you can do other things.
-;; 1. open doi
-;; 2. open in wos
-;; 3. open citing articles
-;; 4. open related articles
-;; 5. open bibtex entry
-;; 6. get bibtex entry
-
-
-;;;###autoload
-(defun doi-utils-open (doi)
-  "Open DOI in browser."
-  (interactive "sDOI: ")
-  (browse-url (concat doi-utils-dx-doi-org-url doi)))
-
-
-;;;###autoload
-(defun doi-utils-open-bibtex (doi)
-  "Search through variable `bibtex-completion-bibliography' for DOI."
-  (interactive "sDOI: ")
-  (cl-loop for f in (if (listp bibtex-completion-bibliography)
-                       bibtex-completion-bibliography
-                     (list bibtex-completion-bibliography))
-          when (progn (find-file f)
-                      (when (search-forward doi (point-max) t)
-                        (bibtex-beginning-of-entry)))
-          return f))
-
-
-;;;###autoload
-(defun doi-utils-crossref (doi)
-  "Search DOI in CrossRef."
-  (interactive "sDOI: ")
-  (browse-url
-   (format
-    "http://search.crossref.org/?q=%s" doi)))
-
-
-;;;###autoload
-(defun doi-utils-google-scholar (doi)
-  "Google scholar the DOI."
-  (interactive "sDOI: ")
-  (browse-url
-   (format
-    "http://scholar.google.com/scholar?q=%s" doi)))
-
-
-;;;###autoload
-(defun doi-utils-pubmed (doi)
-  "Search Pubmed for the DOI."
-  (interactive "sDOI: ")
-  (browse-url
-   (format
-    "http://www.ncbi.nlm.nih.gov/pubmed/?term=%s"
-    (url-hexify-string doi))))
-
-(declare-function org-element-property "org-element")
-
-(defhydra doi-link-follow (:color blue :hint nil)
-  "DOI actions:
-"
-  ("o" (doi-utils-open (org-element-property :path (org-element-context))) "open")
-  ("w" (doi-utils-wos (org-element-property :path (org-element-context))) "wos")
-  ("c" (doi-utils-wos-citing (org-element-property :path (org-element-context))) "wos citing articles")
-  ("r" (doi-utils-wos-related (org-element-property :path (org-element-context))) "wos related articles" )
-  ("a" (doi-utils-ads (org-element-property :path (org-element-context))) "ads")
-  ("s" (doi-utils-google-scholar (org-element-property :path (org-element-context))) "Google Scholar")
-  ("f" (doi-utils-crossref (org-element-property :path (org-element-context))) "CrossRef")
-  ("p" (doi-utils-pubmed (org-element-property :path (org-element-context))) "Pubmed")
-  ("b" (doi-utils-open-bibtex (org-element-property :path (org-element-context))) "open in bibtex")
-  ("g" (doi-utils-add-bibtex-entry-from-doi (org-element-property :path (org-element-context))) "get bibtex entry"))
-
-
-(org-link-set-parameters "doi"
-                        :follow (lambda (_) (doi-link-follow/body))
-                        :export (lambda (doi desc format)
-                                  (cond
-                                   ((eq format 'html)
-                                    (format "<a href=\"%s%s\">%s</a>"
-                                            doi-utils-dx-doi-org-url
-                                            doi
-                                            (or desc (concat "doi:" doi))))
-                                   ((eq format 'latex)
-                                    (format "\\href{%s%s}{%s}"
-                                            doi-utils-dx-doi-org-url
-                                            doi
-                                            (or desc (concat "doi:" doi)))))))
-
-;;* Getting a doi for a bibtex entry missing one
-
-;; Some bibtex entries do not have a DOI, maybe because they were entered by
-;; hand, or copied from a source that did not have it available. Here we develop
-;; some functions to help you find the DOI using Crossref.
-
-;; Here is our example bibtex entry.
-;; #+BEGIN_SRC bibtex
-;; @article{deml-2014-oxide,
-;;   author =   {Ann M. Deml and Vladan Stevanovi{\'c} and
-;;                   Christopher L. Muhich and Charles B. Musgrave and
-;;                   Ryan O'Hayre},
-;;   title =    {Oxide Enthalpy of Formation and Band Gap Energy As
-;;                   Accurate Descriptors of Oxygen Vacancy Formation
-;;                   Energetics},
-;;   journal =  {Energy Environ. Sci.},
-;;   volume =   7,
-;;   number =   6,
-;;   pages =    1996,
-;;   year =     2014,
-;;   doi =              {10.1039/c3ee43874k,
-;;   url =              {http://dx.doi.org/10.1039/c3ee43874k}},
-
-;; }
-
-
-;; The idea is to query Crossref in a way that is likely to give us a hit
-;; relevant to the entry.
-
-;; According to http://search.crossref.org/help/api we can send a query with a
-;; free form citation that may give us something back. We do this to get a list
-;; of candidates, which could be used to get the doi.
-
-(declare-function org-ref-bib-citation "org-ref-bibtex")
-;;;###autoload
-(defun doi-utils-crossref-citation-query ()
-  "Query Crossref with the title of the bibtex entry at point.
-Get a list of possible matches. Choose one with completion."
-  (interactive)
-  (bibtex-beginning-of-entry)
-  (let* ((entry (bibtex-parse-entry))
-        (raw-json-string)
-         (json-string)
-         (json-data)
-         (doi (bibtex-autokey-get-field "doi")))
-    (unless (string= "" doi)
-      (error "Entry already has a doi field"))
-
-    (with-current-buffer
-        (url-retrieve-synchronously
-         (concat
-          "http://search.crossref.org/dois?q="
-          (url-hexify-string (org-ref-bib-citation))))
-      (save-excursion
-       (goto-char (point-min))
-       (while (re-search-forward "<i>\\|</i>" nil t)
-         (replace-match ""))
-       (goto-char (point-min))
-       (while (re-search-forward "&amp;" nil t)
-         (replace-match "&"))
-       (goto-char (point-min))
-       (while (re-search-forward "&quot;" nil t)
-         (replace-match "\\\"" nil t)))
-      (setq raw-json-string (buffer-substring url-http-end-of-headers (point-max)))
-      ;; decode json string
-      (setq json-string (decode-coding-string (encode-coding-string raw-json-string 'utf-8) 'utf-8))
-      (setq json-data (json-read-from-string json-string)))
-
-    (let* ((name (format "Crossref hits for %s" (org-ref-bib-citation)))
-           (candidates (mapcar (lambda (x)
-                                 (cons
-                                  (concat
-                                   (cdr (assoc 'fullCitation x)))
-                                  (cdr (assoc 'doi x))))
-                               json-data))
-
-          (doi (cdr (assoc (completing-read "DOI: " candidates) candidates))))
-      (bibtex-make-field "doi" t)
-      (backward-char)
-      ;; crossref returns doi url, but I prefer only a doi for the doi field
-      (insert (replace-regexp-in-string "^https?://\\(dx.\\)?doi.org/" "" doi))
-      (when (string= "" (bibtex-autokey-get-field "url"))
-        (bibtex-make-field "url" t)
-        (backward-char)
-        (insert doi)))))
-
-
-
-;;* Debugging a DOI
-
-;; I wrote this function to help debug a DOI. This function generates an
-;; org-buffer with the doi, gets the json metadata, shows the bibtex entry, and
-;; the pdf link for it.
-(defun doi-utils-get-json (doi)
-  "Return json data as a string for DOI."
-  (let ((url-request-method "GET")
-        (url-mime-accept-string "application/citeproc+json")
-        (json-data))
-    (with-temp-buffer
-      (url-insert
-       (url-retrieve-synchronously
-       (concat doi-utils-dx-doi-org-url doi)))
-      (setq json-data (buffer-string))
-      (if (string-match "Resource not found" json-data)
-          (progn
-            (browse-url (concat doi-utils-dx-doi-org-url doi))
-            (error "Resource not found.  Opening website"))
-       json-data))))
-
-
-;;;###autoload
-(defun doi-utils-debug (doi)
-  "Generate an org-buffer showing data about DOI."
-  (interactive "sDOI: ")
-  (switch-to-buffer "*debug-doi*")
-  (erase-buffer)
-  (org-mode)
-  (insert (concat "doi:" doi) "\n\n")
-  (insert "* JSON
-"
-         (let ((url-request-method "GET")
-               (url-mime-accept-string "application/citeproc+json"))
-           (pp
-            (json-read-from-string (with-temp-buffer
-                                     (url-insert
-                                      (url-retrieve-synchronously
-                                       (concat doi-utils-dx-doi-org-url doi)))
-                                     (buffer-string)))))
-         "\n\n")
-  (goto-char (point-min)))
-
-;;* Adding a bibtex entry from a crossref query
-
-;; The idea here is to perform a query on Crossref, get a completion buffer of
-;; candidates, and select the entry(ies) you want to add to your bibtex file.
-;; You can select a region, e.g. a free form citation, or set of words, or you
-;; can type the query in by hand.
-
-;;;###autoload
-(defun doi-utils-add-entry-from-crossref-query (query bibtex-file)
-  "Search Crossref with QUERY and use completion to select an entry to add to BIBTEX-FILE."
-  (interactive (list
-                (read-string
-                 "Query: "
-                 ;; now set initial input
-                 (cond
-                  ;; If region is active assume we want it
-                  ((region-active-p)
-                   (replace-regexp-in-string
-                    "\n" " "
-                    (buffer-substring (region-beginning) (region-end))))
-                  ;; type or paste it in
-                  (t
-                   nil)))
-                (completing-read
-                 "Bibfile: "
-                 (append (f-entries "." (lambda (f) (f-ext? f "bib")))
-                         bibtex-completion-bibliography))))
-  (let* ((json-data (with-temp-buffer
-                     (url-insert
-                      (url-retrieve-synchronously
-                       (concat
-                        "https://api.crossref.org/works?query="
-                        (url-hexify-string query))))
-                     
-                     (json-read-from-string (buffer-string))))
-        (name (format "Crossref hits for %s"
-                      ;; remove carriage returns. They can make completion confusing.
-                      (replace-regexp-in-string "\n" " " query)))
-        (candidates (let-alist json-data
-                      (cl-loop for item across .message.items
-                               collect (let-alist item
-                                         (cons (format "%s, %s, %s, %s."
-                                                       (string-join .title " ")
-                                                       (string-join
-                                                        (cl-loop for author across .author collect
-                                                                 (let-alist author
-                                                                   (format "%s %s"
-                                                                           .given .family)))
-                                                        ", ")
-                                                       .publisher
-                                                       .created.date-parts)                           
-                                               .DOI)))))
-        (doi (cdr (assoc (completing-read "Choice: " candidates) candidates))))
-
-    (with-current-buffer (find-file-noselect bibtex-file)
-      (doi-utils-add-bibtex-entry-from-doi
-       (replace-regexp-in-string
-       "^https?://\\(dx.\\)?doi.org/" "" doi)
-       bibtex-file)
-      (save-buffer))))
-
-
-(defalias 'crossref-add-bibtex-entry 'doi-utils-add-entry-from-crossref-query
-  "Alias function for convenience.")
-
-;; * Convenience
-
-(defun doi-utils-toggle-pdf-download ()
-  "Toggle the setting of `doi-utils-download-pdf'.
-I find this useful when downloading the pdfs slows down adding a
-lot of references; then you just toggle it off."
-  (interactive)
-  (message "Setting doi-utils-download-pdf to %s"
-          (setq doi-utils-download-pdf (not doi-utils-download-pdf))))
-
-;;* The end
-(provide 'doi-utils)
-;;; doi-utils.el ends here
diff --git a/elpa/org-ref-20241124.2012/nist-webbook.el b/elpa/org-ref-20241124.2012/nist-webbook.el
deleted file mode 100644 (file)
index 35b1608..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-;;; nist-webbook.el --- Integration of Emacs with NIST Webbook -*- lexical-binding: t; -*-
-;; Integration of Emacs with NIST webbook
-
-;;; Commentary:
-;; nist-webbook-name :: search for a chemical name
-;; nist-webbook-formula :: search by chemical formula
-
-;;; Code:
-
-(require 'org)
-(require 'org-ref-utils)
-
-;;;###autoload
-(defun nist-webbook-formula (formula)
-  "Search NIST webbook for FORMULA."
-  (interactive "sFormula: ")
-  (browse-url
-   (concat
-    "http://webbook.nist.gov/cgi/cbook.cgi?Formula="
-    formula
-    "&NoIon=on&Units=SI")))
-
-;;;###autoload
-(defun nist-webbook-name (name)
-  "Search NIST webbook for NAME."
-  (interactive "sChemical Name: ")
-  (browse-url
-   (concat "http://webbook.nist.gov/cgi/cbook.cgi?Name="
-           (url-hexify-string name)
-           "&Units=SI")))
-
-(org-link-set-parameters "nist-wb-name"
-                        :follow (lambda (name)
-                                  (nist-webbook-name name)))
-
-(org-link-set-parameters "nist-wb-formula"
-                        :follow (lambda (formula)
-                                  (nist-webbook-formula formula)))
-
-(provide 'nist-webbook)
-
-;;; nist-webbook.el ends here
diff --git a/elpa/org-ref-20241124.2012/openalex.el b/elpa/org-ref-20241124.2012/openalex.el
deleted file mode 100644 (file)
index 78bcd79..0000000
+++ /dev/null
@@ -1,1179 +0,0 @@
-;;; openalex.el --- Org-ref interface to OpenAlex 
-
-;;; Commentary:
-;; This is an elisp interface to OpenAlex (https://docs.openalex.org/) for org-ref.
-;;
-;; This provides functionality for the OpenAlex APIs.
-;;
-;; `oa-query' provides a general interface to all the endpoints with a filter.
-;; It is not interactive though.
-;;
-;; `oa-author' provides an interactive way to search for an author and then see
-;; a Google Scholar like org buffer with information about the author.
-;;
-;; `oa-fulltext-search' provides an interactive full text search of Works in
-;; OpenAlex. You get an org-buffer of results, with links to subsequent pages of
-;; results.
-;;
-;; `oa-coa' is an interactive command to generate the NSF COA form data for
-;; coauthors.
-;;
-;; `oa-get-bibtex-entries' is an interactive command to download all bibtex
-;; entries from headings in the current buffer with a DOI property.
-;;
-;; if you have an OpenAlex API you can set `oa-api-key' to use it. The
-;; `user-mail-address' value will be added to the queries if it exists so you
-;; will get the polite pool.
-;;
-;; This library extends the `org-ref-citation-hydra' and adds keys to get to
-;; cited by, references and related documents in OpenAlex.
-
-(require 'dash)
-(require 's)
-(require 'request)
-(require 'doi-utils)
-(require 'org-ref-citation-links)
-
-(declare-function org-ref-possible-bibfiles "org-ref-core")
-(declare-function org-ref-find-bibliography "org-ref-core")
-(declare-function org-ref-get-bibtex-key-and-file "org-ref-core")
-(declare-function bibtex-completion-show-entry "bibtex-completion")
-(declare-function bibtex-completion-apa-format-reference "bibtex-completion")
-(declare-function ivy-read "ivy")
-
-(defcustom oa-api-key
-  nil
-  "Your API key if you have one."
-  :group 'openalex
-  :type 'string)
-
-;;; Code:
-
-(defun oa--response-parser ()
-  "Parse the response from json to elisp."
-  (let ((json-array-type 'list)
-       (json-object-type 'plist)
-       (json-key-type 'keyword)
-       (json-false nil)
-       (json-encoding-pretty-print nil))
-    (json-read)))
-
-
-(defun oa-get (data query &optional iterable)
-  "Get fields from DATA with QUERY.
-QUERY is a dot notation string.
-key1.key2.key3 represents a nested item.
-key1.key2[].key3 represents key3 on all items in key1.key2.
-
-Tested with up to two [] in the query.
-
-Assumes data is in plist form."
-  (let* ((fields (and query (split-string query "\\.")))
-        (current-field (and fields (pop fields))))
-
-    (cond
-     ;; return condition
-     ((null query)
-      data)
-
-     ;; query[] means get query then turn iteration on
-     ((and (s-ends-with-p "[]" current-field) (null iterable))
-      (setq current-field (substring current-field 0 -2))
-      (oa-get (plist-get data (intern-soft (concat ":" current-field)))
-             (when fields
-               (string-join fields "."))
-             t))
-
-     ;; this means another level of iteration. You already have a collection. we
-     ;; have to iterate over each one I think.
-     ((and (s-ends-with-p "[]" current-field) iterable)
-      (setq current-field (substring current-field 0 -2))
-      (cl-loop for item in data collect
-              (oa-get (plist-get item (intern-soft (concat ":" current-field)))
-                      (when fields
-                        (string-join fields "."))
-                      t)))
-
-     ;; single keyword, iterate over collection
-     (iterable
-      (oa-get (cl-loop for item in data collect
-                      (plist-get item (intern-soft (concat ":" current-field))))
-             (when fields
-               (string-join fields "."))
-             t))
-
-     ;; single keyword
-     (t
-      (oa-get (plist-get data (intern-soft (concat ":" current-field)))
-             (when fields
-               (string-join fields ".")))))))
-
-
-;; * General query
-(defun oa--query-all-data (endpoint &rest filter)
-  (let* ((page 1)
-        (url (concat "https://api.openalex.org/" endpoint))
-        (filter-string (string-join (cl-loop for key in (plist-get-keys filter) collect
-                                             (concat (substring (symbol-name key) 1)
-                                                     ":"
-                                                     (url-hexify-string
-                                                      (plist-get filter key))))
-                                    ","))
-        (params `(("mailto" . ,user-mail-address)
-                  ("api_key" . ,oa-api-key)
-                  ("filter" . ,filter-string)
-                  ("page" . ,page)))
-        
-        (req (request url :sync t :parser 'oa--response-parser :params params))
-        (data (request-response-data req))
-        (meta (plist-get data :meta))
-        (count (plist-get meta :count))
-        (per-page (plist-get meta :per_page))
-        (pages (ceiling (/ (float count) per-page)))
-        (results (plist-get data :results)))
-    (cl-loop for i from 2 to pages do
-            (setf (cdr (assoc "page" params)) i)
-            (setq req (request purl :sync t :parser 'oa--response-parser :params params)
-                  data (request-response-data req)
-                  results (append results (plist-get data :results))))
-    results))
-
-
-(defun oa-query (endpoint &rest filter)
-  "Run a query at ENDPOINT with FILTER.
-ENDPOINT can be works, authors, sources, institutions, concepts,
-publishers, or funders.
-
-FILTER is a plist (:field value) where :field is a valid filter
-field (see
-https://docs.openalex.org/how-to-use-the-api/get-lists-of-entities/filter-entity-lists),
-and value is what you want to filter on. The following logic is supported:
-
-!value is negation
-<value is less than
->value is greater than
-value1+value2 is and within a field
-value1|value2 is or within a field
-
-Your email address will be added if `user-mail-address' is
-non-nil, and `oa-api-key' if it is non-nil to the API url."
-  (let* ((page (if (plist-get filter :page)
-                  (prog1
-                      (string-to-number (plist-get filter :page))
-                    (setq filter (org-plist-delete filter :page)))
-                1))
-        (base-url "https://api.openalex.org")
-        (url (concat base-url "/" endpoint "?filter="))
-        (filter-string (string-join
-                        (cl-loop for key in (plist-get-keys filter) collect
-                                 (concat (substring (symbol-name key) 1)
-                                         ":"
-                                         (url-hexify-string
-                                          (plist-get filter key))))
-                        ","))
-        
-        (req (request url :sync t :parser 'oa--response-parser
-               :params `(("mailto" . ,user-mail-address)
-                         ("api_key" . ,oa-api-key)
-                         ("filter" . ,filter-string)
-                         ("page" . ,page))))
-        (data (request-response-data req))
-        (meta (plist-get data :meta))
-        (count (plist-get meta :count))
-        (per-page (plist-get meta :per_page))
-        (pages (ceiling (/ (float count) per-page)))
-        (results (plist-get data :results))
-        (next-page (format "[[elisp:(oa-query \"%s\" %s :page \"%s\")][Next page: %s]]"
-                           endpoint 
-                           (string-join (cl-loop for x in filter
-                                                 collect
-                                                 (if (keywordp x)
-                                                     (format "%s" x)
-                                                   (format "%S" x)))
-                                        " ")
-                           (+ page 1)
-                           (+ page 1)))
-        (buf (generate-new-buffer "*OpenAlex - Query*")))
-    
-    (with-current-buffer buf
-      (erase-buffer)
-      (org-mode)
-      (insert (concat
-              (format "#+title: %s
-** Results
-:PROPERTIES:
-:FILTER: %s
-:COUNT: %s
-:END:
-
-%s
-\n\n"
-                      filter-string
-                      filter-string
-                      count
-                      next-page)
-              (cond
-               ((string= endpoint "works")
-                (string-join
-                 (cl-loop for wrk in results collect
-                          (s-format "*** ${title}
-:PROPERTIES:
-:HOST: ${primary_location.source.display_name}
-:YEAR: ${publication_year}
-:CITED_BY_COUNT: ${cited_by_count}
-:AUTHOR: ${authors}
-:DOI: ${doi}
-:OPENALEX: ${id}
-:CREATED_DATE: ${created_date}
-:END:
-
-
-${get-bibtex}
-
-- ${oa-refs}
-- ${oa-related}
-- ${oa-cited}
-
-${abstract}
-
-"
-                                    (lambda (key data)
-                                      (or (cdr (assoc key data)) ""))
-                                    `(("title" . ,(oa--title wrk))
-                                      ("primary_location.source.display_name" . ,(oa-get wrk "primary_location.source.display_name"))
-                                      ("publication_year" . ,(oa-get wrk "publication_year"))
-                                      ("cited_by_count" . ,(oa-get wrk "cited_by_count"))
-                                      ("authors" . ,(oa--authors wrk))
-                                      ("doi" . ,(oa-get wrk "doi"))
-                                      ("id" . ,(oa-get wrk "id"))
-                                      ("created_date" . ,(oa-get wrk "created_date"))
-                                      ("get-bibtex" . ,(oa--elisp-get-bibtex wrk))
-                                      ("oa-refs" . ,(oa--elisp-get-oa-refs wrk))
-                                      ("oa-related" . ,(oa--elisp-get-oa-related wrk))
-                                      ("oa-cited" . ,(oa--elisp-get-oa-cited-by wrk))
-                                      ("abstract" . ,(oa--abstract wrk)))))
-                 "\n"))
-               (t
-                (format "%s" results)
-                )))))
-    (pop-to-buffer buf)
-    (goto-char (point-min))))
-
-
-;; * Work object
-
-(defun oa--work (entity-id &optional filter)
-  "Retrieve json data for a Work object for ENTITY-ID.
-ENTITY-ID is an OpenAlex ID, DOI, Pubmed id,etc.
-
-ENTITY-ID may also be a list of ids with a filter.
-
-If FILTER is non-nil it should be a string like \"filter=openalex:\"
-
-https://docs.openalex.org/api-entities/works"
-
-  (let* ((url (concat "https://api.openalex.org/works"
-                     ;; This is hackier than I prefer, but sometimes entity-id
-                     ;; is nil, or starts with ? for a filter, and I couldn't
-                     ;; see a cleaner way to solve this. this function is used
-                     ;; in a lot of places.
-                     (cond
-                      ((string-prefix-p "?" entity-id)
-                       entity-id)
-                      (t
-                       (format "/%s" entity-id)))))
-        (req (request url :sync t :parser 'oa--response-parser
-               :params `(("mailto" . ,user-mail-address)
-                         ("api_key" . ,oa-api-key)
-                         ("filter" . ,filter))))
-        (data (request-response-data req)))
-    ;; this is for convenience to inspect data in a browser, e.g. you can click
-    ;; on the url in Emacs and it opens in a browser.
-    (plist-put data :oa-url url)
-    data))
-
-
-;; * autocomplete works
-
-(defun oa--works-candidates (query)
-  "Retrieve autocomplete works from OpenAlex."
-  (or
-   (ivy-more-chars)
-   (let* ((url "https://api.openalex.org/autocomplete/works")
-         (req (request url :sync t :parser 'oa--response-parser
-                :params `(("mailto" . ,user-mail-address)
-                          ("api_key" . ,oa-api-key)
-                          ("q" . ,query))))
-         (data (request-response-data req))
-         (results (plist-get data :results)))
-     (cl-loop for work in results collect
-             (propertize
-              (format "%s, %s"
-                      (plist-get work :display_name)
-                      (plist-get work :hint))
-              'oaid (plist-get work :id))))))
-
-
-(defun oa-works ()
-  "Autocomplete works.
-This doesn't seem as useful as it could be."
-  (interactive)
-  
-  (ivy-read "Work: " #'oa--works-candidates
-           :dynamic-collection t
-           :action
-           '(1 
-             ("o" (lambda (candidate)
-                    (browse-url (get-text-property 0 'oaid candidate)))
-              "Open in browser"))))
-
-;; * Viewing works
-
-
-;; ** help functions for complex data
-;;
-;; Some things like authors need to be constructed, and cannot just be looked
-;; up. In other cases, I want logic, e.g. if data is there provide something,
-;; and if not return an empty string. These functions do that work.
-(defun oa--authors (wrk)
-  "Return an author string for WRK.
-The string is a comma-separated list of links to author pages in OpenAlex."
-  (s-join ", " (cl-loop for author in (plist-get wrk :authorships)
-                       collect
-                       (format "[[elisp:(oa--author-org \"%s\")][%s]]"
-                               (plist-get
-                                (plist-get author :author)
-                                :id)
-                               (plist-get
-                                (plist-get author :author)
-                                :display_name)))))
-
-
-(defun oa--title (wrk)
-  "Return a title from WRK with linebreaks removed."
-  (string-replace "\n" " " (plist-get wrk :title)))
-
-
-;; I want some links if they can be made so the buffer is interactive. It might
-;; be nice to integrate M-, navigation.
-(defun oa--elisp-get-bibtex (wrk)
-  "Return a elisp link to get a bibtex entry for WRK if there is a doi."
-  (if-let ((doi (plist-get wrk :doi)))
-      (format "[[elisp:(doi-add-bibtex-entry \"%s\")][Get bibtex entry]]" doi)
-    ""))
-
-
-(defun oa--elisp-get-oa-related (wrk)
-  "Return a elisp link to get related works for WRK."
-  (format "[[elisp:(progn (xref--push-markers (current-buffer) (point)) (oa--related-works \"%s\"))][Get related work (%s)]]"
-         (plist-get wrk :id)
-         (length (plist-get wrk :related_works))))
-
-
-(defun oa--elisp-get-oa-refs (wrk)
-  "Return a elisp link to get references for WRK."
-  (format "[[elisp:(progn (xref--push-markers (current-buffer) (point)) (oa--referenced-works \"%s\"))][Get references (%s)]]"
-         (plist-get wrk :id)
-         (length  (plist-get wrk :referenced_works))))
-
-
-(defun oa--elisp-get-oa-cited-by (wrk)
-  "Return a elisp link to get works that cite WRK."
-  (format "[[elisp:(progn (xref--push-markers (current-buffer) (point)) (oa--cited-by-works \"%s\"))][Get cited by (%s)]]"
-         (plist-get wrk :id)
-         (plist-get wrk :cited_by_count)))
-
-
-(defun oa--works-entries (works)
-  "Return a list of org-formatted entries in WORKS.
-WORKS is a list of results from OpenAlex."
-  (cl-loop for wrk in (plist-get works :results)
-          collect
-          (s-format "** ${title}
-:PROPERTIES:
-:HOST: ${primary_location.source.display_name}
-:YEAR: ${publication_year}
-:CITED_BY_COUNT: ${cited_by_count}
-:AUTHOR: ${authors}
-:DOI: ${doi}
-:OPENALEX: ${id}
-:END:
-
-
-${get-bibtex}
-
-- ${oa-refs}
-- ${oa-related}
-- ${oa-cited}
-
-"
-                    (lambda (key data)
-                      (or (cdr (assoc key data)) ""))
-                    `(("title" . ,(oa-get wrk "title"))
-                      ("primary_location.source.display_name" . ,(oa-get wrk "primary_location.source.display_name"))
-                      ("publication_year" . ,(oa-get wrk "publication_year"))
-                      ("cited_by_count" . ,(oa-get wrk "cited_by_count"))
-                      ("authors" . ,(oa--authors wrk))
-                      ("doi" . ,(oa-get wrk "doi"))
-                      ("id" . ,(oa-get wrk "id"))
-                      ("get-bibtex" . ,(oa--elisp-get-bibtex wrk))
-                      ("oa-refs" . ,(oa--elisp-get-oa-refs wrk))
-                      ("oa-related" . ,(oa--elisp-get-oa-related wrk))
-                      ("oa-cited" . ,(oa--elisp-get-oa-cited-by wrk))))))
-
-
-(defun oa--works-buffer (bufname header entries)
-  "Create an org-buffer with BUFNAME representing the results in WORKS.
-HEADER is the first thing in the buffer
-WORKS is usually a list of results from OpenAlex.
-Argument ENTRIES A list of strings for each org entry."
-  (let ((buf (get-buffer-create bufname)))
-    
-    (with-current-buffer buf
-      (erase-buffer)
-      (insert header)
-      (insert "#+COLUMNS: %25ITEM %YEAR %CITED_BY_COUNT
-elisp:org-columns    elisp:org-columns-quit
-
-
-#+caption: Sort
-| year     | [[elisp:(oa-buffer-sort-year t)][old first]] | [[elisp:(oa-buffer-sort-year)][new first]] |
-| cited by | [[elisp:(oa-buffer-sort-cited-by-count t)][low first]] | [[elisp:(oa-buffer-sort-cited-by-count)][high first]] |
-
-")
-      (insert (s-join "\n" entries))
-      (org-mode)
-      (goto-char (point-min))
-      (org-next-visible-heading 1))
-    ;; (display-buffer-in-side-window buf '((side . right)))
-    (pop-to-buffer buf)))
-
-
-(defun oa--related-works (entity-id)
-  "Show the Related works buffer for ENTITY-ID."
-  (let* ((wrk (oa--work entity-id))
-        (related-work (plist-get wrk :related_works))
-        split
-        entries)
-    (while related-work
-      (setq split (-split-at 25 related-work)
-           related-work (nth 1 split))
-      
-      ;; split is what we process now
-      (setq entries (append entries
-                           (oa--works-entries
-                            (oa--work (format "?filter=openalex:%s" (s-join "|" (nth 0 split))))))))
-    
-    (oa--works-buffer
-     "*OpenAlex - Related works*"
-     (format "* OpenAlex - Related works for %s ([[%s][json]])
-%s\n\n"
-            entity-id
-            (plist-get wrk :oa-url)
-            (s-format ":PROPERTIES:
-:TITLE: ${title}
-:HOST: ${primary_location.source.display_name}
-:AUTHOR: ${authors}
-:DOI: ${doi}
-:YEAR: ${publication_year}
-:OPENALEX: ${id}
-:END:
-
-Found ${nentries} results.
-"
-                      (lambda (key data)
-                        (or (cdr (assoc key data)) ""))
-                      `(("title" . ,(oa-get wrk "title"))
-                        ("primary_location.source.display_name" . ,(oa-get wrk "primary_location.source.display_name"))
-                        ("authors" . ,(oa--authors wrk))
-                        ("doi" . ,(oa-get wrk "doi"))
-                        ("publication_year" . ,(oa-get wrk "publication_year"))
-                        ("id" . ,(oa-get wrk "id"))
-                        ("nentries" . ,(length entries)))))
-     entries)))
-
-
-(defun oa--referenced-works (entity-id)
-  "Show the Referenced work for ENTITY-ID."
-  (let* ((wrk (oa--work entity-id))
-        (referenced-work (plist-get wrk :referenced_works))
-        split
-        (entries '()))
-    (while referenced-work
-      (setq split (-split-at 25 referenced-work)
-           referenced-work (nth 1 split))
-      ;; split is what we process now
-      (setq entries (append entries
-                           (oa--works-entries
-                            (oa--work (format "?filter=openalex:%s"    
-                                              (s-join "|" (nth 0 split))))))))
-    (oa--works-buffer
-     "*OpenAlex - References*"
-     (format "* OpenAlex - References from %s ([[%s][json]])
-%s\n\n"
-            entity-id
-            (plist-get wrk :oa-url)
-            (s-format ":PROPERTIES:
-:TITLE: ${title}
-:HOST: ${primary_location.source.display_name}
-:AUTHOR: ${authors}
-:DOI: ${doi}
-:YEAR: ${publication_year}
-:OPENALEX: ${id}
-:END:
-
-Found ${nentries} results.
-"
-                      (lambda (key data)
-                        (or (cdr (assoc key data)) ""))
-                      `(("title" . ,(oa-get wrk "title"))
-                        ("primary_location.source.display_name" . ,(oa-get wrk "primary_location.source.display_name"))
-                        ("authors" . ,(oa--authors wrk))
-                        ("doi" . ,(oa-get wrk "doi"))
-                        ("publication_year" . ,(oa-get wrk "publication_year"))
-                        ("id" . ,(oa-get wrk "id"))
-                        ("nentries" . ,(length entries)))))
-     entries)))
-
-
-;; This function is different than the previous two. First we follow a URL
-;; provided by the data, and second, here we do follow pages.
-(defun oa--cited-by-works (entity-id)
-  "Show the Cited by buffer for ENTITY-ID."
-  (let* ((wrk (oa--work entity-id))
-        (url (plist-get wrk :cited_by_api_url))
-        (cited-by-works (request-response-data
-                         (request url
-                           :sync t
-                           :parser 'oa--response-parser
-                           :params `(("mailto" . ,user-mail-address)
-                                     ("api_key" . ,oa-api-key)))))
-        (count (plist-get (plist-get cited-by-works :meta) :count))
-        (per-page (plist-get (plist-get cited-by-works :meta) :per_page))
-        (entries '())
-        (page 2))
-    ;; get first page
-    (setq entries (oa--works-entries cited-by-works))
-    (while (> count (* per-page (- page 1)))
-      (setq cited-by-works (request-response-data
-                           (request url
-                             :sync t
-                             :parser 'oa--response-parser
-                             :params `(("mailto" . ,user-mail-address)
-                                       ("api_key" . ,oa-api-key)
-                                       ("page" . ,page)))))
-      (setq entries (append entries (oa--works-entries cited-by-works)))
-      (cl-incf page))
-    
-    (oa--works-buffer
-     "*OpenAlex - Cited by*"
-     (format "* OpenAlex - %s Cited by ([[%s][json]])
-%s"
-            entity-id
-            url
-            (s-format ":PROPERTIES:
-:TITLE: ${title}
-:HOST: ${primary_location.source.display_name}
-:AUTHOR: ${authors}
-:DOI: ${doi}
-:YEAR: ${publication_year}
-:OPENALEX: ${id}
-:END:
-
-Found ${nentries} results.
-
-"
-                      (lambda (key data)
-                        (or (cdr (assoc key data)) ""))
-                      `(("title" . ,(oa-get wrk "title"))
-                        ("primary_location.source.display_name" . ,(oa-get wrk "primary_location.source.display_name"))
-                        ("authors" . ,(oa--authors wrk))
-                        ("doi" . ,(oa-get wrk "doi"))
-                        ("publication_year" . ,(oa-get wrk "publication_year"))
-                        ("id" . ,(oa-get wrk "id"))
-                        ("nentries" . ,(length entries)))))
-     entries)))
-
-
-;; ** buffer utilities for sorting entries
-
-(defun oa-buffer-sort-year (&optional ascending)
-  "Sort org headings by year in descending order (new to old).
-With prefix arg ASCENDING, sort in ascending order (old to new)"
-  (interactive "P")
-  (if ascending
-      (org-sort-entries nil ?f
-                       (lambda () (string-to-number (or (org-entry-get (point) "YEAR") "0")))
-                       (lambda (y1 y2)
-                         (< y1 y2)))
-    (org-sort-entries nil ?f
-                     (lambda () (string-to-number (or (org-entry-get (point) "YEAR") "0")))
-                     (lambda (y1 y2)
-                       (> y1 y2))))
-  (org-fold-show-all))
-
-
-(defun oa-buffer-sort-cited-by-count (&optional ascending)
-  "Sort org headings by cited by count in descending order high to low.
-With prefix arg ASCENDING sort from low to high."
-  (interactive "P")
-  (if ascending
-      (org-sort-entries nil ?f
-                       (lambda ()
-                         (string-to-number
-                          (or (org-entry-get (point) "CITED_BY_COUNT")
-                              "0")))
-                       #'<)
-    (org-sort-entries nil ?f
-                     (lambda ()
-                       (string-to-number
-                        (or
-                         (org-entry-get (point) "CITED_BY_COUNT")
-                         "0")))
-                     #'>))
-  (org-fold-show-all))
-
-
-;; * Interactive versions for org-ref citations
-
-(defun oa-related-works ()
-  "Open the side window for Related works on cite at point."
-  (interactive)
-  (oa--related-works (concat "https://doi.org/" (org-ref-get-doi-at-point))))
-
-
-(defun oa-referenced-works ()
-  "Open the side window for References from the cite at point."
-  (interactive)
-  (oa--referenced-works (concat "doi:" (org-ref-get-doi-at-point))))
-
-
-(defun oa-cited-by-works ()
-  "Open the side window for Citing works for the cite at point."
-  (interactive)
-  (oa--cited-by-works (concat "doi:" (org-ref-get-doi-at-point))))
-
-
-(defun oa-open ()
-  "Open the cite at point in OpenAlex."
-  (interactive)
-  (let* ((url (concat
-              "https://api.openalex.org/works/https://doi.org/"
-              (org-ref-get-doi-at-point)))
-        (req (request url :sync t :parser 'oa--response-parser))
-        (data (request-response-data req)))
-    (browse-url (plist-get data :id))))
-
-
-(defhydra+ org-ref-citation-hydra ()
-  "Add open from action to `org-ref-citation-hydra'."
-  ("xa" oa-open "Open in OpenAlex" :column "OpenAlex")
-  ("xr" oa-related-works "Related documents" :column "OpenAlex")
-  ("xc" oa-cited-by-works "Cited by documents" :column "OpenAlex")
-  ("xf" oa-referenced-works "References from" :column "OpenAlex"))
-
-
-;; * Author object
-
-(defun oa--author (entity-id &optional filter)
-  "Get an Author object for ENTITY-ID.
-FILTER is an optional string to add to the URL."
-  (let* ((url (concat  "https://api.openalex.org/authors"
-                      entity-id))
-        (req (request url :sync t :parser 'oa--response-parser
-               :params `(("mailto" . ,user-mail-address)
-                         ("api_key" . ,oa-api-key)
-                         ("filter" . ,filter))))
-        (data (request-response-data req))) 
-    ;; this is for convenience to inspect data in a browser.
-    (plist-put data :oa-url url)
-    data))
-
-
-(defun oa--author-entries (works-data url)
-  "Get entries from WORKS-DATA."
-  (let* ((meta (plist-get works-data :meta)) 
-        (per-page (plist-get meta :per_page))
-        (count (plist-get meta :count))
-        (pages (/ count per-page))
-        (entries '())
-        purl)
-    ;; if there is a remainder we need to get the rest
-    (when (> (mod count per-page) 0) (cl-incf pages))
-    
-    ;; Now we have to loop through the pages
-    (cl-loop for i from 1 to pages
-            do
-            (setq works-data (request-response-data
-                              (request url
-                                :sync t
-                                :parser 'oa--response-parser
-                                :params `(("mailto" . ,user-mail-address)
-                                          ("api_key" . ,oa-api-key)
-                                          ("page" . ,i))))
-                  entries (append entries
-                                  (cl-loop for result in (plist-get works-data :results)
-                                           collect
-                                           (s-format "*** ${title}
-:PROPERTIES:
-:ID: ${id}
-:DOI: ${ids.doi}
-:PDF: ${primary_location.pdf_url}
-:LANDING_PAGE: ${primary_location.landing_page_url}
-:YEAR: ${publication_year}
-:HOST_VENUE: ${primary_location.source.display_name}
-:AUTHORS: ${authors}
-:CITED_BY_COUNT: ${cited_by_count}
-:END:
-
-${get-bibtex}
-
-- ${oa-refs}
-- ${oa-related}
-- ${oa-cited}
-
-${abstract}
-
-    " (lambda (key data)
-       (or (cdr (assoc key data)) ""))
-    `(("title" . ,(oa--title result))
-      ("id" . ,(oa-get result "id"))
-      ("ids.doi" . ,(oa-get result "ids.doi"))
-      ("publication_year" . ,(oa-get result "publication_year"))
-      ("primary_location.pdf_url" . ,(oa-get result "primary_location.pdf_url"))
-      ("primary_location.landing_page_url" . ,(oa-get result "primary_location.landing_page_url"))
-      ("primary_location.source.display_name" . ,(oa-get result "primary_location.source.display_name"))
-      ("authors" . ,(oa--authors result))
-      ("cited_by_count" . ,(oa-get result "cited_by_count"))
-      ("get-bibtex" . ,(oa--elisp-get-bibtex result))
-      ("oa-refs" . ,(oa--elisp-get-oa-refs result))
-      ("oa-related" . ,(oa--elisp-get-oa-related result))
-      ("oa-cited" . ,(oa--elisp-get-oa-cited-by result))
-      ("abstract" . ,(oa--abstract result))))))))
-    entries))
-
-
-(defun oa--abstract (wrk)
-  "Construct an abstract from a WRK."
-  (let* ((aii (plist-get wrk :abstract_inverted_index))
-        (word_index '())
-        sorted)
-
-    (cl-loop for (k v) on aii by 'cddr
-            do
-            (cl-loop for index in v
-                     do
-                     (push (list k index) word_index)))
-
-    (setq sorted (sort
-                 word_index
-                 (lambda (a b)
-                   (<
-                    (nth 1 a)
-                    (nth 1 b)))))
-
-    (string-join (mapcar
-                 (lambda (x)
-                   (substring
-                    (symbol-name (car x))
-                    1))
-                 sorted)
-                " ")))
-
-
-(defun oa--author-candidates (query)
-  "Retrieve autocomplete authors from OpenAlex."
-  (or
-   (ivy-more-chars)
-   (let* ((url "https://api.openalex.org/autocomplete/authors")
-         (req (request url :sync t :parser 'oa--response-parser
-                :params `(("mailto" . ,user-mail-address)
-                          ("api_key" . ,oa-api-key)
-                          ("q" . ,query))))
-         (data (request-response-data req))
-         (results (plist-get data :results)))
-     (cl-loop for author in results collect
-             (propertize
-              (format "%s - %s"
-                      (plist-get author :display_name)
-                      (plist-get
-                       author :hint))
-              'oaid (plist-get author :id))))))
-
-
-(defun oa--counts-by-year (data)
-  "Get citation counts by year and make a graph.
-DATA is an author from OpenAlex.
-Requires gnuplot. Generates a temporary file."
-  (if (executable-find "gnuplot")
-      (let* ((pngfile (make-temp-file "oa-" nil ".png"))
-            (counts (sort
-                     (cl-loop for i from 1 for item in (plist-get data :counts_by_year)
-                              collect
-                              (list
-                               (plist-get item :year)
-                               (plist-get item :cited_by_count)
-                               (plist-get item :works_count)))
-                     (lambda (a b)
-                       (< (nth 0 a)
-                          (nth 0 b)))))
-            (count-string (cl-loop for i from 1 for (year cites works) in counts
-                                   concat
-                                   (format "%s \"%s\" %s %s\n"
-                                           i year cites works)))
-            (gnuplot (format "set terminal \"png\" size 800,400
-set output \"%s\"
-$counts << EOD
-%s
-EOD
-set boxwidth 0.5
-set style fill solid noborder
-set style line 1 lc rgb \"grey\"
-set ylabel \"Citation count\"
-set y2label \"Document count\"
-set y2tics nomirror
-set key left top
-plot $counts using 1:3:xtic(2) with boxes lc rgb \"grey\" title \"Citations per year\", \"\" using 1:4 axes x1y2 with lines title \"Document count\"
-"
-                             pngfile
-                             count-string))
-            (cmdfile (make-temp-file "gnuplot-cmds-" nil ".gpl"))
-             (shellcmd (format "gnuplot --persist -c \"%s\"" cmdfile)))
-       (with-temp-file cmdfile
-         (insert gnuplot))
-       (shell-command shellcmd)
-       (delete-file cmdfile)
-       (format "[[%s]]" pngfile))
-    "Gnuplot required to see citation graph. Please install it."))
-
-
-(defun oa--author-org (entity-id)
-  "Generate an org-buffer for an author with ENTITY-ID."
-  (let* ((buf (get-buffer-create "*OpenAlex - Author*"))
-        (data (oa--author entity-id))
-        (citations-image (oa--counts-by-year data))
-        (works-count (plist-get data :works_count))
-        (works-url (plist-get data :works_api_url))
-        (works-data (request-response-data
-                     (request works-url
-                       :sync t
-                       :parser 'oa--response-parser
-                       :params `(("mailto" . ,user-mail-address)
-                                 ("api_key" . ,oa-api-key))))))
-    (with-current-buffer buf
-      (erase-buffer)
-      (insert (s-format "* ${display_name} ([[${oa-url}][json]])
-:PROPERTIES:
-:OPENALEX: ${id}
-:ORCID: ${orcid}
-:SCOPUS: ${ids.scopus}
-:WORKS_COUNT: ${works_count}
-:CITED_BY_COUNT: ${cited_by_count}
-:INSTITUTION: ${last_known_institution.display_name}, ${last_known_institution.country_code}
-:END:
-
-#+COLUMNS: %25ITEM %YEAR %CITED_BY_COUNT
-elisp:org-columns    elisp:org-columns-quit
-
-${citations-image}
-
-** Articles
-
-#+caption: Sort
-| year     | [[elisp:(oa-buffer-sort-year t)][old first]] | [[elisp:(oa-buffer-sort-year)][new first]] |
-| cited by | [[elisp:(oa-buffer-sort-cited-by-count t)][low first]] | [[elisp:(oa-buffer-sort-cited-by-count)][high first]] |
-
-"
-                       (lambda (key data)
-                         (or (cdr (assoc key data)) ""))
-                       `(("display_name" . ,(oa-get data "display_name"))
-                         ("oa-url" . ,(oa-get data "oa-url"))
-                         ("id" . ,(oa-get data "id"))
-                         ("orcid" . ,(oa-get data "orcid"))
-                         ("ids.scopus" . ,(oa-get data "ids.scopus"))
-                         ("works_count" . ,(oa-get data "works_count"))
-                         ("last_known_institution.display_name" . ,(oa-get data "last_known_institution.display_name"))
-                         ("last_known_institution.country_code" . ,(oa-get data "last_known_institution.country_code"))
-                         ("citations-image" . ,citations-image))))
-      (insert (s-join "\n" (oa--author-entries works-data works-url)))
-
-      (org-mode)
-      (goto-char (point-min))
-      (org-next-visible-heading 1))
-    (pop-to-buffer buf)))
-
-
-(defun oa-author ()
-  "Get data and act on it for an author."
-  (interactive)
-  
-  (ivy-read "Author: " #'oa--author-candidates
-           :dynamic-collection t
-           :action
-           '(1
-             ("o" (lambda (candidate)
-                    (oa--author-org (get-text-property 0 'oaid candidate)))
-              "Open org file")
-             ("l" (lambda (candidate)
-                    (insert (format "[[%s][%s]]"
-                                    (get-text-property 0 'oaid candidate)
-                                    candidate))))
-             ("u" (lambda (candidate)
-                    (browse-url (get-text-property 0 'oaid candidate)))
-              "Open in browser"))))
-
-
-;; * Full text search
-
-
-(defun oa-fulltext-search (query &optional page)
-  "Perform a fulltext search on QUERY.
-PAGE is optional, and loads that page of results. Defaults to 1."
-  (interactive (list (read-string "Query: ")
-                    nil))
-  (when (null page) (setq page 1))
-  (let* ((url "https://api.openalex.org/works")
-        (req (request url
-               :sync t
-               :parser #'oa--response-parser
-               :params `(("mailto" . ,user-mail-address)
-                         ("api_key" . ,oa-api-key)
-                         ("page" . ,page)
-                         ("filter" . ,(format "fulltext.search:%s" query)))))
-        (data (request-response-data req))
-        (metadata (plist-get data :meta))
-        (count (plist-get metadata :count))
-        (per-page (plist-get metadata :per_page))
-        (npages (+ (/ count per-page) (if (= 0 (mod count per-page)) 0 1)))
-        (results (plist-get data :results))
-        (next-page (format "[[elisp:(oa-fulltext-search \"%s\" %s)][Next page: %s of %s]]"
-                           query
-                           (+ page 1)
-                           (+ page 1)
-                           npages))
-        (buf (get-buffer-create "*OpenAlex Full-text search*")))
-    
-    (with-current-buffer buf
-      (erase-buffer)
-      (org-mode)
-      (insert (s-format "#+title: Full-text search: ${query}
-
-[[elisp:(oa-fulltext-search \"${query}\" ${page})]]"
-                       'aget
-                       `(("query" . ,query)
-                         ("page" . ,page))))
-      (insert (s-format
-              "
-${meta.count} results: Page ${meta.page} of ${s1} ${s2}
-\n\n"
-              (lambda (key data)
-                (or (cdr (assoc key data)) ""))
-              `(("meta.page" . ,(oa-get data "meta.page"))
-                ("s1" . ,(format "%s" npages))
-                ("s2" . ,(format "%s" next-page)))))
-      
-      (insert
-       (cl-loop for result in results concat 
-               (s-format "* ${title}
-:PROPERTIES:
-:JOURNAL: ${primary_location.source.display_name}
-:AUTHOR: ${authors}
-:YEAR: ${publication_year}
-:OPENALEX: ${id}
-:DOI: ${ids.doi}
-:END:
-
-${get-bibtex}
-
-- ${oa-refs}
-- ${oa-related}
-- ${oa-cited}
-
-" (lambda (key data)
-    (or (cdr (assoc key data)) ""))
-
-`(("title" . ,(oa--title result))
-  ("primary_location.source.display_name" . ,(oa-get result "primary_location.source.display_name"))
-  ("authors" . ,(oa--authors result))
-  ("publication_year" . ,(oa-get result "publication_year"))
-  ("id" . ,(oa-get result "id"))
-  ("ids.doi" . ,(oa-get result "ids.doi"))
-  ("get-bibtex" . ,(oa--elisp-get-bibtex result))
-  ("oa-refs" . ,(oa--elisp-get-oa-refs result))
-  ("oa-related" . ,(oa--elisp-get-oa-related result))
-  ("oa-cited" . ,(oa--elisp-get-oa-cited-by result))))))
-
-      (insert next-page)
-      
-      (goto-char (point-min)))
-    (pop-to-buffer buf)))
-
-
-;; * NSF Collaborators and Other Affiliations
-(defun oa-coa (entity-id &optional COA-file)
-  "Get a list of collaborators for the past 5 years in tab-delimited form.
-This is for Table 4 in the COA_template at
-https://www.nsf.gov/bfa/dias/policy/coa/coa_template.xlsx.
-
-ENTITY-ID is an identifier that OpenAlex can use. Used
-interactively you can query and select an author.
-
-If COA-FILE is non-nil write results to that file, otherwise save
-to the clipboard. You should be able to paste the results
-directly into Excel.
-
-Results are sorted in alphaphabetical order by last name.
-
-Caveats: OpenAlex provides the name in Firstname Initial Lastname
-form. I assume this can be split on spaces, and the last word is
-the last name. That is not always correct, so some manual name
-fixing may be required.
-
-The Institutions are not always reliable. I use the most recent
-institution if an author is listed multiple times. Sometimes this
-is empty, and sometimes an author has multiple institutions
-listed.
-
-There may be duplicates for people who have different names in
-OpenAlex, e.g. missing initials, differences in spelling,
-abbreviations, including having a period or not.
-
-Your name will be included, you will need to delete this manually
-in the Excel sheet.
-
-This only gets the coauthors in publications known to OpenAlex.
-Recently published papers are probably missing.
-"
-  (interactive (list
-               (get-text-property 0 'oaid
-                                  (ivy-read "Author: " #'oa--author-candidates
-                                            :dynamic-collection t))
-               (when (y-or-n-p "Save to file?")
-                 (read-file-name "File: "))))
-  
-  (let* ((data (oa--author entity-id))
-        (works-url (plist-get data :works_api_url)) 
-        (works-data (request-response-data
-                     (request works-url
-                       :sync t
-                       :parser 'oa--response-parser
-                       :params `(("mailto" . ,user-mail-address)
-                                 ("api_key" . ,oa-api-key)))))
-        (meta (plist-get works-data :meta))
-        (count (plist-get meta :count))
-        (per-page (plist-get meta :per_page))
-        (pages (/ count per-page))
-        (results (plist-get works-data :results))
-        (current-year (string-to-number (format-time-string "%Y" (current-time))))
-        (current-authors '())
-        purl)
-
-    ;; Now we need to accumulate the rest of the results from other pages
-    (when (> (mod count per-page) 0) (cl-incf pages))
-
-    (cl-loop for i from 2 to pages
-            do
-            (setq works-data (request-response-data
-                              (request works-url
-                                :sync t
-                                :parser 'oa--response-parser
-                                :params `(("mailto" . ,user-mail-address)
-                                          ("api_key" . ,oa-api-key)
-                                          ("page" . ,i))))
-                  results (append results (plist-get works-data :results))))
-    
-    ;; Now results is a list of your publications. We need to iterate over each
-    ;; one, and accumulate author information
-    (cl-loop for result in results do
-            (let ((year (plist-get result :publication_year)))
-              (when (> year (- current-year 5))
-                (cl-loop for authorship in (plist-get result :authorships) do
-                         (let* ((author (plist-get authorship :author))
-                                (name (plist-get author :display_name))
-                                (name-parts (mapcar #'capitalize (split-string name)))
-                                (name-string (concat (car (last name-parts)) ", "
-                                                     (string-join (butlast name-parts) " ")))
-                                
-                                (institutions (plist-get authorship :institutions)) 
-                                (institution (plist-get (car institutions) :display_name)))
-                           ;; name, institution, contact info, last-active
-                           ;; we won't have contact info from openalex.
-                           (push (list name-string institution "" year
-                                       (plist-get result :publication_date))
-                                 current-authors))))))
-    
-    (setq current-authors (sort current-authors
-                               (lambda (a b)
-                                 "Sort first on name, then on year in descending order"
-                                 (if (string= (nth 0 a) (nth 0 b))
-                                     (> (nth 3 a) (nth 3 b))
-                                   (string< (car a) (car b))))))
-    
-    ;; now filter for unique authors
-    (setq current-authors (cl-loop for group in (seq-group-by (lambda (x)
-                                                               (car x))
-                                                             current-authors)     
-                                  collect (cadr group)))
-
-    ;; Finally lets fix the year so Excel reads it correctly. I use the publication date
-    (setq current-authors (cl-loop for row in current-authors 
-                                  collect
-                                  (list "A:"
-                                        (nth 0 row)
-                                        (nth 1 row)
-                                        (nth 2 row)
-                                        (nth 4 row))))
-
-    (if COA-file
-       (with-temp-file COA-file
-         (cl-loop for row in current-authors do
-                  (insert (string-join (mapcar (lambda (x)
-                                                 (format "%s" (or x "")))
-                                               row)
-                                       "\t")
-                          "\n")))
-      
-
-      (kill-new (mapconcat (lambda (row)
-                            (concat (string-join (mapcar (lambda (x)
-                                                           (format "%s" (or x "")))
-                                                         row)
-                                                 "\t")
-                                    "\n"))
-                          current-authors))
-      (message "COA data on the clipboard."))))
-
-
-
-;; * utilities
-
-(defun oa-kill-buffers ()
-  "Kill OpenAlex buffers."
-  (interactive)
-  (cl-loop for buf in (buffer-list)
-          do
-          (when (s-starts-with? "*OpenAlex" (buffer-name buf))
-            (kill-buffer buf))))
-
-
-(defun oa-get-bibtex-entries ()
-  "Download all the bibtex entries in the buffer.
-Operates on headings with a DOI property."
-  (interactive)
-  (let ((bibfile (completing-read "Bibfile: " (org-ref-possible-bibfiles))))
-    (org-map-entries
-     (lambda ()
-       (kill-new (org-entry-get (point) "DOI"))
-       (doi-utils-add-bibtex-entry-from-doi
-       (doi-utils-maybe-doi-from-region-or-current-kill) 
-       bibfile))
-     "DOI<>\"\"")))
-
-
-(provide 'openalex)
-
-;;; openalex.el ends here
-
-;; Local Variables:
-;; byte-compile-warnings: (not docstrings-wide)
-;; End:
diff --git a/elpa/org-ref-20241124.2012/org-ref-arxiv.el b/elpa/org-ref-20241124.2012/org-ref-arxiv.el
deleted file mode 100644 (file)
index c16739c..0000000
+++ /dev/null
@@ -1,299 +0,0 @@
-;;; org-ref-arxiv.el --- arxiv utilities for org-mode        -*- lexical-binding: t; -*-
-
-;; Copyright (C) 2015-2024  John Kitchin
-
-;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
-;; Keywords:
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-;; this library creates a new org-link for Arxiv (http://arxiv.org/) entries,
-;; and provides functions to retrieve bibtex entries from an Arxiv number.
-;;
-;; An Arxiv number might look like: cond-mat/0410285 or 1503.01742
-
-;;; Code:
-(require 'bibtex)
-(require 'dash)
-(require 'f)
-(require 'org)
-(require 's)
-(require 'org-ref-utils)
-(require 'parsebib)
-
-(require 'xml)
-
-;; This is a local variable defined in `url-http'.  We need it to avoid
-;; byte-compiler errors.
-(defvar url-http-end-of-headers)
-
-
-(declare-function parsebib-find-bibtex-dialect "parsebib")
-(declare-function org-ref-clean-bibtex-entry "org-ref-core")
-;; this is a C function
-(declare-function libxml-parse-xml-region "xml")
-
-;;* The org-mode link
-;; this just makes a clickable link that opens the entry.
-;; example: arxiv:cond-mat/0410285
-(org-link-set-parameters "arxiv"
-                        :follow (lambda (link-string)
-                                  (browse-url (format "http://arxiv.org/abs/%s" link-string)))
-                        :export (lambda (keyword desc format)
-                                  (cond
-                                   ((eq format 'html)
-                                    (format  "<a href=\"http://arxiv.org/abs/%s\">arxiv:%s</a>"
-                                             keyword  (or desc keyword)))
-                                   ((eq format 'latex)
-                                    ;; write out the latex command
-                                    (format "\\url{http://arxiv.org/abs/%s}{%s}" keyword (or desc keyword))))))
-
-;;* Getting a bibtex entry for an arXiv article using remote service:
-;; For an arxiv article, there is a link to a NASA ADS page like this:
-;; http://adsabs.harvard.edu/cgi-bin/bib_query?arXiv:1503.01742
-;; On that page, there is a link to a bibtex entry:
-;; http://adsabs.harvard.edu/cgi-bin/nph-bib_query?bibcode=2015arXiv150301742H&data_type=BIBTEX&db_key=PRE&nocookieset=1
-;;
-;; It looks like you need to get a Bibliographic code from the arxiv number to
-;; then get the bibtex entry.
-
-(defun arxiv-get-bibliographic-code (arxiv-number)
-  "Get Bibliographic code for ARXIV-NUMBER."
-  (with-current-buffer
-      (url-retrieve-synchronously
-       (concat
-        "http://adsabs.harvard.edu/cgi-bin/bib_query?arXiv:"
-        arxiv-number))
-    (search-forward-regexp "<link rel=\"canonical\" href=\"http://ui.adsabs.harvard.edu/abs/\\(.*\\)/abstract\"/>")
-    (match-string 1)))
-
-
-(defun arxiv-get-bibtex-entry (arxiv-bibliographic-code)
-  "Get bibtex entry for ARXIV-BIBLIOGRAPHIC-CODE."
-  (with-current-buffer
-      (url-retrieve-synchronously (format "https://ui.adsabs.harvard.edu/abs/%s/exportcitation" arxiv-bibliographic-code))
-    (when (re-search-forward
-          "<textarea.*>\\(.*\\(?:\n.*\\)*?\\(?:\n\\s-*\n\\|\\'\\)\\)</textarea>"
-          nil t)
-      (xml-substitute-special (match-string 1)))))
-
-;;* Getting a bibtex entry for an arXiv article using arXiv API:
-;; Retrieves the meta data of an article view arXiv's http API,
-;; extracts the necessary information, and formats a new BibTeX entry.
-
-(defvar arxiv-entry-format-string "@article{%s,
-  journal = {CoRR},
-  title = {%s},
-  author = {%s},
-  archivePrefix = {arXiv},
-  year = {%s},
-  eprint = {%s},
-  primaryClass = {%s},
-  abstract = {%s},
-  url = {%s},
-}"
-  "Template for BibTeX entries of arXiv articles.")
-
-
-(declare-function doi-utils-doi-to-bibtex-string "doi-utils")
-(declare-function org-ref-replace-nonascii "org-ref-bibtex")
-
-(defun arxiv-get-bibtex-entry-via-arxiv-api (arxiv-number)
-  "Retrieve meta data for ARXIV-NUMBER.
-Returns a formatted BibTeX entry."
-  (with-current-buffer
-      (url-retrieve-synchronously (format "http://export.arxiv.org/api/query?id_list=%s" arxiv-number) t)
-    (let* ((parse-tree (libxml-parse-xml-region
-                        (progn (goto-char 0)
-                               (search-forward "<?xml ")
-                               (match-beginning 0))
-                        (point-max)))
-           (entry (assq 'entry parse-tree))
-           (authors (--map (nth 2 (nth 2 it))
-                           (--filter (and (listp it) (eq (car it) 'author)) entry)))
-           (year (format-time-string "%Y" (date-to-time (nth 2 (assq 'published entry)))))
-           (title (nth 2 (assq 'title entry)))
-           (names (arxiv-bibtexify-authors authors))
-           (category (cdar (nth 1 (assq 'primary_category entry))))
-           (abstract (s-trim (nth 2 (assq 'summary entry))))
-           (url (nth 2 (assq 'id entry)))
-           (temp-bibtex (format arxiv-entry-format-string "" title names year arxiv-number category abstract url))
-           (key (with-temp-buffer
-                  (insert temp-bibtex)
-                 (bibtex-mode)
-                 (bibtex-set-dialect (parsebib-find-bibtex-dialect) t)
-                 (org-ref-replace-nonascii)
-                  (bibtex-generate-autokey)))
-          (doi (assq 'doi entry)))
-      (unless (and doi
-                  (ignore-errors (doi-utils-doi-to-bibtex-string (nth 2 doi))))
-       ;; no doi or inactive doi, so we fall back to the simple template
-       (format arxiv-entry-format-string key title names year arxiv-number category abstract url)))))
-
-
-(defun arxiv-bibtexify-authors (authors)
-  "Return names in 'SURNAME, FIRST NAME' format from AUTHORS list."
-  (s-join " and "
-          (--map (concat (-last-item it) ", " (s-join " " (-remove-last 'stringp it)))
-                 (--map (s-split " +" it) authors))))
-
-
-(defun arxiv-maybe-arxiv-id-from-current-kill ()
-  "Try to get an arxiv ID from the current kill."
-  (let* ((the-current-kill (ignore-errors (current-kill 0 t)))  ;; nil if empty kill ring
-         (arxiv-url-prefix-regexp "^https?://arxiv\\.org/\\(pdf\\|abs\\|format\\)/")
-         (arxiv-cite-prefix-regexp "^\\(arXiv\\|arxiv\\):")
-         (arxiv-id-old-regexp "[a-z-]+\\(\\.[A-Z]\\{2\\}\\)?/[0-9]\\{5,7\\}") ; Ex: math.GT/0309136
-         (arxiv-id-new-regexp "[0-9]\\{4\\}[.][0-9]\\{4,5\\}\\(v[0-9]+\\)?") ; Ex: 1304.4404v2
-         (arxiv-id-regexp (concat "\\(" arxiv-id-old-regexp "\\|" arxiv-id-new-regexp "\\)")))
-    (cond
-     (;; make sure current-kill has something in it
-      ;; if current-kill is not a string, return nil
-      (not (stringp the-current-kill))
-      nil)
-     (;; check if current-kill looks like an arxiv ID
-      ;; if so, return it
-      ;; Ex: 1304.4404v2
-      (s-match (concat "^" arxiv-id-regexp) the-current-kill)
-      the-current-kill)
-     (;; check if current-kill looks like an arxiv cite
-      ;; if so, remove the prefix and return
-      ;; Ex: arXiv:1304.4404v2 --> 1304.4404v2
-      (s-match (concat arxiv-cite-prefix-regexp arxiv-id-regexp "$") the-current-kill)
-      (replace-regexp-in-string arxiv-cite-prefix-regexp "" the-current-kill))
-     (;; check if current-kill looks like an arxiv url
-      ;; if so, remove the url prefix and return
-      ;; Ex: https://arxiv.org/abs/1304.4404 --> 1304.4404
-      (s-match (concat arxiv-url-prefix-regexp arxiv-id-regexp "$") the-current-kill)
-      (replace-regexp-in-string arxiv-url-prefix-regexp "" the-current-kill))
-     (;; check if current-kill looks like an arxiv PDF url
-      ;; if so, remove the url prefix, the .pdf suffix, and return
-      ;; Ex: https://arxiv.org/pdf/1304.4404.pdf --> 1304.4404
-      (s-match (concat arxiv-url-prefix-regexp arxiv-id-regexp "\\.pdf$") the-current-kill)
-      (replace-regexp-in-string arxiv-url-prefix-regexp "" (substring the-current-kill 0 (- (length the-current-kill) 4))))
-     ;; otherwise, return nil
-     (t
-      nil))))
-
-(defvar bibtex-completion-bibliography)
-
-;;;###autoload
-(defun arxiv-add-bibtex-entry (arxiv-number bibfile)
-  "Add bibtex entry for ARXIV-NUMBER to BIBFILE."
-  (interactive
-   (list (read-string
-          "arxiv: "
-          (arxiv-maybe-arxiv-id-from-current-kill))
-         ;;  now get the bibfile to add it to
-         (completing-read
-          "Bibfile: "
-          (append (f-entries "." (lambda (f) (f-ext? f "bib")))
-                 (if (stringp bibtex-completion-bibliography)
-                     (list bibtex-completion-bibliography)
-                   bibtex-completion-bibliography)))))
-  (save-window-excursion
-    (find-file bibfile)
-    (goto-char (point-max))
-    (when (not (looking-at "^")) (insert "\n"))
-    (insert (arxiv-get-bibtex-entry-via-arxiv-api arxiv-number))
-    (org-ref-clean-bibtex-entry)
-    (goto-char (point-max))
-    (when (not (looking-at "^")) (insert "\n"))
-    (save-buffer)))
-
-
-;;;###autoload
-(defun arxiv-get-pdf (arxiv-number pdf)
-  "Retrieve a pdf for ARXIV-NUMBER and save it to PDF."
-  (interactive
-   (list (read-string
-          "arxiv: "
-          (arxiv-maybe-arxiv-id-from-current-kill))
-         (read-string
-          "PDF: ")))
-  (let ((pdf-url (format "https://arxiv.org/pdf/%s" arxiv-number)))
-    (url-copy-file pdf-url pdf)
-    ;; now check if we got a pdf
-    (unless (org-ref-pdf-p pdf)
-      (delete-file pdf)
-      (message "Error downloading arxiv pdf %s" pdf-url))))
-
-(defvar bibtex-completion-library-path)
-
-;;;###autoload
-(defun arxiv-get-pdf-add-bibtex-entry (arxiv-number bibfile pdfdir)
-  "Add bibtex entry for ARXIV-NUMBER to BIBFILE.
-Remove troublesome chars from the bibtex key, retrieve a pdf
-for ARXIV-NUMBER and save it to PDFDIR with the same name of the
-key."
-  (interactive
-   (list (read-string
-          "arxiv: "
-          (arxiv-maybe-arxiv-id-from-current-kill))
-         ;;  now get the bibfile to add it to
-         (completing-read
-          "Bibfile: "
-          (append (f-entries "." (lambda (f) (f-ext? f "bib")))
-                  bibtex-completion-bibliography))
-        (cond
-         ((stringp bibtex-completion-library-path)
-          bibtex-completion-library-path)
-         ((= 1 (length bibtex-completion-library-path))
-          (car bibtex-completion-library-path))
-         (t
-          (completing-read "PDF dir: " bibtex-completion-library-path)))))
-
-  (arxiv-add-bibtex-entry arxiv-number bibfile)
-
-  (save-window-excursion
-    (let ((key ""))
-      (find-file bibfile)
-      (goto-char (point-max))
-      (bibtex-beginning-of-entry)
-      (re-search-forward bibtex-entry-maybe-empty-head)
-      (if (match-beginning bibtex-key-in-head)
-          (progn
-            (setq key (delete-and-extract-region
-                       (match-beginning bibtex-key-in-head)
-                       (match-end bibtex-key-in-head)))
-            ;; remove potentially troublesome characters from key
-            ;; as it will be used as  a filename
-            (setq key (replace-regexp-in-string   "\"\\|\\*\\|/\\|:\\|<\\|>\\|\\?\\|\\\\\\||\\|\\+\\|,\\|\\.\\|;\\|=\\|\\[\\|]\\|!\\|@"
-                                                  "" key))
-            ;; check if the key is in the buffer
-            (when (save-excursion
-                    (bibtex-search-entry key))
-              (save-excursion
-                (bibtex-search-entry key)
-                (bibtex-copy-entry-as-kill)
-                (switch-to-buffer-other-window "*duplicate entry*")
-                (bibtex-yank))
-              (setq key (bibtex-read-key "Duplicate Key found, edit: " key))))
-        (setq key (bibtex-read-key "Key not found, insert: ")))
-      (insert key)
-      (arxiv-get-pdf arxiv-number (concat pdfdir key ".pdf"))
-      ;; Check that it worked, and insert a field for it.
-      (when (file-exists-p (concat pdfdir key ".pdf"))
-       (bibtex-end-of-entry)
-       (backward-char)
-       (insert (format "  file = {%s}\n  " (concat pdfdir key ".pdf")))))))
-
-
-(provide 'org-ref-arxiv)
-;;; org-ref-arxiv.el ends here
-
-;; Local Variables:
-;; byte-compile-warnings: (not docstrings)
-;; End:
diff --git a/elpa/org-ref-20241124.2012/org-ref-autoloads.el b/elpa/org-ref-20241124.2012/org-ref-autoloads.el
deleted file mode 100644 (file)
index 912667b..0000000
+++ /dev/null
@@ -1,661 +0,0 @@
-;;; org-ref-autoloads.el --- automatically extracted autoloads (do not edit)   -*- lexical-binding: t -*-
-;; Generated by the `loaddefs-generate' function.
-
-;; This file is part of GNU Emacs.
-
-;;; Code:
-
-(add-to-list 'load-path (or (and load-file-name (directory-file-name (file-name-directory load-file-name))) (car load-path)))
-
-
-\f
-;;; Generated autoloads from contrib.el
-
-(register-definition-prefixes "contrib" '("org-ref-"))
-
-\f
-;;; Generated autoloads from doi-utils.el
-
-(autoload 'doi-utils-async-download-pdf "doi-utils" "\
-Download the PDF for bibtex entry at point asynchronously.
-It is not fully async, only the download is. Fully async is
-harder because you need to run `doi-utils-get-pdf-url' async
-too. " t)
-(autoload 'doi-utils-get-bibtex-entry-pdf "doi-utils" "\
-Download pdf for entry at point if the pdf does not already exist locally.
-The entry must have a doi. The pdf will be saved, by the name
-%s.pdf where %s is the bibtex label. Files will not be
-overwritten. The pdf will be checked to make sure it is a pdf,
-and not some html failure page. You must have permission to
-access the pdf. We open the pdf at the end if
-`doi-utils-open-pdf-after-download' is non-nil.
-
-With one prefix ARG, directly get the pdf from a file (through
-`read-file-name') instead of looking up a DOI. With a double
-prefix ARG, directly get the pdf from an open buffer (through
-`read-buffer-to-switch') instead. These two alternative methods
-work even if the entry has no DOI, and the pdf file is not
-checked.
-
-(fn &optional ARG)" t)
-(autoload 'doi-utils-add-bibtex-entry-from-doi "doi-utils" "\
-Add DOI entry to end of a file in the current directory.
-Pick the file ending with .bib or in .  If you have an active region that
-starts like a DOI, that will be the initial prompt.  If no region
-is selected and the first entry of the ‘kill-ring’ starts like a
-DOI, then that is the initial prompt.  Otherwise, you have to type
-or paste in a DOI.
-Argument BIBFILE the bibliography to use.
-
-(fn DOI &optional BIBFILE)" t)
-(autoload 'doi-utils-doi-to-org-bibtex "doi-utils" "\
-Convert a DOI to an ‘org-bibtex’ form and insert it at point.
-
-(fn DOI)" t)
-(autoload 'bibtex-set-field "doi-utils" "\
-Set FIELD to VALUE in bibtex file.  create field if it does not exist.
-Optional argument NODELIM see `bibtex-make-field'.
-
-(fn FIELD VALUE &optional NODELIM)" t)
-(autoload 'doi-utils-update-bibtex-entry-from-doi "doi-utils" "\
-Update fields in a bibtex entry from the DOI.
-Every field will be updated, so previous change will be lost.
-
-(fn DOI)" t)
-(autoload 'doi-utils-update-field "doi-utils" "\
-Update the field at point in the bibtex entry.
-Data is retrieved from the doi in the entry." t)
-(autoload 'doi-utils-wos "doi-utils" "\
-Open Web of Science entry for DOI.
-
-(fn DOI)" t)
-(autoload 'doi-utils-wos-citing "doi-utils" "\
-Open Web of Science citing articles entry for DOI.
-May be empty if none are found.
-
-(fn DOI)" t)
-(autoload 'doi-utils-wos-related "doi-utils" "\
-Open Web of Science related articles page for DOI.
-
-(fn DOI)" t)
-(autoload 'doi-utils-ads "doi-utils" "\
-Open ADS entry for DOI
-
-(fn DOI)" t)
-(autoload 'doi-utils-open "doi-utils" "\
-Open DOI in browser.
-
-(fn DOI)" t)
-(autoload 'doi-utils-open-bibtex "doi-utils" "\
-Search through variable `bibtex-completion-bibliography' for DOI.
-
-(fn DOI)" t)
-(autoload 'doi-utils-crossref "doi-utils" "\
-Search DOI in CrossRef.
-
-(fn DOI)" t)
-(autoload 'doi-utils-google-scholar "doi-utils" "\
-Google scholar the DOI.
-
-(fn DOI)" t)
-(autoload 'doi-utils-pubmed "doi-utils" "\
-Search Pubmed for the DOI.
-
-(fn DOI)" t)
-(autoload 'doi-utils-crossref-citation-query "doi-utils" "\
-Query Crossref with the title of the bibtex entry at point.
-Get a list of possible matches. Choose one with completion." t)
-(autoload 'doi-utils-debug "doi-utils" "\
-Generate an org-buffer showing data about DOI.
-
-(fn DOI)" t)
-(autoload 'doi-utils-add-entry-from-crossref-query "doi-utils" "\
-Search Crossref with QUERY and use completion to select an entry to add to BIBTEX-FILE.
-
-(fn QUERY BIBTEX-FILE)" t)
-(register-definition-prefixes "doi-utils" '("*doi-utils-" "agu-pdf-url" "aip-pdf-url" "aps-pdf-url" "arxiv-pdf-url" "chemistry-europe-pdf-url" "copernicus-" "crossref-add-bibtex-entry" "doi-" "ecs" "frontiers-pdf-url" "generic-full-pdf-url" "highwire-pdf-url" "ieee" "iop-pdf-url" "jneurosci-pdf-url" "jstor-pdf-url" "linkinghub-elsevier-pdf-url" "nature-pdf-url" "osa-pdf-url" "pnas-pdf-url" "rsc-pdf-url" "rss-pdf-url" "sage-pdf-url" "science-" "siam-pdf-url" "springer-" "tandfonline-pdf-url" "wiley-pdf-url-2"))
-
-\f
-;;; Generated autoloads from nist-webbook.el
-
-(autoload 'nist-webbook-formula "nist-webbook" "\
-Search NIST webbook for FORMULA.
-
-(fn FORMULA)" t)
-(autoload 'nist-webbook-name "nist-webbook" "\
-Search NIST webbook for NAME.
-
-(fn NAME)" t)
-
-\f
-;;; Generated autoloads from openalex.el
-
-(register-definition-prefixes "openalex" '("oa-" "org-ref-citation-hydra"))
-
-\f
-;;; Generated autoloads from org-ref-arxiv.el
-
-(autoload 'arxiv-add-bibtex-entry "org-ref-arxiv" "\
-Add bibtex entry for ARXIV-NUMBER to BIBFILE.
-
-(fn ARXIV-NUMBER BIBFILE)" t)
-(autoload 'arxiv-get-pdf "org-ref-arxiv" "\
-Retrieve a pdf for ARXIV-NUMBER and save it to PDF.
-
-(fn ARXIV-NUMBER PDF)" t)
-(autoload 'arxiv-get-pdf-add-bibtex-entry "org-ref-arxiv" "\
-Add bibtex entry for ARXIV-NUMBER to BIBFILE.
-Remove troublesome chars from the bibtex key, retrieve a pdf
-for ARXIV-NUMBER and save it to PDFDIR with the same name of the
-key.
-
-(fn ARXIV-NUMBER BIBFILE PDFDIR)" t)
-(register-definition-prefixes "org-ref-arxiv" '("arxiv-"))
-
-\f
-;;; Generated autoloads from org-ref-bibliography-links.el
-
-(register-definition-prefixes "org-ref-bibliography-links" '("org-ref-"))
-
-\f
-;;; Generated autoloads from org-ref-bibtex.el
-
-(autoload 'org-ref-bibtex-generate-longtitles "org-ref-bibtex" "\
-Generate longtitles.bib which are @string definitions.
-The full journal names are in `org-ref-bibtex-journal-abbreviations'." t)
-(autoload 'org-ref-bibtex-generate-shorttitles "org-ref-bibtex" "\
-Generate shorttitles.bib which are @string definitions.
-The abbreviated journal names in `org-ref-bibtex-journal-abbreviations'." t)
-(autoload 'org-ref-stringify-journal-name "org-ref-bibtex" "\
-Replace journal name in a bibtex entry with a string.
-The strings are defined in
-`org-ref-bibtex-journal-abbreviations'.  The optional arguments KEY,
-START and END allow you to use this with `bibtex-map-entries'
-
-(fn &optional KEY START END)" t)
-(autoload 'org-ref-set-journal-string "org-ref-bibtex" "\
-Set a bibtex journal name to the string that represents FULL-JOURNAL-NAME.
-This is defined in `org-ref-bibtex-journal-abbreviations'.
-
-(fn FULL-JOURNAL-NAME)" t)
-(autoload 'org-ref-replace-nonascii "org-ref-bibtex" "\
-Replace non-ascii characters with LaTeX representations in a
-bibtex entry." t)
-(autoload 'org-ref-title-case "org-ref-bibtex" "\
-Convert a bibtex entry title and booktitle to title-case.
-Convert only if the entry type is a member of the list
-`org-ref-title-case-types'. The arguments KEY, START and END are
-optional, and are only there so you can use this function with
-`bibtex-map-entries' to change all the title entries in articles and
-books.
-
-(fn &optional KEY START END)" t)
-(autoload 'org-ref-title-case-article "org-ref-bibtex" "\
-Convert a bibtex entry article or book title to title-case.
-The arguments KEY, START and END are optional, and are only there
-so you can use this function with `bibtex-map-entries' to change
-all the title entries in articles and books.
-
-(fn &optional KEY START END)" t)
-(autoload 'org-ref-sentence-case-article "org-ref-bibtex" "\
-Convert a bibtex entry article title to sentence-case.
-The arguments KEY, START and END are optional, and are only there
-so you can use this function with `bibtex-map-entries' to change
-all the title entries in articles.
-
-(fn &optional KEY START END)" t)
-(autoload 'org-ref-bibtex-next-entry "org-ref-bibtex" "\
-Jump to the beginning of the next bibtex entry.
-N is a prefix argument.  If it is numeric, jump that many entries
-forward.  Negative numbers do nothing.
-
-(fn &optional N)" t)
-(autoload 'org-ref-bibtex-previous-entry "org-ref-bibtex" "\
-Jump to beginning of the previous bibtex entry.
-N is a prefix argument.  If it is numeric, jump that many entries back.
-
-(fn &optional N)" t)
-(autoload 'org-ref-bibtex-visible-entry "org-ref-bibtex" "\
-Jump to visible entry." t)
-(autoload 'org-ref-bibtex-visible-field "org-ref-bibtex" "\
-Jump to visible field." t)
-(autoload 'org-ref-bibtex-format-url-if-doi "org-ref-bibtex" "\
-Hook function to format url to follow the current DOI conventions." t)
-(autoload 'org-ref-bibtex-wos "org-ref-bibtex" "\
-Open bibtex entry in Web Of Science if there is a DOI." t)
-(autoload 'org-ref-bibtex-wos-citing "org-ref-bibtex" "\
-Open citing articles for bibtex entry in Web Of Science if
-there is a DOI." t)
-(autoload 'org-ref-bibtex-wos-related "org-ref-bibtex" "\
-Open related articles for bibtex entry in Web Of Science if
-there is a DOI." t)
-(autoload 'org-ref-bibtex-crossref "org-ref-bibtex" "\
-Open the bibtex entry in Crossref by its doi." t)
-(autoload 'org-ref-bibtex-google-scholar "org-ref-bibtex" "\
-Open the bibtex entry at point in google-scholar by its doi." t)
-(autoload 'org-ref-bibtex-pubmed "org-ref-bibtex" "\
-Open the bibtex entry at point in Pubmed by its doi." t)
-(autoload 'org-ref-bibtex-pdf "org-ref-bibtex" "\
-Open the pdf for the bibtex entry at point.
-Thin wrapper to get `org-ref-bibtex' to open pdf, because it
-calls functions with a DOI argument.
-
-(fn &optional _)" t)
-(autoload 'org-ref-bibtex-assoc-pdf-with-entry "org-ref-bibtex" "\
-Prompt for pdf associated with entry at point and rename it.
-Check whether a pdf already exists in `bibtex-completion-library' with the
-name '[bibtexkey].pdf'. If the file does not exist, rename it to
-'[bibtexkey].pdf' using
-`org-ref-bibtex-assoc-pdf-with-entry-move-function' and place it in
-a directory. Optional PREFIX argument toggles between
-`rename-file' and `copy-file'.
-
-(fn &optional PREFIX)" t)
-(autoload 'org-ref-email-bibtex-entry "org-ref-bibtex" "\
-Email current bibtex entry at point and pdf if it exists." t)
-(autoload 'org-ref-set-bibtex-keywords "org-ref-bibtex" "\
-Add KEYWORDS to a bibtex entry.
-If KEYWORDS is a list, it is converted to a comma-separated
-string.  The KEYWORDS are added to the beginning of the
-field.  Otherwise KEYWORDS should be a string of comma-separate
-keywords.  Optional argument ARG prefix arg to replace keywords.
-
-(fn KEYWORDS &optional ARG)" t)
-(autoload 'org-ref-extract-bibtex-blocks "org-ref-bibtex" "\
-Extract all bibtex blocks in buffer to BIBFILE.
-If BIBFILE exists, append, unless you use a prefix arg (C-u), which
-will clobber the file.
-
-(fn BIBFILE)" t)
-(autoload 'org-ref-open-bibtex-pdf "org-ref-bibtex" "\
-Open pdf for a bibtex entry, if it exists." t)
-(autoload 'org-ref-open-bibtex-notes "org-ref-bibtex" "\
-From a bibtex entry, open the notes if they exist." t)
-(autoload 'org-ref-open-in-browser "org-ref-bibtex" "\
-Open the bibtex entry at point in a browser using the url field or doi field." t)
-(autoload 'org-ref-build-full-bibliography "org-ref-bibtex" "\
-Build pdf of all bibtex entries, and open it." t)
-(autoload 'org-ref-sort-bibtex-entry "org-ref-bibtex" "\
-Sort fields of entry in standard order." t)
-(autoload 'org-ref-downcase-bibtex-entry "org-ref-bibtex" "\
-Downcase the entry type and fields." t)
-(autoload 'org-ref-clean-bibtex-entry "org-ref-bibtex" "\
-Clean and replace the key in a bibtex entry.
-See functions in `org-ref-clean-bibtex-entry-hook'." t)
-(register-definition-prefixes "org-ref-bibtex" '("orcb-" "org-ref-"))
-
-\f
-;;; Generated autoloads from org-ref-citation-links.el
-
-(autoload 'org-ref-delete-citation-at-point "org-ref-citation-links" "\
-Delete the citation or reference at point." t)
-(autoload 'org-ref-replace-citation-at-point "org-ref-citation-links" "\
-Replace the citation at point." t)
-(autoload 'org-ref-edit-pre-post-notes "org-ref-citation-links" "\
-Edit the pre/post notes at point.
-
-if you are not on a key, or with optional prefix
-arg COMMON, edit the common prefixes instead.
-
-(fn &optional COMMON)" t)
-(autoload 'org-ref-change-cite-type "org-ref-citation-links" "\
-Change the cite type of citation link at point." t)
-(autoload 'org-ref-sort-citation-link "org-ref-citation-links" "\
-Replace link at point with sorted link by year." t)
-(autoload 'org-ref-next-key "org-ref-citation-links" "\
-Move cursor to the next cite key when on a cite link.
-Otherwise run `right-word'. If the cursor moves off the link,
-move to the beginning of the next cite link after this one." t)
-(autoload 'org-ref-previous-key "org-ref-citation-links" "\
-Move cursor to the previous cite key when on a cite link.
-Otherwise run `left-word'. If the cursor moves off the link,
-move to the beginning of the previous cite link after this one." t)
-(autoload 'org-ref-jump-to-visible-key "org-ref-citation-links" "\
-Jump to a visible key with avy." t)
-(autoload 'org-ref-insert-cite-link "org-ref-citation-links" "\
-Insert a cite link with completion.
-Optional prefix arg SET-TYPE to choose the cite type.
-
-(fn &optional SET-TYPE)" t)
-(register-definition-prefixes "org-ref-citation-links" '("org-ref-"))
-
-\f
-;;; Generated autoloads from org-ref-compat.el
-
-(register-definition-prefixes "org-ref-compat" '("org-ref-to-org-cite"))
-
-\f
-;;; Generated autoloads from org-ref-core.el
-
-(autoload 'org-ref-insert-link "org-ref-core" "\
-Insert an org-ref link.
-If no prefix ARG insert a cite.
-If one prefix ARG insert a ref.
-If two prefix ARGs insert a label.
-
-This is a generic function. Specific backends might
-provide their own version.
-
-(fn ARG)" t)
-(autoload 'org-ref-help "org-ref-core" "\
-Open the `org-ref' manual." t)
-(register-definition-prefixes "org-ref-core" '("org-ref-"))
-
-\f
-;;; Generated autoloads from org-ref-export.el
-
-(register-definition-prefixes "org-ref-export" '("org-ref"))
-
-\f
-;;; Generated autoloads from org-ref-extract.el
-
-(register-definition-prefixes "org-ref-extract" '("org-ref-"))
-
-\f
-;;; Generated autoloads from org-ref-glossary.el
-
-(register-definition-prefixes "org-ref-glossary" '("or-" "org-ref-"))
-
-\f
-;;; Generated autoloads from org-ref-helm.el
-
-(autoload 'org-ref-cite-insert-helm "org-ref-helm" "\
-Search BibTeX entries.
-
-With a prefix ARG, the cache is invalidated and the bibliography
-reread.
-
-If LOCAL-BIB is non-nil, display that the BibTeX entries are read
-from the local bibliography.  This is set internally by
-`helm-bibtex-with-local-bibliography'.
-
-If INPUT is non-nil and a string, that value is going to be used
-as a predefined search term.  Can be used to define functions for
-frequent searches (e.g. your own publications).
-
-(fn &optional ARG LOCAL-BIB INPUT)" t)
-(register-definition-prefixes "org-ref-helm" '("org-ref-helm-source-"))
-
-\f
-;;; Generated autoloads from org-ref-isbn.el
-
-(autoload 'org-ref-isbn-clean-bibtex-entry "org-ref-isbn" "\
-Clean a bibtex entry inserted via `isbn-to-bibtex'.
-See functions in `org-ref-isbn-clean-bibtex-entry-hook'." t)
-(autoload 'isbn-to-bibtex-lead "org-ref-isbn" "\
-Search lead.to for ISBN bibtex entry.
-You have to copy the entry if it is on the page to your bibtex
-file.
-
-(fn ISBN)" t)
-(autoload 'isbn-to-bibtex "org-ref-isbn" "\
-Get bibtex entry for ISBN and insert it into BIBFILE.
-Nothing happens if an entry with the generated key already exists
-in the file. Data comes from www.ebook.de.
-
-(fn ISBN BIBFILE)" t)
-(register-definition-prefixes "org-ref-isbn" '("isbn-to-bibtex-open-library" "org-ref-isbn-" "oricb-"))
-
-\f
-;;; Generated autoloads from org-ref-ivy.el
-
-(register-definition-prefixes "org-ref-ivy" '("org-ref-"))
-
-\f
-;;; Generated autoloads from org-ref-label-link.el
-
-(autoload 'org-ref-insert-label-link "org-ref-label-link" "\
-Insert a new label with completion.
-The completion helps ensure you use a unique label." t)
-
-\f
-;;; Generated autoloads from org-ref-latex.el
-
-(register-definition-prefixes "org-ref-latex" '("org-ref-" "orl-"))
-
-\f
-;;; Generated autoloads from org-ref-misc-links.el
-
-(autoload 'org-ref-list-of-figures "org-ref-misc-links" "\
-Generate buffer with list of figures in them.
-ARG does nothing.
-Ignore figures in COMMENTED sections.
-
-(fn &optional ARG)" t)
-(autoload 'org-ref-list-of-tables "org-ref-misc-links" "\
-Generate a buffer with a list of tables.
-ARG does nothing.
-
-(fn &optional ARG)" t)
-(autoload 'org-ref-index "org-ref-misc-links" "\
-Open an *index* buffer with links to index entries.
-PATH is required for the org-link, but it does nothing here.
-
-(fn &optional PATH)" t)
-(register-definition-prefixes "org-ref-misc-links" '("org-ref-idxproc"))
-
-\f
-;;; Generated autoloads from org-ref-natbib-bbl-citeproc.el
-
-(register-definition-prefixes "org-ref-natbib-bbl-citeproc" '("org-"))
-
-\f
-;;; Generated autoloads from org-ref-pdf.el
-
-(autoload 'org-ref-pdf-to-bibtex "org-ref-pdf" "\
-Add pdf of current buffer to bib file and save pdf. The pdf
-should be open in Emacs using the `pdf-tools' package." t)
-(autoload 'org-ref-pdf-debug-pdf "org-ref-pdf" "\
-Try to debug getting a doi from a pdf.
-Opens a buffer with the pdf converted to text, and `occur' on the
-variable `org-ref-pdf-doi-regex'.
-
-(fn PDF-FILE)" t)
-(autoload 'org-ref-pdf-crossref-lookup "org-ref-pdf" "\
-Lookup highlighted text in PDFView in CrossRef." t)
-(register-definition-prefixes "org-ref-pdf" '("org-ref-" "pdftotext-executable"))
-
-\f
-;;; Generated autoloads from org-ref-publish.el
-
-(register-definition-prefixes "org-ref-publish" '("org-ref-publish-"))
-
-\f
-;;; Generated autoloads from org-ref-pubmed.el
-
-(autoload 'pubmed-insert-bibtex-from-pmid "org-ref-pubmed" "\
-Insert a bibtex entry at point derived from PMID.
-You must clean the entry after insertion.
-
-(fn PMID)" t)
-(autoload 'pubmed "org-ref-pubmed" "\
-Open http://www.ncbi.nlm.nih.gov/pubmed in a browser." t)
-(autoload 'pubmed-advanced "org-ref-pubmed" "\
-Open http://www.ncbi.nlm.nih.gov/pubmed/advanced in a browser." t)
-(autoload 'pubmed-simple-search "org-ref-pubmed" "\
-Open QUERY in Pubmed in a browser.
-
-(fn QUERY)" t)
-(autoload 'pubmed-clinical "org-ref-pubmed" "\
-Open http://www.ncbi.nlm.nih.gov/pubmed/clinical in a browser." t)
-(autoload 'pubmed-clinical-search "org-ref-pubmed" "\
-Open QUERY in pubmed-clinical.
-
-(fn QUERY)" t)
-(register-definition-prefixes "org-ref-pubmed" '("pubmed-"))
-
-\f
-;;; Generated autoloads from org-ref-ref-links.el
-
-(register-definition-prefixes "org-ref-ref-links" '("org-ref-"))
-
-\f
-;;; Generated autoloads from org-ref-refproc.el
-
-(register-definition-prefixes "org-ref-refproc" '("org-ref-"))
-
-\f
-;;; Generated autoloads from org-ref-scifinder.el
-
-(autoload 'scifinder "org-ref-scifinder" "\
-Open https://scifinder.cas.org/scifinder/view/scifinder/scifinderExplore.jsf in a browser." t)
-
-\f
-;;; Generated autoloads from org-ref-scopus.el
-
-(autoload 'scopus-related-by-keyword-url "org-ref-scopus" "\
-Return a Scopus url to articles related by keyword for DOI.
-
-(fn DOI)" t)
-(autoload 'scopus-related-by-author-url "org-ref-scopus" "\
-Return a Scopus url to articles related by author for DOI.
-
-(fn DOI)" t)
-(autoload 'scopus-related-by-references-url "org-ref-scopus" "\
-Return a Scopus url to articles related by references for DOI.
-
-(fn DOI)" t)
-(autoload 'scopus-open-eid "org-ref-scopus" "\
-Open article with EID in browser.
-
-(fn EID)" t)
-(autoload 'scopus-basic-search "org-ref-scopus" "\
-Open QUERY as a basic title-abstract-keyword search at scopus.com.
-
-(fn QUERY)" t)
-(autoload 'scopus-advanced-search "org-ref-scopus" "\
-Open QUERY as an advanced search at scopus.com.
-
-(fn QUERY)" t)
-(register-definition-prefixes "org-ref-scopus" '("*hydra-eid*" "*scopus-api-key*" "scopus"))
-
-\f
-;;; Generated autoloads from org-ref-url-utils.el
-
-(autoload 'org-ref-url-debug-url "org-ref-url-utils" "\
-Open a buffer to URL with all doi patterns highlighted.
-
-(fn URL)" t)
-(autoload 'org-ref-url-html-to-bibtex "org-ref-url-utils" "\
-Convert URL to a bibtex or biblatex entry in BIBFILE.
-If URL is the first in the kill ring, use it. Otherwise, prompt for
-one in the minibuffer.
-
-(fn BIBFILE &optional URL)" t)
-(register-definition-prefixes "org-ref-url-utils" '("org-ref-"))
-
-\f
-;;; Generated autoloads from org-ref-utils.el
-
-(autoload 'org-ref-version "org-ref-utils" "\
-Provide a version string for org-ref.
-Copies the string to the clipboard." t)
-(autoload 'org-ref-debug "org-ref-utils" "\
-Print some debug information to a buffer." t)
-(autoload 'org-ref-open-pdf-at-point "org-ref-utils" "\
-Open the pdf for bibtex key under point if it exists." t)
-(autoload 'org-ref-add-pdf-at-point "org-ref-utils" "\
-Add the pdf for bibtex key under point if it exists.
-
-Similar to org-ref-bibtex-assoc-pdf-with-entry prompt for pdf
-associated with bibtex key at point and rename it.  Check whether a
-pdf already exists in `bibtex-completion-library' with the name
-'[bibtexkey].pdf'. If the file does not exist, rename it to
-'[bibtexkey].pdf' using
-`org-ref-bibtex-assoc-pdf-with-entry-move-function' and place it
-in a directory. Optional PREFIX argument toggles between
-`rename-file' and `copy-file'.
-
-(fn &optional PREFIX)" t)
-(autoload 'org-ref-open-url-at-point "org-ref-utils" "\
-Open the url for bibtex key under point." t)
-(autoload 'org-ref-open-notes-at-point "org-ref-utils" "\
-Open the notes for bibtex key under point in a cite link in a buffer.
-Can also be called with THEKEY in a program.
-
-(fn &optional THEKEY)" t)
-(autoload 'org-ref-open-citation-at-point "org-ref-utils" "\
-Open bibtex file to key at point." t)
-(autoload 'org-ref-copy-entry-as-summary "org-ref-utils" "\
-Copy the bibtex entry for the citation at point as a summary." t)
-(autoload 'org-ref-ads-at-point "org-ref-utils" "\
-Open the doi in ADS for bibtex key under point." t)
-(autoload 'org-ref-wos-at-point "org-ref-utils" "\
-Open the doi in wos for bibtex key under point." t)
-(autoload 'org-ref-wos-citing-at-point "org-ref-utils" "\
-Open the doi in wos citing articles for bibtex key under point." t)
-(autoload 'org-ref-wos-related-at-point "org-ref-utils" "\
-Open the doi in wos related articles for bibtex key under point." t)
-(autoload 'org-ref-google-scholar-at-point "org-ref-utils" "\
-Search google scholar for bibtex key under point using the title." t)
-(autoload 'org-ref-biblio-at-point "org-ref-utils" "\
-Do a biblio search for bibtex key under point using the title." t)
-(autoload 'org-ref-pubmed-at-point "org-ref-utils" "\
-Open the doi in pubmed for bibtex key under point." t)
-(autoload 'org-ref-crossref-at-point "org-ref-utils" "\
-Open the doi in crossref for bibtex key under point." t)
-(autoload 'org-ref-email-at-point "org-ref-utils" "\
-Email the citation(s) at point." t)
-(autoload 'org-ref-find-non-ascii-characters "org-ref-utils" "\
-Find non-ascii characters in the buffer.  Useful for cleaning up bibtex files." t)
-(autoload 'org-ref-extract-bibtex-to-file "org-ref-utils" "\
-Extract all bibtex entries for citations buffer to BIBFILE.
-If BIBFILE exists, append, unless you use a prefix arg (C-u),
-which will CLOBBER the file.
-
-(fn BIBFILE &optional CLOBBER)" t)
-(autoload 'org-ref-extract-bibtex-entries "org-ref-utils" "\
-Extract the bibtex entries in the current buffer into a bibtex src block." t)
-(autoload 'org-ref-extract-cited-pdfs "org-ref-utils" "\
-Copy PDFs in citations in current buffer to NEWDIR.
-
-(fn NEWDIR)" t)
-(register-definition-prefixes "org-ref-utils" '("ords" "org-ref"))
-
-\f
-;;; Generated autoloads from org-ref-worldcat.el
-
-(register-definition-prefixes "org-ref-worldcat" '("worldcat-query-all"))
-
-\f
-;;; Generated autoloads from org-ref-wos.el
-
-(autoload 'wos-search "org-ref-wos" "\
-Open the word at point or selection in Web of Science as a topic query." t)
-(autoload 'wos "org-ref-wos" "\
-Open Web of Science search page in a browser." t)
-(register-definition-prefixes "org-ref-wos" '("*wos-" "wos-"))
-
-\f
-;;; Generated autoloads from x2bib.el
-
-(autoload 'ris2bib "x2bib" "\
-Convert RISFILE to bibtex and insert at point.
-Without a prefix arg, stderr is diverted.
-If VERBOSE is non-nil show command output.
-If the region is active, assume it is a ris entry
-and convert it to bib format in place.
-
-(fn RISFILE &optional VERBOSE)" t)
-(autoload 'medxml2bib "x2bib" "\
-Convert MEDFILE (in Pubmed xml) to bibtex and insert at point.
-Without a prefix arg, stderr is diverted.
-Display output if VERBOSE is non-nil.
-
-(fn MEDFILE &optional VERBOSE)" t)
-(autoload 'clean-entries "x2bib" "\
-Map over bibtex entries and clean them." t)
-\f
-;;; End of scraped data
-
-(provide 'org-ref-autoloads)
-
-;; Local Variables:
-;; version-control: never
-;; no-byte-compile: t
-;; no-update-autoloads: t
-;; no-native-compile: t
-;; coding: utf-8-emacs-unix
-;; End:
-
-;;; org-ref-autoloads.el ends here
diff --git a/elpa/org-ref-20241124.2012/org-ref-bibliography-links.el b/elpa/org-ref-20241124.2012/org-ref-bibliography-links.el
deleted file mode 100644 (file)
index 6deb0b1..0000000
+++ /dev/null
@@ -1,316 +0,0 @@
-;;; org-ref-bibliography-links.el --- Bibliography and bibliographystyle links -*- lexical-binding: t; -*-
-;;
-;; Copyright (C) 2024  John Kitchin
-
-;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
-;; Keywords: convenience
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
-;;
-;;; Commentary:
-;;
-
-;;; Code:
-
-(defcustom org-ref-latex-bib-resolve-func #'file-relative-name
-  "Function to expand paths to the bibliography file on latex export.
-Use this to convert a path to what you want, e.g. relative to
-some directory, absolute, etc."
-  :type 'function
-  :group 'org-ref)
-
-
-(defcustom org-ref-validate-bibliography nil
-  "If non-nil, validate bibliography files in fontification.
-This can be slow, so we don't do it by default."
-  :type 'boolean
-  :group 'org-ref)
-
-
-;;* bibliography* links
-
-(defun org-ref-get-bibfile-path (bibfile)
-  "Get a path to BIBFILE as local file, or using kpsewhich.
-This should allow you to use a bib file that is setup with TeX
-variables like BIBINPUTS."
-  (or (when (file-exists-p bibfile) bibfile)
-      (let ((f (replace-regexp-in-string
-               "\n$" ""
-               (shell-command-to-string (format "kpsewhich %s" bibfile)))))
-       (unless (string= "" f)
-         f))))
-
-
-(defun org-ref-bibliography*-export (cmd bibfiles _desc backend)
-  "Exporting function for bibliography links.
-To be used as a partial function e.g.
- (apply-partially \"bibliography\" 'org-ref-bibliography*-export)
-Argument CMD is the command it should export to.
-Argument BIBFILES is a comma-separated list of strings.
-Argument BACKEND is the export backend."
-  (cond
-   ((eq backend 'latex)
-    (format "%s{%s}"
-           cmd
-           (if (not (string= "" bibfiles)) 
-               (replace-regexp-in-string
-                "\\.bib" ""
-                (mapconcat
-                 'identity
-                 (mapcar
-                  (lambda (f)
-                    (funcall org-ref-latex-bib-resolve-func (org-ref-get-bibfile-path f)))
-                  (split-string bibfiles ","))
-                 ","))
-             "")))))
-
-
-(defun org-ref-bibliography-activate (start end path _bracketp)
-  "Activate a bibliography link.
-Adds a warning face to non-existent or invalid bib-files.
-START and END are the bounds of the link.
-PATH is a comma-separated list of bibfiles."
-  (goto-char start)
-  (cl-loop for p in (split-string path ",") do
-          (setq p (string-trim p))
-          (search-forward p)
-          (setq p (org-ref-get-bibfile-path p))
-          (put-text-property (match-beginning 0) (match-end 0) 'org-ref-bibfile p)
-          (put-text-property (match-beginning 0) (match-end 0) 'help-echo (format "File exists at %s" p))
-
-          ;; activate files that don't exist
-          (when (or (null p) (not (file-exists-p p)))
-            (put-text-property (match-beginning 0) (match-end 0)
-                               'face 'font-lock-warning-face)
-            (put-text-property (match-beginning 0) (match-end 0)
-                               'help-echo "This file was not found."))
-
-          (when (and p (file-exists-p p))
-            (when org-ref-validate-bibliography
-              ;; Let's do a validation, but only if it has changed since the last time we checked.
-              (let* ((mod-time-last-check (or (get-text-property (match-beginning 0)
-                                                                 'mod-time-last-check)
-                                              '(0 0 0 0)))
-                     (last-modified (file-attribute-modification-time (file-attributes p)))
-                     (bibtex-valid))
-                (if (time-equal-p mod-time-last-check last-modified)
-                    (setq bibtex-valid (get-text-property (match-beginning 0) 'bibtex-valid))
-
-                  ;; the times were not equal, so we check and store the state.
-                  (setq bibtex-valid (save-match-data
-                                       (with-current-buffer (find-file-noselect p)
-                                         (bibtex-validate))))
-                  (put-text-property (match-beginning 0)
-                                     (match-end 0)
-                                     'mod-time-last-check
-                                     last-modified)
-                  (put-text-property (match-beginning 0)
-                                     (match-end 0)
-                                     'bibtex-valid
-                                     bibtex-valid))
-
-                (unless bibtex-valid
-                  (put-text-property (match-beginning 0) (match-end 0)
-                                     'face 'font-lock-warning-face)
-                  (put-text-property (match-beginning 0) (match-end 0)
-                                     'help-echo "This file did not pass `bibtex-validate'.")))))))
-
-
-(defun org-ref-bibliography*-follow (_path)
-  "Function to follow bibliography links."
-  (interactive)
-  (save-excursion
-    (unless (get-text-property (point) 'org-ref-bibfile)
-      (re-search-forward ":"))
-    (find-file (org-ref-get-bibfile-path (get-text-property (point) 'org-ref-bibfile)))))
-
-
-(defun org-ref-printbibliography-export (options _desc backend)
-  "Export function for printbibliography links.
-Argument OPTIONS are the options used for the command.
-Optional argument BACKEND is the export backend."
-  (cond
-   ((eq backend 'latex)
-    ;; write out the biblatex bibliography command
-    (format "\\printbibliography%s"
-           (if (not (string= "" options))
-               (format "[%s]" options)
-             "")))))
-
-(defvar org-ref-cite-types)
-(declare-function org-element-map "org-element")
-(declare-function org-element-property "org-element")
-(declare-function org-element-parse-buffer "org-element")
-(declare-function bibtex-completion-show-entry "bibtex-completion")
-(declare-function org-ref-possible-bibfiles "org-ref-core")
-(declare-function org-ref-parse-cite-path "org-ref-citation-links")
-
-(defun org-ref-insert-bibliography-link ()
-  "Insert a bibliography link for the files used in this buffer."
-  (interactive)
-  (let* ((cite-links (org-element-map (org-element-parse-buffer) 'link
-                      (lambda (lnk)
-                        (when (assoc (org-element-property :type lnk) org-ref-cite-types)
-                          lnk))))
-        (keys (delete-dups (cl-loop for cl in cite-links append
-                                    (cl-loop for ref in (plist-get (org-ref-parse-cite-path
-                                                                    (org-element-property :path cl))
-                                                                   :references)
-                                             collect (plist-get ref :key)))))
-        (files (delete-dups (cl-loop for key in keys collect
-                                     (save-window-excursion
-                                       (bibtex-completion-show-entry (list key))
-                                       (buffer-file-name))))))
-    (insert (format "[[bibliography:%s]]" (string-join files ",")))))
-
-
-(defun org-ref-bibliography-complete (&optional arg)
-  "Completion function for bibliography links."
-  (concat "bibliography:"
-         (completing-read "Bibliography file: " (org-ref-possible-bibfiles))))
-
-(defun org-ref-nobibliography-complete (&optional arg)
-  "Completion function for bibliography links."
-  (concat "nobibliography:"
-         (completing-read "Bibliography file: " (org-ref-possible-bibfiles))))
-
-
-(defvar org-ref-default-citation-link)
-
-(defun org-ref-bibtex-store-link ()
-  "Store a link from a bibtex file. Only supports the cite link.
-This essentially the same as the store link in org-bibtex, but it
-creates a cite link."
-  (when (eq major-mode 'bibtex-mode)
-    (let ((link (concat org-ref-default-citation-link
-                       ":&"
-                       (save-excursion
-                          (bibtex-beginning-of-entry)
-                         (cdr (assoc "=key=" (bibtex-parse-entry)))))))
-      (push (list link) org-stored-links)
-      (car org-stored-links))))
-
-
-;; ** bibliography* links
-
-(org-link-set-parameters "bibliography"
-                        :follow #'org-ref-bibliography*-follow
-                        :store #'org-ref-bibtex-store-link
-                        :complete #'org-ref-bibliography-complete
-                        :help-echo "Bibliography link"
-                        :export (apply-partially 'org-ref-bibliography*-export "\\bibliography")
-                        :activate-func #'org-ref-bibliography-activate
-                        :face 'org-link)
-
-
-(org-link-set-parameters "nobibliography"
-                        :complete #'org-ref-nobibliography-complete
-                        :store #'org-ref-bibtex-store-link
-                        :help-echo "No bibliography link"
-                        :activate-func #'org-ref-bibliography-activate
-                        :follow #'org-ref-bibliography*-follow
-                        :export (apply-partially 'org-ref-bibliography*-export "\\nobibliography")
-                        :face 'org-link)
-
-
-(org-link-set-parameters "nobibliography*"
-                        :complete #'org-ref-nobibliography-complete
-                        :store #'org-ref-bibtex-store-link
-                        :help-echo "No bibliography link"
-                        :activate-func #'org-ref-bibliography-activate
-                        :follow #'org-ref-bibliography*-follow
-                        :export (apply-partially 'org-ref-bibliography*-export "\\nobibliography*")
-                        :face 'org-link)
-
-
-(org-link-set-parameters "printbibliography"
-                        :export #'org-ref-printbibliography-export)
-
-;; Note I removed the addbibresource link, it goes in the header, not the document.
-
-;; *** bibliographystyle
-(defvar-local org-ref-bst-styles nil
-  "A list of known bibliography styles. Used to cache results.")
-
-
-(defun org-ref-clear-bst-cache ()
-  "Clear `org-ref-bst-styles' to reload it."
-  (interactive)
-  (setq org-ref-bst-styles nil))
-
-
-(defun org-ref-bibliography-styles ()
-  "Return a list of known bibliography styles.
-Returns `org-ref-bst-styles' or sets it and returns it."
-  (or org-ref-bst-styles
-      (setq org-ref-bst-styles
-           (mapcar 'file-name-nondirectory
-                   (mapcar 'file-name-sans-extension
-                           (-flatten
-                            (mapcar (lambda (path)
-                                      (setq path (replace-regexp-in-string "!" "" path))
-                                      (when (file-directory-p path)
-                                        (f-entries path (lambda (f) (f-ext? f "bst")))))
-                                    (split-string
-                                     ;; https://tex.stackexchange.com/questions/431948/get-a-list-of-installed-bibliography-styles-with-kpsewhich?noredirect=1#comment1082436_431948
-                                     (shell-command-to-string "kpsewhich -expand-path '$BSTINPUTS'")
-                                     ":"))))))))
-
-
-(defun org-ref-bibliographystyle-complete-link (&optional arg)
-  "Completion function for bibliography style links.
-ARG is a not used."
-  (when (executable-find "kpsewhich")
-    (concat "bibliographystyle:"
-           (completing-read "Style: " (org-ref-bibliography-styles)))))
-
-
-(defun org-ref-bibliographystyle-activate (start _end path _bracketp)
-  "Activation function for bibliography styles.
-START is the beginning position of the link.
-Optional argument PATH contains the selected style."
-  (unless (member path (org-ref-bibliography-styles))
-    (goto-char start)
-    (search-forward path)
-    (put-text-property (match-beginning 0) (match-end 0) 'face 'font-lock-warning-face)
-    (put-text-property (match-beginning 0) (match-end 0) 'help-echo "Unrecognized style")))
-
-
-(defun org-ref-bibliographystyle-export (style _desc backend)
-  "Export function for bibliographystyle links.
-Argument STYLE is the desired style.
-Optional argument BACKEND is the export backend."
-  (cond
-   ((or (eq backend 'latex)
-       (eq backend 'beamer))
-    ;; write out the latex bibliography command
-    (format "\\bibliographystyle{%s}" style))
-   ;; No other backend needs this I think
-   (t
-    "")))
-
-
-(org-link-set-parameters "bibliographystyle"
-                        :complete #'org-ref-bibliographystyle-complete-link
-                        :activate-func #'org-ref-bibliographystyle-activate
-                        :export #'org-ref-bibliographystyle-export)
-
-
-(provide 'org-ref-bibliography-links)
-
-;;; org-ref-bibliography-links.el ends here
-
-;; Local Variables:
-;; byte-compile-warnings: (not docstrings)
-;; End:
diff --git a/elpa/org-ref-20241124.2012/org-ref-bibtex.el b/elpa/org-ref-20241124.2012/org-ref-bibtex.el
deleted file mode 100644 (file)
index 3c66683..0000000
+++ /dev/null
@@ -1,1467 +0,0 @@
-;;; org-ref-bibtex.el -- org-ref-bibtex utilities -*- lexical-binding: t; -*-
-
-;; Copyright(C) 2014-2024 John Kitchin
-
-;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
-;; URL: https://github.com/jkitchin/org-ref
-;; Keywords: org-mode, bibtex
-
-;; This file is not currently part of GNU Emacs.
-
-;; This program is free software; you can redistribute it and/or
-;; modify it under the terms of the GNU General Public License as
-;; published by the Free Software Foundation; either version 2, or (at
-;; your option) any later version.
-
-;; This program is distributed in the hope that it will be useful, but
-;; WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-;; General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program ; see the file COPYING.  If not, write to
-;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
-
-;;; Commentary:
-
-
-;; Functions to act on a bibtex entry or file
-;;
-;; ** Modifying bibtex entries
-;; - `org-ref-sort-bibtex-entry' :: sort the fields in an entry
-;; - `org-ref-downcase-bibtex-entry' :: downcase the fields in an entry
-;; - `org-ref-clean-bibtex-entry' :: run hooks in `org-ref-clean-bibtex-entry-hook' on an entry
-;; - `org-ref-title-case-article' :: title case the title in an article or book
-;; - `org-ref-sentence-case-article' :: sentence case the title in an article.
-;; org-ref-bibtex-generate-longtitles
-;; org-ref-bibtex-generate-shorttitles
-;; org-ref-stringify-journal-name :: replace a journal name with a string in
-;; `org-ref-bibtex-journal-abbreviations'
-;; org-ref-set-journal-string :: in a bibtex entry run this to replace the
-;; journal with a string
-;;
-
-;; * Navigating bibtex entries
-;; `org-ref-bibtex-next-entry' :: bound to M-n
-;; `org-ref-bibtex-previous-entry' :: bound to M-p
-
-;;
-;; ** Operate on whole bibtex file
-;; - `org-ref-build-full-bibliography'
-;; org-ref-replace-nonascii :: replace nonascii characters in a bibtex
-;; entry.  Replacements are in `org-ref-nonascii-latex-replacements'.
-;;
-;; ** hydra menu for bibtex files
-;; `org-ref-bibtex-hydra/body' gives a hydra menu to a lot of useful functions.
-;; `org-ref-bibtex-new-entry/body' gives a hydra menu to add new bibtex entries.
-;; `org-ref-bibtex-file/body' gives a hydra menu of actions for the bibtex file
-;;
-;;; Code
-
-(require 'bibtex)
-(require 'dash)
-(require 'hydra)
-(require 'message)
-(require 's)
-(require 'doi-utils)
-(require 'avy)
-(require 'sgml-mode)
-
-(defvar bibtex-completion-bibliography)
-(defvar bibtex-completion-library-path)
-(declare-function bibtex-completion-show-entry "bibtex-completion")
-(declare-function org-ref-find-bibliography "org-ref-core")
-(declare-function org-element-property "org-element")
-
-;;* Custom variables
-(defgroup org-ref-bibtex nil
-  "Customization group for org-ref-bibtex."
-  :group 'org-ref-bibtex)
-
-
-(defcustom org-ref-shorten-authors nil
-  "If non-nil show only last names in the completion selection buffer."
-  :type 'boolean
-  :group 'org-ref-bibtex)
-
-
-(defcustom org-ref-bibtex-sort-order
-  '(("article"  . ("author" "title" "journal" "volume" "number" "pages" "year" "doi" "url"))
-    ("inproceedings" . ("author" "title" "booktitle" "year" "volume" "number" "pages" "doi" "url"))
-    ("book" . ("author" "title" "year" "publisher" "url")))
-  "A-list of bibtex entry fields and the order to sort an entry with.
-\(entry-type . (list of fields). This is used in
-`org-ref-sort-bibtex-entry'. Entry types not listed here will
-have fields sorted alphabetically."
-  :type '(alist :key-type (string) :value-type (repeat string))
-  :group 'org-ref)
-
-
-(defcustom orcb-%-replacement-string " \\\\%"
-  "Replacement for a naked % sign in cleaning a BibTeX entry.
-The replacement string should be escaped for use with
-`replace-match'. Compare to the default value. Common choices
-would be to omit the space or to replace the space with a ~ for a
-non-breaking space."
-  :type 'regexp
-  :group 'org-ref)
-
-
-(defcustom org-ref-clean-bibtex-key-function
-  (lambda (key)
-    (replace-regexp-in-string ":" "" key))
-  "Function to modify a bibtex key.
-The default behavior is to remove : from the key."
-  :type 'function
-  :group 'org-ref)
-
-
-(defcustom org-ref-clean-bibtex-entry-hook
-  '(org-ref-bibtex-format-url-if-doi
-    orcb-key-comma
-    org-ref-replace-nonascii
-    orcb-&
-    orcb-%
-    org-ref-title-case-article
-    orcb-clean-year
-    orcb-key
-    orcb-clean-doi
-    orcb-clean-pages
-    orcb-check-journal
-    org-ref-sort-bibtex-entry
-    orcb-fix-spacing
-    orcb-download-pdf)
-  "Hook that is run in `org-ref-clean-bibtex-entry'.
-The functions should have no arguments, and
-operate on the bibtex entry at point. You can assume point starts
-at the beginning of the entry. These functions are wrapped in
-`save-restriction' and `save-excursion' so you do not need to
-save the point position.
-
-Org ref contains some functions that are not included by default
-such as `orcb-clean-nil' or `orcb-clean-nil-opinionated' that
-users may be interested in adding themselves."
-  :group 'org-ref
-  :type 'hook)
-
-;; see https://github.com/fxcoudert/tools/blob/master/doi2bib for more replacements
-(defcustom org-ref-nonascii-latex-replacements
-  '(("í" . "{\\\\'i}")
-    ("æ" . "{\\\\ae}")
-    ("ć" . "{\\\\'c}")
-    ("é" . "{\\\\'e}")
-    ("ä" . "{\\\\\"a}")
-    ("è" . "{\\\\`e}")
-    ("à" . "{\\\\`a}")
-    ("á" . "{\\\\'a}")
-    ("ø" . "{\\\\o}")
-    ("ë" . "{\\\\\"e}")
-    ("ü" . "{\\\\\"u}")
-    ("ñ" . "{\\\\~n}")
-    ("ņ" . "{\\\\c{n}}")
-    ("ñ" . "{\\\\~n}")
-    ("å" . "{\\\\aa}")
-    ("ö" . "{\\\\\"o}")
-    ("Á" . "{\\\\'A}")
-    ("í" . "{\\\\'i}")
-    ("ó" . "{\\\\'o}")
-    ("ó" . "{\\\\'o}")
-    ("ú" . "{\\\\'u}")
-    ("ú" . "{\\\\'u}")
-    ("ý" . "{\\\\'y}")
-    ("š" . "{\\\\v{s}}")
-    ("č" . "{\\\\v{c}}")
-    ("ř" . "{\\\\v{r}}")
-    ("š" . "{\\\\v{s}}")
-    ("İ" . "{\\\\.I}")
-    ("ğ" . "{\\\\u{g}}")
-    ("δ" . "$\\\\delta$")
-    ("ç" . "{\\\\c{c}}")
-    ("ß" . "{\\\\ss}")
-    ("≤" . "$\\\\le$")
-    ("≥" . "$\\\\ge$")
-    ("θ" . "$\\\\theta$")
-    ("μ" . "$\\\\mu$")
-    ("→" . "$\\\\rightarrow$")
-    ("⇌" . "$\\\\leftrightharpoons$")
-    ("×" . "$\\\\times$")
-    ("°" . "$\\\\deg$")
-    ("ş" . "{\\\\c{s}}")
-    ("γ" . "$\\\\gamma$")
-    ("ɣ" . "$\\\\gamma$")
-    ("º" . "degC")
-    ("η" . "$\\\\eta$")
-    ("µ" . "$\\\\mu$")
-    ("α" . "$\\\\alpha$")
-    ("β" . "$\\\\beta$")
-    ("ɛ" . "$\\\\epsilon$")
-    ("Ⅵ" . "\\textrm{VI}")
-    ("Ⅲ" . "\\textrm{III}")
-    ("Ⅴ" . "\\textrm{V}")
-    ("λ" . "$\\\\lambda$")
-    ("π" . "$\\\\pi$")
-    ("∞" . "$\\\\infty$")
-    ("χ" . "$\\\\chi$")
-    ("∼" . "\\\\textasciitilde{}")
-    ("‑" . "\\\\textemdash{}")
-    (" " . " ")
-    ("…" . "...")
-    ("•" . "\\\\textbullet ")
-    ;; I think these are non-ascii spaces. there seems to be more than one.
-    (" " . " ")
-    (" " . " ")
-    (" " . " ")
-    ("–" . "-")
-    ("−" . "-")
-    ("–" . "-")
-    ("—" . "-")
-    ("‒" . "\\\\textemdash{}")
-    ("‘" . "'")
-    ("’" . "'")
-    ("’" . "'")
-    ("“" . "\"")
-    ("’" . "'")
-    ("”" . "\""))
-  "Cons list of non-ascii characters and their LaTeX representations.
-This may be deprecated. When `org-ref' started, non-ascii
-characters were often problematic with bibtex, but in 2021, it is
-not obvious that is still try."
-  :type '(alist :key-type (string) :value-type (string))
-  :group 'org-ref-bibtex)
-
-(defcustom org-ref-bibtex-assoc-pdf-with-entry-move-function 'rename-file
-  "Function to use when associating pdf files with bibtex entries.
-The value should be either `rename-file' or `copy-file'. The former
-will move and rename the original file. The latter will leave the
-original file in place while creating a renamed copy in some directory."
-  :type 'function
-  :group 'org-ref-bibtex)
-
-;;* Journal abbreviations
-(defcustom org-ref-bibtex-journal-abbreviations
-  '(("ACR" "Accounts of Chemical Research" "Acc. Chem. Res.")
-    ("ACAT" "ACS Catalysis" "ACS Catal.")
-    ("AM" "Acta Materialia" "Acta Mater.")
-    ("AMM" "Acta Metallurgica et Materialia" "Acta Metall. Mater.")
-    ("AEM" "Advanced Energy Materials" "Adv. Energy Mater.")
-    ("AAMI" "ACS Applied Materials \\& Interfaces"
-     "ACS Appl. Mater. Interfaces")
-    ("AMiner" "American Mineralogist" "Am. Mineral.")
-    ("AngC" "Angewandte Chemie-International Edition"
-     "Angew. Chem. Int. Edit.")
-    ("APLM" "APL Materials" "APL Mat.")
-    ("ACBE" "Applied Catalysis B: Environmental" "Appl. Catal. B-Environ.")
-    ("APL" "Applied Physics Letters" "Appl. Phys. Lett.")
-    ("ASS" "Applied Surface Science" "Appl. Surf. Sci.")
-    ("CL" "Catalysis Letters" "Catal. Lett.")
-    ("CC" "Catalysis Communications" "Catal. Commun.")
-    ("CST" "Catalysis Science & Technology" "Catal. Sci. Technol.")
-    ("CT" "Catalysis Today" "Catal. Today")
-    ("ChC" "Chemical Communications" "Chem. Commun.")
-    ("CPL" "Chemical Physics Letters" "Chem. Phys. Lett")
-    ("CR" "Chemical Reviews" "Chem. Rev.")
-    ("CSR" "Chemical Society Reviews" "Chem. Soc. Rev.")
-    ("CSR" "Chemical Society Reviews" "Chem. Soc. Rev.")
-    ("CM" "Chemistry of Materials" "Chem. Mater.")
-    ("CSA" "Colloids and Surfaces, A: Physicochemical and Engineering Aspects"
-     "Colloids Surf., A")
-    ("CF" "Combustion and Flame" "Combust. Flame")
-    ("CPMS" "Computational Materials Science" "Comp. Mater. Sci.")
-    ("CPC" "Computer Physics Communications" "Comput. Phys. Commun.")
-    ("CSE" "Computing in Science \\& Engineering" "Comput. Sci. Eng.")
-    ("CGD" "Crystal Growth \\& Design" "Cryst. Growth Des.")
-    ("CEC" "CrystEngComm" "CrystEngComm")
-    ("EA" "Electrochimica Acta" "Electrochim. Acta")
-    ("ECST" "ECS Transactions" "ECS Trans.")
-    ("EES" "Energy \\& Environmental Science" "Energy Environ. Sci.")
-    ("HPR" "High Pressure Research" "High Pressure Res.")
-    ("IC" "Inorganic Chemistry" "Inorg. Chem.")
-    ("IECR" "Industrial \\& Engineering Chemistry Research"
-     "Ind. Eng. Chem. Res.")
-    ("JJAP" "Japanese Journal of Applied Physics" "Jpn. J. Appl. Phys.")
-    ("JMatR" "Journal of  Materials Research" "J. Mater. Res.")
-    ("JALC" "Journal of Alloys and Compounds" "J. Alloy Compd.")
-    ("JAC" "Journal of Applied Crystallography" "J. Appl. Crystallogr.")
-    ("JAE" "Journal of Applied Electrochemistry" "J. Appl. Electrochem.")
-    ("JAP" "Journal of Applied Physics" "J. Appl. Phys.")
-    ("JC" "Journal of Catalysis" "J. Catal.")
-    ("JCP" "Journal of Chemical Physics" "J. Chem. Phys.")
-    ("JCC" "Journal of Computational Chemistry" "J. Comput. Chem.")
-    ("JCG" "Journal of Crystal Growth" "J. Crys. Growth")
-    ("JMC" "Journal of Materials Chemistry" "J. Mater. Chem.")
-    ("JMC" "Journal of Materials Chemistry" "J. Mater. Chem.")
-    ("JMSL" "Journal of Materials Science Letters" "J. Mater. Sci. Lett.")
-    ("JMS" "Journal of Membrane Science" "J. Memb. Sci.")
-    ("JPE" "Journal of Phase Equilibria" "J. Phase Equilib.")
-    ("JPCS" "Journal of Physics and Chemistry of Solids"
-     "J. Phys. Chem. Solids")
-    ("JPCM" "Journal of Physics: Condensed Matter"
-     "J. Phys.: Condens. Matter")
-    ("JPS" "Journal of Power Sources" "J. Power Sources")
-    ("JSSC" "Journal of Solid State Chemistry" "J. Solid State Chem.")
-    ("JACerS" "Journal of the American Ceramic Society" "J. Am. Ceram. Soc.")
-    ("JACS" "Journal of the American Chemical Society" "J. Am. Chem. Soc.")
-    ("JASIST" "Journal of the American Society for Information Science and Technology"
-     "J. Am. Soc. Inf. Sci. Technol.")
-    ("JES" "Journal of The Electrochemical Society" "J. Electrochem. Soc.")
-    ("JEaC" "Journal of Electroanalytical Chemistry" "J. Electroanal. Chem.")
-    ("JMS" "Journal of Membrane Science" "J. Memb. Sci.")
-    ("JRS" "Journal of Raman Spectroscopy" "J. Raman Spectrosc.")
-    ("JVST" "Journal of Vacuum Science \\& Technology A"
-     "J. Vac. Sci. Technol. A")
-    ("ML" "Materials Letters" "Mater. Lett.")
-    ("MSE-BS" "Materials Science and Engineering B" "Mat. Sci. Eng. B-Solid")
-    ("MOLSIM" "Molecular Simulation" "Mol. Sim.")
-    ("Nature" "Nature" "Nature")
-    ("NM" "Nature Materials" "Nat. Mater.")
-    ("NC" "Nature Chemistry" "Nat. Chem.")
-    ("PML" "Philosophical Magazine Letters" "Phil. Mag. Lett.")
-    ("PMA" "Philosophical Magazine A" "Phil. Mag. A")
-    ("PA" "Physica A: Statistical Mechanics and its Applications" "Physica A")
-    ("PB" "Physica B-Condensed Matter" "Physica B")
-    ("PCCP" "Physical Chemistry Chemical Physics" "Phys. Chem. Chem. Phys.")
-    ("PSSB" "physica status solidi (b)" "Phys. Status Solidi B")
-    ("PRA" "Physical Review A" "Phys. Rev. A")
-    ("PRB" "Physical Review B" "Phys. Rev. B")
-    ("PRL" "Physical Review Letters" "Phys. Rev. Lett.")
-    ("PCM" "Physics and Chemistry of Minerals" "Phys. Chem. Miner.")
-    ("PNAS" "Proceedings of the National Academy of Sciences of the United States of America"
-     "Proc. Natl. Acad. Sci. U. S. A.")
-    ("PSurfSci" "Progress in Surface Science" "Prog. Surf. Sci.")
-    ("Science" "Science" "Science")
-    ("SM" "Scripta Materialia" "Scr. Mater.")
-    ("SABC" "Sensors and Actuators B: Chemical" "Sensor. Actuat. B-Chem.")
-    ("SS" "Surface Science" "Surf. Sci.")
-    ("EPJB" "The European Physical Journal B" "Eur. Phys. J. B")
-    ("JPC" "The Journal of Physical Chemistry" "J. Phys. Chem.")
-    ("JPCB" "The Journal of Physical Chemistry B" "J. Phys. Chem. B")
-    ("JPCC" "The Journal of Physical Chemistry C" "J. Phys. Chem. C")
-    ("JPCL" "The Journal of Physical Chemistry Letters"
-     "J. Phys. Chem. Lett.")
-    ("JCP" "The Journal of Chemical Physics" "J. Chem. Phys.")
-    ("MSMSE" "Modelling and Simulation in Materials Science and Engineering"
-     "Modell. Simul. Mater. Sci. Eng.")
-    ("TSF" "Thin Solid Films" "Thin Solid Films")
-    ("TC" "Topics in Catalysis" "Top. Catal.")
-    ("WR" "Water Research" "Water Res."))
-  "List of (string journal-full-name journal-abbreviation). Find
-  new abbreviations at http://cassi.cas.org/search.jsp."
-  :type '(list (repeat (list string string)))
-  :group 'org-ref-bibtex)
-
-
-(defcustom org-ref-title-case-types '(("article" . ("title"))
-                                     ("book" . ("booktitle")))
-
-  "An a-list of bibtex entry types and fields that will be converted to
-title-case by org-ref-title-case."
-  :type '(repeat string)
-  :group 'org-ref-bibtex)
-
-
-(defcustom org-ref-bibtex-pdf-download-dir
-  (cond
-   ((stringp bibtex-completion-library-path)
-    bibtex-completion-library-path)
-   (t
-    (car bibtex-completion-library-path)))
-  "Default directory to look for downloaded pdfs.
-Used in `org-ref-bibtex-assoc-pdf-with-entry' when looking for a
-PDF to associate with an entry. Defaults to the first entry in
-`bibtex-completion-library-path'."
-  :group 'org-ref-bibtex
-  :type 'directory)
-
-
-;; * Modifying journal titles
-;;;###autoload
-(defun org-ref-bibtex-generate-longtitles ()
-  "Generate longtitles.bib which are @string definitions.
-The full journal names are in `org-ref-bibtex-journal-abbreviations'."
-  (interactive)
-  (with-temp-file "longtitles.bib"
-    (dolist (row org-ref-bibtex-journal-abbreviations)
-      (insert (format "@string{%s=\"%s\"}\n"
-                      (nth 0 row)
-                      (nth 1 row))))))
-
-
-;;;###autoload
-(defun org-ref-bibtex-generate-shorttitles ()
-  "Generate shorttitles.bib which are @string definitions.
-The abbreviated journal names in `org-ref-bibtex-journal-abbreviations'."
-  (interactive)
-  (with-temp-file "shorttitles.bib"
-    (dolist (row org-ref-bibtex-journal-abbreviations)
-      (insert (format "@string{%s=\"%s\"}\n"
-                      (nth 0 row)
-                      (nth 2 row))))))
-
-
-;;;###autoload
-(defun org-ref-stringify-journal-name (&optional key start end)
-  "Replace journal name in a bibtex entry with a string.
-The strings are defined in
-`org-ref-bibtex-journal-abbreviations'.  The optional arguments KEY,
-START and END allow you to use this with `bibtex-map-entries'"
-  (interactive)
-  (bibtex-beginning-of-entry)
-  (when
-      (string= "article"
-               (downcase
-                (cdr (assoc "=type=" (bibtex-parse-entry)))))
-    (let* ((full-names (mapcar
-                        (lambda (row)
-                          (cons  (nth 1 row) (nth 0 row)))
-                        org-ref-bibtex-journal-abbreviations))
-           (abbrev-names (mapcar
-                          (lambda (row)
-                            (cons  (nth 2 row) (nth 0 row)))
-                          org-ref-bibtex-journal-abbreviations))
-           (journal (s-trim (bibtex-autokey-get-field "journal")))
-           (bstring (or
-                     (cdr (assoc journal full-names))
-                     (cdr (assoc journal abbrev-names)))))
-      (when bstring
-        (bibtex-set-field "journal" bstring t)
-        (bibtex-fill-entry)))))
-
-
-;;;###autoload
-(defun org-ref-set-journal-string (full-journal-name)
-  "Set a bibtex journal name to the string that represents FULL-JOURNAL-NAME.
-This is defined in `org-ref-bibtex-journal-abbreviations'."
-  (interactive (list
-                (completing-read
-                 "Journal: "
-                 (mapcar
-                  (lambda (x)
-                    (nth 1 x))
-                  org-ref-bibtex-journal-abbreviations))))
-  ;; construct data alist for the string lookup.
-  (let ((alist (mapcar
-                (lambda (x)
-                  (cons (nth 1 x) (nth 0 x)))
-                org-ref-bibtex-journal-abbreviations)))
-    (bibtex-set-field "journal" (cdr (assoc full-journal-name alist)) t)
-    (bibtex-fill-entry)
-    (bibtex-clean-entry)))
-
-;;* Non-ascii character replacement
-
-;;;###autoload
-(defun org-ref-replace-nonascii ()
-  "Replace non-ascii characters with LaTeX representations in a
-bibtex entry."
-  (interactive)
-  (save-restriction
-    (bibtex-narrow-to-entry)
-    (goto-char (point-min))
-    (dolist (char (mapcar (lambda (x)
-                           (car x))
-                         org-ref-nonascii-latex-replacements))
-      (while (re-search-forward char nil t)
-        (replace-match (cdr (assoc char org-ref-nonascii-latex-replacements))))
-      (goto-char (point-min)))))
-
-
-;;* Title case transformations
-(defvar org-ref-lower-case-words
-  '("a" "an" "on" "and" "for"
-    "the" "of" "in")
-  "List of words to keep lowercase when changing case in a title.")
-
-
-;;;###autoload
-(defun org-ref-title-case (&optional key start end)
-  "Convert a bibtex entry title and booktitle to title-case.
-Convert only if the entry type is a member of the list
-`org-ref-title-case-types'. The arguments KEY, START and END are
-optional, and are only there so you can use this function with
-`bibtex-map-entries' to change all the title entries in articles and
-books."
-  (interactive)
-  (save-restriction
-    (bibtex-narrow-to-entry)
-    (bibtex-beginning-of-entry)
-    (let* ((entry-type (downcase (cdr (assoc "=type=" (bibtex-parse-entry)))))
-          (fields (cdr (assoc entry-type org-ref-title-case-types)))
-          ;; temporary variables
-          title words)
-      (when fields
-       (cl-loop for field in fields
-                when (bibtex-autokey-get-field field)
-                do
-                (setq title (bibtex-autokey-get-field field)
-                      words (split-string title)
-                      start 0)
-                (setq words (mapcar
-                             (lambda (word)
-                               (cond
-                                ;; words containing more than one . are probably
-                                ;; abbreviations. We do not change those.
-                                ((with-temp-buffer
-                                   (insert word)
-                                   (goto-char (point-min))
-                                   (> (count-matches "\\.") 1))
-                                 word)
-                                ;; match words containing {} or \ which are probably
-                                ;; LaTeX or protected words, ignore
-                                ((string-match "\\$\\|{\\|}\\|(\\|)\\|\\\\" word)
-                                 word)
-                                ;; these words should not be capitalized, unless they
-                                ;; are the first word
-                                ((-contains? org-ref-lower-case-words
-                                             (s-downcase word))
-                                 (s-downcase word))
-                                ;; Words that are quoted
-                                ((s-starts-with? "\"" word)
-                                 (concat "\"" (s-capitalize (substring word 1))))
-                                (t
-                                 (s-capitalize word))))
-                             words))
-
-                ;; Check if first word should be capitalized
-                (when (-contains? org-ref-lower-case-words (car words))
-                  (setf (car words) (s-capitalize (car words))))
-
-                (setq title (mapconcat 'identity words " "))
-
-                ;; Capitalize letters after a dash
-                (while
-                    (string-match "[a-zA-Z]-\\([a-z]\\)" title start)
-                  (let ((char (substring title (match-beginning 1) (match-end 1))))
-                    (setf (substring title (match-beginning 1) (match-end 1))
-                          (format "%s" (upcase char)))
-                    (setq start (match-end 1))))
-
-                ;; this is defined in doi-utils
-                (bibtex-set-field
-                 field
-                 title)
-                (bibtex-fill-entry))))))
-
-
-;;;###autoload
-(defun org-ref-title-case-article (&optional key start end)
-  "Convert a bibtex entry article or book title to title-case.
-The arguments KEY, START and END are optional, and are only there
-so you can use this function with `bibtex-map-entries' to change
-all the title entries in articles and books."
-  (interactive)
-  (let ((org-ref-title-case-types '(("article" . ("title")))))
-    (org-ref-title-case)))
-
-
-;;;###autoload
-(defun org-ref-sentence-case-article (&optional key start end)
-  "Convert a bibtex entry article title to sentence-case.
-The arguments KEY, START and END are optional, and are only there
-so you can use this function with `bibtex-map-entries' to change
-all the title entries in articles."
-  (interactive)
-  (bibtex-beginning-of-entry)
-
-  (let* ((title (bibtex-autokey-get-field "title"))
-         (words (split-string title))
-         (start 0))
-    (when
-        (string= "article"
-                (downcase
-                 (cdr (assoc "=type="
-                             (bibtex-parse-entry)))))
-      (setq words (mapcar
-                   (lambda (word)
-                     (if
-                         ;; match words containing {} or \ which are probably
-                         ;; LaTeX or protected words
-                         (string-match "\\$\\|{\\|}\\|\\\\" word)
-                         word
-                       (s-downcase word)))
-                   words))
-
-      ;; capitalize first word
-      (setf (car words) (s-capitalize (car words)))
-
-      ;; join the words
-      (setq title (mapconcat 'identity words " "))
-
-      ;; capitalize a word after a :, eg. a subtitle, and protect it
-      (while
-          (string-match "[a-z]:\\s-+\\([A-Z]\\)" title start)
-        (let ((char (substring title (match-beginning 1) (match-end 1))))
-          (setf (substring title (match-beginning 1) (match-end 1))
-                (format "%s" (upcase char)))
-          (setq start (match-end 1))))
-
-      ;; this is defined in doi-utils
-      (bibtex-set-field "title" title)
-
-      ;; clean and refill entry so it looks nice
-      (bibtex-clean-entry)
-      (bibtex-fill-entry))))
-
-
-;;* Navigation in bibtex file
-;;;###autoload
-(defun org-ref-bibtex-next-entry (&optional n)
-  "Jump to the beginning of the next bibtex entry.
-N is a prefix argument.  If it is numeric, jump that many entries
-forward.  Negative numbers do nothing."
-  (interactive "P")
-  ;; Note if we start at the beginning of an entry, nothing
-  ;; happens. We need to move forward a char, and call again.
-  (when (= (point) (save-excursion
-                     (bibtex-beginning-of-entry)))
-    (forward-char)
-    (org-ref-bibtex-next-entry))
-
-  ;; search forward for an entry
-  (when
-      (re-search-forward bibtex-entry-head nil t (and (numberp n) n))
-    ;; go to beginning of the entry
-    (bibtex-beginning-of-entry)))
-
-
-;;;###autoload
-(defun org-ref-bibtex-previous-entry (&optional n)
-  "Jump to beginning of the previous bibtex entry.
-N is a prefix argument.  If it is numeric, jump that many entries back."
-  (interactive "P")
-  (bibtex-beginning-of-entry)
-  (when
-      (re-search-backward bibtex-entry-head nil t (and (numberp n) n))
-    (bibtex-beginning-of-entry)))
-
-
-;;;###autoload
-(defun org-ref-bibtex-visible-entry ()
-  "Jump to visible entry."
-  (interactive)
-  (avy-with avy-ve
-    (avy-process
-     (save-excursion
-       (goto-char (window-start))
-       (let ((positions ()))
-        (while (re-search-forward "^@.*{" (window-end) t)
-          (push (match-beginning 0) positions))
-        (reverse positions))))
-    (avy--style-fn avy-style)))
-
-
-;;;###autoload
-(defun org-ref-bibtex-visible-field ()
-  "Jump to visible field."
-  (interactive)
-  (avy-with avy-vf
-    (avy-process
-     (save-excursion
-       (goto-char (window-start))
-       (let ((positions ()))
-        (while (re-search-forward ".*=\\s-*." (window-end) t)
-          (push (match-end 0) positions))
-        (reverse positions))))
-    (avy--style-fn avy-style)))
-
-
-(defun org-ref-bibtex-mode-keys ()
-  "Modify keymaps used by `bibtex-mode'."
-  (local-set-key (kbd "M-n") 'org-ref-bibtex-next-entry)
-  (local-set-key (kbd "M-p") 'org-ref-bibtex-previous-entry))
-
-;; add to bibtex-mode-hook
-(add-hook 'bibtex-mode-hook 'org-ref-bibtex-mode-keys)
-
-;;* Functions to act on an entry with a doi
-
-(defun org-ref-bibtex-entry-doi ()
-  "Get doi from entry at point."
-  (save-excursion
-    (bibtex-beginning-of-entry)
-    (when (not (looking-at bibtex-any-valid-entry-type))
-      (error "This entry does not appear to be a valid type."))
-    (let ((entry (bibtex-parse-entry t)))
-      (when (null entry)
-       (error "Unable to parse this bibtex entry."))
-      (cdr (assoc "doi" entry)))))
-
-;; function that ensures that the url field of a bibtex entry is the
-;; properly-formatted hyperlink of the DOI. See
-;; http://blog.crossref.org/2016/09/new-crossref-doi-display-guidelines.html
-;; for more information.
-;;;###autoload
-(defun org-ref-bibtex-format-url-if-doi ()
-  "Hook function to format url to follow the current DOI conventions."
-  (interactive)
-  ;; Don't overwrite an existing url field though.
-  (unless (bibtex-autokey-get-field "url")
-    (if (eq (org-ref-bibtex-entry-doi) "") nil
-      (let ((front-url "https://doi.org/")
-            (doi (org-ref-bibtex-entry-doi)))
-       (bibtex-set-field "url"
-                          (concat front-url doi))))))
-
-
-;;;###autoload
-(defun org-ref-bibtex-wos ()
-  "Open bibtex entry in Web Of Science if there is a DOI."
-  (interactive)
-  (doi-utils-wos (org-ref-bibtex-entry-doi)))
-
-
-;;;###autoload
-(defun org-ref-bibtex-wos-citing ()
-  "Open citing articles for bibtex entry in Web Of Science if
-there is a DOI."
-  (interactive)
-  (doi-utils-wos-citing (org-ref-bibtex-entry-doi)))
-
-
-;;;###autoload
-(defun org-ref-bibtex-wos-related ()
-  "Open related articles for bibtex entry in Web Of Science if
-there is a DOI."
-  (interactive)
-  (doi-utils-wos-related (org-ref-bibtex-entry-doi)))
-
-
-;;;###autoload
-(defun org-ref-bibtex-crossref ()
-  "Open the bibtex entry in Crossref by its doi."
-  (interactive)
-  (doi-utils-crossref (org-ref-bibtex-entry-doi)))
-
-
-;;;###autoload
-(defun org-ref-bibtex-google-scholar ()
-  "Open the bibtex entry at point in google-scholar by its doi."
-  (interactive)
-  (let ((doi (org-ref-bibtex-entry-doi)))
-    (doi-utils-google-scholar
-     (if (string= "" doi)
-        (save-excursion
-          (bibtex-beginning-of-entry)
-          (cdr (assoc "title" (bibtex-parse-entry t))))
-       doi))))
-
-
-;;;###autoload
-(defun org-ref-bibtex-pubmed ()
-  "Open the bibtex entry at point in Pubmed by its doi."
-  (interactive)
-  (doi-utils-pubmed (org-ref-bibtex-entry-doi)))
-
-
-;;;###autoload
-(defun org-ref-bibtex-pdf (&optional _)
-  "Open the pdf for the bibtex entry at point.
-Thin wrapper to get `org-ref-bibtex' to open pdf, because it
-calls functions with a DOI argument."
-  (interactive)
-  (org-ref-open-bibtex-pdf))
-
-
-(defun org-ref-bibtex-get-file-move-func (prefix)
-  "Determine whether to use `rename-file' or `copy-file' for `org-ref-bibtex-assoc-pdf-with-entry'.
-When called with a PREFIX argument,
-`org-ref-bibtex-assoc-pdf-with-entry-move-function' switches to the
-opposite function from that which is defined in
-`org-ref-assoc-pdf-with-entry-move-function'."
-  (message (format "%s" prefix))
-  (if (eq prefix nil)
-      org-ref-bibtex-assoc-pdf-with-entry-move-function
-    (if (eq org-ref-bibtex-assoc-pdf-with-entry-move-function 'rename-file)
-       'copy-file
-      'rename-file)))
-
-
-(defvar bibtex-completion-library-path)
-(declare-function bibtex-completion-find-pdf-in-library "bibtex-completion")
-
-
-;;;###autoload
-(defun org-ref-bibtex-assoc-pdf-with-entry (&optional prefix)
-  "Prompt for pdf associated with entry at point and rename it.
-Check whether a pdf already exists in `bibtex-completion-library' with the
-name '[bibtexkey].pdf'. If the file does not exist, rename it to
-'[bibtexkey].pdf' using
-`org-ref-bibtex-assoc-pdf-with-entry-move-function' and place it in
-a directory. Optional PREFIX argument toggles between
-`rename-file' and `copy-file'."
-  (interactive "P")
-  (save-excursion
-    (bibtex-beginning-of-entry)
-    (let* ((file (read-file-name
-                 "Select file associated with entry: "
-                 org-ref-bibtex-pdf-download-dir))
-          (bibtex-expand-strings t)
-           (entry (bibtex-parse-entry t))
-           (key (cdr (assoc "=key=" entry)))
-          (file-move-func (org-ref-bibtex-get-file-move-func prefix))
-          pdf)
-      (if (bibtex-completion-find-pdf-in-library key)
-         (message (format "A file named %s already exists" (bibtex-completion-find-pdf-in-library key)))
-       (setq pdf (expand-file-name (concat key ".pdf") (cond
-                                                        ((stringp bibtex-completion-library-path)
-                                                         bibtex-completion-library-path)
-                                                        ((and (listp bibtex-completion-library-path)
-                                                              (= 1 (length bibtex-completion-library-path)))
-                                                         (car bibtex-completion-library-path))
-                                                        (t
-                                                         (completing-read "Dir: " bibtex-completion-library-path)))))
-       (funcall file-move-func file pdf)
-       (message (format "Created file %s" pdf))))))
-
-
-;;* Hydra menus
-;;** Hydra menu for bibtex entries
-;; hydra menu for actions on bibtex entries
-(defhydra org-ref-bibtex-hydra (:color blue :hint nil)
-  "Bibtex actions:
-"
-  ;; Open-like actions
-  ("p" org-ref-open-bibtex-pdf "PDF" :column "Open")
-  ("n" org-ref-open-bibtex-notes "Notes" :column "Open")
-  ("b" org-ref-open-in-browser "URL" :column "Open")
-
-  ;; edit/modify
-  ("K" (lambda ()
-         (interactive)
-         (org-ref-set-bibtex-keywords
-          (read-string "Keywords: "
-                       (bibtex-autokey-get-field "keywords"))
-          t))
-   "Keywords" :column "Edit")
-  ("a" org-ref-replace-nonascii "Replace nonascii" :column "Edit")
-  ("s" org-ref-sort-bibtex-entry "Sort fields" :column "Edit")
-  ("T" org-ref-title-case-article "Title case" :column "Edit")
-  ("S" org-ref-sentence-case-article "Sentence case" :column "Edit")
-  ("U" (doi-utils-update-bibtex-entry-from-doi (org-ref-bibtex-entry-doi)) "Update entry" :column "Edit")
-  ("u" doi-utils-update-field "Update field" :column "Edit" :color red)
-  ("<backspace>" (cl--set-buffer-substring (line-beginning-position) (+ 1 (line-end-position)) "")
-   "Delete line" :column "Edit" :color red)
-  ("d" bibtex-kill-entry "Kill entry" :column "Edit")
-  ("L" org-ref-clean-bibtex-entry "Clean entry" :column "Edit")
-  ("A" org-ref-bibtex-assoc-pdf-with-entry "Add pdf" :column "Edit")
-  ("r" (lambda ()
-        (interactive)
-         (bibtex-beginning-of-entry)
-         (bibtex-kill-entry)
-         (find-file (completing-read
-                     "Bibtex file: "
-                    (append bibtex-completion-bibliography
-                            (f-entries "." (lambda (f) (f-ext? f "bib"))))))
-         (goto-char (point-max))
-         (bibtex-yank)
-         (save-buffer)
-         (kill-buffer))
-   "Refile entry" :column "Edit")
-
-  ;; www
-  ("P" org-ref-bibtex-pubmed "Pubmed" :column "WWW")
-  ("w" org-ref-bibtex-wos "WOS" :column "WWW")
-  ("c" org-ref-bibtex-wos-citing "WOS citing" :column "WWW")
-  ("a" org-ref-bibtex-wos-related "WOS related" :column "WWW")
-  ("R" org-ref-bibtex-crossref "Crossref" :column "WWW")
-  ("g" org-ref-bibtex-google-scholar "Google Scholar" :column "WWW")
-  ("e" org-ref-email-bibtex-entry "Email" :column "WWW")
-
-
-  ;; Copy
-  ("o" (lambda ()
-        (interactive)
-        (bibtex-copy-entry-as-kill)
-        (message "Use %s to paste the entry"
-                 (substitute-command-keys (format "\\[bibtex-yank]"))))
-   "Copy entry" :column "Copy")
-
-  ("y" (save-excursion
-        (bibtex-beginning-of-entry)
-        (when (looking-at bibtex-entry-maybe-empty-head)
-          (kill-new (bibtex-key-in-head))))
-   "Copy key" :column "Copy")
-
-  ("f" (save-excursion
-        (bibtex-beginning-of-entry)
-        (kill-new (bibtex-completion-apa-format-reference
-                   (cdr (assoc "=key=" (bibtex-parse-entry t))))))
-   "Formatted entry" :column "Copy")
-
-  ;; Navigation
-  ("[" org-ref-bibtex-next-entry "Next entry" :column "Navigation" :color red)
-  ("]" org-ref-bibtex-previous-entry "Previous entry" :column "Navigation" :color red)
-  ("<down>" next-line "Next line" :column "Navigation" :color red)
-  ("<up>" previous-line "Previous line" :column "Navigation" :color red)
-  ("<next>" scroll-up-command "Scroll up" :column "Navigation" :color red)
-  ("<prior>" scroll-down-command "Scroll down" :column "Navigation" :color red)
-  ("v" org-ref-bibtex-visible-entry "Visible entry" :column "Navigation" :color red)
-  ("V" org-ref-bibtex-visible-field "Visible field" :column "Navigation" :color red)
-
-
-  ;; Miscellaneous
-  ("F" org-ref-bibtex-file/body "File hydra" :column "Misc")
-  ("N" org-ref-bibtex-new-entry/body "New entry" :column "Misc")
-  ("q" nil))
-
-
-(declare-function biblio-lookup "biblio")
-(declare-function arxiv-add-bibtex-entry "org-ref-arxiv")
-(declare-function doi-insert-bibtex "doi-utils")
-
-;;** Hydra menu for new bibtex entries
-;; A hydra for adding new bibtex entries.
-(defhydra org-ref-bibtex-new-entry (:color blue)
-  "New Bibtex entry:"
-  ("d" doi-insert-bibtex "from DOI" :column "Automatic")
-  ("c" crossref-add-bibtex-entry "from Crossref" :column "Automatic")
-  ("a" arxiv-add-bibtex-entry "From Arxiv" :column "Automatic")
-  ("b" biblio-lookup "From biblio" :column "Automatic")
-  ;; Bibtex types
-  ("ma" bibtex-Article "Article" :column "Manual")
-  ("mb" bibtex-Book "Book" :column "Manual")
-  ("mi" bibtex-InBook "In book" :column "Manual")
-  ("ml" bibtex-Booklet "Booklet" :column "Manual")
-  ("mP" bibtex-Proceedings "Proceedings" :column "Manual")
-  ("mp" bibtex-InProceedings "In proceedings" :column "Manual")
-  ("mm" bibtex-Misc "Misc." :column "Manual")
-  ("mM" bibtex-Manual "Manual" :column "Manual")
-  ("mT" bibtex-PhdThesis "PhD Thesis" :column "Manual")
-  ("mt" bibtex-MastersThesis "MS Thesis" :column "Manual")
-  ("mR" bibtex-TechReport "Report" :column "Manual")
-  ("mu" bibtex-Unpublished "unpublished" :column "Manual")
-  ("mc" bibtex-InCollection "Article in collection" :column "Manual")
-  ("q" nil "quit"))
-
-
-;;** Hydra menu of functions to act on a bibtex file.
-(defhydra org-ref-bibtex-file (:color blue)
-  "Bibtex file functions: "
-  ("v" bibtex-validate "Validate entries")
-  ("s" bibtex-sort-buffer "Sort entries")
-  ("r" bibtex-reformat "Reformat entries")
-  ("c" bibtex-count-entries "Count entries")
-  ("p" org-ref-build-full-bibliography "PDF bibliography"))
-
-
-;;* Email a bibtex entry
-(declare-function bibtex-completion-find-pdf "bibtex-completion")
-
-;;;###autoload
-(defun org-ref-email-bibtex-entry ()
-  "Email current bibtex entry at point and pdf if it exists."
-  (interactive)
-  (bibtex-beginning-of-entry)
-  (let* ((key (cdr (assoc "=key=" (bibtex-parse-entry t))))
-        (pdfs (bibtex-completion-find-pdf key)))
-
-    (bibtex-copy-entry-as-kill)
-    (compose-mail)
-    (message-goto-body)
-    (insert (pop bibtex-entry-kill-ring))
-    (message-goto-subject)
-    (insert key)
-    (cl-loop for pdf in pdfs do (mml-attach-file pdf))
-    (message-goto-to)
-    ;; I am not sure why I have to put an empty string here, but it prevents a
-    ;; bell error.
-    ""))
-
-;;* org-ref bibtex keywords
-;; adapted from bibtex-utils.el
-;; these are candidates for selecting keywords/tags
-(defun org-ref-bibtex-keywords ()
-  "Get keywords defined in current bibtex file.
-These are in the keywords field, and are comma or semicolon separated."
-  (save-excursion
-    (goto-char (point-min))
-    (let (keywords kstring)
-      (while (re-search-forward "^\\s-*keywords.*{\\([^}]+\\)}" nil t)
-        ;; TWS - remove newlines/multiple spaces:
-        (setq kstring (replace-regexp-in-string
-                      "[ \t\n]+" " "
-                      (match-string 1)))
-        (mapc
-         (lambda (v)
-           (add-to-list 'keywords v t))
-         (split-string kstring "\\(,\\|;\\)[ \n]*\\|{\\|}" t)))
-      keywords)))
-
-
-;;;###autoload
-(defun org-ref-set-bibtex-keywords (keywords &optional arg)
-  "Add KEYWORDS to a bibtex entry.
-If KEYWORDS is a list, it is converted to a comma-separated
-string.  The KEYWORDS are added to the beginning of the
-field.  Otherwise KEYWORDS should be a string of comma-separate
-keywords.  Optional argument ARG prefix arg to replace keywords."
-  (interactive
-   (list
-    (completing-read "Keyword: " (org-ref-bibtex-keywords))
-    current-prefix-arg))
-  (bibtex-set-field
-   "keywords"
-   (if arg
-       ;; replace with arg
-       (if (listp keywords)
-           (mapconcat 'identity keywords ", ")
-         keywords)
-     ;; else concatenate
-     (concat
-      (if (listp keywords)
-          (mapconcat 'identity keywords ", ")
-        keywords)
-      (when (not (string= "" (bibtex-autokey-get-field "keywords")))
-        (concat ", "  (bibtex-autokey-get-field "keywords"))))))
-  (when (buffer-file-name)
-    (save-buffer)))
-
-
-(defun org-ref-save-all-bibtex-buffers ()
-  "Save all bibtex-buffers."
-  (cl-loop for buffer in (buffer-list)
-          do
-          (with-current-buffer buffer
-            (when (and (buffer-file-name) (f-ext? (buffer-file-name) "bib"))
-              (save-buffer)))))
-
-
-;; * Extract bibtex blocks from an org-file
-
-;;;###autoload
-(defun org-ref-extract-bibtex-blocks (bibfile)
-  "Extract all bibtex blocks in buffer to BIBFILE.
-If BIBFILE exists, append, unless you use a prefix arg (C-u), which
-will clobber the file."
-  (interactive
-   (list (read-file-name "Bibfile: " nil nil nil
-                        (file-name-nondirectory
-                         (concat (file-name-sans-extension
-                                  (buffer-file-name))
-                                 ".bib")))))
-
-  (let ((contents ""))
-    (when (and (file-exists-p bibfile)
-              (not current-prefix-arg))
-      (setq contents (with-temp-buffer
-                      (insert-file-contents bibfile)
-                      (buffer-string))))
-
-    (save-excursion
-      (goto-char (point-min))
-      (while (re-search-forward "#\\+BEGIN_SRC bibtex" nil t)
-       (setq contents
-             (concat
-              contents
-              (org-element-property :value (org-element-at-point))))))
-
-    (with-temp-file bibfile
-      (insert contents))))
-
-
-;;** create text citations from a bibtex entry
-(declare-function bibtex-completion-apa-format-reference "bibtex-completion")
-(declare-function bibtex-completion-get-key-bibtex "bibtex-completion")
-
-(defun org-ref-bib-citation ()
-  "From a bibtex entry, create and return a lightly formatted citation string."
-  (bibtex-completion-apa-format-reference (list (bibtex-completion-get-key-bibtex))))
-
-
-;;** Open pdf in bibtex entry
-(declare-function bibtex-completion-open-pdf "bibtex-completion")
-;;;###autoload
-(defun org-ref-open-bibtex-pdf ()
-  "Open pdf for a bibtex entry, if it exists."
-  (interactive)
-  (bibtex-completion-open-pdf (list (bibtex-completion-get-key-bibtex))))
-
-
-;;** Open notes from bibtex entry
-(declare-function bibtex-completion-edit-notes "bibtex-completion")
-
-;;;###autoload
-(defun org-ref-open-bibtex-notes ()
-  "From a bibtex entry, open the notes if they exist."
-  (interactive)
-  (bibtex-completion-edit-notes (list (bibtex-completion-get-key-bibtex))))
-
-
-;;** Open bibtex entry in browser
-(declare-function bibtex-completion-open-url-or-doi "bibtex-completion")
-
-;;;###autoload
-(defun org-ref-open-in-browser ()
-  "Open the bibtex entry at point in a browser using the url field or doi field."
-  (interactive)
-  (bibtex-completion-open-url-or-doi (list (bibtex-completion-get-key-bibtex))))
-
-
-;;** Build a pdf of the bibtex file
-;;;###autoload
-(defun org-ref-build-full-bibliography ()
-  "Build pdf of all bibtex entries, and open it."
-  (interactive)
-  (let* ((bibfile (file-name-nondirectory (buffer-file-name)))
-         (bib-base (file-name-sans-extension bibfile))
-         (texfile (concat bib-base ".tex"))
-         (pdffile (concat bib-base ".pdf")))
-    (find-file texfile)
-    (erase-buffer)
-    (insert (format "\\documentclass[12pt]{article}
-\\usepackage[version=3]{mhchem}
-\\usepackage{url}
-\\usepackage[numbers]{natbib}
-\\usepackage[colorlinks=true, linkcolor=blue, urlcolor=blue, pdfstartview=FitH]{hyperref}
-\\usepackage{doi}
-\\begin{document}
-\\nocite{*}
-\\bibliographystyle{unsrtnat}
-\\bibliography{%s}
-\\end{document}" bib-base))
-    (save-buffer)
-    (shell-command (concat "pdflatex " bib-base))
-    (shell-command (concat "bibtex " bib-base))
-    (shell-command (concat "pdflatex " bib-base))
-    (shell-command (concat "pdflatex " bib-base))
-    (kill-buffer texfile)
-    (org-open-file pdffile)))
-
-
-;;** Sort fields in a bibtex entry
-;;;###autoload
-(defun org-ref-sort-bibtex-entry ()
-  "Sort fields of entry in standard order."
-  (interactive)
-  (bibtex-beginning-of-entry)
-  (let* ((entry (bibtex-parse-entry))
-         (entry-fields)
-         (other-fields)
-         (type (cdr (assoc "=type=" entry)))
-         (key (cdr (assoc "=key=" entry)))
-        (field-order (cdr (assoc (if type (downcase type))
-                                 org-ref-bibtex-sort-order))))
-
-    ;; these are the fields we want to order that are in this entry
-    (setq entry-fields (mapcar (lambda (x) (car x)) entry))
-    ;; we do not want to reenter these fields
-    (setq entry-fields (remove "=key=" entry-fields))
-    (setq entry-fields (remove "=type=" entry-fields))
-
-    ;;these are the other fields in the entry, and we sort them alphabetically.
-    (setq other-fields
-         (sort (-remove (lambda(x) (member x field-order)) entry-fields)
-               'string<))
-
-    (save-restriction
-      (bibtex-kill-entry)
-      (insert
-       (concat "@" type "{" key ",\n"
-              (mapconcat
-               (lambda (field)
-                 (when (member field entry-fields)
-                   (format "%s = %s,"
-                           field
-                           (cdr (assoc field entry)))))
-               field-order "\n")
-              ;; now add the other fields
-              (mapconcat
-               (lambda (field)
-                 (cl-loop for (f . v) in entry concat
-                          (when (string= f field)
-                            (format "%s = %s,\n" f v))))
-               (-uniq other-fields) "\n")
-              "\n}"))
-      (bibtex-search-entry key)
-      (bibtex-fill-entry)
-      (bibtex-clean-entry))))
-
-;; downcase entries
-;;;###autoload
-(defun org-ref-downcase-bibtex-entry ()
-  "Downcase the entry type and fields."
-  (interactive)
-  (bibtex-beginning-of-entry)
-  (let* ((entry (bibtex-parse-entry))
-         (entry-fields)
-         (type (downcase (cdr (assoc "=type=" entry))))
-         (key (cdr (assoc "=key=" entry))))
-
-    (setq entry-fields (mapcar (lambda (x) (car x)) entry))
-    ;; we do not want to reenter these fields
-    (setq entry-fields (remove "=key=" entry-fields))
-    (setq entry-fields (remove "=type=" entry-fields))
-
-    (bibtex-kill-entry)
-    (insert
-     (concat "@" (downcase type) "{" key ",\n"
-            (mapconcat
-             (lambda (field)
-               (format "%s = %s,"
-                       (downcase field)
-                       (cdr (assoc field entry))))
-             entry-fields "\n")
-            "\n}\n\n"))
-    (bibtex-search-entry key)
-    (bibtex-fill-entry)
-    (bibtex-clean-entry)))
-
-
-;;** Clean a bibtex entry
-;; These functions operate on a bibtex entry and "clean" it in some way.
-
-(defun orcb-clean-nil (&optional arg)
-  "Remove nil from some article fields.
-The removal is conditional. Sometimes it is useful to have nil
-around, e.g. for ASAP articles where the fields are not defined
-yet but will be in the future.
-
-With \\[universal-argument], run `bibtex-clean-entry' after."
-  (interactive "P")
-  (bibtex-beginning-of-entry)
-  (let* ((entry (bibtex-parse-entry))
-         (type (downcase (cdr (assoc "=type=" entry)))))
-    (when (string= type "article")
-      (cond
-       ;; we have volume and pages but number is nil.
-       ;; remove the number field.
-       ((and (string= type "article")
-            (not (string= (cdr (assoc "volume" entry)) "{nil}"))
-            (not (string= (cdr (assoc "pages" entry)) "{nil}"))
-            (string= (cdr (assoc "number" entry)) "{nil}"))
-       (bibtex-set-field "number" "")
-       (if arg
-            (bibtex-clean-entry)))))))
-
-
-(defun orcb-clean-nil-opinionated ()
-  "Remove nil from all article fields.
-
-Note that by default, this will leave the entry empty, which may
-then get deleted by `bibtex-clean-entry.' To disable this
-behavior, remove opts-or-alts from `bibtex-entry-format'. This
-will leave the empty entries so that you may fill them in later."
-  (interactive)
-  (bibtex-beginning-of-entry)
-  (let* ((entry (bibtex-parse-entry))
-         (type (downcase (cdr (assoc "=type=" entry)))))
-    (when (string= type "article")
-      (cl-loop for (field . text) in entry do
-               (if (string= text "{nil}")
-                   (bibtex-set-field field ""))))))
-
-
-(defun orcb-clean-doi ()
-  "Remove http://dx.doi.org/ or https://doi.org in the doi field."
-  (let ((doi (bibtex-autokey-get-field "doi")))
-    (when (or (string-match "^http://dx.doi.org/" doi)
-             (string-match "^https://doi.org/" doi))
-      (setq doi (replace-match "" nil nil doi))
-      (bibtex-beginning-of-entry)
-      (goto-char (car (cdr (bibtex-search-forward-field "doi" t))))
-      (bibtex-kill-field)
-      (bibtex-make-field "doi")
-      (backward-char)
-      (insert doi))))
-
-
-(defun orcb-clean-year (&optional new-year)
-  "Fix years set to 0.
-If optional NEW-YEAR set it to that, otherwise prompt for it."
-  ;; asap articles often set year to 0, which messes up key
-  ;; generation. fix that.
-  (let ((year (bibtex-autokey-get-field "year")))
-    (when (string= "0" year)
-      (bibtex-beginning-of-entry)
-      (goto-char (car (cdr (bibtex-search-forward-field "year" t))))
-      (bibtex-kill-field)
-      (bibtex-make-field "year")
-      (backward-char)
-      (insert (or new-year (read-string "Enter year: "))))))
-
-
-(defun orcb-clean-pages ()
-  "Check for empty pages, and put eid in its place if it exists."
-  (let ((pages (bibtex-autokey-get-field "pages"))
-       (eid (bibtex-autokey-get-field "eid")))
-    (when (and (not (string= "" eid))
-              (or (string= "" pages)))
-      (bibtex-set-field "pages" eid))))
-
-
-(defun orcb-& ()
-  "Replace naked & with \& in a bibtex entry."
-  (save-restriction
-    (bibtex-narrow-to-entry)
-    (bibtex-beginning-of-entry)
-    (while (re-search-forward " & " nil t)
-      (replace-match " \\\\& "))))
-
-
-(defun orcb-% ()
-  "Replace naked % with % in a bibtex entry.
-Except when it is already escaped or in a URL. The replacement
-for the % is defined by `orcb-%-replacement-string'."
-  (save-restriction
-    (bibtex-narrow-to-entry)
-    (bibtex-beginning-of-entry)
-    (while (re-search-forward "\\([^\\]\\)%\\([^[:xdigit:]]\\)" nil t)
-      (replace-match (concat "\\1"
-                             orcb-%-replacement-string
-                             "\\2")))))
-
-
-(defun orcb-key-comma ()
-  "Make sure there is a comma at the end of the first line."
-  (bibtex-beginning-of-entry)
-  (end-of-line)
-  ;; some entries do not have a key or comma in first line. We check and add it,
-  ;; if needed.
-  (unless (string-match ", *$" (thing-at-point 'line))
-    (end-of-line)
-    (insert ",")))
-
-
-(defun orcb-key (&optional allow-duplicate-keys)
-  "Replace the key in the entry.
-Prompts for replacement if the new key duplicates one already in
-the file, unless ALLOW-DUPLICATE-KEYS is non-nil."
-  (let ((key (funcall org-ref-clean-bibtex-key-function
-                     (bibtex-generate-autokey))))
-    ;; remove any \\ in the key
-    (setq key (replace-regexp-in-string "\\\\" "" key))
-    ;; first we delete the existing key
-    (bibtex-beginning-of-entry)
-    (re-search-forward bibtex-entry-maybe-empty-head)
-    (if (match-beginning bibtex-key-in-head)
-       (delete-region (match-beginning bibtex-key-in-head)
-                      (match-end bibtex-key-in-head)))
-    ;; check if the key is in the buffer
-    (when (and (not allow-duplicate-keys)
-               (save-excursion
-                 (bibtex-search-entry key)))
-      (save-excursion
-       (bibtex-search-entry key)
-       (bibtex-copy-entry-as-kill)
-       (switch-to-buffer-other-window "*duplicate entry*")
-       (bibtex-yank))
-      (setq key (bibtex-read-key "Duplicate Key found, edit: " key)))
-
-    (insert key)
-    (kill-new key)))
-
-
-(defun orcb-check-journal ()
-  "Check entry at point to see if journal exists in `org-ref-bibtex-journal-abbreviations'.
-If not, issue a warning."
-  (interactive)
-  (when
-      (string= "article"
-               (downcase
-                (cdr (assoc "=type=" (bibtex-parse-entry)))))
-    (save-excursion
-      (bibtex-beginning-of-entry)
-      (let* ((entry (bibtex-parse-entry t))
-             (journal (cdr (assoc "journal" entry))))
-        (when (null journal)
-          (warn "Unable to get journal for this entry."))
-        (unless (member journal (-flatten org-ref-bibtex-journal-abbreviations))
-          (message "Journal \"%s\" not found in org-ref-bibtex-journal-abbreviations." journal))))))
-
-
-(defun orcb-fix-spacing ()
-  "Delete whitespace and fix spacing between entries."
-  (let (beg end)
-    (save-excursion
-      (save-restriction
-       (widen)
-       (bibtex-beginning-of-entry)
-       (setq beg (point))
-       (bibtex-end-of-entry)
-       (setq end (if (re-search-forward bibtex-any-entry-maybe-empty-head nil t)
-                     (progn (beginning-of-line)
-                            (point))
-                   (point-max)))
-       ;; 1. delete whitespace
-       (narrow-to-region beg end)
-       (delete-trailing-whitespace)
-       ;; 2. delete consecutive empty lines
-       (goto-char end)
-       (while (re-search-backward "\n\n\n+" nil 'move)
-         (replace-match "\n\n"))
-       ;; 3. add one line between entries
-       (goto-char end)
-       (forward-line -1)
-       (when (looking-at "[}][ \t]*\\|@Comment.+\\|%.+")
-         (end-of-line)
-         (newline))))))
-
-
-(defun orcb-download-pdf ()
-  "Try to get the pdf in an entry."
-  ;; try to get pdf
-  (when doi-utils-download-pdf
-    (if doi-utils-async-download
-       (doi-utils-async-download-pdf)
-      (doi-utils-get-bibtex-entry-pdf))))
-
-
-(defun orcb-clean-<>-tags ()
-  "Try removing <tags> from the entry."
-  (sgml-mode)
-  (ignore-errors
-    (while (sgml-skip-tag-forward 1)
-      (sgml-skip-tag-backward 1)
-      (sgml-delete-tag 1)))
-  (bibtex-mode))
-
-
-;;;###autoload
-(defun org-ref-clean-bibtex-entry ()
-  "Clean and replace the key in a bibtex entry.
-See functions in `org-ref-clean-bibtex-entry-hook'."
-  (interactive)
-  (save-excursion
-    (save-restriction
-      (bibtex-narrow-to-entry)
-      (bibtex-beginning-of-entry)
-      ;; run hooks. each of these operates on the entry with no arguments.
-      ;; this did not work like  i thought, it gives a symbolp error.
-      ;; (run-hooks org-ref-clean-bibtex-entry-hook)
-      (mapc (lambda (x)
-             (save-restriction
-               (save-excursion
-                 (funcall x))))
-           org-ref-clean-bibtex-entry-hook))))
-
-
-;; * Missing functions in bibtex-completion
-;; I couldn't find these, and they seem useful.
-
-(defun org-ref-bibtex-get-entry (key)
-  "Return a parsed bibtex entry."
-  (save-window-excursion
-    (let ((bibtex-completion-bibliography (org-ref-find-bibliography)))
-      (bibtex-completion-show-entry (list key))
-      (bibtex-beginning-of-entry)
-      (bibtex-parse-entry))))
-
-
-(defun org-ref-bibtex-get-entry-value (key field)
-  "For the entry associated with KEY get the FIELD value."
-  (cdr (assoc field (org-ref-bibtex-get-entry key))))
-
-
-(defun org-ref-get-citation-year (key)
-  "Get the year of an entry with KEY.  Return year as a string."
-  (org-ref-bibtex-get-entry-value key "year"))
-
-
-;;* The end
-(provide 'org-ref-bibtex)
-
-;;; org-ref-bibtex.el ends here
-
-;; Local Variables:
-;; byte-compile-warnings: (not docstrings-wide)
-;; End:
diff --git a/elpa/org-ref-20241124.2012/org-ref-citation-links.el b/elpa/org-ref-20241124.2012/org-ref-citation-links.el
deleted file mode 100644 (file)
index d030746..0000000
+++ /dev/null
@@ -1,1429 +0,0 @@
-;;; org-ref-citation-links.el --- citation links for org-ref -*- lexical-binding: t; -*-
-;;
-;; Copyright (C) 2024  John Kitchin
-
-;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
-;; Keywords: convenience
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
-;;
-;;; Commentary:
-;;
-;; This library provides hyper-functional citation links. These links can
-;; contain common pre/post notes, and multiple citation keys that each have
-;; their own pre/postnotes.
-;;
-;; These links are fontified to indicate if the citation keys are valid, and to
-;; indicate the pre/post-note structure. They also have tooltips that show
-;; information from the bibtex entry.
-;;
-;; Each link is functional, and clicking on one will open a hydra menu
-;; `org-ref-citation-hydra/body' of actions that range from opening the bibtex
-;; entry, notes, pdf or associated URL, to searching the internet for related
-;; articles.
-;;
-;; Each citation link also has a local keymap on it, which provides keyboard
-;; shortcuts for some actions like sorting, rearranging and navigating citation
-;; links. See `org-ref-cite-keymap' for the key bindings.
-;;
-;; Each link exports to a corresponding LaTeX citation command, or can be
-;; rendered with CSL for other kinds of exports like HTML, markdown, or ODT.
-;;
-;; This library also provides a minimal set of insertion functions that use
-;; completion. You can also use the org link completion mechanism to insert a
-;; citation.
-;;
-;; natmove like preprocessing is provided with `org-ref-cite-natmove'.
-;;
-;;; Code:
-(require 'org-keys)
-(require 'hydra)
-(require 'xref)
-(eval-when-compile (require 'subr-x))
-
-(defvar bibtex-completion-cache)
-(declare-function bibtex-completion-format-citation-cite "bibtex-completion")
-(declare-function bibtex-completion-show-entry "bibtex-completion")
-
-(defgroup org-ref-faces nil
-  "A group for faces in `org-ref'."
-  :group 'org-ref-faces)
-
-
-(defface org-ref-cite-face
-  `((t (:inherit org-link
-                 :foreground "forest green")))
-  "Color for cite-like links in org-ref."
-  :group 'org-ref-faces)
-
-
-(defface org-ref-bad-cite-key-face
-  `((t (:inherit org-ref-cite-face
-                :foreground "red")))
-  "Color for bad cite keys in org-ref."
-  :group 'org-ref-faces)
-
-
-(defface org-ref-cite-global-prefix/suffix-face
-  `((t (:inherit org-ref-cite-face :weight bold)))
-  "Face for global prefix/suffix in a cite link."
-  :group 'org-ref-faces)
-
-
-(defface org-ref-cite-&-face
-  `((t (:inherit org-ref-cite-face :weight bold)))
-  "Face for the starting & in a cite key."
-  :group 'org-ref-faces)
-
-
-(defface org-ref-cite-local-prefix/suffix-face
-  `((t (:inherit org-ref-cite-face :slant italic)))
-  "Face for local prefix/suffix in a cite link."
-  :group 'org-ref-faces)
-
-
-(defface org-ref-cite-invalid-local-prefix/suffix-face
-  `((t (:inherit org-ref-cite-face :foreground "red")))
-  "Face for invalid local prefix/suffix in a cite link.
-This is mostly for multicites and natbib."
-  :group 'org-ref-faces)
-
-
-(defcustom org-ref-activate-cite-links t
-  "If non-nil use font-lock to activate citations.
-In large documents with many citations activation can be slow.
-Set this to nil to turn that off, which increase performance."
-  :type 'boolean
-  :group 'org-ref)
-
-
-(defcustom org-ref-default-citation-link
-  "cite"
-  "The default type of citation link to use."
-  :type 'string
-  :group 'org-ref)
-
-
-(defcustom org-ref-natbib-types
-  '(("cite" "basic citation")
-    ("nocite" "add key to bibliography, but do not cite it in the text")
-    ("citet" "textual, Jones et al. (1990)")
-    ("citet*" "textual, full author list Jones, Baker, and Williams (1990)")
-    ("citep" "parenthetical citation (Jones et al. (1990))")
-    ("citep*" "parenthetical, full author list, (Jones, Baker, and Williams, 1990)")
-    ("citealt" "same as citet, but without parentheses")
-    ("citealt*" "same as citet, with full author list but without parentheses")
-    ("citealp" "same as citep, but without parentheses")
-    ("citealp*" "same as citep, with full author list, but without parentheses")
-    ("citenum" "The number of the citation in the bibliography, e.g. 11")
-    ("citetext" "text inserted in citation in the document")
-    ("citeauthor" "Only the author, Jones et al.")
-    ("citeauthor*" "The full author list, Jones, Baker, and Williams")
-    ("citeyear" "The year of the citation, 2021")
-    ("citeyearpar" "The year in parentheses (2021)")
-    ("Citet" "like citet, but with forced capitalization for starting sentences")
-    ("Citep" "like citep, but with forced capitalization for starting sentences")
-    ("Citealt" "like citet, but with forced capitalization and no parentheses")
-    ("Citealp" "like citep, but with forced capitalization and no parentheses")
-    ("Citeauthor" "like citeauthor with forced capitalization")
-    ("Citet*" "like citet, with full author list and forced capitalization")
-    ("Citep*" "like citep, with full author list and forced capitalization")
-    ("Citealt*" "like citet, with full author list, forced capitalization and no parentheses")
-    ("Citealp*" "like citep, with full author list, forced capitalization and no parentheses")
-    ("Citeauthor*" "like citeauthor with forced capitalization"))
-  "Natbib commands can have many references, and global prefix/suffix text.
-  For natbib cite commands see
-  http://tug.ctan.org/macros/latex/contrib/natbib/natnotes.pdf"
-  :type '(repeat :tag "List of citation types" (list string string))
-  :group 'org-ref)
-
-
-(defcustom org-ref-biblatex-types
-  '(("Cite" "basic citation with capitalization")
-    ("parencite" "similar to cite with parentheses")
-    ("Parencite" "similar to cite with parentheses and capitalization")
-    ("footcite" "Put the citation in a footnote")
-    ("footcitetext" "Put the citation in a footnote using \footnotetext")
-
-    ("textcite" "print the authors or editors as a subject of the sentence")
-    ("Textcite" "print the authors or editors as a subject of the sentence with capitalization")
-    ("smartcite" "like parencite in a footnote, and footcite in the body")
-    ("Smartcite" "like parencite in a footnote, and footcite in the body with capitalization")
-    ("cite*" "similar to cite, but prints the year or title")
-    ("parencite*" "similar to parencite, but prints the year or title")
-    ("supercite" "superscripted numeric citation (only in numeric styles)")
-
-    ("autocite" "handles some punctuation nuances")
-    ("Autocite" "handles some punctuation nuances with punctuation")
-    ("autocite*" "same as autocite but * is passed to the backend")
-    ("Autocite*" "same as Autocite but * is passed to the backend")
-
-    ("citetitle" "the shorttitle or title field")
-    ("citetitle*" "the full title")
-
-    ("citeyear" "the year field")
-    ("citeyear*" "the year field and extradate information if available")
-
-    ("citedate" "the full date or year")
-    ("citedate*" "the full date or year, including extradate information if available")
-
-    ("citeurl" "the url field")
-
-    ("fullcite" "create a full citation similar to what is in the bibliography")
-    ("footfullcite" "create a full citation as a footnote")
-    ;; "volcite" "Volcite" cannot support the syntax
-    ("notecite" "print prenote and postnote, but no citation")
-    ("Notecite" "print prenote and postnote, but no citation with capitalization")
-
-    ("pnotecite" "similar to notecite with parentheses")
-    ("Pnotecite" "similar to Notecite with parentheses")
-    ("fnotecite" "similar to notecite in a footnote"))
-  "biblatex commands.
-  Biblatex commands
-  https://mirrors.ibiblio.org/CTAN/macros/latex/contrib/biblatex/doc/biblatex.pdf"
-  :type '(repeat :tag "List of citation types" string)
-  :group 'org-ref)
-
-
-(defcustom org-ref-biblatex-multitypes
-  '(("cites" "multicite version of cite")
-    ("Cites" "multicite version of Cite")
-    ("parencites" "multicite version of parencite")
-    ("Parencites" "multicite version of Parencite")
-    ("footcites" "multicite version of footcite")
-    ("footcitetexts" "multicite version of footcitetext")
-    ("smartcites" "multicite version of smartcite")
-    ("Smartcites" "multicite version of Smartcite")
-    ("textcites" "multicite version of textcite")
-    ("Textcites" "multicite version of Textcite")
-    ("supercites" "multicite version of supercite")
-    ("autocites" "multicite version of autocite")
-    ("Autocites" "multicite version of Autocite"))
-  "Multicite link types"
-  :type '(repeat :tag "List of citation types" string)
-  :group 'org-ref)
-
-
-(defcustom org-ref-cite-types
-  (append
-   org-ref-natbib-types
-   org-ref-biblatex-types
-   org-ref-biblatex-multitypes
-   ;; for the bibentry package
-   '(("bibentry" "Insert the bibtex entry")))
-  "List of citation types known in `org-ref'."
-  :type '(repeat :tag "List of citation types (type description)" (list string string))
-  :group 'org-ref)
-
-
-(defvar org-ref-insert-cite-function)
-
-(defcustom org-ref-cite-keymap
-  (let ((map (copy-keymap org-mouse-map)))
-    ;; Navigation keys
-    (define-key map (kbd "C-<left>") 'org-ref-previous-key)
-    (define-key map (kbd "C-<right>") 'org-ref-next-key)
-
-    ;; rearrangement keys
-    (define-key map (kbd "S-<left>") (lambda () (interactive) (org-ref-swap-citation-link -1)))
-    (define-key map (kbd "S-<right>") (lambda () (interactive) (org-ref-swap-citation-link 1)))
-    (define-key map (kbd "S-<up>") 'org-ref-sort-citation-link)
-    (define-key map (kbd "<tab>") (lambda ()
-                                   (interactive)
-                                   (funcall org-ref-insert-cite-function)))
-
-    ;; xref navigation
-    (define-key map (kbd "M-.") (lambda ()
-                                 (interactive)
-                                 (xref-push-marker-stack)
-                                 (org-ref-open-citation-at-point)))
-    map)
-  "Keymap for cite links."
-  :type 'symbol
-  :group 'org-ref)
-
-
-(defcustom org-ref-cite-insert-version 3
-  "Default version to insert citations with.
-  The default is 3. In legacy documents you might prefer 2 though,
-  so this variable can be buffer- or directory local if you want.
-
-  version 2 means the links are not bracketed, and comma-separated keys.
-
-  version 3 means the links are bracketed, with semicolon-separated
-  &keys."
-  :type 'number
-  :group 'org-ref)
-
-
-(defvar org-ref-citation-key-re
-  (rx-to-string
-   '(seq "&" (group-n 1 (one-or-more (any word "-.:?!`'/*@+|(){}<>&_^$#%~")))))
-  "Numbered regular expression for a version 3 cite key.
-  Key is in group 1.
-  Adapted from the expression in org-cite.")
-
-
-(defun org-ref-cite-version (path)
-  "Return the version for PATH.
-  PATH is from a cite link.
-  Version 2 is separated by commas and uses plain keys.
-  Version 3 is separated by semicolons and uses &keys.
-  I think that if there is a & in path, it must be version 3."
-  (if (string-match "&" path)
-      3
-    2))
-
-
-;; * Parsing/interpreting a citation path
-
-(defun org-ref-parse-cite-path (path)
-  "Return a data structure representing the PATH.
-  the data structure is a plist with (:version :prefix :suffix :references).
-  Each reference is a plist with (:key :prefix :suffix)."
-  (pcase (org-ref-cite-version path)
-    (2
-     ;; This will not have any prefix or suffix, since that was previously done in the desc.
-     (list :version 2 :references (cl-loop for key in (split-string path ",") collect
-                                          (list :key (string-trim key)))))
-    (3 (let ((citation-references (split-string path ";"))
-            (these-results '(:version 3)))
-        ;; if the first ref doesn't match a key, it must be a global prefix
-        ;; this pops the reference off.
-        (when (null (string-match org-ref-citation-key-re (cl-first citation-references)))
-          (setq these-results (append these-results (list :prefix (cl-first citation-references)))
-                citation-references (cdr citation-references)))
-
-        ;; if the last ref doesn't match a key, then it is a global suffix
-        ;; we remove the last one if this is true after getting the suffix.
-        (when (null (string-match org-ref-citation-key-re (car (last citation-references))))
-          (setq these-results (append these-results (list :suffix (car (last citation-references))))
-                citation-references (butlast citation-references)))
-
-        (setq these-results
-              (append these-results
-                      (list
-                       :references
-                       (cl-loop for s in citation-references collect
-                                (if (null (string-match org-ref-citation-key-re s))
-                                    (error "No matching key found in %s" s)
-                                  (let* ((key (match-string-no-properties 1 s))
-                                         (key-start (match-beginning 0))
-                                         (key-end (match-end 0))
-                                         (prefix (let ((p (substring s 0 key-start)))
-                                                   (if (string= "" (string-trim p))
-                                                       nil
-                                                     p)))
-                                         (suffix (let ((s (substring s key-end)))
-                                                   (if (string= "" (string-trim s))
-                                                       nil
-                                                     s))))
-                                    (list :key key :prefix prefix :suffix suffix)))))))))))
-
-
-(defun org-ref-interpret-cite-data (data)
-  "Interpret the DATA structure from `org-ref-parse-cite-path' back
-to a path string."
-  (pcase (plist-get data :version)
-    (2
-     (string-join (cl-loop for ref in (plist-get data :references) collect (plist-get ref :key)) ","))
-    (3
-     (concat
-      (when-let (prefix (plist-get data :prefix)) (concat prefix ";"))
-      (string-join (cl-loop for ref in (plist-get data :references) collect
-                           (concat
-                            (plist-get ref :prefix)
-                            "&" (plist-get ref :key)
-                            (plist-get ref :suffix)))
-                  ";")
-      (when-let (suffix (plist-get data :suffix)) (concat ";" suffix))))))
-
-
-;; * Activating citation links
-;;
-;; We use the activate-func for fontification of pieces of each link.
-
-
-(declare-function bibtex-completion-candidates "bibtex-completion")
-(declare-function bibtex-completion-init "bibtex-completion")
-(defvar bibtex-completion-bibliography)
-(defvar bibtex-completion-display-formats-internal)
-
-;; (defun org-ref-valid-keys ()
-;;   "Return a list of valid bibtex keys for this buffer.
-;; This is used a lot in `org-ref-cite-activate' so it needs to be
-;; fast, but also up to date."
-;;   ;; this seems to be needed, but we don't want to do this every time
-;;   (unless bibtex-completion-display-formats-internal
-;;     (bibtex-completion-init))
-
-;;   (let ((bibtex-completion-bibliography (org-ref-find-bibliography)))
-;;     (cl-loop for entry in (bibtex-completion-candidates)
-;;          collect
-;;          (cdr (assoc "=key=" (cdr entry))))))
-
-
-(defun org-ref-valid-keys ()
-  "Return a list of valid bibtex keys for this buffer.
-This is used a lot in `org-ref-cite-activate' so it needs to be
-fast, but also up to date."
-
-  ;; this seems to be needed, but we don't want to do this every time
-  (unless bibtex-completion-display-formats-internal
-    (bibtex-completion-init))
-
-  (let* ((files (org-ref-find-bibliography)))
-    (if (seq-every-p 'identity
-                    (cl-loop for file in files
-                             collect (assoc file bibtex-completion-cache)))
-       ;; We have a cache for each file
-       ;; bibtex-completion-cache contains (filename md5hash entries)
-       (cl-loop for entry in
-                (cl-loop
-                 for file in files
-                 append (cddr (assoc file bibtex-completion-cache)))
-                collect (cdr (assoc "=key=" (cdr entry))))
-      ;; you need to get a cache because one or more of the files was not in the cache.
-      (let ((bibtex-completion-bibliography files))
-       (cl-loop for entry in (bibtex-completion-candidates)
-                collect
-                (cdr (assoc "=key=" (cdr entry))))))))
-
-
-(defvar-local org-ref-valid-keys-hashes nil)
-(defvar-local org-ref-valid-keys-cache  nil)
-
-(defun org-ref-valid-keys-cached ()
-  "Update `org-ref-valid-keys-cache` only when files changed."
-
-  (let ((local-hashes (cons bibtex-completion-bibliography
-                            (mapcar 'cadr bibtex-completion-cache))))
-    (when (not (equal local-hashes org-ref-valid-keys-hashes))
-      (setq-local org-ref-valid-keys-hashes local-hashes)
-      (setq-local org-ref-valid-keys-cache (make-hash-table :test 'equal))
-      (cl-loop for entry in (org-ref-valid-keys)
-               do
-               (puthash entry t org-ref-valid-keys-cache))))
-  org-ref-valid-keys-cache)
-
-
-(defun org-ref-cite-activate (start end path _bracketp)
-  "Activation function for a cite link.
-START and END are the bounds of the link.
-PATH has the citations in it."
-  (when (and org-ref-activate-cite-links
-            ;; Try avoid fontifying org-cite elements. this is based on the
-            ;; path containing @ which makes it likely to be an org-cite. Maybe
-            ;; a text property is better, in case this is an issue in the
-            ;; future.
-            (not (s-contains-p "@" path)))
-    (let* ((valid-keys (org-ref-valid-keys))
-          valid-key
-          substrings)
-      (goto-char start)
-      (pcase (org-ref-cite-version path)
-       (2
-        ;; This makes the brackets visible, but we only need it when there is a
-        ;; description.
-        (when (looking-at "\\[\\[\\(.*\\)\\]\\[\\(.*\\)\\]\\]")
-          (remove-text-properties start end '(invisible nil)))
-        (setq substrings (split-string path ","))
-        (cl-loop for key in substrings
-                 do
-                 ;; get to the substring
-                 (search-forward key end)
-                 (put-text-property (match-beginning 0)
-                                    (match-end 0)
-                                    'keymap
-                                    org-ref-cite-keymap)
-                 (put-text-property (match-beginning 0)
-                                    (match-end 0)
-                                    'cite-key
-                                    key)
-                 (unless (member (string-trim key) valid-keys)
-                   (put-text-property (match-beginning 0)
-                                      (match-end 0)
-                                      'face 'org-ref-bad-cite-key-face)
-                   (put-text-property (match-beginning 0)
-                                      (match-end 0)
-                                      'help-echo "Key not found"))))
-       (3
-        (setq substrings (split-string path ";"))
-        (cl-loop for i from 0 for s in substrings
-                 do
-                 ;; get to the substring
-                 (search-forward s end)
-                 (put-text-property (match-beginning 0)
-                                    (match-end 0)
-                                    'keymap
-                                    org-ref-cite-keymap)
-                 (let* (key-begin
-                        key-end
-                        key)
-
-                   ;; Look for a key. common pre/post notes do not have keys in them.
-                   (save-match-data
-                     (when (string-match org-ref-citation-key-re s)
-                       (setq key (match-string-no-properties 1 s)
-                             valid-key (member key valid-keys))))
-
-                   ;; these are global prefix/suffixes
-                   (when (and (or (= i 0)
-                                  (= i (- (length substrings) 1)))
-                              (null key))
-                     (put-text-property (match-beginning 0) (match-end 0)
-                                        'face 'org-ref-cite-global-prefix/suffix-face)
-                     (put-text-property (match-beginning 0) (match-end 0)
-                                        'help-echo "Global prefix/suffix"))
-
-                   ;; we have a key. we have to re-search to get its position
-                   (when key
-                     (save-excursion
-                       (save-match-data
-                         (search-backward (concat "&" key))
-                         (setq key-begin (match-beginning 0)
-                               key-end (match-end 0))))
-                     ;; mark the &
-                     (put-text-property key-begin (+ 1 key-begin)
-                                        'face 'org-ref-cite-&-face)
-                     ;; store key on the whole thing
-                     (put-text-property (match-beginning 0)
-                                        (match-end 0)
-                                        'cite-key
-                                        key)
-
-                     ;; fontify any prefix /suffix text
-                     (put-text-property (match-beginning 0) key-begin
-                                        'face 'org-ref-cite-local-prefix/suffix-face)
-
-                     (put-text-property key-end (match-end 0)
-                                        'face 'org-ref-cite-local-prefix/suffix-face)
-
-                     ;; bad key activation
-                     (unless valid-key
-                       (put-text-property key-begin key-end
-                                          'face 'font-lock-warning-face)
-                       (put-text-property key-begin key-end
-                                          'help-echo "Key not found"))))))))))
-
-
-;; * Following citation links
-
-(declare-function org-ref-get-bibtex-key-and-file "org-ref-core")
-
-(defhydra org-ref-citation-hydra (:color blue :hint nil)
-  "Citation actions
-"
-  ("o" org-ref-open-citation-at-point  "Bibtex" :column "Open")
-  ("p" org-ref-open-pdf-at-point "PDF" :column "Open")
-  ("n" org-ref-open-notes-at-point "Notes" :column "Open")
-  ("u" org-ref-open-url-at-point "URL" :column "Open")
-
-  ;; WWW actions
-  ("ww" org-ref-wos-at-point "WOS" :column "WWW")
-  ("wr" org-ref-wos-related-at-point "WOS related" :column "WWW")
-  ("wc" org-ref-wos-citing-at-point "WOS citing" :column "WWW")
-  ("wg" org-ref-google-scholar-at-point "Google Scholar" :column "WWW")
-  ("wp" org-ref-pubmed-at-point "Pubmed" :column "WWW")
-  ("wf" org-ref-crossref-at-point "Crossref" :column "WWW")
-  ("wb" org-ref-biblio-at-point "Biblio" :column "WWW")
-  ("e" org-ref-email-at-point "Email" :column "WWW")
-
-  ;; Copyish actions
-  ("K" (save-window-excursion
-        (let ((bibtex-completion-bibliography (org-ref-find-bibliography)))
-          (bibtex-completion-show-entry (list (org-ref-get-bibtex-key-under-cursor)))
-          (bibtex-copy-entry-as-kill)
-          (kill-new (pop bibtex-entry-kill-ring))))
-   "Copy bibtex" :column "Copy")
-  ("a" org-ref-add-pdf-at-point "add pdf to library" :column "Copy")
-  ("k" (kill-new (car (org-ref-get-bibtex-key-and-file))) "Copy key" :column "Copy")
-  ("f" (kill-new (bibtex-completion-apa-format-reference
-                 (org-ref-get-bibtex-key-under-cursor)))
-   "Copy formatted" :column "Copy")
-  ("h" (kill-new
-       (format "* %s\n\n cite:&%s"
-               (bibtex-completion-apa-format-reference
-                (org-ref-get-bibtex-key-under-cursor))
-               (car (org-ref-get-bibtex-key-and-file))))
-   "Copy org heading"
-   :column "Copy")
-
-  ;; Editing actions
-  ("<left>" org-ref-cite-shift-left "Shift left" :color red :column "Edit")
-  ("<right>" org-ref-cite-shift-right "Shift right" :color red :column "Edit")
-  ("<up>" org-ref-sort-citation-link "Sort by year" :column "Edit")
-  ("i" (funcall org-ref-insert-cite-function) "Insert cite" :column "Edit")
-  ("t" org-ref-change-cite-type "Change cite type" :column "Edit")
-  ("d" org-ref-delete-citation-at-point "Delete at point" :column "Edit")
-  ("r" org-ref-replace-citation-at-point "Replace cite" :column "Edit")
-  ("P" org-ref-edit-pre-post-notes "Edit pre/suffix" :column "Edit")
-
-  ;; Navigation
-  ("[" org-ref-previous-key "Previous key" :column "Navigation" :color red)
-  ("]"  org-ref-next-key "Next key" :column "Navigation" :color red)
-  ("v" org-ref-jump-to-visible-key "Visible key" :column "Navigation" :color red)
-  ("q" nil "Quit"))
-
-
-(defun org-ref-cite-follow (_path)
-  "Follow a cite link."
-  (org-ref-citation-hydra/body))
-
-
-;; * Citation links tooltips
-(defvar bibtex-completion-bibliography)
-(defvar bibtex-completion-pdf-symbol)
-(defvar bibtex-completion-notes-symbol)
-(defvar bibtex-completion-find-note-functions)
-
-(declare-function org-ref-find-bibliography "org-ref-core")
-(declare-function bibtex-completion-find-pdf "bibtex-completion")
-(declare-function bibtex-completion-apa-format-reference "bibtex-completion")
-
-(defun org-ref-cite-tooltip (_win _obj position)
-  "Get a tooltip for the cite at POSITION."
-  (let ((key (get-text-property position 'cite-key)))
-    (when key
-      (let* ((bibtex-completion-bibliography (org-ref-find-bibliography))
-            (has-pdf (when (bibtex-completion-find-pdf key) bibtex-completion-pdf-symbol))
-            (has-notes (when (cl-some #'identity
-                                      (mapcar (lambda (fn)
-                                                (funcall fn key))
-                                              bibtex-completion-find-note-functions))
-                         bibtex-completion-notes-symbol)))
-       (format "%s%s %s" (or has-pdf "") (or has-notes "")
-               (bibtex-completion-apa-format-reference key))))))
-
-
-;; * Exporting citation links
-
-(defun org-ref-cite-export (cmd path desc backend)
-  "Export a cite link.
-This supports the syntax:  \\cmd[optional prefix][optional suffix]{keys}
-The prefix and suffix must be the global version. Local prefix/suffixes are ignored.
-PATH contains the link path.
-BACKEND is the export backend.
-Use with apply-partially."
-  (pcase backend
-    ('latex
-     (let* ((cite (org-ref-parse-cite-path path))
-           (references (plist-get cite :references))
-           (keys (cl-loop for ref in references collect
-                          (plist-get ref :key))))
-       (pcase (org-ref-cite-version path)
-        (2
-         (let* ((prefix-suffix (split-string (or desc "") "::"))
-                (prefix (cond
-                         ((and (cl-first prefix-suffix) (not (string= "" (cl-first prefix-suffix))))
-                          (format "[%s]" (cl-first prefix-suffix)))
-                         ((cl-second prefix-suffix)
-                          "[]")
-                         (t
-                          "")))
-                (suffix (cond
-                         ((cl-second prefix-suffix)
-                          (format "[%s]" (cl-second prefix-suffix)))
-                         (t
-                          ""))))
-           (s-format "\\${cmd}${prefix}${suffix}{${keys}}" 'aget
-                     `(("cmd" . ,cmd)
-                       ("prefix" . ,(string-trim prefix))
-                       ("suffix" . ,(string-trim suffix))
-                       ("keys" . ,(string-join keys ","))))))
-        (3
-         (s-format "\\${cmd}${prefix}${suffix}{${keys}}" 'aget
-                   `(("cmd" . ,cmd)
-                     ;; if there is more than one key, we only do global
-                     ;; prefix/suffix But for one key, we should allow local
-                     ;; prefix and suffix or the global one.
-                     ("prefix" . ,(if (= 1 (length references))
-                                      ;; single reference
-                                      (cond
-                                       ;; global and common prefixes exist, combine them
-                                       ((and (plist-get cite :prefix)
-                                             (plist-get (car references) :prefix))
-
-                                        (concat "["
-                                                (plist-get cite :prefix)
-                                                ";" ;; add this back as a separator
-                                                (plist-get (car references) :prefix)
-                                                "]"))
-                                       ;; local prefix is not empty, we use it.
-                                       ((plist-get (car references) :prefix)
-                                        (concat "["
-                                                (string-trim (plist-get (car references) :prefix))
-                                                "]"))
-                                       ;; local prefix is empty, but global one
-                                       ;; is not, so we use it
-                                       ((plist-get cite :prefix)
-                                        (concat "["
-                                                (string-trim (plist-get cite :prefix))
-                                                "]"))
-                                       ;; if you have a suffix, you need an empty prefix
-                                       ((plist-get cite :suffix)
-                                        "[]")
-                                       (t
-                                        ""))
-                                    ;; Multiple references
-                                    (cond
-                                     ;; Check the common prefix
-                                     ((plist-get cite :prefix)
-                                      (concat "["
-                                              (string-trim (plist-get cite :prefix))
-                                              "]"))
-                                     ;; Check the prefix in the first cite
-                                     ((plist-get (car references) :prefix)
-                                      (concat "["
-                                              (string-trim (plist-get (car references) :prefix))
-                                              "]"))
-                                     ;; if you get here, the prefix is empty.
-                                     ;; if you have a suffix, you need an empty prefix placeholder
-                                     ((plist-get cite :suffix)
-                                      "[]")
-                                     (t
-                                      ""))))
-                     ("suffix" . ,(if (= 1 (length references))
-                                      ;; Single reference
-                                      (cond
-                                       ;; local suffix is not empty, so use it
-                                       ((plist-get (car references) :suffix)
-                                        (format "[%s]"
-                                                (string-trim (plist-get (car references) :suffix))))
-                                       ;; global suffix is not empty
-                                       ((plist-get cite :suffix)
-                                        (format "[%s]" (string-trim (plist-get cite :suffix))))
-                                       (t
-                                        ;; If there is a prefix, then this should
-                                        ;; be an empty bracket, and if not it
-                                        ;; should am empty string. You need an
-                                        ;; empty bracket, at least for biblatex
-                                        ;; commands. With just one set of
-                                        ;; brackets it is interpreted as a
-                                        ;; suffix.
-                                        (if (or (plist-get cite :prefix)
-                                                (plist-get (car references) :prefix))
-                                            "[]"
-                                          "")))
-                                    ;; Multiple references
-                                    (cond
-                                     ;; this is a common suffix
-                                     ((plist-get cite :suffix)
-                                      (format "[%s]" (string-trim (plist-get cite :suffix))))
-                                     ;; last reference has a suffix
-                                     ((plist-get (car (last references)) :suffix)
-                                      (format "[%s]" (string-trim (plist-get (car (last references)) :suffix))))
-                                     (t
-                                      ;; If there is a prefix, then this should
-                                      ;; be an empty bracket, and if not it
-                                      ;; should am empty string. You need an
-                                      ;; empty bracket, at least for biblatex
-                                      ;; commands. With just one set of
-                                      ;; brackets it is interpreted as a
-                                      ;; suffix.
-                                      (if (or (plist-get cite :prefix)
-                                              (plist-get (car references) :prefix))
-                                          "[]"
-                                        "")))))
-                     ("keys" . ,(string-join keys ","))))))))))
-
-
-(defun org-ref-multicite-export (cmd path _desc backend)
-  "Export a multicite link.
-This supports the syntax:  \\cmd(multiprenote)(multipostnote)[prenote][postnote]{key1}...[prenote][postnote]{key}
-PATH contains the link path.
-BACKEND is the export backend.
-Use with apply-partially."
-  (pcase backend
-    ('latex
-     (let ((cite (org-ref-parse-cite-path path)))
-       (s-format "\\${cmd}${global-prefix}${global-suffix}${keys}" 'aget
-                `(("cmd" . ,cmd)
-                  ("global-prefix" . ,(cond
-                                       ((plist-get cite :prefix)
-                                        (concat "(" (plist-get cite :prefix) ")"))
-                                       ;; if you have a suffix, you need an empty prefix
-                                       ((plist-get cite :suffix)
-                                        "()")
-                                       (t
-                                        "")))
-                  ("global-suffix" . ,(if (not (string= "" (or (plist-get cite :suffix) "")))
-                                          (format "(%s)" (plist-get cite :suffix))
-                                        ""))
-                  ("keys" . ,(string-join
-                              (cl-loop for ref in (plist-get cite :references)
-                                       collect
-                                       (format "%s%s{%s}"
-                                               (cond
-                                                ;; we have a prefix, stick it in
-                                                ((not (string= ""
-                                                               (or (plist-get ref :prefix) "")))
-                                                 (concat "[" (plist-get ref :prefix) "]"))
-                                                ;; no prefix, but a suffix, so
-                                                ;; empty prefix for placeholder
-                                                ((not (string= ""
-                                                               (or (plist-get ref :suffix) "")))
-                                                 "[]")
-                                                (t
-                                                 ""))
-                                               (cond
-                                                ((not (string= ""
-                                                               (or (plist-get ref :suffix) "")))
-                                                 (concat "[" (plist-get ref :suffix) "]"))
-                                                (t
-                                                 ""))
-                                               (plist-get ref :key)))))))))))
-
-;; * Completion for citation links
-;;
-;; This allows you to type C-c l, choose a cite link type, and then insert a key.
-
-(defun org-ref-cite-link-complete (cmd &optional _arg)
-  "Cite link completion for CMD."
-  (concat
-   cmd ":"
-   "&" (org-ref-read-key)))
-
-;; * Generate all the links
-;;
-;; We loop on the three categories because there are some differences between
-;; them, mostly in the multitypes.
-
-(cl-loop for (cmd _desc) in (append org-ref-natbib-types
-                                   org-ref-biblatex-types)
-        do
-        (org-link-set-parameters
-         cmd
-         :complete (apply-partially #'org-ref-cite-link-complete cmd)
-         :follow #'org-ref-cite-follow
-         :face 'org-ref-cite-face
-         :help-echo #'org-ref-cite-tooltip
-         :export (apply-partially 'org-ref-cite-export  cmd)
-         :activate-func #'org-ref-cite-activate))
-
-
-(cl-loop for (cmd _desc) in org-ref-biblatex-multitypes do
-        (org-link-set-parameters
-         cmd
-         :complete (apply-partially #'org-ref-cite-link-complete cmd)
-         :follow #'org-ref-cite-follow
-         :face 'org-ref-cite-face
-         :help-echo #'org-ref-cite-tooltip
-         :export (apply-partially 'org-ref-multicite-export cmd)
-         :activate-func #'org-ref-cite-activate))
-
-
-(org-link-set-parameters
- "bibentry"
- :complete (apply-partially #'org-ref-cite-link-complete "bibentry")
- :follow #'org-ref-cite-follow
- :face 'org-ref-cite-face
- :help-echo #'org-ref-cite-tooltip
- :export (apply-partially 'org-ref-cite-export  "bibentry")
- :activate-func #'org-ref-cite-activate)
-
-
-;; * Cite link utilities
-
-;;;###autoload
-(defun org-ref-delete-citation-at-point ()
-  "Delete the citation or reference at point."
-  (interactive)
-  (let* ((object (org-element-context))
-         (type (org-element-property :type object))
-         (begin (org-element-property :begin object))
-         (end (org-element-property :end object))
-         (link-string (org-element-property :path object))
-        (data (org-ref-parse-cite-path link-string))
-        (references (plist-get data :references))
-        (cp (point))
-         key i)
-    ;;   We only want this to work on citation links
-    (when (assoc type org-ref-cite-types)
-      (setq key (org-ref-get-bibtex-key-under-cursor))
-      (if (null key)
-         ;; delete the whole cite
-         (cl--set-buffer-substring begin end "")
-       (setq i (seq-position references key (lambda (el key)
-                                              (string= key (plist-get el :key)))))
-       ;; delete i'th reference
-       (setq references (-remove-at i references))
-       (setq data (plist-put data :references references))
-       (save-excursion
-         (goto-char begin)
-         (re-search-forward link-string)
-         (replace-match (org-ref-interpret-cite-data data)))
-       (goto-char cp)))))
-
-
-;;;###autoload
-(defun org-ref-replace-citation-at-point ()
-  "Replace the citation at point."
-  (interactive)
-  (let* ((object (org-element-context))
-         (type (org-element-property :type object))
-         (begin (org-element-property :begin object))
-         (end (org-element-property :end object))
-         (link-string (org-element-property :path object))
-        (data (org-ref-parse-cite-path link-string))
-        (references (plist-get data :references))
-        (cp (point))
-         key i)
-    ;;   We only want this to work on citation links
-    (when (assoc type org-ref-cite-types)
-      (setq key (org-ref-get-bibtex-key-under-cursor))
-
-      (if (null key)
-         ;; delete the whole cite
-         (cl--set-buffer-substring begin end "")
-       (setq i (seq-position references key (lambda (el key) (string= key (plist-get el :key))))) ;; defined in org-ref
-       (setf (plist-get (nth i references) :key)  (org-ref-read-key))
-
-       (setq data (plist-put data :references references))
-       (save-excursion
-         (goto-char begin)
-         (re-search-forward link-string)
-         (replace-match (org-ref-interpret-cite-data data)))
-       (goto-char cp)))))
-
-
-;;;###autoload
-(defun org-ref-edit-pre-post-notes (&optional common)
-  "Edit the pre/post notes at point.
-
-if you are not on a key, or with optional prefix
-arg COMMON, edit the common prefixes instead."
-  (interactive "P")
-  ;; find out what the point is on.
-  (let* ((key (get-text-property (point) 'cite-key))
-        (cp (point))
-        (cite (org-element-context))
-        (type (org-element-property :type cite))
-        (data (org-ref-parse-cite-path (org-element-property :path cite)))
-        prefix suffix
-        (delta 0))
-
-    (if (or (null key) common)
-       (progn
-         (setq prefix (read-string "prenote: " (plist-get data :prefix))
-               suffix (read-string "postnote: " (plist-get data :suffix))
-               delta (- (length (plist-get data :prefix)) (length prefix)))
-
-         (plist-put data :prefix (if (string= "" prefix)
-                                     nil prefix))
-
-         (plist-put data :suffix (if (string= "" suffix)
-                                     nil suffix)))
-
-      ;; On a key
-      (let ((index (seq-position (plist-get data :references)
-                                key
-                                (lambda (el1 key-at-point)
-                                  (string= key-at-point (plist-get el1 :key))))))
-       ;; Pad with spaces after prefix and before suffix
-       (setq prefix (concat
-                     (read-string "prenote: "
-                                  (string-trim
-                                   (or
-                                    (plist-get
-                                     (nth index (plist-get data :references))
-                                     :prefix)
-                                    "")))
-                     " ")
-             suffix (concat " "
-                            (read-string "postnote: "
-                                         (string-trim
-                                          (or
-                                           (plist-get
-                                            (nth index (plist-get data :references))
-                                            :suffix)
-                                           ""))))
-             delta (- (length (plist-get
-                               (nth index (plist-get data :references))
-                               :prefix))
-                      (length prefix)))
-       (plist-put
-        (nth index (plist-get data :references))
-        :prefix (if (string= "" prefix)
-                    nil prefix))
-
-       (plist-put
-        (nth index (plist-get data :references))
-        :suffix (if (string= "" suffix)
-                    nil suffix))))
-
-
-    (cl--set-buffer-substring (org-element-property :begin cite) (org-element-property :end cite)
-                             (format "[[%s:%s]]" type (org-ref-interpret-cite-data data)))
-
-    ;; This doesn't exactly save the point. I need a fancier calculation for
-    ;; that I think that accounts for the change due to the prefix change. e.g.
-    ;; you might add or subtract from the prefix.
-    (goto-char (- cp delta))))
-
-
-(declare-function org-element-create "org-element")
-
-;;;###autoload
-(defun org-ref-change-cite-type ()
-  "Change the cite type of citation link at point."
-  (interactive)
-  (let* ((type-annotation (lambda (s)
-                           (let ((item (assoc s minibuffer-completion-table)))
-                             (when item (concat
-                                         (make-string (- 12 (length s)) ? )
-                                         "-- "
-                                         (cl-second item))))))
-        (completion-extra-properties `(:annotation-function ,type-annotation))
-        (new-type (completing-read "Type: " org-ref-cite-types))
-        (cite-link (org-element-context))
-        (cp (point)))
-    (cl--set-buffer-substring
-     (org-element-property :begin cite-link)
-     (org-element-property :end cite-link)
-     (org-element-interpret-data
-      (org-element-create 'link
-                         `(:type ,new-type
-                                 :path ,(org-element-property :path cite-link)
-                                 :contents-begin ,(org-element-property :contents-begin cite-link)
-                                 :contents-end ,(org-element-property :contents-end  cite-link)))))
-    (goto-char cp)))
-
-
-(defun org-ref-get-bibtex-key-under-cursor ()
-  "Return key under the cursor in org-mode.
-If not on a key, but on a cite, prompt for key."
-  (cond
-   (org-ref-activate-cite-links
-    (if-let ((key (get-text-property (point) 'cite-key)))
-       ;; Point is on a key, so we get it directly
-       key
-      ;; point is not on a key, but may still be on a cite link
-      (let ((el (org-element-context))
-           (cp (point))
-           data
-           keys)
-       (cond
-        ;; on a cite-link type
-        ((and
-          (eq (org-element-type el) 'link)
-          (assoc (org-element-property :type el) org-ref-cite-types))
-
-         (goto-char (org-element-property :begin el))
-         (setq data (org-ref-parse-cite-path (org-element-property :path el))
-               keys (cl-loop for ref in (plist-get data :references)
-                             collect (plist-get ref :key)))
-         (cond
-          ((= 1 (length keys))
-           (search-forward (car keys))
-           (goto-char (match-beginning 0)))
-          ;; multiple keys
-          (t
-           (setq key (completing-read "Key: " keys))
-           (search-forward key)
-           (goto-char (match-beginning 0))))
-         (prog1
-             (get-text-property (point) 'cite-key)
-           (goto-char cp)))
-
-        ;; somewhere else, but looking at a cite-type see issue #908. links in
-        ;; places like keywords are not parsed as links, but they seem to get
-        ;; activated, so we can just get onto the key, and then open it.
-        ((assoc (thing-at-point 'word) org-ref-cite-types)
-         (save-excursion
-           (when (re-search-forward ":" (line-end-position) t)
-             (prog1
-                 (get-text-property (point) 'cite-key)
-               (goto-char cp)))))))))
-   
-   ;; org-ref-activate-cite-links is nil so font-lock does not put
-   ;; text-properties on keys. We temporarily activate this
-   
-   (t
-    (let ((el (org-element-context))
-         (org-ref-activate-cite-links t)) ;; temporary
-      (when (and
-            (eq (org-element-type el) 'link)
-            (assoc (org-element-property :type el) org-ref-cite-types))
-       (save-excursion
-         ;; We activate just this one link
-         (org-ref-cite-activate
-          (org-element-property :begin el)
-          (org-element-property :end el)
-          (org-element-property :path el)
-          nil)))
-      ;; Now we have to handle some cases.
-      (cond
-       ;; on a key, return a key
-       ((get-text-property (point) 'cite-key)
-       (get-text-property (point) 'cite-key))
-       ;; not on a key, but on a cite. this is lazy, but we just search forward
-       ;; to the first key
-       (t
-       (search-forward ":")
-       (get-text-property (point) 'cite-key)))))))
-
-
-;; ** Shift-arrow sorting of keys in a cite link
-
-(defun org-ref-swap-list-elements (i j lst)
-  "Swap index I and J in the list LST."
-  (let ((tempi (nth i lst)))
-    (setf (nth i lst) (nth j lst))
-    (setf (nth j lst) tempi))
-  lst)
-
-
-(defun org-ref-swap-citation-link (direction)
-  "Move citation at point in DIRECTION +1 is to the right, -1 to the left."
-  (let* ((object (org-element-context))
-         (type (org-element-property :type object))
-         (begin (org-element-property :begin object))
-         ;; (end (org-element-property :end object))
-         (link-string (org-element-property :path object))
-        (data (org-ref-parse-cite-path link-string))
-        (references (plist-get data :references))
-         key i)
-    ;;   We only want this to work on citation links
-    (when (assoc type org-ref-cite-types)
-      (setq key (org-ref-get-bibtex-key-under-cursor))
-      (setq i (seq-position references key (lambda (el key) (string= key (plist-get el :key))))) ;; defined in org-ref
-      (if (> direction 0) ;; shift right
-          (org-ref-swap-list-elements i (min (+ i 1) (- (length references) 1)) references)
-        (org-ref-swap-list-elements i (max (- i 1) 0) references))
-      (setq data (plist-put data :references references))
-
-      ;; and replace the link with the sorted keys
-      (save-excursion
-       (goto-char begin)
-       (re-search-forward link-string)
-       (replace-match (org-ref-interpret-cite-data data)))
-      ;; now go forward to key so we can move with the key
-      (goto-char begin)
-      (re-search-forward key)
-      (goto-char (match-beginning 0)))))
-
-
-(defun org-ref-cite-shift-left ()
-  "Shift reference at point to the left."
-  (interactive)
-  (org-ref-swap-citation-link -1))
-
-
-(defun org-ref-cite-shift-right ()
-  "Shift citation at point to the right."
-  (interactive)
-  (org-ref-swap-citation-link +1))
-
-
-;;** Sort cite in cite link
-
-;;;###autoload
-(defun org-ref-sort-citation-link ()
-  "Replace link at point with sorted link by year."
-  (interactive)
-  (let* ((object (org-element-context))
-         ;; (type (org-element-property :type object))
-         (begin (org-element-property :begin object))
-         ;; (end (org-element-property :end object))
-         (link-string (org-element-property :path object))
-        (data (org-ref-parse-cite-path link-string))
-        (references (plist-get data :references))
-        (bibtex-completion-bibliography (org-ref-find-bibliography))
-        current-point)
-
-    (setq references (cl-sort (cl-loop for ref in references collect
-                                      (append ref (list :year (bibtex-completion-get-value
-                                                               "year"
-                                                               (bibtex-completion-get-entry
-                                                                (plist-get ref :key))))))
-                             (lambda (x y)
-                               (< (string-to-number (plist-get x :year))
-                                  (string-to-number (plist-get y :year))))))
-    (setq data (plist-put data :references references)
-         current-point (point))
-    (goto-char begin)
-    (re-search-forward link-string)
-    (replace-match (org-ref-interpret-cite-data data))
-    (goto-char current-point)))
-
-
-;;** C-arrow navigation of cite keys
-;;
-;; These are a little tricky to understand to me. There are two calls because
-;; when you are on a cite, and move, the first change is the boundary of the
-;; current cite, and the second is the boundary of next cite.
-
-;;;###autoload
-(defun org-ref-next-key ()
-  "Move cursor to the next cite key when on a cite link.
-Otherwise run `right-word'. If the cursor moves off the link,
-move to the beginning of the next cite link after this one."
-  (interactive)
-  (when-let (next (next-single-property-change (point) 'cite-key))
-    (goto-char next))
-  (unless (get-text-property (point) 'cite-key)
-    (when-let (next (next-single-property-change (point) 'cite-key))
-      (goto-char next))))
-
-
-;;;###autoload
-(defun org-ref-previous-key ()
-  "Move cursor to the previous cite key when on a cite link.
-Otherwise run `left-word'. If the cursor moves off the link,
-move to the beginning of the previous cite link after this one."
-  (interactive)
-  (when-let (prev (previous-single-property-change (point) 'cite-key))
-    (goto-char prev))
-  (unless (get-text-property (point) 'cite-key)
-    (when-let (prev (previous-single-property-change (point) 'cite-key))
-      (goto-char prev))))
-
-(defvar avy-goto-key)
-(defvar avy-style)
-(declare-function avy--style-fn "avy")
-(declare-function avy-process "avy")
-(declare-function avy-with "avy")
-(declare-function org-element-parse-buffer "org-element")
-(declare-function org-element-property "org-element")
-(declare-function org-element-type "org-element")
-(declare-function org-element-map "org-element")
-(declare-function bibtex-completion-get-value "bibtex-completion")
-(declare-function bibtex-completion-get-entry "bibtex-completion")
-
-;;;###autoload
-(defun org-ref-jump-to-visible-key ()
-  "Jump to a visible key with avy."
-  (interactive)
-  (avy-with avy-goto-key
-    (avy-process
-     (apply #'append
-           (save-excursion
-             (org-element-map (org-element-parse-buffer) 'link
-               (lambda (c)
-                 (when (assoc (org-element-property :type c) org-ref-cite-types)
-                   (goto-char (org-element-property :begin c))
-                   (let* ((path (org-element-property :path c))
-                          (data (org-ref-parse-cite-path path))
-                          (references (plist-get data :references)))
-                     (append (list (org-element-property :begin c))
-                             (cl-loop for ref in references collect
-                                      (progn
-                                        (search-forward (plist-get ref :key))
-                                        (match-beginning 0)))))))))))
-    (avy--style-fn avy-style)))
-
-
-;; * Insert links
-(declare-function bibtex-completion-format-entry "bibtex-completion")
-
-;; The formatting is adapted from ivy-bibtex-transformer. I feel like it is
-;; slower than ivy-bibtex though. It is completion agnostic though...
-(defun org-ref-read-key ()
-  "Read a key with completion."
-  (unless bibtex-completion-display-formats-internal
-    (bibtex-completion-init))
-  (let* ((bibtex-completion-bibliography (org-ref-find-bibliography))
-        (candidates (mapcar (lambda (entry)
-                              (cons (bibtex-completion-format-entry entry (1- (frame-width)))
-                                    (cdr entry)))
-                            (bibtex-completion-candidates)))
-        (choice (completing-read "org-ref BibTeX entries: " candidates)))
-    (cdr (assoc "=key=" (assoc choice candidates)))))
-
-
-(defun org-ref-insert-cite-key (key &optional set-type)
-  "Insert KEY at point as a cite link.
-With optional prefix SET-TYPE choose the link type (only on initial insert).
-Rules:
-1. at beginning of key, insert before it.
-2. at middle or end of key, insert after it."
-  (let* ((object (org-element-context))
-        (type (org-element-property :type object))
-        ;; (cp (point))
-        link-string version data references key-at-point index
-        (type-annotation (lambda (s)
-                           (let ((item (assoc s minibuffer-completion-table)))
-                             (when item (concat
-                                         (make-string (- 12 (length s)) ? )
-                                         "-- "
-                                         (cl-second item))))))
-        (completion-extra-properties `(:annotation-function ,type-annotation)))
-
-    (cond
-     ((derived-mode-p 'latex-mode)
-      (insert (bibtex-completion-format-citation-cite (list key))))
-     (t
-    (cond
-     ;; Not on a link, so we just insert a cite
-     ((null (assoc type org-ref-cite-types))
-      (insert (format "[[%s:%s%s]]"
-                     (if set-type
-                         (completing-read "cite type: " org-ref-cite-types)
-                       org-ref-default-citation-link)
-                     (pcase org-ref-cite-insert-version
-                       (2 "")
-                       (3 "&"))
-                     key)))
-     ;; On a link with no path
-     ;; See https://github.com/jkitchin/org-ref/issues/951#issuecomment-985998821
-     ;; This is an unusual corner case most often triggered by a snippet, although
-     ;; perhaps there is some scenario like [[cite:]]
-     ((string= "" (org-element-property :path object))
-      (unless (looking-back ":" 1)
-       (goto-char (org-element-property :end object))
-       (skip-chars-backward "]"))
-      (insert (concat
-              (pcase org-ref-cite-insert-version
-                (2 "")
-                (3 "&"))
-              key)))
-
-     ;; On a link somewhere, and we need to figure out what to do.
-     (t
-      (setq link-string (org-element-property :path object)
-           version (org-ref-cite-version link-string)
-           data (org-ref-parse-cite-path link-string)
-           references (plist-get data :references)
-           key-at-point (get-text-property (point) 'cite-key))
-
-      ;; There are two scenarios where key-at-point is null
-      ;; 1. on the link-type before the :
-      ;; 2. at the end of the link
-      ;; Either way we just go to the end.
-      (when (null key-at-point)
-       ;; that failed, so move to the last one This seems weird, but when you
-       ;; insert several marked candidates the point does weird things.
-       (goto-char (org-element-property :end object))
-       (skip-chars-backward " ")
-       (setq key-at-point (plist-get (car (last references)) :key)))
-
-
-      ;; this is index of selected key
-      (setq index (seq-position references key-at-point
-                               (lambda (el1 key-at-point)
-                                 (string= key-at-point (plist-get el1 :key)))))
-
-      (setq data (plist-put data :references
-                           (-insert-at
-                            (+ index (if (and (= 3 version) (looking-at "&"))
-                                         0
-                                       1))
-                            (list :key key) references)))
-
-      (pcase org-ref-cite-insert-version
-       (2
-        (cl--set-buffer-substring
-         (org-element-property :begin object)
-         (org-element-property :end object)
-         (concat type ":" (string-join (cl-loop for ref in (plist-get data :references)
-                                                collect (plist-get ref :key))
-                                       ","))))
-       (3 (cl--set-buffer-substring
-           (org-element-property :begin object)
-           (org-element-property :end object)
-           (concat "[["
-                   type ":"
-                   (org-ref-interpret-cite-data data)
-                   "]]"
-                   (make-string (org-element-property :post-blank object) ? )))))))
-
-    ;; Now get to the end of the key you just put in.
-    (setq object (org-element-context))
-    (goto-char (org-element-property :end object))
-    (skip-chars-backward " ")))))
-
-
-(defun org-ref-insert-cite-keys (keys &optional set-type)
-  "Insert KEYS as citation links.
-Optional SET-TYPE to choose the cite type."
-  (cl-loop for key in keys
-          do
-          (org-ref-insert-cite-key key set-type)))
-
-
-;;;###autoload
-(defun org-ref-insert-cite-link (&optional set-type)
-  "Insert a cite link with completion.
-Optional prefix arg SET-TYPE to choose the cite type."
-  (interactive "P")
-  (org-ref-insert-cite-key (org-ref-read-key) set-type))
-
-
-;; * natmove like pre-processing
-;;
-;; I think that citations belong in the sentence where they are used, which
-;; means on the left side of punctuation. However, for some citation styles,
-;; especially superscripts, it is nicer if they appear on the right hand side of
-;; punctuation. achemso in LaTeX provides natmove
-;; (https://ctan.org/pkg/natmove?lang=en) for this. It doesn't seem to work for
-;; all LaTeX styles though, and in particular only works on the cite command
-;; itself. So, Here is a preprocessor function you can use to move all the
-;; cites.
-
-(declare-function org-ref-get-cite-links "org-ref-export")
-
-(defun org-ref-cite-natmove (_backend)
-  "Move citations to the right side of punctuation.
-Intended for use in `org-export-before-parsing-hook'.
-
-Here is an example use:
-
-  (let ((org-export-before-parsing-hook '(org-ref-cite-natmove)))
-    (org-open-file (org-latex-export-to-pdf)))"
-  (let ((cites (org-ref-get-cite-links))
-       punct)
-    (cl-loop for cite in (reverse cites) do
-            (goto-char (org-element-property :end cite))
-            (skip-chars-backward " ")
-            (when (string-match-p "[[:punct:]]" (buffer-substring (point) (+ (point) 1)))
-              (setq punct (buffer-substring (point) (+ (point) 1)))
-              ;; delete the punctuation
-              (cl--set-buffer-substring (point) (+ (point) 1) "")
-              ;; and insert it at the beginning of the link.
-              (goto-char (org-element-property :begin cite))
-              ;; delete spaces backward
-              (skip-chars-backward " ")
-              (cl--set-buffer-substring (point) (org-element-property :begin cite) "")
-              (insert punct)))))
-
-;; * Convert version 2 to version 3
-
-(defun org-ref-v2-cites-to-v3 ()
-  "Replace version 2 citation syntax with version 3 citation syntax"
-  (interactive)
-  (cl-loop for cite in (reverse (org-ref-get-cite-links))
-          collect
-          (let ((data (org-ref-parse-cite-path (org-element-property :path cite)))
-                prefix-suffix)
-            (when (org-element-property :contents-begin cite)
-              (setq prefix-suffix (split-string (buffer-substring (org-element-property :contents-begin cite)
-                                                                  (org-element-property :contents-end cite))
-                                                "::"))
-              (plist-put data :prefix (cl-first prefix-suffix))
-              (plist-put data :suffix (cl-second prefix-suffix)))
-            (plist-put data :version  3)
-            (cl--set-buffer-substring (org-element-property :begin cite)
-                                      (org-element-property :end cite)
-                                      (format "[[%s:%s]]" (org-element-property :type cite)
-                                              (org-ref-interpret-cite-data data))))))
-
-
-(provide 'org-ref-citation-links)
-
-;;; org-ref-citation-links.el ends here
-
-;; Local Variables:
-;; byte-compile-warnings: (not docstrings docstrings-wide)
-;; End:
diff --git a/elpa/org-ref-20241124.2012/org-ref-compat.el b/elpa/org-ref-20241124.2012/org-ref-compat.el
deleted file mode 100644 (file)
index da287aa..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-;;; org-ref-compat.el --- Compatibility functions for org-cite -*- lexical-binding: t; -*-
-
-;;; Commentary:
-;;
-;; The main function of this library is to provide compatibility functions for
-;; converting between org-ref and org-cite.
-
-(require 'org-ref-export)
-
-
-(defcustom org-ref-to-org-cite-mapping
-  '(("cite" . "")
-    ("citep" . "")
-    ("Citep" . "//caps-full")
-    ("citealp" . "//bare")
-    ("Citealp" . "//bare-caps")
-    ("Citealp*" . "//bare-caps-full")
-    ("citep*" . "//full")
-
-    ("citet" . "/text")
-
-    ("citeyear" . "/noauthor/bare")
-    ("citeyearpar" . "/noauthor")
-    
-    ("nocite" . "/nocite")
-
-    ("citeauthor" . "/author")
-    ("citeauthor*" . "/author/full")
-    ("Citeauthor" . "/author/caps"))
-  
-  "A-list of (org-ref-type . org-cite-style).
-This builds from
-https://blog.tecosaur.com/tmio/2021-07-31-citations.html#cite-syntax.
-There is no way to get them all though, there are conflicting
-translations with some biblatex and some natbib commands. This
-list maps the natbib commands. I have also opted to use the full
-names rather than the short names."
-  :group 'org-ref
-  :type '(list (cons string string)))
-
-
-(defun org-ref-to-org-cite ()
-  (interactive)
-  (let ((ref-cites (reverse (org-ref-get-cite-links)))
-       type path
-       beg end)
-    ;; This takes care of the cite links
-    (cl-loop for rc in ref-cites do
-            (setq
-             type (org-element-property :type rc)
-             path (org-element-property :path rc)
-             beg (org-element-property :begin rc)
-             end (org-element-property :end rc))
-            (cl--set-buffer-substring
-             beg end
-             (format "[cite%s:%s]"
-                     (or (cdr (assoc type org-ref-to-org-cite-mapping)) "")
-                     ;; This is not 100% correct, if someone has put an extra &
-                     ;; anywhere in a note, this will be a little wrong. It
-                     ;; would be a little more correct if I also look for a
-                     ;; word next to it. The most correct would probably be to
-                     ;; build the data and then use org-element interpret I
-                     ;; think
-                     (replace-regexp-in-string "&" "@" path))))
-
-    ;; Next replace bibliography links. I assume the paths are ok, and we just
-    ;; need to convert them to keywords.
-    (cl-loop for bib-link in
-            (reverse (org-element-map (org-element-parse-buffer) 'link
-                       (lambda (bl)
-                         (when (member (org-element-property :type bl)
-                                       '("bibliography" "nobibliography"))
-                           bl))))
-            do
-            (cl--set-buffer-substring
-             (org-element-property :begin bib-link)
-             (org-element-property :end bib-link)
-             (format "#+bibliography: %s%s"
-                     (org-element-property :path bib-link)
-                     (if (string= "bibliography"
-                                  (org-element-property :type bib-link))
-                         "\n#+print_bibliography:"
-                       ""))))
-    ;; Note it is a bit ambiguous what do do about where the bibliography is to
-    ;; be printed. This should be done via #+print_bibliography:. In org-ref the
-    ;; bibliography normally goes where the bibliography link was, and I sue
-    ;; that convention.
-    
-    ))
-
-
-(provide 'org-ref-compat)
-
-;;; org-ref-compat.el ends here
diff --git a/elpa/org-ref-20241124.2012/org-ref-core.el b/elpa/org-ref-20241124.2012/org-ref-core.el
deleted file mode 100644 (file)
index c7b34de..0000000
+++ /dev/null
@@ -1,344 +0,0 @@
-;;; org-ref-core.el --- citations, cross-references and bibliographies in org-mode -*- lexical-binding: t; -*-
-
-;; Copyright(C) 2014-2024 John Kitchin
-
-;; This file is not currently part of GNU Emacs.
-
-;; This program is free software; you can redistribute it and/or
-;; modify it under the terms of the GNU General Public License as
-;; published by the Free Software Foundation; either version 2, or (at
-;; your option) any later version.
-
-;; This program is distributed in the hope that it will be useful, but
-;; WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-;; General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program ; see the file COPYING.  If not, write to
-;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
-
-;;; Commentary:
-;;
-;; This is the core library.
-;;
-
-;;; Code:
-
-(eval-when-compile
-  (require 'cl-lib))
-
-(require 'org)
-;; the eval and compile seems especially necessary for native compilation on the newest Emacs.
-(eval-and-compile (require 'org-macs))
-
-(require 'org-element)
-
-(require 'dash)
-(require 'f)
-(require 's)
-
-(require 'parsebib)
-(require 'bibtex-completion)
-(require 'hydra)
-
-(require 'org-ref-bibliography-links)
-(require 'org-ref-citation-links)
-(require 'org-ref-ref-links)
-(require 'org-ref-label-link)
-(require 'org-ref-misc-links)
-(require 'org-ref-export)
-
-(require 'org-ref-utils)
-(require 'org-ref-bibtex)
-(require 'org-ref-glossary)
-(require 'openalex)
-
-
-;;* Custom variables
-
-(defgroup org-ref nil
-  "Customization group for org-ref."
-  :tag "Org Ref"
-  :group 'org)
-
-
-(defcustom org-ref-insert-link-function
-  nil
-  "Generic function for inserting org-ref links.
-The function should take a prefix arg.
-No arg means insert a cite link
-1 arg means insert a ref link
-2 args means insert a label."
-  :type 'function
-  :group 'org-ref)
-
-
-(defcustom org-ref-insert-cite-function
-  nil
-  "Function to call to insert citation links.
-This function should prompt for keys with completion, and insert
-the citation link into the buffer."
-  :type 'function
-  :group 'org-ref)
-
-
-(defcustom org-ref-cite-completion-function
-  nil
-  "Function to prompt for keys with completion."
-  :type '(choice (const nil)
-                 (function))
-  :group 'org-ref)
-
-
-(defcustom org-ref-insert-label-function
-  nil
-  "Function to call to insert label links.
-This function should prompt for a label, and insert the label
-link."
-  :type 'function
-  :group 'org-ref)
-
-
-(defcustom org-ref-insert-ref-function
-  nil
-  "Function to call to insert ref links.
-This function should prompt for a label with completion, and
-insert the ref link."
-  :type 'function
-  :group 'org-ref)
-
-
-(defcustom org-ref-cite-onclick-function
-  nil
-  "Function that runs when you click on a cite link.
-The function must take one argument which is the path of the link
-that was clicked on."
-  :type 'function
-  :group 'org-ref)
-
-
-(defvar org-ref-prefix-arg nil
-  "Variable to store a prefix arg during completion.")
-
-
-(defun org-ref-minibuffer-prefix ()
-  "Hook function for `minibuffer-setup-hook'.
-The idea is to locally bind C-u to a function that captures
-prefix args in `org-ref-prefix-arg' so you can use them later."
-  (setq org-ref-prefix-arg nil)
-  (local-set-key (kbd "C-u") (lambda ()
-                              (interactive)
-                              (setq org-ref-prefix-arg
-                                    (if (null org-ref-prefix-arg)
-                                        '(4)
-                                      (list (* 4 (car org-ref-prefix-arg))))))))
-
-
-;; * Bibliography related functions
-
-(defun org-ref-find-bibliography ()
-  "Find the bibliography in the buffer.
-This function sets and returns a list of files either from internal bibliographies, from files in the
-BIBINPUTS env var, and finally falling back to what the user has
-set in `bibtex-completion-bibliography'"
-  (let ((org-ref-bibliography-files ()))
-    (catch 'result
-      (save-excursion
-       (when (eq major-mode 'org-mode)
-         (org-with-wide-buffer
-           (goto-char (point-min))
-          ;; This just searches for these strings, and then checks if it
-          ;; is on a link. This is faster than parsing the org-file when
-          ;; it gets large.
-           ;; look for org-ref bibliography
-           (while (re-search-forward "\\(no\\)?bibliography:" nil t)
-            (let ((link (org-element-context)))
-              (when (and (eq (car link) 'link)
-                         (member (org-element-property :type link) '("bibliography" "nobibliography")))
-                (setq org-ref-bibliography-files
-                      (mapcar 'org-ref-get-bibfile-path
-                              (mapcar 'string-trim (split-string
-                                                    (org-element-property :path link)
-                                                    ","))))
-                (throw 'result (nreverse (delete-dups org-ref-bibliography-files))))))
-
-           (goto-char (point-min))
-           (while (re-search-forward "\\\\addbibresource{\\(.*\\)}" nil t)
-             (push (match-string 1) org-ref-bibliography-files))
-
-           (when org-ref-bibliography-files
-             (throw 'result (nreverse (delete-dups (mapcar 'org-ref-get-bibfile-path org-ref-bibliography-files)))))))
-       ;; we did not find anything. use defaults. Make sure we have a list in
-        ;; case it is a single string. 
-       (throw 'result (if (listp bibtex-completion-bibliography)
-                          bibtex-completion-bibliography
-                        (list bibtex-completion-bibliography)))))))
-
-
-(defun org-ref-key-in-file-p (key filename)
-  "Determine if the KEY is in the FILENAME."
-  (with-temp-buffer
-    (insert-file-contents filename)
-    (hack-local-variables)
-    (bibtex-set-dialect (parsebib-find-bibtex-dialect) t)
-    (bibtex-search-entry key)))
-
-
-(defun org-ref-possible-bibfiles ()
-  "Make a unique list of possible bibliography files for completing-read"
-  (-uniq
-   (append
-    ;; see if we should add it to a bib-file defined in the file
-    (org-ref-find-bibliography)
-    ;; or any bib-files that exist in the current directory
-    (f-entries "." (lambda (f)
-                    (and (not (string-match "#" f))
-                         (f-ext? f "bib"))))
-    ;; and last in the default bibliography
-    (if (stringp bibtex-completion-bibliography)
-       (list bibtex-completion-bibliography)
-      bibtex-completion-bibliography))))
-
-
-(defun org-ref-get-bibtex-key-and-file (&optional key)
-  "Return a  a cons cell of (KEY . file) that KEY is in.
-If no key is provided, get one under point."
-  (unless key
-    (setq key (org-ref-get-bibtex-key-under-cursor)))
-
-  (cons key (save-window-excursion
-             (let ((bibtex-completion-bibliography (org-ref-find-bibliography)))
-               (bibtex-completion-show-entry (list key))
-               (buffer-file-name)))))
-
-
-;; * Insert link functions
-
-;;;###autoload
-(defun org-ref-insert-link (arg)
-  "Insert an org-ref link.
-If no prefix ARG insert a cite.
-If one prefix ARG insert a ref.
-If two prefix ARGs insert a label.
-
-This is a generic function. Specific backends might
-provide their own version."
-  (interactive "P")
-  (cond
-   ((eq arg nil)
-    (funcall org-ref-insert-cite-function))
-   ((equal arg '(4))
-    (funcall org-ref-insert-ref-function))
-   ((equal arg '(16))
-    (funcall org-ref-insert-label-function))))
-
-
-;; This is an alternative that doesn't rely on prefix args.
-(defhydra org-ref-insert-link-hydra (:color red :hint nil)
-  "Insert an org-ref link
-"
-  ("[" (funcall org-ref-insert-cite-function) "Citation" :column "org-ref")
-  ("]" (funcall org-ref-insert-ref-function) "Cross-reference" :column "org-ref")
-  ("\\" (funcall org-ref-insert-label-function) "Label"  :column "org-ref")
-  
-  ("bs" (insert (org-ref-bibliographystyle-complete-link)) "Bibliographystyle" :column "Bibliography" :color blue)
-  ("bf" (insert (org-ref-bibliography-complete)) "Bibliography" :column "Bibliography" :color blue)
-  ("nb" (insert (org-ref-nobibliography-complete)) "Bibliography" :column "Bibliography" :color blue)
-  
-  ("g" org-ref-insert-glossary-link "Glossary link" :column "Glossary" :color blue)
-  ("a" org-ref-insert-acronym-link "Acronym link" :column "Glossary" :color blue)
-  ("ng" (progn
-         (org-mark-ring-push)
-         (goto-char (point-min))
-         (if (re-search-forward "#\\+name: glossary" nil t)
-             (progn
-               (goto-char (org-element-property :contents-end (org-element-context)))
-               (backward-char)
-               (org-table-insert-row '(4)))
-           ;; no table found
-           (goto-char (point-max))
-           (insert "\n\n#+name: glossary
-| label | term    | definition                    |
-|-------+---------+-------------------------------|
-|       |         |                               |")
-           (beginning-of-line)
-           (forward-char)))
-   "New glossary term" :column "Glossary")
-  
-  ("na" (progn
-         (org-mark-ring-push)
-         (goto-char (point-min))
-         (if (re-search-forward "#\\+name: acronym" nil t)
-             (progn
-               (goto-char (org-element-property :contents-end (org-element-context)))
-               (backward-char)
-               (org-table-insert-row '(4)))
-           ;; no table found
-           (goto-char (point-max))
-           (insert "\n\n#+name: acronyms
-| label | abbreviation | full form                  |
-|-------+--------------+----------------------------|
-|       |              |                            |")
-           (beginning-of-line)
-           (forward-char)))
-   "New acronym term" :column "Glossary")
-
-  ("bd" doi-add-bibtex-entry "Add bibtex entry from a DOI" :column "Bibtex")
-  ("bc" crossref-add-bibtex-entry "Add bibtex entry from Crossref" :column "Bibtex")
-  ("bo" (find-file (completing-read "Bibliography: " (org-ref-find-bibliography)))
-   "Open bibtex file" :column "Bibtex")
-  
-  ("t" (insert "[[list-of-tables:]]\n") "List of tables" :column "Misc")
-  ("f" (insert "[[list-of-figures:]]\n") "List of figures" :column "Misc")
-  ("i" (insert (format "[[index:%s]]" (string-trim (read-string "Index entry: ")))) "Index entry" :column "Misc")
-  ("pi" (insert "[[printindex:]]") "Print index" :column "Misc")
-  ("pg" (insert "[[printglossaries:]]") "Print glossary" :column "Misc"))
-
-
-;;* org-ref-help
-;;;###autoload
-(defun org-ref-help ()
-  "Open the `org-ref' manual."
-  (interactive)
-  (find-file (expand-file-name
-              "org-ref.org"
-              (file-name-directory
-               (find-library-name "org-ref")))))
-
-
-;;* org-ref menu
-
-(defun org-ref-org-menu ()
-  "Add `org-ref' menu to the Org menu."
-
-  (easy-menu-change
-   '("Org") "org-ref"
-   `(["Insert citation" ,org-ref-insert-cite-function]
-     ["Insert ref" ,org-ref-insert-ref-function]
-     ["Insert label" ,org-ref-insert-label-function]
-     "--"
-     ["List of figures" org-ref-list-of-figures]
-     ["List of tables" org-ref-list-of-tables]
-     ["Extract bibtex entries" org-ref-extract-bibtex-entries]
-     ["Check org-file" org-ref]
-     "--"
-     ["Help" org-ref-help]
-     ["Customize org-ref" (customize-group 'org-ref)])
-   "Show/Hide")
-
-  (easy-menu-change '("Org") "--" nil "Show/Hide"))
-
-(add-hook 'org-mode-hook 'org-ref-org-menu)
-
-
-
-;;* The end
-(provide 'org-ref-core)
-
-;;; org-ref-core.el ends here
-
-;; Local Variables:
-;; byte-compile-warnings: (not docstrings docstrings-wide)
-;; End:
diff --git a/elpa/org-ref-20241124.2012/org-ref-export.el b/elpa/org-ref-20241124.2012/org-ref-export.el
deleted file mode 100644 (file)
index 983d47e..0000000
+++ /dev/null
@@ -1,676 +0,0 @@
-;;; org-ref-export.el --- org-ref-export library -*- lexical-binding: t; -*-
-;;
-;; Copyright (C) 2024  John Kitchin
-
-;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
-;; Keywords: convenience
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
-;;
-;;; Commentary:
-;; This is an export library that uses CSL to process the citations and bibliography.
-;;
-;; It is intended for non-LaTeX exports, but you can also use it with LaTeX if
-;; you want to avoid using bibtex/biblatex for some reason.
-;;
-;; The default style is set by a CSL-STYLE keyword or
-;; `org-ref-csl-default-style'. If this is an absolute or relative path that
-;; exists, it is used. Otherwise, it looks in `org-cite-csl-styles-dir' from
-;; `org-cite' if it is defined, and in the citeproc/csl-styles directory in
-;; `org-ref' otherwise.
-;;
-;; The default locale is set by a CSL-LOCALE keyword or
-;; `org-ref-csl-default-locale'. This is looked for in
-;; `org-cite-csl-locales-dir' if it is defined, and otherwise in the csl-locales
-;; directory of `org-ref'.
-;;
-;; Note that citeproc does not do anything for cross-references, so if non-LaTeX
-;; export is your goal, you may want to use org-ref-refproc.el to handle
-;; cross-references.
-;;
-
-;;; Code:
-(eval-when-compile
-  (require 'hydra))
-
-(defvar hfy-user-sheet-assoc)                  ; to quiet compiler
-
-(require 'ox-org)
-(if (executable-find "pandoc")
-    (require 'ox-pandoc))
-
-(require 'citeproc)
-
-(defvar org-cite-csl-styles-dir)
-
-(defcustom org-ref-backend-csl-formats
-  '((html . html)
-    (latex . latex)
-    (md . plain)
-    (org . org)
-    (ascii . plain)
-    (odt . org-odt)
-    (docx . org))
-  "Mapping of export backend to csl-backends."
-  :type '(alist :key-type (symbol) :value-type (symbol))
-  :group 'org-ref)
-
-
-(defcustom org-ref-cite-internal-links 'auto
-  "Should be one of these symbols (quoted)
-- bib-links :: link cites to bibliography entries
-- no-links :: do not link cites to bibliography entries
-- nil or auto :: add links based on the style."
-  :type '(choice symbol (sexp :tag bib-links)
-                symbol (sexp :tag no-links)
-                symbol (sexp :tag auto-links)
-                symbol (sexp :tag nil))
-  :group 'org-ref)
-
-
-(defcustom org-ref-csl-default-style "chicago-author-date-16th-edition.csl"
-  "Default csl style to use.
-Should be a csl filename, or an absolute path to a csl filename."
-  :type 'string
-  :group 'org-ref)
-
-
-(defcustom org-ref-csl-default-locale "en-US"
-  "Default csl locale to use."
-  :type 'string
-  :group 'org-ref)
-
-
-(defcustom org-ref-csl-label-aliases
-  '((("app" "apps") . "appendix")
-    (("art" "arts") . "article-locator")
-    (("bk" "bks") . "book")
-    (("can") . "canon")
-    (("ch" "chap" "chaps" "chapt") . "chapter")
-    (("col" "cols") . "column")
-    (("el") . "elocation")
-    (("eq" "eqs") . "equation")
-    (("fig" "figs") . "figure")
-    (("fol" "fols") . "folio")
-    (("iss") . "issue")
-    (("l" "ll") . "line")
-    (("n" "nn") . "note")
-    ;; number is not listed in the url in the docstring
-    (("no" "nos" "#") . "number")
-    (("op" "opp") . "opus")
-    (("p" "pp" "pg" "pgs") . "page")
-    (("para" "paras" "¶" "¶¶" "§" "§§") . "paragraph")
-    (("pt" "pts") . "part")
-    (("sec" "secs") . "section")
-    (("s.v" "s.vv") . "sub verbo")
-    (("sup" "supp") . "supplement")
-    (("tab" "tabs") . "table")
-    (("ts") . "timestamp")
-    (("ti" "tit") . "title")
-    (("v" "vv") . "verse")
-    (("vol" "vols") . "volume"))
-  "A-list of aliases for a csl label.
-The car is a list of possible aliases (including if they end in a .
-This list was adapted from `org-cite-csl--label-alist'.
-See https://github.com/citation-style-language/documentation/blob/master/specification.rst#locators"
-  :type '(alist :key-type (list (repeat string)) :value-type string)
-  :group 'org-ref)
-
-
-(defcustom org-ref-export-suppress-affix-types 
-  '("citet"
-    "citet*"
-    "citetitle"
-    "citeyear"
-    "citeauthor"
-    "citenum"
-    "textcite")
-  "List of cite types to suppress affixes (usually parentheses) on."
-  :type '(list (repeat string))
-  :group 'org-ref)
-
-
-(defun org-ref-dealias-label (alias)
-  "Return the full, de-aliased label for ALIAS.
-Looked up from `org-ref-csl-label-aliases'.
-
-I added this because I think it is reasonable to expect if you
-write pg. 2 that it will show that way when rendered. At the
-moment that is not the case, and only page is accepted. This is
-actually done in oc-csl too, although it uses a flat a-list."
-  (or (cdr (assoc "page" org-ref-csl-label-aliases
-                 (lambda (x1 _x2)
-                   (or (member alias x1)
-                       (member (concat (downcase alias) ".") x1)))))
-      alias))
-
-
-(defun org-ref-get-cite-links ()
-  "Return list of cite links in the order they appear in the buffer."
-  (org-element-map (org-element-parse-buffer) 'link
-    (lambda (lnk)
-      (when (assoc (org-element-property :type lnk) org-ref-cite-types)
-       lnk))))
-
-
-(defun org-ref-ref-csl-data (ref type)
-  "Return the CSL alist for a REF of TYPE.
-REF is a plist data structure returned from `org-ref-parse-cite-path'."
-  ;; I believe the suffix contains "label locator suffix"
-  ;; where locator is a number, or maybe a range of numbers like 5-6.
-  ;; label is something like page or chapter
-  ;; and the rest is the suffix text.
-  ;; For example: ch. 5, for example
-  ;; would be label = ch., locator=5, ",for example" as suffix.
-  (let* ((full-suffix (string-trim (or (plist-get ref :suffix) ""))) 
-        locator
-        label locator suffix)
-
-    ;; org-cite is more sophisticated than this and would allow things like 5, 6
-    ;; and 12. I am not sure about what all should be supported yet. I guess the
-    ;; idea there is you use everything from the first to last number as the
-    ;; locator, but that seems tricky, what about something like: 5, 6 and 12,
-    ;; because he had 3 books. One solution might be some kind of delimiter,
-    ;; e.g. {5, 6 and 12}, because he had 3 books.
-
-    (if (and (string-match
-             (rx-to-string
-              `(seq
-                ;; optional label
-                (group-n 1 (optional
-                            (regexp ,(regexp-opt (cl-loop for (abbrvs . full)
-                                                          in org-ref-csl-label-aliases
-                                                          append (append abbrvs (list full)))))))
-                (optional (one-or-more space))
-                ;; number or numeric ranges
-                (group-n 2 (one-or-more digit) (optional "-" (one-or-more digit)))
-                ;; everything else
-                (group-n 3 (* "."))))        
-             full-suffix)
-            (match-string 2 full-suffix)
-            (not (string= "" (match-string 2 full-suffix)))) 
-       ;; We found a locator
-       (setq label (match-string 1 full-suffix)
-             locator (match-string 2 full-suffix)
-             suffix (match-string 3 full-suffix))
-      (setq label nil
-           locator nil
-           suffix full-suffix))
-    
-    ;; Let's assume if you have a locator but not a label that you mean page.
-    (when (and locator (string= "" (string-trim label)))
-      (setq label "page"))
-    
-    `((id . ,(plist-get ref :key))
-      (prefix . ,(plist-get ref :prefix))
-      (suffix . ,suffix)
-      (locator . ,locator)
-      (label . ,(when label (org-ref-dealias-label (string-trim label))))
-      ;; [2024-01-29 Mon] see
-      ;; https://github.com/jkitchin/org-ref/issues/1103#issuecomment-1915028374
-      ;; and related comments at
-      ;; https://github.com/andras-simonyi/citeproc-el/issues/151. It seems I
-      ;; should not be adding this. TODO: proof of concept and not complete. I
-      ;; did not go through all the types to see what else should be in here.
-      ;; (suppress-author . ,(not (null (member type '("citenum" "citeyear"
-      ;; "citeyear*" "citedate" "citedate*" "citetitle" "citetitle*"
-      ;; "citeurl")))))
-      )))
-
-(declare-function org-ref-find-bibliography "org-ref-core")
-
-(defun org-ref-process-buffer (backend &optional subtreep)
-  "Process the citations and bibliography in the org-buffer.
-Usually run on a copy of the buffer during export.
-BACKEND is the org export backend."
-  (save-restriction
-    (when subtreep
-      (org-narrow-to-subtree))
-    (let* ((csl-backend (or (cdr (assoc backend org-ref-backend-csl-formats)) 'plain))
-
-          (style (or (cadr (assoc "CSL-STYLE"
-                                  (org-collect-keywords
-                                   '("CSL-STYLE"))))
-                     org-ref-csl-default-style))
-          (locale (or (cadr (assoc "CSL-LOCALE"
-                                   (org-collect-keywords
-                                    '("CSL-LOCALE"))))
-                      org-ref-csl-default-locale))
-
-          (proc (citeproc-create
-                 ;; The style
-                 (cond
-                  ((file-exists-p style)
-                   style)
-                  ;; In a user-dir
-                  ((and (bound-and-true-p org-cite-csl-styles-dir)
-                        (file-exists-p (f-join org-cite-csl-styles-dir style)))
-                   (f-join org-cite-csl-styles-dir style))
-                  ;; provided by org-ref
-                  ((file-exists-p (expand-file-name style
-                                                    (f-join (file-name-directory
-                                                             (locate-library "org-ref"))
-                                                            "citeproc/csl-styles")))
-                   (expand-file-name style (f-join
-                                            (file-name-directory
-                                             (locate-library "org-ref"))
-                                            "citeproc/csl-styles")))
-                  (t
-                   (error "%s not found" style)))
-                 ;; item-getter
-                 ;; (citeproc-itemgetter-from-bibtex (org-ref-find-bibliography))
-                 (citeproc-hash-itemgetter-from-any (org-ref-find-bibliography) t)
-                 ;; locale getter
-                 (citeproc-locale-getter-from-dir (if (bound-and-true-p org-cite-csl-locales-dir)
-                                                      org-cite-csl-locales-dir
-                                                    (f-join (file-name-directory
-                                                             (locate-library "org-ref"))
-                                                            "citeproc/csl-locales")))
-                 ;; the actual locale
-                 locale))
-
-          ;; list of links in the buffer
-          (cite-links (org-element-map (org-element-parse-buffer) 'link
-                        (lambda (lnk)
-                          (when (assoc (org-element-property :type lnk) org-ref-cite-types)
-                            lnk))))
-
-          (cites (cl-loop for cl in cite-links collect
-                          (let* ((cite-data (org-ref-parse-cite-path (org-element-property :path cl)))
-                                 (common-prefix (or (plist-get cite-data :prefix) ""))
-                                 (common-suffix (or (plist-get cite-data :suffix) ""))
-                                 (refs (plist-get cite-data :references))
-                                 (type (org-element-property :type cl))
-
-                                 (cites (cl-loop for ref in refs collect
-                                                 (org-ref-ref-csl-data ref type))))
-                            ;; TODO: update eventually
-                            ;; https://github.com/andras-simonyi/citeproc-el/issues/46
-                            ;; To handle common prefixes, suffixes, I just concat
-                            ;; them with the first/last entries. That is all that
-                            ;; is supported for now. Combine common/local prefix
-                            (setf (cdr (assoc 'prefix (cl-first cites)))
-                                  (concat common-prefix
-                                          (cdr (assoc 'prefix (cl-first cites)))))
-                            ;; Combine local/common suffix
-                            (setf (cdr (assoc 'suffix (car (last cites))))
-                                  (concat (cdr (assoc 'suffix (car (last cites))))
-                                          common-suffix))
-
-                            ;; https://github.com/andras-simonyi/citeproc-el#creating-citation-structures
-                            (citeproc-citation-create
-                             :cites cites
-                             :suppress-affixes (let ((type (org-element-property :type cl)))
-                                                 (when (member type
-                                                               org-ref-export-suppress-affix-types)
-                                                   t))
-
-                             ;; TODO: this is proof of concept, and not complete.
-                             ;; mode is one of suppress-author, textual,
-                             ;; author-only, year-only, or nil for default. These
-                             ;; are not all clear to me.
-                             :mode (let ((type (org-element-property :type cl)))
-                                     (cond
-                                      ((member type '("citet" "citet*"))
-                                       'textual)
-                                      ((member type '("citeauthor" "citeauthor*"))
-                                       'author-only)
-                                      ((member type '("citeyear" "citeyear*"))
-                                       'year-only)
-                                      ((member type '("citedate" "citedate*"))
-                                       'suppress-author)
-                                      (t
-                                       nil)))
-
-                             ;; I think the capitalized styles are what this is for
-                             :capitalize-first (string-match
-                                                "[A-Z]"
-                                                (substring
-                                                 (org-element-property :type cl) 0 1))
-                             ;; I don't know where this information would come from.
-                             :note-index nil
-                             :ignore-et-al nil
-                             :grouped nil))))
-
-          (rendered-citations (progn (citeproc-append-citations cites proc)
-                                     (citeproc-render-citations proc csl-backend org-ref-cite-internal-links)))
-          ;; I only use the returned bibliography string. citeproc returns a
-          ;; bunch of other things related to offsets and linespacing, but I
-          ;; don't know what you do with these, so just ignore them here.
-          (bibdata (citeproc-render-bib proc csl-backend))
-          (rendered-bib (car bibdata))
-          (bib-parameters (cdr bibdata))
-          ;; The idea is we will wrap each citation and the bibliography in
-          ;; org-code so it exports appropriately.
-          (cite-formatters '((html . "@@html:%s@@")
-                             (latex . "@@latex:%s@@")
-                             (odt . "@@odt:%s@@")))
-          (bib-formatters '((html .  "\n#+BEGIN_EXPORT html\n%s\n#+END_EXPORT\n")
-                            (latex .  "\n#+BEGIN_EXPORT latex\n%s\n#+END_EXPORT\n")
-                            (odt . "\n#+BEGIN_EXPORT ODT\n%s\n#+END_EXPORT\n"))))
-
-      ;; replace the cite links
-      (cl-loop for cl in (reverse cite-links) for rc in (reverse rendered-citations) do
-              (cl--set-buffer-substring (org-element-property :begin cl)
-                                        (org-element-property :end cl)
-                                        (format (or
-                                                 (cdr (assoc backend cite-formatters))
-                                                 "%s")
-                                                (concat
-                                                 rc
-                                                 ;; Add on extra spaces that were
-                                                 ;; following it.
-                                                 (make-string
-                                                  (or
-                                                   (org-element-property :post-blank cl) 0)
-                                                  ? )))))
-
-      ;; Decorate the bibliography for different outputs adapted from
-      ;;  `org-cite-csl-render-bibliography' in oc-csl I don't know what all
-      ;;  these do or how to use them in the CSS for html, or LaTeX. This is to
-      ;;  fix an annoying HTML feature that has an extra line in the numbering.
-      ;;  This seems to do the right thing. I don't support hanging-indent like
-      ;;  oc-csl does, and I don't currently support LaTeX here. It already does
-      ;;  a good job there.
-      ;;
-      ;; (find-library "oc-csl")
-      ;;
-      ;; Here are some examples of what is in the bib-parameters.
-      ;;  (max-offset . 2) (hanging-indent) (second-field-align . flush)
-      ;; (entry-spacing . 0)
-      ;; (line-spacing . 2)
-      ;;
-      ;; Here we add style css for html output.
-      (cond
-       ((or (eq 'html backend) (eq 'html csl-backend))
-       (let ((s1 "")
-             (s2 ""))
-         (when (cdr (assq 'second-field-align bib-parameters))
-           (setq s1 (format
-                     "<style>.csl-left-margin{float: left; padding-right: 0em;}
- .csl-right-inline{margin: 0 0 0 %dem;}</style>"
-                     ;; I hard coded this factor of 0.6 from the oc-csl code.  
-                     (* 0.6  (or (cdr (assq 'max-offset bib-parameters)) 0)))))
-
-         ;; hard-coded the hanging indent. oc-csl uses a variable for this. I
-         ;; guess we could too, but this seems simpler.
-         (when (cdr (assq 'hanging-indent bib-parameters))
-           (setq s2 "<style>.csl-entry{text-indent: -1.5em; margin-left: 1.5em;}</style>"))
-         
-         (setq rendered-bib (concat
-                             s1 s2
-                             rendered-bib)))))
-
-      ;; replace the bibliography
-      (org-element-map (org-element-parse-buffer) 'link
-       (lambda (lnk)
-         (cond
-          ((string= (org-element-property :type lnk) "bibliography")
-           (cl--set-buffer-substring (org-element-property :begin lnk)
-                                     (org-element-property :end lnk)
-                                     (format (or
-                                              (cdr (assoc backend bib-formatters))
-                                              "%s")
-                                             rendered-bib)))
-          ;; We just get rid of nobibliography links.
-          ((string= (org-element-property :type lnk) "nobibliography")
-           (cl--set-buffer-substring (org-element-property :begin lnk)
-                                     (org-element-property :end lnk)
-                                     "")))))
-      ;; For LaTeX we need to define the citeprocitem commands
-      ;; see https://www.mail-archive.com/emacs-orgmodeNOSPAMgnu.org/msg138546.html
-      (when (eq backend 'latex)
-       (goto-char (point-min))
-       (insert "#+latex_header: \\makeatletter
-#+latex_header: \\newcommand{\\citeprocitem}[2]{\\hyper@linkstart{cite}{citeproc_bib_item_#1}#2\\hyper@linkend}
-#+latex_header: \\makeatother\n")))))
-
-
-(defun org-ref-export-to (backend &optional async subtreep visible-only
-                                 body-only info)
-  "Export buffer to BACKEND.
-See `org-export-as' for the meaning of ASYNC SUBTREEP
-VISIBLE-ONLY BODY-ONLY and INFO."
-  (let* ((fname (buffer-file-name))
-        (extensions '((html . ".html")
-                      (latex . ".tex")
-                      (ascii . ".txt")
-                      (md . ".md")
-                      (odt . ".odf")))
-        (cp (point))
-        (mm)                           ;marker to save place
-        (export-name (concat (file-name-sans-extension fname)
-                             (or (cdr (assoc backend extensions)) ""))))
-
-    (org-export-with-buffer-copy
-     ;; Note I use a marker here to make sure we stay in the same place we were.
-     ;; This is more robust than save-excursion I think, since processing moves
-     ;; points around. In theory the marker should move too.
-     (setq mm (make-marker))
-     (move-marker mm cp)
-     ;; make sure we expand includes
-     (org-export-expand-include-keyword)
-     (goto-char (marker-position mm))
-     (org-ref-process-buffer backend subtreep)
-     (set-marker mm nil)
-     
-     (pcase backend
-       ;; odt is a little bit special, and is missing one argument
-       ('odt (org-open-file (org-odt-export-to-odt async subtreep visible-only
-                                                  info)
-                           'system))
-       ;; for pandoc, we mean make a docx via pandoc
-       ('docx (org-open-file (plist-get (org-pandoc-export-to-docx async subtreep visible-only
-                                                                  body-only info)
-                                       'output-file)
-                            'system))
-       (_
-       (org-open-file (org-export-to-file backend export-name
-                        async subtreep visible-only
-                        body-only info)
-                      'system))))))
-
-
-;; I guess I tried to use apply-partially here, and it did not work, so these
-;; are each defined manually
-
-(defun org-ref-export-to-html (&optional async subtreep visible-only
-                                        body-only info)
-  "Export the buffer to HTML and open.
-See `org-export-as' for the meaning of ASYNC SUBTREEP
-VISIBLE-ONLY BODY-ONLY and INFO."
-  (org-ref-export-to 'html async subtreep visible-only
-                    body-only info))
-
-
-(defun org-ref-export-to-ascii (&optional async subtreep visible-only
-                                         body-only info)
-  "Export the buffer to ascii and open.
-See `org-export-as' for the meaning of ASYNC SUBTREEP
-VISIBLE-ONLY BODY-ONLY and INFO."
-  (org-ref-export-to 'ascii async subtreep visible-only
-                    body-only info))
-
-
-(defun org-ref-export-to-md (&optional async subtreep visible-only
-                                      body-only info)
-  "Export the buffer to md and open.
-See `org-export-as' for the meaning of ASYNC SUBTREEP
-VISIBLE-ONLY BODY-ONLY and INFO."
-  (org-ref-export-to 'md async subtreep visible-only
-                    body-only info))
-
-
-(defun org-ref-export-to-pdf (&optional async subtreep visible-only
-                                       body-only info)
-  "Export the buffer to PDF via LaTeX and open.
-See `org-export-as' for the meaning of ASYNC SUBTREEP
-VISIBLE-ONLY BODY-ONLY and INFO."
-  (let ((org-export-before-parsing-functions (append
-                                             org-export-before-parsing-functions
-                                             '(org-ref-csl-preprocess-buffer))))
-    (org-open-file (org-latex-export-to-pdf async subtreep visible-only
-                                           body-only info))))
-
-
-(defun org-ref-export-to-latex (&optional async subtreep visible-only
-                                         body-only info)
-  "Export the buffer to LaTeX and open.
-See `org-export-as' for the meaning of ASYNC SUBTREEP
-VISIBLE-ONLY BODY-ONLY and INFO."
-  (org-ref-export-to 'latex async subtreep visible-only
-                    body-only info))
-
-
-(defun org-ref-export-to-odt (&optional async subtreep visible-only
-                                       body-only info)
-  "Export the buffer to ODT and open.
-See `org-export-as' for the meaning of ASYNC SUBTREEP
-VISIBLE-ONLY BODY-ONLY and INFO."
-  (require 'htmlfontify)
-  (unless (boundp 'hfy-user-sheet-assoc) (setq  hfy-user-sheet-assoc nil))
-  (org-ref-export-to 'odt async subtreep visible-only
-                    body-only info))
-
-
-(defun org-ref-export-to-docx (&optional async subtreep visible-only
-                                        body-only info)
-  "Export the buffer to docx via pandoc and open.
-See `org-export-as' for the meaning of ASYNC SUBTREEP
-VISIBLE-ONLY BODY-ONLY and INFO."
-  (org-ref-export-to 'docx async subtreep visible-only
-                    body-only info))
-
-
-(defun org-ref-export-as-org (&optional _async subtreep visible-only
-                                       body-only info)
-  "Export the buffer to an ORG buffer and open.
-We only make a buffer here to avoid overwriting the original file.
-See `org-export-as' for the meaning of ASYNC SUBTREEP
-VISIBLE-ONLY BODY-ONLY and INFO."
-  (let* ((export-buf "*org-ref ORG Export*")
-        export)
-
-    (org-export-with-buffer-copy
-     (org-ref-process-buffer 'org subtreep)
-     (setq export (org-export-as 'org subtreep visible-only body-only info))
-     (with-current-buffer (get-buffer-create export-buf)
-       (erase-buffer)
-       (org-mode)
-       (insert export)))
-    (pop-to-buffer export-buf)))
-
-
-(defun org-ref-export-to-message (&optional _async subtreep visible-only
-                                           body-only info)
-  "Export to ascii and insert in an email message."
-  (let* ((backend 'ascii)
-        (content (org-export-with-buffer-copy
-                  (org-ref-process-buffer backend subtreep)
-                  (org-export-as backend subtreep visible-only
-                                 body-only info))))
-    (compose-mail)
-    (message-goto-body)
-    (insert content)
-    (message-goto-to)))
-
-
-(org-export-define-derived-backend 'org-ref 'org
-  :menu-entry
-  '(?r "Org-ref export"
-       ((?a "to Ascii" org-ref-export-to-ascii)
-       (?m "to markdown" org-ref-export-to-md)
-       (?h "to html" org-ref-export-to-html)
-       (?l "to LaTeX" org-ref-export-to-latex)
-       (?p "to PDF" org-ref-export-to-pdf)
-       (?o "to ODT" org-ref-export-to-odt)
-       (?O "to Org buffer" org-ref-export-as-org)
-       (?e "to email" org-ref-export-to-message)
-       (?w "to docx" org-ref-export-to-docx))))
-
-;; An alternative to this exporter is to use an  `org-export-before-parsing-functions'
-;; (add-hook 'org-export-before-parsing-functions 'org-ref-csl-preprocess-buffer)
-
-(defun org-ref-csl-preprocess-buffer (backend)
-  "Preprocess the buffer in BACKEND export.
-Note this may not work as expected, what about subtreep? The hook
-function just takes one argument. For now we rely on
-`buffer-narrowed-p' and an org-heading at the beginning.
-I am not positive on this though."
-  (org-ref-process-buffer backend (and (buffer-narrowed-p)
-                                      (save-excursion
-                                        (goto-char (point-min))
-                                        (org-at-heading-p)))))
-
-
-;; A hydra exporter with preprocessors
-(defhydradio org-ref ()
-  (natmove "natmove")
-  (citeproc "CSL citations")
-  (refproc "cross-references")
-  (acrossproc "Acronyms, glossary")
-  (idxproc "Index")
-  (bblproc "BBL citations"))
-
-
-(defun org-ref-export-from-hydra (&optional arg)
-  "Run the export dispatcher with the desired hooks selected in `org-ref-export/body'."
-  (interactive "P")
-
-  (when (and org-ref/citeproc org-ref/bblproc)
-    (error "You cannot use CSL and BBL at the same time."))
-  
-  (let ((org-export-before-parsing-functions org-export-before-parsing-functions))
-    (when org-ref/citeproc
-      (cl-pushnew 'org-ref-csl-preprocess-buffer org-export-before-parsing-functions))
-
-    (when org-ref/refproc
-      (cl-pushnew 'org-ref-refproc org-export-before-parsing-functions))
-
-    (when org-ref/acrossproc
-      (cl-pushnew 'org-ref-acrossproc org-export-before-parsing-functions))
-
-    (when org-ref/idxproc
-      (cl-pushnew 'org-ref-idxproc org-export-before-parsing-functions))
-
-    (when org-ref/bblproc
-      (unless (featurep 'org-ref-natbib-bbl-citeproc)
-       (require 'org-ref-natbib-bbl-citeproc))
-      (cl-pushnew 'org-ref-bbl-preprocess org-export-before-parsing-functions))
-    
-    ;; this goes last since it moves cites before they might get replaced.
-    (when org-ref/natmove
-      (cl-pushnew 'org-ref-cite-natmove org-export-before-parsing-functions))
-
-    (org-export-dispatch arg)))
-
-
-(defhydra org-ref-export (:color red)
-  "
-_C-n_: natmove % -15`org-ref/natmove       _C-c_: citeproc % -15`org-ref/citeproc^^^  _C-r_: refproc % -15`org-ref/refproc^^^
-_C-a_: acrossproc % -15`org-ref/acrossproc    _C-i_: idxproc % -15`org-ref/idxproc^^^   _C-b_: bblproc % -15`org-ref/bblproc^^^
-"
-  ("C-n" (org-ref/natmove) nil)
-  ("C-c" (org-ref/citeproc) nil)
-  ("C-r" (org-ref/refproc) nil)
-  ("C-a" (org-ref/acrossproc) nil)
-  ("C-i" (org-ref/idxproc) nil)
-  ("C-b" (org-ref/bblproc) nil)
-
-  ("e" org-ref-export-from-hydra "Export" :color blue)
-  ("q" nil "quit"))
-
-(provide 'org-ref-export)
-
-;;; org-ref-export.el ends here
diff --git a/elpa/org-ref-20241124.2012/org-ref-extract.el b/elpa/org-ref-20241124.2012/org-ref-extract.el
deleted file mode 100644 (file)
index bbd01f1..0000000
+++ /dev/null
@@ -1,190 +0,0 @@
-;;; org-ref-extract.el --- Extract BibTeX from HTML  -*- lexical-binding: t; -*-
-
-;; Copyright (C) 2023  Justus Piater
-
-;; Author: Justus Piater <Justus-devNOSPAMPiater.name>
-;; Keywords:
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;;
-
-
-(defun org-ref--extract (html-buffer rx num)
-  "Return content matched within HTML-BUFFER by RX at parenthesized
-sub-expression NUM."
-  (with-current-buffer html-buffer
-    (goto-char (point-min))
-    (if (re-search-forward rx nil t)
-       (match-string num)
-      nil)))
-
-
-(defun org-ref--get-pdf (pdf-url)
-  "For BibTeX entry at point, if not already present, get PDF, place
-it in`bibtex-completion-library-path', and add a corresponding
-FILE field to the entry."
-  (bibtex-beginning-of-entry)
-  (let* ((key (cdr (assoc "=key=" (bibtex-parse-entry))))
-         (pdf-file (concat (car bibtex-completion-library-path) key ".pdf")))
-    (unless (file-exists-p pdf-file)
-      (url-copy-file pdf-url pdf-file)
-      (if (org-ref-pdf-p pdf-file)
-          (message "%s saved" pdf-file)
-        (delete-file pdf-file)
-        (message "No pdf was downloaded.")
-        (browse-url pdf-url)))
-    (when (file-exists-p pdf-file)
-      (bibtex-set-field "file" pdf-file)
-      (when doi-utils-open-pdf-after-download
-       (org-open-file pdf-file)))))
-
-
-(defun org-ref--extract-entry-from-html
-    (html-buffer bibtex pdf-url &rest more-fields)
-  "At point, create a BibTeX entry using information extracted
-  from the HTML-BUFFER, and kill HTML-BUFFER."
-  (bibtex-mode)
-  (let ((bibtex (if (consp bibtex)
-                   (org-ref--extract html-buffer (car bibtex) (cdr bibtex))
-                 bibtex))
-       (pdf-url (if (consp pdf-url)
-                    (org-ref--extract html-buffer (car pdf-url) (cdr pdf-url))
-                  pdf-url))
-       (more-fields
-        (mapcar
-         (lambda (field)
-           (cons (car field)
-                 (if (consp (cdr field))
-                     (org-ref--extract html-buffer (cadr field) (cddr field))
-                   (cdr field))))
-         more-fields)))
-    (insert bibtex)
-    (goto-char (point-min))
-    (while (search-forward "{\\n" nil t)
-      (replace-match "{"))
-    (goto-char (point-min))
-    (while (search-forward "\\n" nil t)
-      (replace-match "\n"))
-    (org-ref-clean-bibtex-entry)
-    (dolist (pair more-fields)
-      (when (cdr pair)
-       (bibtex-set-field (car pair) (cdr pair))))
-    (org-ref--get-pdf pdf-url))
-  (kill-buffer html-buffer))
-
-
-(defun org-ref--html-buffer (url)
-  "Retrieve resource from URL, decode it, substitute XML entities,
-and return the buffer."
-  (with-current-buffer (generate-new-buffer "org-ref--html")
-    (let ((url-request-method "GET"))
-      (url-insert (url-retrieve-synchronously url)))
-    (goto-char (point-min))
-    (insert (xml-substitute-special (buffer-string)))
-    (delete-region (point) (point-max))
-    (current-buffer)))
-
-
-(defun org-ref-extract-from-openreview (id)
-  "At point, create a BibTeX entry for the given OpenReview ID."
-  (interactive "MOpenReview ID: ")
-  (let* ((url (concat "https://openreview.net/forum?id=" id))
-        (html-buffer (org-ref--html-buffer url)))
-    (org-ref--extract-entry-from-html
-     html-buffer
-     '("\"_bibtex\":\"\\(@.+?}\\)\"" . 1)
-     (replace-regexp-in-string "forum" "pdf" url)
-     '("abstract" .
-       ("<meta name=\"citation_abstract\" content=\"\\(.+?\\(\n.*?\\)*?\\)\"/>" . 1))
-     '("area" .
-       ("\"Please_choose_the_closest_area_that_your_submission_falls_into\":\"\\(.+?\\)\"" . 1))
-     '("keywords" . ("Keywords.*?\"note-content-value\">\\(.+?\\)</span>" . 1))
-     '("summary" .
-       ("\\(Summary\\|TL;DR\\).*?\"note-content-value\">\\(.+?\\)</span>" . 2))
-     ;; Should we proactively download supplementary materials too?
-     (cons "supp"
-          (if-let ((supp (org-ref--extract
-                          html-buffer
-                          ">Supplementary Material<.*?href=\"\\([^\"]+\\)" 1)))
-              (concat "https://openreview.net" supp))))))
-
-
-(defun org-ref-extract-from-pmlr (url)
-  "At point, create a BibTeX entry for the given PMLR URL."
-  (interactive "MPMLR URL: ")
-  (org-ref--extract-entry-from-html
-   (org-ref--html-buffer url)
-   '("id=\"bibtex\">\n\\(@.+\\(\n.*?\\)+?\\)\n</" . 1)
-   '("{\\(http.+\\.pdf\\)}" . 1)
-   ;; Should we proactively download supplementary materials too?
-   '("supp" . ("href=\"\\(https?://proceedings\\.mlr\\.press/[^\"]+?-supp[^\"]*?\\)\".*?>Supplementary PDF</" . 1))))
-
-
-(defun org-ref-extract-from-neurips (url)
-  "At point, create a BibTeX entry for the given NeurIPS Abstract URL."
-  (interactive "MNeurIPS Abstract URL: ")
-  (let ((hash (progn (string-match "/\\([0-9a-f]+\\)-" url)
-                    (match-string 1 url)))
-       (neurips-url "https://proceedings.neurips.cc")
-       (html-buffer (org-ref--html-buffer url))
-       (bibtex))
-    (with-current-buffer html-buffer
-      (goto-char (point-min))
-      (re-search-forward "href=[\"']\\([^\"']+bibtex[^\"']*\\)[\"']")
-      (let ((bibtex-url (match-string 1)))
-       (with-temp-buffer
-         (url-insert
-          (url-retrieve-synchronously (concat neurips-url bibtex-url)))
-         (setq bibtex (buffer-string)))))
-    (org-ref--extract-entry-from-html
-     html-buffer
-     bibtex
-     (concat neurips-url
-            (org-ref--extract html-buffer
-                              "href=[\"']\\([^\"']+-Paper[^\"']*\\)[\"']" 1))
-     (cons "url" url)
-     '("abstract" . ("<h4>Abstract</h4>[ \n]*?\\(<p>\\)+\\(.+?\\)</p>" . 2))
-     ;; Should we proactively download supplementary materials too?
-     (cons "supp"
-          (if-let
-              ((supp (org-ref--extract
-                      html-buffer
-                      "href=[\"']\\([^\"']+-Supplemental[^\"']*\\)[\"']" 1)))
-              (concat neurips-url supp))))))
-
-
-(defun org-ref-extract-from-cvf (url)
-  "At point, create a BibTeX entry for the given CVF HTML URL."
-  (interactive "MCVF HTML URL: ")
-  (let ((cvf-url "https://openaccess.thecvf.com")
-       (html-buffer (org-ref--html-buffer url)))
-    (org-ref--extract-entry-from-html
-     html-buffer
-     '("class=\"bibref[^\"]*\">[ \n]*\\(@.+?\\(\n.*?\\)+?\\)[ \n]*</" . 1)
-     (concat cvf-url (org-ref--extract
-                     html-buffer "<a href=[\"']\\([^\"']+\\)[\"']>pdf</a>" 1))
-     (cons "url" url)
-     '("abstract" . ("id=\"abstract\">[ \n]*\\([^<]+\\)[ \n]*</" . 1))
-     ;; Should we proactively download supplementary materials too?
-     (cons "supp" (concat cvf-url
-                         (org-ref--extract html-buffer
-                                           "href=[\"']\\([^\"']+\\)[\"']>supp</"
-                                           1))))))
-
-
-(provide 'org-ref-extract)
-;;; org-ref-extract.el ends here
diff --git a/elpa/org-ref-20241124.2012/org-ref-glossary.el b/elpa/org-ref-20241124.2012/org-ref-glossary.el
deleted file mode 100644 (file)
index aea320a..0000000
+++ /dev/null
@@ -1,938 +0,0 @@
-;;; org-ref-glossary.el --- glossary support in org-ref  -*- lexical-binding: t; -*-
-
-;; Copyright (C) 2016-2024  John Kitchin
-
-;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
-;; Keywords:
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;; Provides Some acronym and glossary support for org-mode. Only export to LaTeX
-;; is currently supported. The functionality is based on the LaTeX glossaries
-;; package. See https://en.wikibooks.org/wiki/LaTeX/Glossary and
-;; http://ctan.math.washington.edu/tex-archive/macros/latex/contrib/glossaries/glossaries-user.pdf
-
-;; Put something like this in your org-file.
-;; #+latex_header: \usepackage{glossaries}
-;; #+latex_header: \makeglossaries
-
-;; Put this where you want the glossaries to appear in your org-file.
-;; [[printglossaries:]]
-
-;; This is the preferred way to add glossary entries to an org-file. The table
-;; must be named glossary.
-;; 
-;; #+name: glossary
-;; | label | name  | description   |
-;; |-------+-------+---------------|
-;; | tree  | Tree  | A woody plant |
-;; | shrub | Shrub | A woody bush  |
-;;
-;; This is the preferred way to add acronyms
-;; #+name: acronyms
-;; | key  | abbreviation | full form                      |
-;; |------+--------------+--------------------------------|
-;; | mimo | mimo         | multiple-input multiple output |
-;; | qos  | QoS          | quality-of-service             |
-;; | bb   | BB           | branch and bound               |
-;;
-;; Then add `org-ref-glossary-before-parsing' and
-;; `org-ref-acronyms-before-parsing' to the `org-export-before-parsing-hook'.
-
-;; See `org-ref-acronym-types' and `org-ref-glossary-gls-commands' for the types defined.
-
-;; Use `org-ref-insert-glossary-link' and `org-ref-insert-acronym-link' to
-;; insert a link with completion.
-
-;; * Known limitations
-;; 
-;; This only works well in a single file (i.e. you cannot include the tables
-;; from another file). I tried implementing that once, and it was too slow.
-
-
-
-;; * DEPRECATED way of adding entries
-;; This is still supported but using the tables is preferred.
-;; Add new glossary entries to your org-file like this. Enclose strings
-;; containing a comma in {}. Multiline entries are supported.
-
-;; #+latex_header_extra: \newglossaryentry{computer}{name=computer,description={A machine, that computes}}
-;; #+latex_header_extra: \newglossaryentry{tree}{name=tree,description=a big plant}
-
-;; #+latex_header_extra: \newglossaryentry{naiive}
-;; #+latex_header_extra: {
-;; #+latex_header_extra:   name=na\"{\i}ve,
-;; #+latex_header_extra:   description={is a French loanword (adjective, form of naïf)
-;; #+latex_header_extra:                indicating having or showing a lack of experience,
-;; #+latex_header_extra:                understanding or sophistication}
-;; #+latex_header_extra: }
-
-;; Here is an example acronym definition
-;; #+latex_header_extra: \newacronym{lvm}{LVM}{Logical Volume Manager}
-
-(require 'org-element)
-(require 'org-ref-utils)
-(require 'ox)
-
-;;; Code:
-(defgroup org-ref-glossary nil
-  "Customization group for org-ref-glossary."
-  :tag "Org Ref glossary"
-  :group 'org)
-
-
-(defcustom org-ref-activate-glossary-links t
-  "If non-nil activate acronym and glossary links.
-Checks in `org-ref-glossary-face-fn' and `org-ref-acronym-face-fn'.
-This is not always fast, so we provide a way to disable it."
-  :type 'boolean
-  :group 'org-ref-glossary)
-
-
-(defcustom org-ref-glsentries '()
-  "Variable to hold locations of glsentries load files.")
-
-
-(defvar-local org-ref-glossary-cache nil
-  "Buffer-local variable for glossary entry cache.")
-
-
-(defvar-local org-ref-acronym-cache nil
-  "Buffer-local variable for acronym entry cache.")
-
-
-(defun or-find-closing-curly-bracket (&optional limit)
-  "Find closing bracket for the bracket at point and move point to it.
-Go up to LIMIT or `point-max'. This is a parsing function. I
-wrote this because using `forward-list' does not always work if
-there is an escaped \" for example. This seems pretty robust."
-  (unless (looking-at "{") (error "Not at a curley bracket"))
-
-  (let ((level 1))
-    (while (and (not (= 0 level))
-               (not (eobp))
-               (< (point) (or limit (point-max))))
-      (forward-char)
-      (when (and (looking-at "{")
-                (not (looking-back "\\\\" (- (point) 2))))
-       (cl-incf level))
-      (when (and (looking-at "}")
-                (not (looking-back "\\\\" (- (point) 2))))
-       (cl-decf level)))
-    (point)))
-
-
-;;* Glossary
-(defun or-parse-glossary-entry (entry)
-  "Parse a LaTeX glossary ENTRY definition to a p-list of key=value.
-ENTRY is the label we are looking for.
-Typically returns  (:name name :description description)
-but there could be other :key value pairs.
-
-This is a source of performance loss, because this is search
-based and it is done on each fontification. It is easy to cache
-the results, but not easy to invalidate them, e.g. to reflect
-changes."
-  (if (and org-ref-glossary-cache (gethash entry org-ref-glossary-cache))
-      ;; We have the cache, and an entry and use it
-      (gethash entry org-ref-glossary-cache)
-    ;; We don't have a cache, or an entry in it, so we find it.
-    ;; No cache? we make one
-    (unless org-ref-glossary-cache
-      (setq-local org-ref-glossary-cache (make-hash-table :test 'equal)))
-
-    ;; Now we search to get the data
-    (save-excursion
-      (goto-char (point-min))
-      (let* (end-of-entry
-            data
-            (external (when (re-search-forward
-                             "\\loadglsentries\\(\\[.*\\]\\){\\(?1:.*\\)}" nil t)
-                        (match-string 1)))
-            (glsentries (and external
-                             (or (cdr (assoc external org-ref-glsentries))
-                                 (progn
-                                   (cl-pushnew (cons external (s-trim
-                                                               (shell-command-to-string
-                                                                (format "kpsewhich tex %s"
-                                                                        external))))
-                                               org-ref-glsentries)
-                                   (cdr (assoc external org-ref-glsentries))))))
-            key value p1 p2 position)
-       (setq data
-             (catch 'data
-               ;; look inside first for latex-headers
-               (goto-char (point-min))
-               (when (re-search-forward
-                      (format "\\newglossaryentry{%s}" entry) nil t)
-                 (setq position (match-beginning 0))
-                 (re-search-forward "{")
-                 (save-excursion
-                   (backward-char)
-                   (or-find-closing-curly-bracket)
-                   (setq end-of-entry (point)))
-
-                 (while (re-search-forward "\\(\\w+?\\)=" end-of-entry t)
-                   (setq key (match-string 1))
-                   ;; get value
-                   (goto-char (+ 1 (match-end 1)))
-                   (setq p1 (point))
-                   (if (looking-at "{")
-                       ;; value is wrapped in {}
-                       (progn
-                         (or-find-closing-curly-bracket)
-                         (setq p2 (point)
-                               value (buffer-substring (+ 1 p1) p2)))
-                     ;; value is up to the next comma
-                     (re-search-forward "," end-of-entry 'mv)
-                     (setq value (buffer-substring p1 (- (point) 1))))
-                   ;; remove #+latex_header_extra:
-                   (setq value (replace-regexp-in-string
-                                "#\\+latex_header_extra: " "" value))
-                   (setq value (replace-regexp-in-string
-                                "\n +" " " value))
-                   (setq data (append data
-                                      (list :label entry)
-                                      (list (intern (format ":%s" key)))
-                                      (list value)
-                                      (list :position position))))
-                 (throw 'data data))
-
-               ;; check for a glossary table
-               (let* ((entries (save-excursion
-                                 (catch 'found
-                                   (org-element-map
-                                       (org-element-parse-buffer)
-                                       'table
-                                     (lambda (el)
-                                       (when (string= "glossary" (org-element-property :name el))
-                                         (goto-char (org-element-property :contents-begin el))
-                                         (setq position (point))
-                                         (throw 'found
-                                                (nthcdr 2 (org-babel-read-table)))))))))
-                      (result (assoc entry entries)))
-                 (when result
-                   (throw 'data (list :label entry
-                                      :name (cl-second result)
-                                      :description (cl-third result)
-                                      :position position))))
-
-               ;; then external
-               (when (and glsentries
-                          (file-exists-p glsentries))
-
-                 (with-current-buffer (find-file-noselect glsentries)
-                   (goto-char (point-min))
-                   (when (re-search-forward
-                          (format "\\newglossaryentry{%s}" entry) nil t) 
-                     (re-search-forward "{")
-                     (save-excursion
-                       (backward-char)
-                       (or-find-closing-curly-bracket)
-                       (setq end-of-entry (point)))
-
-                     (while (re-search-forward "\\(\\w+?\\)=" end-of-entry t)
-                       (setq key (match-string 1))
-                       ;; get value
-                       (goto-char (+ 1 (match-end 1)))
-                       (setq p1 (point))
-                       (if (looking-at "{")
-                           ;; value is wrapped in {}
-                           (progn
-                             (or-find-closing-curly-bracket)
-                             (setq p2 (point)
-                                   value (buffer-substring (+ 1 p1) p2)))
-                         ;; value is up to the next comma
-                         (re-search-forward "," end-of-entry 'mv)
-                         (setq value (buffer-substring p1 (- (point) 1))))
-                       (setq data (append data
-                                          (list :label entry)
-                                          (list (intern (format ":%s" key)))
-                                          (list value)
-                                          (list :position nil))))
-                     (throw 'data data))))))
-       (puthash entry data org-ref-glossary-cache)
-       data))))
-
-
-
-;;** Glossary links
-
-(defun or-activate-glossary (start end path bracketp)
-  "Activate function for a glossary link.
-set data on text with properties
-Set face property, and help-echo."
-  (let ((data (or (or-parse-glossary-entry path)
-                 (or-parse-acronym-entry path)))) 
-    (add-text-properties
-     start end
-     (list 'or-glossary data
-          'face (if data
-                    'org-ref-glossary-face
-                  'font-lock-warning-face)))))
-
-(defface org-ref-glossary-face
-  `((t (:inherit org-link :foreground "Mediumpurple3")))
-  "Face for glossary links.")
-
-
-(defun or-follow-glossary (entry)
-  "Goto beginning of the glossary ENTRY."
-  (org-mark-ring-push)
-  (goto-char (plist-get (get-text-property (point) 'or-glossary) :position)))
-
-
-(defun or-glossary-tooltip (_window buffer position)
-  "Return tooltip for the glossary entry.
-The entry is in WINDOW and OBJECT at POSITION.
-Used in fontification." 
-  (with-current-buffer buffer
-    (let* ((data (get-text-property position 'or-glossary))
-          (name (or (plist-get data :name)
-                    (plist-get data :abbrv)))
-          (description (or (plist-get data :description)
-                           (plist-get data :full))))
-      (format
-       "%s: %s"
-       name
-       (with-temp-buffer
-        (insert (concat  description "."))
-        (fill-paragraph)
-        (buffer-string))))))
-
-
-(defvar org-ref-glossary-gls-commands
-  '(("gls" "The term associated with the label")
-    ("glspl" "The plural term")
-    ("Gls" "The capitalized term")
-    ("Glspl" "The plural capitalized term")
-    ("glssymbol" "The symbol defined (only with latex definition)")
-    ("Glssymbol" "The capitalized symbol defined (only with latex definition)")
-    ("glsdesc" "The description associated with the label")
-    ("Glsdesc" "The capitalized description associated with the label"))
-  "An alist of (cmd description).")
-
-(dolist (command org-ref-glossary-gls-commands)
-  (org-link-set-parameters (cl-first command)
-                          :follow #'or-follow-glossary
-                          :activate-func #'or-activate-glossary 
-                          :help-echo 'or-glossary-tooltip
-                          :export (lambda (path _ format)
-                                    (cond
-                                     ((memq format '(latex beamer))
-                                      (format "\\%s{%s}" (cl-first command) path))
-                                     (t
-                                      (format "%s" path))))))
-
-
-(org-link-set-parameters "glslink"
-                        :follow #'or-follow-glossary
-                        :activate-func #'or-activate-glossary
-                        :face 'org-ref-glossary-face-fn
-                        :help-echo 'or-glossary-tooltip
-                        :export (lambda (path desc format)
-                                  (cond
-                                   ((memq format '(latex beamer))
-                                    (format "\\glslink{%s}{%s}" path desc))
-                                   (t
-                                    (format "%s" path)))))
-
-
-
-
-;; **  printglossaries links
-;; There is a printglossary command in LaTeX, but I am not supporting it for now.
-(org-link-set-parameters "printglossaries"
-                        :export (lambda (path _desc format)
-                                  (cond
-                                   ((memq format '(latex beamer))
-                                    "\\printglossaries")
-                                   (t
-                                    (format "%s" path)))))
-
-
-
-;; ** exporting with a glossary table
-(defun org-ref-glossary-before-parsing (_backend)
-  "Function to preprocess a glossary table on export.
-This assumes a table like
-
-#+name: glossary
-| label | name  | description   |
-|-------+-------+---------------|
-| tree  | Tree  | A woody plant |
-| shrub | Shrub | A woody bush  |
-
-is in the org-buffer, and will add the relevant latex_header
-items if there is. The table is deleted in a copy of the buffer
-before the export, so you can put it where you want. The column
-names are arbitrary, but three columns are expected, and the
-hline is expected.
-
-This is intended to be run in `org-export-before-parsing-hook'."
-  (save-restriction
-    (widen)
-    (let* (begin
-          end
-          (entries (save-excursion
-                     (catch 'found
-                       (org-element-map
-                           (org-element-parse-buffer)
-                           'table
-                         (lambda (el)
-                           (when (and (org-element-property :name el)
-                                      (stringp (org-element-property :name el))
-                                      (string= "glossary" (org-element-property :name el)))
-                             (setq begin (org-element-property :begin el)
-                                   end (org-element-property :end el))
-                             (goto-char (org-element-property :contents-begin el))
-                             (throw 'found
-                                    (nthcdr 2 (org-babel-read-table))))))))))
-      ;; Delete the table
-      (when entries
-       (cl--set-buffer-substring begin end ""))
-
-      (goto-char (point-min))
-      (cl-loop for (label name description) in entries
-              do
-              (insert (format "#+latex_header_extra: \\newglossaryentry{%s}{name=%s,description={{%s}}}\n"
-                              label name description))))))
-
-
-;;* Acronyms
-
-(defun or-parse-acronym-entry (label)
-  "Parse an acronym entry LABEL to a plist.
-Returns (:abbrv abbrv :full full :label label)
-The plist maps to \newacronym{<label>}{<abbrv>}{<full>}"
-  (if (and org-ref-acronym-cache (gethash label org-ref-acronym-cache))
-      ;; We have the cache, and an entry and use it
-      (gethash label org-ref-acronym-cache)
-    ;; We don't have a cache, or an label in it, so we find it.
-    ;; No cache? we make one
-    (unless org-ref-acronym-cache
-      (setq-local org-ref-acronym-cache (make-hash-table :test 'equal )))
-
-    ;; Now search for the data
-    (save-excursion
-      (goto-char (point-min))
-      (let* (abbrv
-            full p1
-            (external (when (re-search-forward "\\loadglsentries\\(\\[.*\\]\\){\\(?1:.*\\)}" nil t)
-                        (match-string 1)))
-            (glsentries (and external
-                             (or (cdr (assoc external org-ref-glsentries))
-                                 (progn
-                                   (cl-pushnew (cons external
-                                                     (s-trim (shell-command-to-string
-                                                              (format "kpsewhich tex %s" external))))
-                                               org-ref-glsentries)
-                                   (cdr (assoc external org-ref-glsentries))))))
-            data)
-       (setq data
-             (catch 'data
-               (goto-char (point-min))
-               ;; check in the definitions of newacronym
-               (when (re-search-forward (format "\\newacronym{%s}" label) nil t)
-                 (setq p1 (+ 1 (point)))
-                 (forward-list)
-                 (setq abbrv (buffer-substring p1 (- (point) 1)))
-                 (setq p1 (+ 1 (point)))
-                 (forward-list)
-                 (setq full (buffer-substring p1 (- (point) 1)))
-                 (throw 'data
-                        (list :label label :abbrv abbrv :full full)))
-
-               ;; look for acronyms table
-               (let* ((entries (save-excursion
-                                 (catch 'found
-                                   (org-element-map
-                                       (org-element-parse-buffer)
-                                       'table
-                                     (lambda (el)
-                                       (when (string= "acronyms" (org-element-property :name el))
-                                         (goto-char (org-element-property :contents-begin el))
-                                         (throw 'found
-                                                (nthcdr 2 (org-babel-read-table)))))))))
-                      (result (assoc label entries)))
-                 (when result
-                   (throw 'data (list :label label
-                                      :abbrv (cl-second result) :full (cl-third result)))))
-
-               ;; look external
-               (when (and glsentries
-                          (file-exists-p glsentries))
-                 (with-current-buffer (find-file-noselect glsentries)
-                   (goto-char (point-min))
-                   (when (re-search-forward (format "\\newacronym{%s}" label) nil t)
-                     (setq p1 (+ 1 (point)))
-                     (forward-list)
-                     (setq abbrv (buffer-substring p1 (- (point) 1)))
-                     (setq p1 (+ 1 (point)))
-                     (forward-list)
-                     (setq full (buffer-substring p1 (- (point) 1)))
-                     (throw 'data
-                            (list :label label :abbrv abbrv :full full )))))))
-       (puthash label data org-ref-acronym-cache)
-       data))))
-
-
-(defun org-ref-glossary-invalidate-caches ()
-  "Function to invalidate the caches."
-  (interactive)
-  (setq-local org-ref-acronym-cache (make-hash-table :test 'equal))
-  (setq-local org-ref-glossary-cache (make-hash-table :test 'equal)))
-
-;;** Acronym links
-
-(defun or-activate-acronym (start end path bracketp)
-  "Activate function for an acronym link.
-set data on text with properties
-Set face property, and help-echo."
-  (let ((data (or-parse-acronym-entry path)))
-    (add-text-properties
-     start end
-     (list 'or-glossary data
-          'face (if data
-                    'org-ref-acronym-face
-                  'font-lock-warning-face)))))
-
-
-(defun or-follow-acronym (label)
-  "Go to the definition of the acronym LABEL."
-  (org-mark-ring-push)
-  (cond
-   ;; table first
-   ((progn (goto-char (point-min))
-          (and (re-search-forward "#\\+name: acronyms" nil t)
-               (re-search-forward label nil t)))
-    nil)
-   
-   ((progn (goto-char (point-min)) (re-search-forward (format "\\newacronym{%s}" label) nil t))
-    (goto-char (match-beginning 0)))
-
-   (t
-    (message "no entry found for %s" label))))
-
-
-;;** Tooltips on acronyms
-(defface org-ref-acronym-face
-  `((t (:inherit org-link :foreground "Darkorange2")))
-  "Face for acronym links.")
-
-
-(defun or-acronym-tooltip (_window buffer position)
-  "Return tooltip for the acronym entry.
-The entry is in WINDOW and OBJECT at POSITION.
-Used in fontification.
-WINDOW and OBJECT are ignored."
-  (with-current-buffer buffer
-    (save-excursion
-      (goto-char position)
-      (let* ((acronym-data (get-text-property position 'or-glossary))
-            (abbrv (plist-get acronym-data :abbrv))
-            (full (plist-get acronym-data :full)))
-       (if acronym-data
-           (format
-            "%s: %s"
-            abbrv full)
-         (format "This is not defined in this file."))))))
-
-
-(defvar org-ref-acronym-types
-  '(("acrshort" "The acronym for label")
-    ("acrshortpl" "The acronym for label in plural")
-    ("Acrshort" "Capitalized acronym")
-    ("Acrshortpl" "Plural capitalized acronym")
-    ("ACRshort" "ALL-CAPS acronym")
-    ("ACRshortpl" "ALL-CAPS plural acronym")
-    
-    ("acrlong" "The label definition")
-    ("acrlongpl" "The plural definition")
-    ("Acrlong" "Capitalized definition")
-    ("Acrlongpl" "Plural capitalized definition")
-    ("ACRlong" "ALL-CAPS definition")
-    ("ACRlongpl" "plural ALL-CAPS definition")
-    
-    ("acrfull" "Both the acronym and its definition")
-    ("acrfullpl" "Both the acronym and its definition in plural")
-    ("Acrfull" "Capitalized both the acronym and its definition")
-    ("Acrfullpl" "Capitalized both the acronym and its definition in plural")
-    ("ACRfull" "Both the acronym and its definition in ALL-CAPS")
-    ("ACRfullpl" "Both the acronym and its definition in plural ALL-CAPS"))
-  "list of acronym types (type description)")
-
-
-(cl-dolist (mapping org-ref-acronym-types)
-  (org-link-set-parameters (cl-first mapping)
-                          :follow #'or-follow-acronym
-                          :activate-func #'or-activate-acronym 
-                          :help-echo #'or-acronym-tooltip
-                          :export (lambda (path _ format)
-                                    (cond
-                                     ((memq format '(latex beamer))
-                                      (format "\\%s{%s}" (cl-first mapping) path))
-                                     (t
-                                      (format "%s" (upcase path)))))))
-
-
-
-
-;; ** Exporting with an acronym table
-(defun org-ref-acronyms-before-parsing (_backend)
-  "Function to preprocess a glossary table on export.
-This assumes a table like
-
-#+name: acronyms
-| Key  | Short | Long                           |
-|------+-------+--------------------------------|
-| mimo |       | multiple-input multiple output |
-| qos  | QoS   | quality-of-service             |
-| bb   | BB    | branch and bound               |
-
-is in the org-buffer, and will add the relevant latex_header items if there is. The table is deleted in a copy of the buffer before the export.
-
-This will run in `org-export-before-parsing-hook'."
-  (save-restriction
-    (widen)
-    (let* (begin
-          end
-          (entries (save-excursion
-                     (catch 'found
-                       (org-element-map
-                           (org-element-parse-buffer)
-                           'table
-                         (lambda (el)
-                           (when (and (org-element-property :name el)
-                                      (stringp (org-element-property :name el))
-                                      (string= "acronyms" (org-element-property :name el)))
-                             (setq begin (org-element-property :begin el)
-                                   end (org-element-property :end el))
-                             (goto-char (org-element-property :contents-begin el))
-                             (throw 'found
-                                    (nthcdr 2 (org-babel-read-table))))))))))
-      (when entries
-       ;; Delete the table
-       (cl--set-buffer-substring begin end ""))
-
-      (goto-char (point-min))
-      (cl-loop for (label name description) in entries
-              do
-              (insert (format "#+latex_header_extra: \\newacronym{%s}{%s}{%s}\n"
-                              label name description))))))
-
-
-;; * Interactive command to insert acroynm/glossary links
-
-(defun org-ref-insert-glossary-link ()
-  "Insert glossary entry as links."
-  (interactive)
-  ;; gather entries
-  (let* ((glossary-candidates '()) 
-        key entry type
-        type-annotation
-        completion-extra-properties
-        choice)
-
-    ;; glossary terms
-    (save-excursion
-      (goto-char (point-min))
-      (while (re-search-forward
-             "\\\\newglossaryentry{\\([[:ascii:]]+?\\)}" nil t)
-
-       (setq key (match-string 1)
-             entry (or-parse-glossary-entry key))
-
-       (cl-pushnew (cons
-                    (propertize (format "%s: %s - glossary."
-                                        (plist-get entry :name)
-                                        (plist-get entry :description))
-                                'face 'org-ref-glossary-face)
-                    entry)
-                   glossary-candidates)))
-
-    ;; get entries from the table
-    (let ((entries (save-excursion
-                    (catch 'found
-                      (org-element-map
-                          (org-element-parse-buffer)
-                          'table
-                        (lambda (el)
-                          (when (and (org-element-property :name el)
-                                     (stringp (org-element-property :name el))
-                                     (string= "glossary"
-                                              (org-element-property :name el)))
-                            (goto-char (org-element-property :contents-begin el))
-                            (throw 'found
-                                   ;; skip header and hline
-                                   (nthcdr 2 (org-babel-read-table))))))))))
-      (cl-loop for (label name description) in entries do
-              (cl-pushnew (cons
-                           (propertize (format "%s: %s - glossary."
-                                               label
-                                               description)
-                                       'face 'org-ref-glossary-face)
-                           (list :label label :name name :description description))
-                          glossary-candidates)))
-
-
-    (setq choice (completing-read "Choose: " glossary-candidates)
-         entry (cdr (assoc choice glossary-candidates))
-         type-annotation (lambda (s)
-                           (let ((item (assoc s minibuffer-completion-table)))
-                             (when item (concat
-                                         (make-string (- 12 (length s)) ? )
-                                         "-- "
-                                         (cl-second item)))))
-         completion-extra-properties `(:annotation-function ,type-annotation)
-         type (completing-read "Type: "
-                               org-ref-glossary-gls-commands
-                               nil t))
-
-    (insert (format
-            "[[%s:%s][%s]]"
-            type
-            (plist-get entry :label)
-            (pcase type
-              ("gls" (plist-get entry :name))
-              ("glspl" (concat (plist-get entry :name) "s"))
-              ("Gls" (concat (capitalize (substring (plist-get entry :name) 0 1))
-                             (substring (plist-get entry :name) 1)))
-              ("Glspl" (concat (capitalize (substring (plist-get entry :name) 0 1))
-                               (substring (plist-get entry :name) 1)
-                               "s"))
-              ("glssymbol" (plist-get entry :name))
-              ("Glssymbol" (concat (capitalize (substring (plist-get entry :name) 0 1))
-                                   (substring (plist-get entry :name) 1)))
-              ("glsdesc" (plist-get entry :description))
-              ("Glsdesc" (concat (capitalize (substring (plist-get entry :description) 0 1))
-                                 (substring (plist-get entry :description) 1)))
-              ;; fall-through for everything else
-              (_ (plist-get entry :name)))))))
-
-
-(defun org-ref-insert-acronym-link ()
-  "Insert acronym entry as links."
-  (interactive)
-  ;; gather entries
-  (let* ((acronym-candidates '())
-        key entry
-        type
-        type-annotation
-        completion-extra-properties
-        choice
-        (cap1 (lambda (s)
-                "capitalize first letter only"
-                (concat
-                 (capitalize (substring s 0 1))
-                 (substring s 1)))))
-
-    (save-excursion
-      (goto-char (point-min))
-      (while (re-search-forward
-             "\\\\newacronym{\\([[:ascii:]]+?\\)}" nil t)
-       (setq key (match-string 1)
-             entry (or-parse-acronym-entry key))
-       (cl-pushnew (cons (propertize
-                          (format "%s (%s) - acronym."
-                                  (plist-get entry :full)
-                                  (plist-get entry :abbrv))
-                          'face 'org-ref-acronym-face)
-                         entry)
-                   acronym-candidates)))
-
-    (let ((entries (save-excursion
-                    (catch 'found
-                      (org-element-map
-                          (org-element-parse-buffer)
-                          'table
-                        (lambda (el)
-                          (when (and (org-element-property :name el)
-                                     (stringp (org-element-property :name el))
-                                     (string= "acronyms"
-                                              (org-element-property :name el)))
-                            (goto-char (org-element-property :contents-begin el))
-                            (throw 'found
-                                   ;; skip header and hline
-                                   (nthcdr 2 (org-babel-read-table))))))))))
-      (cl-loop for (key abbrv full) in entries do
-              (cl-pushnew (cons (propertize
-                                 (format "%s (%s) - acronym."
-                                         full
-                                         abbrv)
-                                 'face 'org-ref-acronym-face)
-                                (list :label key :abbrv abbrv :full full))
-                          acronym-candidates)))
-
-    (setq choice (completing-read "Choose: " acronym-candidates)
-         entry (cdr (assoc choice acronym-candidates))
-         type-annotation (lambda (s)
-                           (let ((item (assoc s minibuffer-completion-table)))
-                             (when item (concat
-                                         (make-string (- 12 (length s)) ? )
-                                         "-- "
-                                         (cl-second item)))))
-         
-         completion-extra-properties `(:annotation-function ,type-annotation)
-         type (completing-read "Type: "
-                               org-ref-acronym-types
-                               nil t))
-
-    (insert (format
-            "[[%s:%s][%s]]"
-            type
-            (plist-get entry :label)
-            (pcase type
-              ("acrshort" (plist-get entry :abbrv))
-              ;; this is a cheap way to pluralize. I don't know what the rules
-              ;; are in LaTeX. this is only for display, so it isn't critical.
-              ("acrshortpl" (concat (plist-get entry :abbrv) "s"))
-              
-              ("Acrshort" (funcall cap1 (plist-get entry :abbrv)))
-              ("Acrshortpl" (concat (capitalize (plist-get entry :abbrv)) "s"))
-
-              ("ACRshort" (upcase (plist-get entry :abbrv)))
-              ("ACRshortpl" (concat (upcase (plist-get entry :abbrv)) "s"))
-
-              ("acrlong" (plist-get entry :full))
-              ("acrlongpl" (concat (plist-get entry :full) "s"))
-              
-              ("Acrlong" (funcall cap1 (plist-get entry :full)))
-              ("Acrlongpl" (concat (funcall cap1 (plist-get entry :full)) "s"))
-              
-              ("acrfull" (format "%s (%s)"
-                                 (plist-get entry :full)
-                                 (plist-get entry :abbrv)))
-              ("acrfullpl" (format "%ss (%ss)"
-                                   (plist-get entry :full)
-                                   (plist-get entry :abbrv)))
-              
-              ("Acrfull" (funcall cap1 (format "%s (%s)"
-                                               (plist-get entry :full)
-                                               (plist-get entry :abbrv))))
-              ("Acrfullpl" (funcall cap1 (format "%ss (%ss)"
-                                                 (plist-get entry :full)
-                                                 (plist-get entry :abbrv))))
-              ("ACRfull" (upcase (format "%s (%s)"
-                                         (plist-get entry :full)
-                                         (plist-get entry :abbrv))))
-              ("ACRfullpl" (upcase (format "%ss (%ss)"
-                                           (plist-get entry :full)
-                                           (plist-get entry :abbrv))))
-              ;; fall-through in case anything is added later.
-              (_ (plist-get entry :abbrv)))))))
-
-
-;; * acrossproc - acronym and glossary preprocessor
-;;
-;; Replace printglossary with the acronym and glossary entries
-;;
-;; Replace the links with links
-;;
-;; TODO: support only one or the other? via printglossary:acronyms for example?
-
-(defun org-ref-acrossproc (_backend)
-  "Preprocessing function for acronyms and glossary entries.
-Meant for non-LaTeX exports."
-  (save-excursion
-    (let* ((glossary)
-          (acronyms)
-          (printglossary-link)
-          (links))
-
-      (setq glossary (org-element-map
-                        (org-element-parse-buffer)
-                        'table 
-                      (lambda (el)
-                        (when (and (org-element-property :name el)
-                                   (stringp (org-element-property :name el))
-                                   (string= "glossary" (org-element-property :name el))) 
-                          (goto-char (org-element-property :contents-begin el))
-                          (prog1
-                              ;; skip header and hline
-                              (nthcdr 2 (org-babel-read-table))
-                            ;; delete the table
-                            (cl--set-buffer-substring (org-element-property :begin el)
-                                                      (org-element-property :end el)
-                                                      ""))))
-                      nil t))
-      (setq acronyms (org-element-map
-                        (org-element-parse-buffer)
-                        'table 
-                      (lambda (el)
-                        (when (and (org-element-property :name el)
-                                   (stringp (org-element-property :name el))
-                                   (string= "acronyms" (org-element-property :name el))) 
-                          (goto-char (org-element-property :contents-begin el))
-                          (prog1
-                              (nthcdr 2 (org-babel-read-table))
-                            ;; delete the table
-                            (cl--set-buffer-substring (org-element-property :begin el)
-                                                      (org-element-property :end el)
-                                                      ""))))
-                      nil t))
-      
-      ;; Replace printglossary link
-      ;; For each entry, use - name :: description <<label>>
-      (setq printglossary-link (org-element-map
-                                  ;; reparse in case the replacement above changed places
-                                  (org-element-parse-buffer)
-                                  'link
-                                (lambda (lnk)
-                                  (when (string= "printglossaries"
-                                                 (org-element-property :type lnk))
-                                    lnk))
-                                nil t))
-      (when printglossary-link
-       (cl--set-buffer-substring (org-element-property :begin printglossary-link)
-                                 (org-element-property :end printglossary-link)
-                                 
-                                 (concat "*Glossary*\n"
-                                         (string-join
-                                          (cl-loop for (label name description) in glossary collect
-                                                   (format "<<%s>>\n- %s :: %s" label name description))
-                                          "\n")
-
-                                         "\n*Acronyms*\n"
-                                         (string-join
-                                          (cl-loop for (label name description) in acronyms collect
-                                                   (format "<<%s>>\n- %s :: %s " label name description))
-                                          "\n"))))
-
-
-      ;; Replace links
-      (setq links (org-element-map
-                     ;; reparse in case the replacement above changed places
-                     (org-element-parse-buffer)
-                     'link
-                   (lambda (lnk)
-                     (when (assoc (org-element-property :type lnk)
-                                  (append org-ref-glossary-gls-commands
-                                          org-ref-acronym-types))
-                       lnk))))
-      ;; For each link, replace with [[label][link description]]
-      (cl-loop for lnk in (reverse links) do
-              (cl--set-buffer-substring (org-element-property :begin lnk)
-                                        (org-element-property :end lnk)
-                                        (format "[[%s][%s]]%s"
-                                                (org-element-property :path lnk)
-                                                (buffer-substring (org-element-property :contents-begin lnk)
-                                                                  (org-element-property :contents-end lnk))
-                                                (make-string (org-element-property :post-blank lnk) ? )))))))
-
-
-(provide 'org-ref-glossary)
-;;; org-ref-glossary.el ends here
diff --git a/elpa/org-ref-20241124.2012/org-ref-helm.el b/elpa/org-ref-20241124.2012/org-ref-helm.el
deleted file mode 100644 (file)
index 162baa7..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-;;; org-ref-helm.el --- org-ref interface to helm-bibtex -*- lexical-binding: t; -*-
-
-;; Copyright(C) 2014-2024 John Kitchin
-
-;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
-;; URL: https://github.com/jkitchin/org-ref
-;; Keywords: org-mode, cite, ref, label
-;; Package-Requires: ((helm-bibtex "0") (org-ref "0"))
-
-;; This file is not currently part of GNU Emacs.
-
-;; This program is free software; you can redistribute it and/or
-;; modify it under the terms of the GNU General Public License as
-;; published by the Free Software Foundation; either version 2, or (at
-;; your option) any later version.
-
-;; This program is distributed in the hope that it will be useful, but
-;; WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-;; General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program ; see the file COPYING.  If not, write to
-;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
-
-;;; Commentary:
-;;
-;; Adapted from helm-bibtex, mostly so you get the default action to insert a citation
-
-(require 'org-ref-core)
-(require 'helm-bibtex)
-
-(defvar helm-bibtex-local-bib)  ; to quiet compiler. 
-
-;;; Code:
-
-(helm-bibtex-helmify-action org-ref-insert-cite-keys org-ref-helm-bibtex-insert-citation)
-
-(defvar org-ref-helm-source-bibtex
-  (helm-build-sync-source "BibTeX entries"
-    :header-name (lambda (name)
-                   (format "%s%s: " name (if helm-bibtex-local-bib " (local)" "")))
-    :candidates 'helm-bibtex-candidates
-    :filtered-candidate-transformer 'helm-bibtex-candidates-formatter
-    :action (helm-make-actions
-            "Insert citation"            'org-ref-helm-bibtex-insert-citation
-            "Insert reference"           'helm-bibtex-insert-reference
-             "Open PDF, URL or DOI"       'helm-bibtex-open-any
-             "Open URL or DOI in browser" 'helm-bibtex-open-url-or-doi
-             "Insert BibTeX key"          'helm-bibtex-insert-key
-             "Insert BibTeX entry"        'helm-bibtex-insert-bibtex
-             "Attach PDF to email"        'helm-bibtex-add-PDF-attachment
-             "Edit notes"                 'helm-bibtex-edit-notes
-             "Show entry"                 'helm-bibtex-show-entry
-             "Add PDF to library"         'helm-bibtex-add-pdf-to-library))
-  "Source for searching in BibTeX files.")
-
-(defvar org-ref-helm-source-fallback-options
-  '((name            . "Fallback options")
-    (match             (lambda (_candidate) t))
-    (candidates      . bibtex-completion-fallback-candidates)
-    (no-matchplugin)
-    (nohighlight)
-    (action          . (lambda (candidate) (bibtex-completion-fallback-action candidate helm-pattern))))
-  "Source for online look-up.")
-
-;; Helm-bibtex command:
-
-;;;###autoload
-(defun org-ref-cite-insert-helm (&optional arg local-bib input)
-  "Search BibTeX entries.
-
-With a prefix ARG, the cache is invalidated and the bibliography
-reread.
-
-If LOCAL-BIB is non-nil, display that the BibTeX entries are read
-from the local bibliography.  This is set internally by
-`helm-bibtex-with-local-bibliography'.
-
-If INPUT is non-nil and a string, that value is going to be used
-as a predefined search term.  Can be used to define functions for
-frequent searches (e.g. your own publications)."
-  (interactive "P")
-  (when arg
-    (bibtex-completion-clear-cache))
-  (bibtex-completion-init)
-  (let* ((candidates (bibtex-completion-candidates))
-         (key (bibtex-completion-key-at-point))
-         (preselect (and key
-                         (cl-position-if (lambda (cand)
-                                          (member (cons "=key=" key)
-                                                  (cdr cand)))
-                                         candidates))))
-    (helm :sources (list org-ref-helm-source-bibtex org-ref-helm-source-fallback-options)
-          :full-frame helm-bibtex-full-frame
-          :buffer "*helm bibtex*"
-          :input input
-          :preselect (lambda ()
-                      (and preselect
-                           (> preselect 0)
-                           (helm-next-line preselect)))
-          :candidate-number-limit (max 500 (1+ (or preselect 0)))
-          :bibtex-candidates candidates
-          :bibtex-local-bib local-bib)))
-
-
-(setq org-ref-insert-cite-function 'org-ref-cite-insert-helm)
-
-
-(provide 'org-ref-helm)
-
-;;; org-ref-helm.el ends here
diff --git a/elpa/org-ref-20241124.2012/org-ref-isbn.el b/elpa/org-ref-20241124.2012/org-ref-isbn.el
deleted file mode 100644 (file)
index e96683e..0000000
+++ /dev/null
@@ -1,259 +0,0 @@
-;;; org-ref-isbn.el --- utilities for generating bibtex entries from an ISBN  -*- lexical-binding: t; -*-
-
-;; Copyright (C) 2015-2024  John Kitchin
-
-;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
-;; Keywords: convenience
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;; Provides functions to download bibtex entries from isbn numbers.
-
-;;; Code:
-(require 'f)
-(require 'org)
-
-
-(defvar url-http-end-of-headers)
-
-;;* ISBN utility
-
-(defcustom org-ref-isbn-clean-bibtex-entry-hook
-  '(oricb-remove-enclosing-brackets
-    oricb-clean-author-field
-    oricb-remove-period
-    oricb-kill-fields
-    oricb-replace-field-names)
-  "Hook that is run in `org-ref-isbn-clean-bibtex-entry'.
-The functions should have no arguments, and operate on the bibtex
-entry at point. You can assume point starts at the beginning of the
-entry. These functions are wrapped in `save-restriction' and
-`save-excursion' so you do not need to save the point position."
-  :group 'org-ref-isbn
-  :type 'hook)
-
-
-(defcustom org-ref-isbn-exclude-fields nil
-  "List of bibtex fields to kill when new entry is inserted."
-  :group 'org-ref-isbn
-  :type '(repeat :tag "List of bibtex fields to kill" string))
-
-
-(defcustom org-ref-isbn-field-name-replacements nil
-  "List of bitex field name/replacement pairs.
-The entries in this list are cons cells where the car is the field name
-and cdr is the replacement name."
-  :group 'org-ref-isbn
-  :type '(repeat (cons (string :tag "Field name")
-                      (string :tag "Field name replacement"))))
-
-
-(defun oricb-replace-field-names ()
-  "Replace bibtex field names defined in
-`org-ref-isbn-field-name-replacements'."
-  (when org-ref-isbn-field-name-replacements
-    (mapcar (lambda (field)
-             (bibtex-beginning-of-entry)
-             (let ((f (bibtex-autokey-get-field (car field))))
-               (unless (string= "" f)
-                 (goto-char (cadr (bibtex-search-forward-field (car field) t)))
-                 (bibtex-kill-field)
-                 (bibtex-make-field (cdr field))
-                 (backward-char)
-                 (insert f))))
-           org-ref-isbn-field-name-replacements)))
-
-
-(defun oricb-kill-fields ()
-  "Kill all bibtex fields defined in `org-ref-isbn-exclude-fields'."
-  (when org-ref-isbn-exclude-fields
-    (mapcar (lambda (field)
-             (bibtex-beginning-of-entry)
-             (let ((f (bibtex-autokey-get-field field)))
-               (unless (string= "" f)
-                 (goto-char (cadr (bibtex-search-forward-field field t)))
-                 (bibtex-kill-field))))
-           org-ref-isbn-exclude-fields)))
-
-
-(defun oricb-remove-enclosing-brackets ()
-  "Remove enclosing brackets from fields."
-  (save-restriction
-    (bibtex-narrow-to-entry)
-    (while (re-search-forward "\\({\\)\\(\\[\\)\\(.+\\)\\(]\\)\\(}\\)" nil t)
-      (replace-match "\\1\\3\\5"))))
-
-
-(defun oricb-clean-author-field ()
-  "Remove extra information from author's field."
-  (goto-char (cadr (bibtex-search-forward-field "author" t)))
-  (let ((case-fold-search nil))
-    (when (re-search-forward "\\({\\)\\(by \\|ed. by \\|edited by \\)" nil t)
-      (replace-match "\\1"))))
-
-
-(defun oricb-remove-period ()
-  "Remove period from author's field."
-  (goto-char (cadr (bibtex-search-forward-field "author" t)))
-  (when (re-search-forward "\\(\\.\\)\\(}\\)" nil t)
-    (replace-match "\\2")))
-
-
-;;;###autoload
-(defun org-ref-isbn-clean-bibtex-entry ()
-  "Clean a bibtex entry inserted via `isbn-to-bibtex'.
-See functions in `org-ref-isbn-clean-bibtex-entry-hook'."
-  (interactive)
-  (bibtex-beginning-of-entry)
-  (mapc (lambda (x)
-         (save-restriction
-           (save-excursion
-             (funcall x))))
-       org-ref-isbn-clean-bibtex-entry-hook))
-
-
-;; I found this on the web. It can be handy, but the bibtex entry has a lot of stuff in it.
-
-;;;###autoload
-(defun isbn-to-bibtex-lead (isbn)
-  "Search lead.to for ISBN bibtex entry.
-You have to copy the entry if it is on the page to your bibtex
-file."
-  (interactive "sISBN: ")
-  (browse-url
-   (format
-    "http://lead.to/amazon/en/?key=%s+&si=all&op=bt&bn=&so=sa&ht=us"
-    isbn)))
-
-
-;; Here we get isbn metadata and build a bibtex entry.
-
-;;;###autoload
-(defun isbn-to-bibtex (isbn bibfile)
-  "Get bibtex entry for ISBN and insert it into BIBFILE.
-Nothing happens if an entry with the generated key already exists
-in the file. Data comes from www.ebook.de."
-  (interactive
-   (list
-    (read-string
-     "ISBN: "
-     ;; now set initial input
-     (cond
-      ;; If region is active and it starts with a number, we use it
-      ((and  (region-active-p)
-             (s-match "^[0-9]" (buffer-substring (region-beginning) (region-end))))
-       (buffer-substring (region-beginning) (region-end)))
-      ;; if first entry in kill ring starts with a number assume it is an isbn
-      ;; and use it as the guess
-      ((stringp (car kill-ring))
-       (when (s-match "^[0-9]" (car kill-ring))
-        (car kill-ring)))
-      ;; type or paste it in
-      (t
-       nil)))
-    (completing-read "Bibfile: " (org-ref-possible-bibfiles))))
-
-  (let* ((url (format "https://www.ebook.de/de/tools/isbn2bibtex?isbn=%s" isbn))
-        (entry))
-    (with-current-buffer (url-retrieve-synchronously url t t)
-      (goto-char (point-min))
-      (when (re-search-forward "@[a-zA-Z]+{.+\\(\n\s+[^\n]+\\)+}$" nil t)
-       (setq entry (match-string 0))))
-
-    (if (not entry)
-       (message "Nothing found.")
-      (find-file bibfile)
-      (goto-char (point-max))
-      (insert (with-temp-buffer
-               (insert (concat entry "\n}"))
-               (goto-char (point-min))
-               ;; [2020-06-06 Sat] I got a report that ottobib returns entries
-               ;; with ,, in the first line. here if we find one, I eliminate
-               ;; one of them.
-               (when (re-search-forward ",," nil t)
-                 (delete-char -1))
-               (org-ref-isbn-clean-bibtex-entry)
-               (org-ref-clean-bibtex-entry)
-               (bibtex-fill-entry)
-               (s-trim (buffer-string))))
-      (save-buffer))))
-
-
-(defun isbn-to-bibtex-open-library (isbn bibfile)
-  "Retrieve bibtex entry for a book with ISBN using openlibrary.org.
-
-API: https://openlibrary.org/developers/api
-"
-  (interactive
-   (list
-    (read-string
-     "ISBN: "
-     ;; now set initial input
-     (cond
-      ;; If region is active and it starts with a number, we use it
-      ((and  (region-active-p)
-             (s-match "^[0-9]" (buffer-substring (region-beginning) (region-end))))
-       (buffer-substring (region-beginning) (region-end)))
-      ;; if first entry in kill ring starts with a number assume it is an isbn
-      ;; and use it as the guess
-      ((stringp (car kill-ring))
-       (when (s-match "^[0-9]" (car kill-ring))
-        (car kill-ring)))
-      ;; type or paste it in
-      (t
-       nil)))
-    (completing-read "Bibfile: " (org-ref-possible-bibfiles))))
-
-  (let* ((url (format "https://openlibrary.org/isbn/%s.json" isbn))
-        (json (with-current-buffer (url-retrieve-synchronously url)
-                (json-read-from-string (string-trim (buffer-substring url-http-end-of-headers (point-max))))))
-        (title (cdr (assoc 'title json)))
-        (publisher (s-join ", " (cdr (assoc 'publishers json))))
-        (year (cdr (assoc 'publish_date  json)))
-        ;; this is a list of urls
-        (author-urls (cdr (assoc 'authors json)))
-        (authors (s-join " and "
-                         (cl-loop for aurl across author-urls
-                                  collect
-                                  (with-current-buffer (url-retrieve-synchronously
-                                                        (format "https://openlibrary.org%s.json"
-                                                                (cdr (assoc 'key  aurl)))) 
-                                    (cdr (assoc 'personal_name
-                                                (json-read-from-string
-                                                 (string-trim (buffer-substring url-http-end-of-headers (point-max)))))))))) 
-        (burl (format "https://openlibrary.org%s" (cdr (assoc 'key json))))
-        (bibtex (format "@Book{,
-  author =      {%s},
-  title =       {%s},
-  publisher =   {%s},
-  year =        {%s},
-  url = {%s}
-}"
-                        authors
-                        title
-                        publisher
-                        year
-                        burl)))
-
-    (with-current-buffer (find-file-noselect bibfile)
-      (goto-char (point-max))
-      (insert "\n\n")
-      (insert bibtex)
-      (org-ref-clean-bibtex-entry)
-      (save-buffer))))
-
-(provide 'org-ref-isbn)
-;;; org-ref-isbn.el ends here
diff --git a/elpa/org-ref-20241124.2012/org-ref-ivy.el b/elpa/org-ref-20241124.2012/org-ref-ivy.el
deleted file mode 100644 (file)
index b66ab28..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-;;; org-ref-ivy.el --- org-ref with ivy completion -*- lexical-binding: t; -*-
-
-;; Copyright (C) 2016-2024  John Kitchin
-
-;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
-;; URL: https://github.com/jkitchin/org-ref
-;; Keywords: org-mode, cite, ref, label
-;; Package-Requires: ((org-ref "0") (ivy-bibtex "0"))
-
-;; This file is not currently part of GNU Emacs.
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-;;
-;; This customizes org-ref specifically around using ivy and ivy-bibtex. The
-;; citation selection looks like `ivy-bibtex' but it is a customized ivy
-;; function with customized actions.
-
-(require 'org-ref-core)
-(require 'ivy-bibtex)
-
-
-;; all these functions are defined in ivy-bibtex, but not in a variable. Here
-;; you can set them as you see fit.
-(defcustom org-ref-citation-alternate-insert-actions
-  '(("p" ivy-bibtex-open-pdf "Open PDF file (if present)")
-    ("u" ivy-bibtex-open-url-or-doi "Open URL or DOI in browser")
-    ;; this insert-citation only inserts an org-ref cite.
-    ;; ("c" ivy-bibtex-insert-citation "Insert citation")
-    ("R" ivy-bibtex-insert-reference "Insert formatted reference")
-    ("k" ivy-bibtex-insert-key "Insert BibTeX key")
-    ("b" ivy-bibtex-insert-bibtex "Insert BibTeX entry")
-    ("a" ivy-bibtex-add-PDF-attachment "Attach PDF to email")
-    ("e" ivy-bibtex-edit-notes "Edit notes")
-    ("s" ivy-bibtex-show-entry "Show entry")
-    ("l" ivy-bibtex-add-pdf-to-library "Add PDF to library")
-    ("h" (lambda (candidate)
-          (org-insert-heading)
-          (insert (bibtex-completion-apa-format-reference
-                   (cdr (assoc "=key=" candidate)))
-                  " "
-                  (format "cite:&%s" (cdr (assoc "=key=" candidate)))))
-     "Insert org-heading")
-    ("m" (lambda (candidate)
-          (insert (bibtex-completion-apa-format-reference
-                   (cdr (assoc "=key=" candidate)))))
-     "Insert formatted citation")
-    ("f" (lambda (_candidate) (ivy-bibtex-fallback ivy-text)) "Fallback options")
-    ("d" (lambda (_)
-          "Add a bibtex entry from doi and insert cite to it at point."
-          (funcall-interactively 'doi-utils-add-bibtex-entry-from-doi
-                                 (read-string
-                                  "DOI: "
-                                  ;; now set initial input
-                                  (doi-utils-maybe-doi-from-region-or-current-kill)))
-          (org-ref-insert-cite-key
-           (current-kill 0 t)))
-     "Insert from a DOI"))
-  "Alternate actions to do instead of inserting."
-  :type '(list (repeat (string function string)))
-  :group 'org-ref)
-
-
-;; This is modified from ivy-bibtex which had " " instead of "" which breaks marking.
-(defun org-ref-ivy-bibtex-display-transformer (candidate)
-  "Prepare bib entry CANDIDATE for display."
-  (let* ((width (- (frame-width) 2))
-        (idx (get-text-property 1 'idx candidate))
-        (entry (cdr (nth idx (ivy-state-collection ivy-last)))))
-    (s-concat (if (s-starts-with-p ivy-mark-prefix candidate) ivy-mark-prefix "")
-             (bibtex-completion-format-entry entry width))))
-
-
-(ivy-configure 'org-ref-cite-insert-ivy :display-transformer-fn 'org-ref-ivy-bibtex-display-transformer)
-
-
-(defun org-ref-cite-multi-insert-ivy (candidates)
-  "A multi-action function to insert CANDIDATES."
-  (with-ivy-window
-    (org-ref-insert-cite-keys
-     (mapcar (lambda (entry)
-              (cdr (assoc "=key=" (cdr entry))))
-            candidates)
-     ivy-current-prefix-arg)))
-
-
-(defun org-ref-cite-insert-ivy ()
-  "Function for inserting a citation."
-  (interactive)
-  ;; Set this in the function so it is updated if you change the functions while
-  ;; writing
-  (ivy-set-actions
-   'org-ref-cite-insert-ivy
-   org-ref-citation-alternate-insert-actions)
-
-  ;; This initializes bibtex if the variable is not defined.
-  (unless bibtex-completion-display-formats-internal
-    (bibtex-completion-init))
-
-  (let* ((bibtex-completion-bibliography (org-ref-find-bibliography))
-        (candidates (bibtex-completion-candidates)))
-    (ivy-read "org-ref-ivy BibTeX entries: " candidates
-             :preselect (ivy-thing-at-point)
-             :multi-action #'org-ref-cite-multi-insert-ivy
-             :action '(1
-                       ("o" (lambda (candidate)
-                              (org-ref-insert-cite-key
-                               (cdr (assoc "=key=" (cdr candidate)))
-                               ivy-current-prefix-arg))
-                        "insert")
-                       ("r" (lambda (candidate)
-                              (let* ((object (org-element-context))
-                                     (type (org-element-property :type object))
-                                     (begin (org-element-property :begin object))
-                                     (end (org-element-property :end object))
-                                     (link-string (org-element-property :path object))
-                                     (data (org-ref-parse-cite-path link-string))
-                                     (references (plist-get data :references))
-                                     (cp (point))
-                                     (key)
-                                     keys i)
-                                ;;   We only want this to work on citation links
-                                (when (assoc type org-ref-cite-types)
-                                  (setq key (org-ref-get-bibtex-key-under-cursor))
-                                  (if (null key)
-                                      ;; delete the whole cite
-                                      (cl--set-buffer-substring begin end "")
-                                    (setq i (seq-position
-                                             references key
-                                             (lambda (el key)
-                                               (string= key
-                                                        (plist-get el :key)))))
-                                    (setf (plist-get (nth i references) :key)
-                                          (cdr (assoc "=key=" (cdr candidate))))
-                                    (setq data (plist-put data :references references))
-                                    (save-excursion
-                                      (goto-char begin)
-                                      (re-search-forward link-string)
-                                      (replace-match (org-ref-interpret-cite-data data)))
-                                    (goto-char cp)))))
-                        "Replace key at point"))
-             :caller 'org-ref-cite-insert-ivy)))
-
-
-(setq org-ref-insert-cite-function 'org-ref-cite-insert-ivy)
-
-
-(provide 'org-ref-ivy)
-
-;;; org-ref-ivy.el ends here
diff --git a/elpa/org-ref-20241124.2012/org-ref-label-link.el b/elpa/org-ref-20241124.2012/org-ref-label-link.el
deleted file mode 100644 (file)
index 9a02e10..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-;;; org-ref-label-link.el --- -*- lexical-binding: t; -*-
-;;
-;; Copyright (C) 2024  John Kitchin
-
-;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
-;; Keywords: convenience
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
-;;
-;;; Commentary:
-;;
-
-;;; Code:
-
-
-(defface org-ref-label-face
-  `((t (:inherit org-link :foreground "dark magenta")))
-  "Color for ref links in `org-ref'."
-  :group 'org-ref-faces)
-
-
-;;** label link (maybe deprecated)
-
-
-(org-link-set-parameters
- "label"
- :export (lambda (path _desc format)
-          (cond
-           ((eq format 'latex)
-            (format "\\label{%s}" path))))
- :face 'org-ref-label-face
- :help-echo "A label")
-
-
-;;;###autoload
-(defun org-ref-insert-label-link ()
-  "Insert a new label with completion.
-The completion helps ensure you use a unique label."
-  (interactive)
-  (let* ((known-labels (mapcar 'car (org-ref-get-labels)))
-        (new-label (completing-read "Label: " known-labels nil)))
-    (when (member new-label known-labels)
-      (warn "Inserting duplicate label"))
-    (insert (format "label:%s" new-label))))
-
-
-(provide 'org-ref-label-link)
-
-;;; org-ref-label-link.el ends here
diff --git a/elpa/org-ref-20241124.2012/org-ref-latex.el b/elpa/org-ref-20241124.2012/org-ref-latex.el
deleted file mode 100644 (file)
index c843e43..0000000
+++ /dev/null
@@ -1,276 +0,0 @@
-;;; org-ref-latex.el --- org-ref functionality for LaTeX files  -*- lexical-binding: t; -*-
-
-;; Copyright (C) 2015-2024  John Kitchin
-
-;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
-;; Keywords: languages
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary: Make cites in LaTeX documents clickable, and with tooltips.
-;; We use font-lock to add some functionality to the keys.
-
-;;; Code:
-
-(require 'org-ref-citation-links)
-(require 'bibtex-completion)
-(require 'tex-mode)
-
-(defvar org-ref-cite-types)
-
-(defcustom orl-cite-keymap
-  (let ((map (copy-keymap latex-mode-map)))
-    (define-key map (kbd "S-<left>") #'orl-cite-shift-left)
-    (define-key map (kbd "S-<right>") #'orl-cite-shift-right)
-    (define-key map (kbd "S-<up>") #'orl-sort-cite-keys)
-    (define-key map (kbd "S-<down>") (lambda () (interactive) (orl-sort-cite-keys t)))
-    (define-key map (kbd "<tab>") #'org-ref-latex-insert-citation)
-
-    (define-key map [mouse-1] (lambda ()
-                               (interactive)
-                               (let ((bibtex-completion-bibliography (org-ref-latex-get-bibliography)))
-                                 (bibtex-completion-show-entry (list (org-ref-latex-key-at-point)))
-                                 (bibtex-beginning-of-entry))))
-    map)
-  "Key map for cite keys."
-  :group 'org-ref-latex
-  :type '(restricted-sexp
-          :match-alternatives
-          ((lambda (x)
-             (or (keymapp x) ; Can be a keymap var.
-                (and (symbolp x)
-                      (boundp x)
-                      (keymapp (symbol-value x))))))))
-
-
-(defvar org-ref-latex-cite-re
-  (concat "\\\\\\(?1:" (mapconcat
-                       (lambda (x)
-                         (replace-regexp-in-string "\\*" "\\\\*" x))
-                       (mapcar 'car org-ref-cite-types)
-                       "\\|")
-         "\\)"
-         "\\(?2:\\[[^]]*\\]\\)?"       ; optional []
-         "\\(?3:\\[[^]]*\\]\\)?"       ; optional []
-         "{\\(?4:[^}]*\\)}")           ; group 4 contains the keys
-  "Regexp for LaTeX citations. \\citetype[opti{o}nal][optiona{l}]{some,keys}.
-The clickable part are the keys.")
-
-
-(defun org-ref-latex-get-bibliography ()
-  "Find bibliographies in the tex file."
-  (save-excursion
-    (let ((bibliography '()))
-      (goto-char (point-min))
-      (while (re-search-forward "\\\\bibliography{\\(?1:.*\\)}" nil t)
-       (setq bibliography (append bibliography
-                                  (mapcar (lambda (f)
-                                            (concat f ".bib"))
-                                          (split-string (match-string-no-properties 1) ",")))))
-      (goto-char (point-min))
-      (while (re-search-forward "\\\\addbibresource{\\(?1:.*\\)}" nil t)
-       (setq bibliography (append bibliography (list (match-string-no-properties 1)))))
-
-      bibliography)))
-
-
-(defun org-ref-next-latex-cite (&optional limit)
-  "Font-lock function to make cites in LaTeX documents clickable."
-  (while (re-search-forward org-ref-latex-cite-re limit t)
-    (setq font-lock-extra-managed-props (delq 'help-echo font-lock-extra-managed-props))
-
-    ;; save data on cite. This is useful later for modifying cites, clicking, etc.
-    (add-text-properties (match-beginning 0) (match-end 0) 
-                        `(org-ref-latex-cite (
-                                              :cite-begin ,(match-beginning 0)
-                                              :cite-end ,(match-end 0)
-                                              :cite-key-begin ,(+ 1 (match-beginning 4))
-                                              :cite-key-end ,(- (match-end 4) 1)
-                                              :cite-type ,(match-string-no-properties 1)
-                                              :optional-1 ,(match-string-no-properties 2)
-                                              :optional-2 ,(match-string-no-properties 3)
-                                              :keys ,(mapcar
-                                                      #'s-trim
-                                                      (s-split
-                                                       ","
-                                                       (match-string-no-properties 4))))))
-    
-    (goto-char (match-beginning 0))
-    (let ((end (match-end 0)))
-      (cl-loop for key in (mapcar #'s-trim (split-string (match-string-no-properties 4) ","))
-              unless (string-empty-p key)
-              do
-              (save-match-data
-                (search-forward key)
-                (add-text-properties
-                 (match-beginning 0)
-                 (match-end 0)
-                 `(
-                   org-ref-cite-key ,key
-                   mouse-face highlight
-                   local-map ,orl-cite-keymap
-                   help-echo ,(let* ((bibtex-completion-bibliography (org-ref-latex-get-bibliography)))
-                                (condition-case nil
-                                    (bibtex-completion-apa-format-reference key)
-                                  (error (display-warning :warning (format "Key %s missing." key)))))))))
-      (goto-char end))))
-
-
-(defun org-ref-latex-cite-on ()
-  "Add the font-lock on for citations."
-  (font-lock-add-keywords
-   'latex-mode
-   '((org-ref-next-latex-cite 0 font-lock-constant-face))))
-
-(add-hook 'LaTeX-mode-hook 'org-ref-latex-cite-on)
-(add-hook 'LaTeX-mode-hook 'org-ref-latex-cite-on)
-
-
-;; * Insert cite link
-
-(defun org-ref-latex-on-citation-p ()
-  "Return non-nil if on a citation."
-  (get-text-property (point) 'org-ref-latex-cite))
-
-
-(defun org-ref-latex-key-at-point ()
-  "Return key at point if there is one."
-  (interactive)
-  (get-text-property (point) 'org-ref-cite-key))
-
-(defun orl-insert-key (key)
-  (cond
-   ;; on a key
-   ((get-text-property (point) 'org-ref-cite-key)
-    (forward-sexp)
-    (insert (format ",%s" key)))
-   ;; on the leading \
-   ((and (get-text-property (point) 'org-ref-latex-cite)
-        (looking-at "\\\\"))
-    (search-forward "{")
-    (insert (format "%s," key)))
-   ;; on {
-   ((and (get-text-property (point) 'org-ref-latex-cite)
-        (looking-at "{"))
-    (forward-char)
-    (insert (format "%s," key)))
-   ;; on }
-   ((and (get-text-property (point) 'org-ref-latex-cite)
-        (looking-at "}")) 
-    (insert (format ",%s" key)))
-   ;; on citetype
-   ((and (get-text-property (point) 'org-ref-latex-cite)
-        (get-text-property (point) 'org-ref-latex-cite-type))
-    (search-forward "{")
-    (insert (format "%s," key)))
-   ;; everything else
-   (t
-    (insert (format "\\cite{%s}" key)))))
-
-
-(defun org-ref-latex-insert-citation ()
-  "Insert a citation key with completion.
-Should DWIM inserting into existing or new citations."
-  (interactive)
-
-  ;; This initializes bibtex if the variable is not defined.
-  (unless bibtex-completion-display-formats-internal
-    (bibtex-completion-init))
-
-  (let* ((bibtex-completion-bibliography (org-ref-latex-get-bibliography))
-        (candidates (bibtex-completion-candidates)))
-    (ivy-read "org-ref-ivy BibTeX entries: " candidates
-             :preselect (ivy-thing-at-point) 
-             :action '(1
-                       ("o" (lambda (candidate)
-                              (orl-insert-key (cdr (assoc "=key=" (cdr candidate)))))
-                        "insert")))))
-
-(defun orl-swap-citation (direction)
-  (let* ((key (org-ref-latex-key-at-point))
-        (data (get-text-property (point) 'org-ref-latex-cite))
-        (keys (plist-get data :keys))
-        (i (seq-position keys key #'string=))
-        cite-string)
-    (if (> direction 0)
-       (org-ref-swap-list-elements i (min (+ i 1) (- (length keys) 1)) keys)
-      (org-ref-swap-list-elements i (max (- i 1) 0) keys))
-    (setq data (plist-put data :keys keys))
-
-    ;; now render it
-    (setq cite-string (concat (format "\\%s" (plist-get data :cite-type))
-                             (or (plist-get data :optional-1) "")
-                             (or (plist-get data :optional-2) "")
-                             (format  "{%s}" (s-join "," (plist-get data :keys)))))
-    (cl--set-buffer-substring (plist-get data :cite-begin)
-                             (plist-get data :cite-end)
-                             cite-string)
-    (search-forward key)
-    (goto-char (match-beginning 0))))
-
-
-(defun orl-cite-shift-left ()
-  "Shift cite key at point to the left."
-  (interactive)
-  (orl-swap-citation -1))
-
-
-(defun orl-cite-shift-right ()
-  "Shift cite-key at point to the right."
-  (interactive)
-  (orl-swap-citation +1))
-
-
-(defun orl-sort-cite-keys (&optional descending)
-  "Sort keys in ascending order by year.
-With prefix arg DESCENDING, sort in descending order."
-  (interactive "P")
-  (let* ((data (get-text-property (point) 'org-ref-latex-cite))
-        (keys (plist-get data :keys)) 
-        cite-string)
-
-    (setq data (plist-put data :keys
-                         (cl-loop for entry in
-                                  (cl-sort (cl-loop for key in keys collect
-                                                    (list :key key :year (bibtex-completion-get-value
-                                                                          "year"
-                                                                          (bibtex-completion-get-entry
-                                                                           key))))
-                                           (if descending
-                                               (lambda (x y)
-                                                 (> (string-to-number (plist-get x :year))
-                                                    (string-to-number (plist-get y :year))))
-                                             (lambda (x y)
-                                               (< (string-to-number (plist-get x :year))
-                                                  (string-to-number (plist-get y :year))))))
-                                  collect
-                                  (plist-get entry :key))))
-    
-    
-
-    ;; now render it
-    (setq cite-string (concat (format "\\%s" (plist-get data :cite-type))
-                             (or (plist-get data :optional-1) "")
-                             (or (plist-get data :optional-2) "")
-                             (format  "{%s}" (s-join "," (plist-get data :keys)))))
-    (cl--set-buffer-substring (plist-get data :cite-begin)
-                             (plist-get data :cite-end)
-                             cite-string)
-    (search-forward (car (plist-get data :keys)))
-    (goto-char (match-beginning 0))))
-
-
-
-(provide 'org-ref-latex)
-;;; org-ref-latex.el ends here
diff --git a/elpa/org-ref-20241124.2012/org-ref-misc-links.el b/elpa/org-ref-20241124.2012/org-ref-misc-links.el
deleted file mode 100644 (file)
index 0994a2f..0000000
+++ /dev/null
@@ -1,305 +0,0 @@
-;;; org-ref-misc-links.el --- Miscellaneous links -*- lexical-binding: t; -*-
-;;
-;; Copyright (C) 2021-2024  John Kitchin
-
-;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
-;; Keywords: convenience
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
-;;
-;; * Miscellaneous links
-
-
-;;; Commentary:
-;;
-
-;;; Code:
-
-;;** List of figures
-
-;;;###autoload
-(defun org-ref-list-of-figures (&optional _arg)
-  "Generate buffer with list of figures in them.
-ARG does nothing.
-Ignore figures in COMMENTED sections."
-  (interactive)
-  (save-excursion
-    (widen)
-    (let* ((c-b (buffer-name))
-          (counter 0)
-          (list-of-figures
-           (org-element-map (org-ref-parse-buffer) 'link
-             (lambda (link)
-               "create a link for to the figure"
-               (when
-                   (and (string= (org-element-property :type link) "file")
-                        (string-match-p
-                         "[^.]*\\.\\(png\\|jpg\\|eps\\|pdf\\|svg\\)$"
-                         (org-element-property :path link))
-                        ;; ignore commented sections
-                        (save-excursion
-                          (goto-char (org-element-property :begin link))
-                          (not (or (org-in-commented-heading-p)
-                                   (org-at-comment-p)
-                                   (-intersection (org-get-tags) org-export-exclude-tags)))))
-                 (cl-incf counter)
-
-                 (let* ((start (org-element-property :begin link))
-                        (linenum (progn (goto-char start) (line-number-at-pos)))
-                        (fname (org-element-property :path link))
-                        (parent (car (cdr
-                                      (org-element-property :parent link))))
-                        (caption (cl-caaar (plist-get parent :caption)))
-                        (name (plist-get parent :name)))
-
-                   (if caption
-                       (format "[[file:%s::%s][Figure %s:]] %s\n" c-b linenum counter caption)
-                     ;; if it has no caption, try the name
-                     ;; if it has no name, use the file name
-                     (cond (name
-                            (format "[[file:%s::%s][Figure %s:]] %s\n" c-b linenum counter name))
-                           (fname
-                            (format "[[file:%s::%s][Figure %s:]] %s\n"
-                                    c-b linenum counter fname))))))))))
-      (switch-to-buffer "*List of Figures*")
-      (setq buffer-read-only nil)
-      (org-mode)
-      (erase-buffer)
-      (insert (mapconcat 'identity list-of-figures ""))
-      (goto-char (point-min))
-      ;; open links in the same window
-      (setq-local org-link-frame-setup
-                 '((file . find-file)))
-      (setq buffer-read-only t)
-      (use-local-map (copy-keymap org-mode-map))
-      (local-set-key "q" #'(lambda () (interactive) (kill-buffer))))))
-
-
-(org-link-set-parameters "list-of-figures"
-                        :follow #'org-ref-list-of-figures
-                        :export (lambda (_path _desc format)
-                                  (cond
-                                   ((eq format 'latex)
-                                    (format "\\listoffigures")))))
-
-;;** List of tables
-;;;###autoload
-(defun org-ref-list-of-tables (&optional _arg)
-  "Generate a buffer with a list of tables.
-ARG does nothing."
-  (interactive)
-  (save-excursion
-    (widen)
-    (let* ((c-b (buffer-name))
-           (counter 0)
-           (list-of-tables
-            (org-element-map (org-ref-parse-buffer 'element) 'table
-              (lambda (table)
-                "create a link for to the table"
-               (save-excursion
-                 (goto-char (org-element-property :begin table))
-                 (when
-                     ;; ignore commented sections
-                     (not (or (org-in-commented-heading-p)
-                              (-intersection (org-get-tags) org-export-exclude-tags)
-                              (looking-at "#\\+RESULTS:") ))
-                   (cl-incf counter)
-                   (let* ((start (org-element-property :begin table))
-                          (linenum (progn (goto-char start) (line-number-at-pos)))
-                          (caption (cl-caaar (org-element-property :caption table)))
-                          (name (org-element-property :name table)))
-                     (if caption
-                         (format "[[file:%s::%s][Table %s:]] %s\n" c-b linenum counter caption)
-                       ;; if it has no caption, try the name
-                       ;; if it has no name, use generic name
-                       (cond (name
-                              (format "[[file:%s::%s][Table %s:]] %s\n"
-                                      c-b linenum counter name))
-                             (t
-                              (format "[[file:%s::%s][Table %s:]] No caption\n"
-                                      c-b linenum counter)))))))))))
-      (switch-to-buffer "*List of Tables*")
-      (setq buffer-read-only nil)
-      (org-mode)
-      (erase-buffer)
-      (insert (mapconcat 'identity list-of-tables ""))
-      (goto-char (point-min))
-      ;; open links in the same window
-      (setq-local org-link-frame-setup
-                 '((file . find-file)))
-      (setq buffer-read-only t)
-      (use-local-map (copy-keymap org-mode-map))
-      (local-set-key "q" #'(lambda () (interactive) (kill-buffer))))))
-
-
-(org-link-set-parameters "list-of-tables"
-                        :follow #'org-ref-list-of-tables
-                        :export (lambda (_path _desc format)
-                                  (cond
-                                   ((eq format 'latex)
-                                    (format "\\listoftables")))))
-
-
-;;* Index link
-;;
-;; You need these lines in the header
-;; 
-;; #+latex_header: \usepackage{makeidx}
-;; #+latex_header: \makeindex
-(org-link-set-parameters "index"
-                        :follow (lambda (path)
-                                  (occur path))
-                        :export (lambda (path _desc format)
-                                  (cond
-                                   ((eq format 'latex)
-                                    (format "\\index{%s}" path)))))
-
-
-;; this will generate a temporary index of entries in the file when clicked on.
-;;;###autoload
-(defun org-ref-index (&optional _path)
-  "Open an *index* buffer with links to index entries.
-PATH is required for the org-link, but it does nothing here."
-  (interactive)
-  (let ((*index-links* '())
-       (*initial-letters* '()))
-
-    ;; get links
-    (org-element-map (org-ref-parse-buffer) 'link
-      (lambda (link)
-       (let ((plist (nth 1 link)))
-
-         (when (equal (plist-get plist ':type) "index")
-           (add-to-list
-            '*index-links*
-            (cons (plist-get plist :path)
-                  (format
-                   "[[elisp:(progn (switch-to-buffer \"%s\") (goto-char %s) (org-cycle '(64)))][%s]] "
-                   (current-buffer)
-                   (plist-get plist :begin) ;; position of link
-                   ;; grab a description
-                   (save-excursion
-                     (goto-char (plist-get plist :begin))
-                     (if (thing-at-point 'sentence)
-                         ;; get a sentence
-                         (let ((s (thing-at-point 'sentence)))
-                           (cl-loop for char in '("[" "]" "\n")
-                                    do
-                                    (setq s (replace-regexp-in-string
-                                             (regexp-quote char) " " s)))
-                           (concat s " "))
-                       ;; or call it a link
-                       "link")))))))))
-
-    ;; sort the links
-    (setq *index-links* (cl-sort *index-links* 'string-lessp :key 'car))
-
-    ;; now separate out into chunks first letters
-    (dolist (link *index-links*)
-      (push (substring (car link) 0 1) *initial-letters*))
-
-    (setq *initial-letters* (reverse *initial-letters*))
-
-    ;; now create the index
-    (switch-to-buffer (get-buffer-create "*index*"))
-    (org-mode)
-    (erase-buffer)
-    (insert "#+TITLE: Index\n\n")
-    (dolist (letter *initial-letters*)
-      (insert (format "* %s\n" (upcase letter)))
-      ;; now process the links
-      (while (and
-             *index-links*
-             (string= letter (substring (car (car *index-links*)) 0 1)))
-       (let ((link (pop *index-links*)))
-         (insert (format "%s %s\n\n" (car link) (cdr link))))))
-    (switch-to-buffer "*index*")))
-
-
-(org-link-set-parameters "printindex"
-                        :follow #'org-ref-index
-                        :export (lambda (_path _desc format)
-                                  (cond
-                                   ((eq format 'latex)
-                                    (format "\\printindex")))))
-
-
-(defun org-ref-idxproc (_backend)
-  "Preprocess index entries.
-Each entry is replaced by a radio target. The printindex is
-replaced by links to them."
-  (let* ((index-links (reverse (org-element-map (org-element-parse-buffer) 'link
-                                (lambda (lnk)
-                                  (when (string= "index" (org-element-property :type lnk))
-                                    lnk)))))
-        (sorted-groups (seq-sort-by
-                        (lambda (x)
-                          "Alphabetically sort groups"
-                          (car x))
-                        #'string-lessp
-                        (seq-group-by
-                         (lambda (lnk)
-                           (org-element-property :path lnk))
-                         index-links)))
-        (link-replacements '()))
-
-    ;; Sort within each group
-    (cl-loop for (key . links) in sorted-groups do
-            (setf (cdr (assoc key sorted-groups))
-                  (sort links (lambda (a b)
-                                (< (org-element-property :begin a)
-                                   (org-element-property :begin b))))))
-    
-    ;; Compute replacements for each index link.
-    (cl-loop for (key . links) in sorted-groups do
-            (cl-loop for i from 0 for lnk in links do
-                     (cl-pushnew (cons
-                                  (org-element-property :begin lnk)
-                                  (format "<<%s-%s>>" key i))
-                                 link-replacements)))
-
-    (cl-loop for il in index-links collect
-            (cl--set-buffer-substring
-             (org-element-property :begin il)
-             (org-element-property :end il)
-             (cdr (assoc (org-element-property :begin il) link-replacements))))
-
-    ;; Now we replace the printindex link
-    (org-element-map (org-element-parse-buffer) 'link
-      (lambda (lnk)
-       (when (string= "printindex" (org-element-property :type lnk))
-         (cl--set-buffer-substring (org-element-property :begin lnk)
-                                   (org-element-property :end lnk)
-                                   ;; If sorted-groups is empty, we should do nothing I think.
-                                   (if sorted-groups
-                                       (format "*Index*\n\n%s"
-                                               (string-join
-                                                (cl-loop for (key . links) in sorted-groups collect
-                                                         (format "%s: %s"
-                                                                 key
-                                                                 (string-join 
-                                                                  (cl-loop for i from 0 for lnk in links collect
-                                                                           (format "[[%s-%s][%s-%s]] "
-                                                                                   (org-element-property :path lnk)
-                                                                                   i
-                                                                                   (org-element-property :path lnk)
-                                                                                   i))
-                                                                  ", ")))
-                                                "\n\n"))
-                                     "")))))))
-
-
-(provide 'org-ref-misc-links)
-
-;;; org-ref-misc-links.el ends here
diff --git a/elpa/org-ref-20241124.2012/org-ref-natbib-bbl-citeproc.el b/elpa/org-ref-20241124.2012/org-ref-natbib-bbl-citeproc.el
deleted file mode 100644 (file)
index ead23a6..0000000
+++ /dev/null
@@ -1,518 +0,0 @@
-;;; org-ref-natbib-bbl-citeproc.el --- A bibtex + natbib BBL-based citeproc -*- lexical-binding: t; -*-
-;;
-;; Copyright (C) 2021-2024  John Kitchin
-
-;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
-;; Keywords:
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
-;;
-;;; Commentary:
-;;
-;; This is a citation processor that uses the bbl from bibtex and natbib.
-;;
-;; It is kind of hacky. I parse the bbl file into entries, and then replace the
-;; in-text citations and the bibliography with data from the parsed bbl.
-;;
-;; The CSL exporter is probably better all around than this, but this does have
-;; the advantage of using LaTeX/bibtex for formatting.
-;;
-;; TODO: pre/post notes are not handled in the bbl file. They have to be handled
-;; separately
-;;
-;; This seems to work ok for
-;; See https://gking.harvard.edu/files/natnotes2.pdf
-;;
-;; Basically supports stylying options in natbib including [numbers, super, authoryear] for style,
-;; and [round, square, curly, angle] for in-text citations
-;; and [comma, semicolon; colon] for citation separators
-;; and [sort, compress, sort&compress] if you want to sort and/or compress citation numbers.
-;;
-;; longnamesfirst is not currently supported.
-;;
-;; To use this for HTML export you do something like this:
-;; (let ((org-export-before-parsing-hook '(org-ref-bbl-preprocess)))
-;;   (org-open-file (org-html-export-to-html)))
-;;
-;;
-;;; Code:
-
-(defvar org-ref-natmove)                       ;silence compiler
-
-(defun org-bbl-clean-string (s)
-  "Clean S of markups.
-This replaces some LaTeX markup and bibtex markups including:
-\\emph{}, \\doi{}, \\url{},\\citename, and {\\em ...} {\\bf ...},
-removes things like \\protect and \\penalty0, and replaces ~ with
-a space. This function is surely not complete, and it does not
-cover any math (yet)."
-  (with-temp-buffer
-    (insert s)
-    ;; I convert these to org syntax.
-    ;; \emph... -> org italics
-    ;; TODO This list is surely not complete.
-    ;; convert \cmd{stuff} to the format string
-    (let (p1 p2 p3 p4 ss cmd-p)
-      (cl-loop for (cmd . repl-format) in '(("emph" . "/%s/")
-                                           ("doi" . "%s")
-                                           ("url" . "%s")
-                                           ("citename" . "%s")
-                                           ;; natexlab seems to be for differentiating similar authors.
-                                           ("natexlab" . "(%s)")
-                                           ;; I use \ce{} a lot, and just strip it here.
-                                           ("ce" . "%s"))
-              do
-              (goto-char (point-min))
-              (while (search-forward (format "\\%s{" cmd) nil t)
-                (setq p1 (match-beginning 0)
-                      p2 (point))
-                (backward-char)
-                (forward-list)
-                (setq p4 (point)
-                      p3 (- (point) 1))
-                (setq s (buffer-substring p2 p3))
-                (cl--set-buffer-substring p1 p4 (format repl-format s))))
-
-      ;; some times we have these markups TODO I bet there are more Note I use
-      ;; non-breaking spaces here to make the org syntax ok. It doesn't seem to
-      ;; do quite the right thing in the bib-items though.
-      (cl-loop for (markup . fmt) in '(("\\em" . " /%s/ ")
-                                      ("\\it" . " /%s/ ")
-                                      ("\\bf" . " *%s* ")
-                                      ("\\tt" . " =%s= "))
-              do
-              (goto-char (point-min))
-              (while (search-forward (concat "{" markup) nil t)
-                (setq p1 (match-beginning 0)
-                      p2 (point))
-                (goto-char (match-beginning 0))
-                (forward-list)
-                (setq p4 (point)
-                      p3 (- (point) 1))
-                (setq ss (string-trim (buffer-substring p2 p3)))
-                (cl--set-buffer-substring p1 p4 (format fmt ss))))
-
-      ;; {text} for protecting case. This is tricky to do reliably. I try to check
-      ;; if this is not part of a command, and skip it if so. This leaves
-      ;; un-cleaned commands in, which is desirable to me so you can see if there
-      ;; are ones we might handle in the future.
-      (goto-char (point-min))
-      (while (search-forward "{" nil t)
-       ;; I think if we go back a word, and are then looking back at \\, we are in a command.
-       ;; this would fail on a latex command like \word-word{} but I can't think of any right now.
-       (save-excursion
-         (backward-word)
-         (setq cmd-p (looking-back "\\\\" 1)))
-       ;; This looks back for a \cmd, basically things not a closing }
-       (unless cmd-p
-         (setq p1 (match-beginning 0)
-               p2 (point))
-         (backward-char)
-         (forward-list)
-         (setq p4 (point)
-               p3 (- (point) 1))
-         (setq s (buffer-substring p2 p3))
-         (cl--set-buffer-substring p1 p4 s))))
-
-
-    (let ((result (buffer-string)))
-      (cl-loop for (s . repl) in '(("~" . " ")
-                                  ("\\\\&" . "&")
-                                  ("\\\\protect" . "")
-                                  ("\\\\penalty0" . "")
-                                  ("\\\\ " . " "))
-              do
-              (setq result (replace-regexp-in-string s repl result)))
-      result)))
-
-
-(defun org-ref-bbl-get-natbib-options ()
-  "Return natbib-options (including the brackets).
-Defaults to [numbers,super,sort]"
-  (goto-char (point-min))
-  (if (re-search-forward "\\usepackage\\(?1:\\[.*\\]\\)?{natbib}")
-      (match-string 1)
-    "[numbers,super,sort]"))
-
-
-
-(defun org-ref-bbl-entry (entry)
-  "ENTRY is a string containing the contents of a bibitem from a bbl file.
-Return the bibliography string associated with the entry. This is
-done in a temp-buffer so we don't actually modify the bbl file."
-  (with-temp-buffer
-    (insert (org-bbl-clean-string entry))
-    (goto-char (point-min))
-    (let (p1
-         p2 
-         authors
-         blocks
-         entry)
-      (setq p1 (point))
-      (search-forward "\\newblock")
-      (setq p2 (match-beginning 0))
-      (setq authors (string-join
-                    (mapcar 'string-trim
-                            (split-string (buffer-substring p1 p2) "\n"))
-                    " "))
-      (goto-char (- p2 1))
-      (while (search-forward "\\newblock" nil t)
-       (setq p1 (point))
-       (setq p2 (save-excursion
-                  (if (search-forward "\\newblock" nil t)
-                      (match-beginning 0)
-                    (point-max))))
-
-       (cl-pushnew (string-join
-                    (mapcar 'string-trim
-                            (split-string (buffer-substring p1 p2) "\n"))
-                    " ")
-                   blocks))
-
-      (setq entry (string-join (append (list authors) blocks) " "))
-      entry)))
-
-
-(defun org-ref-bbl-bibliography-data ()
-  "Get an p-list for each entry in the buffer.
-Assumes you are in a bbl file.
-Returns a plist (list bibitem-key :entry (org-ref-bbl-entry bibitem-entry)
-                         :index counter :bracket-data bibitem-bracket)"
-  (let ((data '())
-       N ss
-       p1 p2 bbl-max
-       bibitem-bracket
-       bibitem-key
-       bibitem-entry
-       (counter 0))
-
-    (goto-char (point-min))
-    (search-forward "\\end{thebibliography}")
-    ;; this is the character that the last line starts on.
-    (setq bbl-max (match-beginning 0))
-
-    (goto-char (point-min))
-    (when (looking-at "\\\\begin{thebibliography}{\\(?1:[0-9]*\\)}")
-      (setq N (string-to-number (match-string 1))))
-
-    ;; This might only work for numeric types
-    (if (> 0 N)
-       (cl-loop for i from 1 to N do
-                (search-forward "\\bibitem[")
-                ;; get text in [...]
-                (setq p1 (point))
-                (forward-list)
-                (setq p2 (point))
-                ;; the bracket usually contains [stuff (year) more stuff]
-                (setq ss (org-bbl-clean-string
-                          (buffer-substring-no-properties p1 p2)))
-
-                (let* ((s (string-match "(" ss))
-                       (e (string-match ")" ss s)))
-                  ;; in numerical mode I think this is ignored, but we get it
-                  ;; just in case for some later day.
-                  (setq bibitem-bracket (format "%s%s"
-                                                (substring ss 0 s)
-                                                (if (string= "()" (substring ss s (+ e 1)))
-                                                    ""
-                                                  (concat " " (substring ss s (+ e 1)))))))
-
-                ;; Now get the key. From the last
-                (search-forward "{")
-                (goto-char (match-beginning 0))
-                (setq p1 (+ 1 (point)))
-                (forward-list)
-                (setq p2 (- (point) 1)
-                      bibitem-key (buffer-substring p1 p2))
-
-                ;; Now get up to the next bibitem
-                (setq p1 (point))
-                (save-excursion
-                  (setq p2 (or (when (search-forward "\\bibitem[" nil t)
-                                 (match-beginning 0))
-                               bbl-max)))
-                (setq bibitem-entry (string-trim (buffer-substring p1 p2)))
-
-                (cl-pushnew (list bibitem-key :entry (org-ref-bbl-entry bibitem-entry)
-                                  :index i :bracket-data bibitem-bracket)
-                            data))
-      ;; no number found probably author year
-      (while (search-forward "\\bibitem[" nil t)
-       (cl-incf counter)
-       ;; get text in [...]
-       (setq p1 (point))
-       (search-forward "]")
-       (backward-char)
-       (setq p2 (point))
-
-       (setq ss (org-bbl-clean-string
-                 (buffer-substring-no-properties p1 p2)))
-
-       (let* ((s (string-match "(" ss))
-              (e (string-match ")" ss s)))
-
-         (setq bibitem-bracket (format "%s%s"
-                                       (substring ss 0 s)
-                                       (if (string= "()" (substring ss s (+ e 1)))
-                                           ""
-                                         (concat " " (substring ss s (+ e 1)))))))
-
-
-       ;; Now get the key. From the last
-       (search-forward "{")
-       (goto-char (match-beginning 0))
-       (setq p1 (+ 1 (point)))
-       (forward-list)
-       (setq p2 (- (point) 1)
-             bibitem-key (buffer-substring p1 p2))
-
-       ;; Now get up to the next bibitem
-       (setq p1 (point))
-       (save-excursion
-         (setq p2 (or (when (search-forward "\\bibitem[" nil t)
-                        (match-beginning 0))
-                      bbl-max)))
-       (setq bibitem-entry (string-trim (buffer-substring p1 p2)))
-
-       (cl-pushnew (list bibitem-key :entry (org-ref-bbl-entry bibitem-entry)
-                         :index counter :bracket-data bibitem-bracket)
-                   data)))
-    (reverse data)))
-
-
-(defun org-ref-bbl-compress-numbers (lst)
-  "Take a list like (1 2 3 6) and return \"1-3,6\"."
-  (let* ((a (pop lst))
-        b
-        (sequence (list a))
-        (sequentials '()))
-    (while lst
-      (setq b (pop lst))
-      (if (= (- b a) 1)
-         ;; we have a sequence, add it, set a=b and continue
-         (setq sequence (append sequence (list b))
-               a b)
-       ;; lost sequence, store the sequence
-       (setq sequentials (append sequentials (list sequence))
-             sequence (list b)
-             a b)))
-    ;; store last one
-    (setq sequentials (append sequentials (list sequence)))
-
-    ;; Now construct strings for each group
-    (cl-loop for group in sequentials collect
-            (pcase (length group)
-              (1 (format "[[%s]]" (car group)))
-              (2 (format "[[%s]],[[%s]]" (cl-first group) (cl-second group)))
-              (_ (format "[[%s]]-[[%s]]" (cl-first group) (car (last group))))))))
-
-
-(defun org-ref-replace-cite-link (link bibdata NATBIB-OPTIONS backend)
-  "NATBIB-OPTIONS is the string to options.
-Argument LINK is an org link for a citation.
-Argument BIBDATA the data parsed from a bbl file.
-Argument BACKEND is the export format."
-  (let* ((refs (plist-get (org-ref-parse-cite-path (org-element-property :path link)) :references))
-        (keys (cl-loop for ref in refs collect (plist-get ref :key)))
-        items replacements replacement joiner p1 p2)
-
-    ;; Numeric types
-    (cond
-     ((or (string-match-p "numbers" NATBIB-OPTIONS)
-         (string-match-p "super" NATBIB-OPTIONS))
-      (setq items (cl-loop for key in keys
-                          collect (plist-get (cdr (assoc key bibdata)) :index)))
-
-      (when (string-match-p "sort" NATBIB-OPTIONS)
-       (setq items (sort items #'<)))
-
-      (setq replacements (if (string-match-p "compress" NATBIB-OPTIONS)
-                            (org-ref-bbl-compress-numbers items)
-                          ;; these are fuzzy org links to the target in item.
-                          (cl-loop for item in items collect (format "[[%s]]" item)))))
-
-     ;; authoryear types
-     ;; This html provides an anchor that is named. Targets are usually replaced with numbers, not the text.
-     ((string-match-p "authoryear" NATBIB-OPTIONS)
-      (setq replacements (cl-loop for key in keys
-                                 collect
-                                 (cond
-                                  ((eq backend 'html)
-                                   (format "@@html:<a href=\"#%s\">%s</a>@@"
-                                           (plist-get (cdr (assoc key bibdata)) :bracket-data) 
-                                           (plist-get (cdr (assoc key bibdata)) :bracket-data)))
-                                  (t
-                                   (format "[[%s]]" (plist-get (cdr (assoc key bibdata)) :bracket-data)))))))
-     (t
-      (error "%s not supported yet" NATBIB-OPTIONS)))
-
-    ;; Now join all the replacements for each reference
-    (setq joiner (cond
-                 ((string-match-p "comma" NATBIB-OPTIONS)
-                  ",")
-                 ((or (string-match-p "semicolon" NATBIB-OPTIONS)
-                      (string-match-p "colon" NATBIB-OPTIONS))
-                  ";")
-                 (t
-                  ";")))
-
-    ;; Finally create the overall replacement
-    (setq replacement (cond
-                      ((string-match-p "super" NATBIB-OPTIONS)
-                       (format "^{%s}" (string-join replacements joiner)))
-
-                      ((string-match-p "square" NATBIB-OPTIONS)
-                       (format "[%s]" (string-join replacements joiner)))
-
-                      ((string-match-p "round" NATBIB-OPTIONS)
-                       (format "(%s)" (string-join replacements joiner)))
-
-                      ((string-match-p "curly" NATBIB-OPTIONS)
-                       (format "{%s}" (string-join replacements joiner)))
-
-                      ((string-match-p "angle" NATBIB-OPTIONS)
-                       (format "<%s>" (string-join replacements joiner)))
-
-                      ((string-match-p "authoryear" NATBIB-OPTIONS)
-                       (string-join replacements joiner))
-
-                      (t
-                       (error "Cannot compute replacement for %s" NATBIB-OPTIONS))))
-
-    ;; When super is the style, we need to replace any blanks back to the last
-    ;; non-space. We just look back and move point if needed here.
-    (if (not (string-match-p "super" NATBIB-OPTIONS))
-       (setq p1 (org-element-property :begin link))
-      (goto-char (org-element-property :begin link))
-      (while (looking-back " " 1)
-       (backward-char))
-      (setq p1 (point)))
-
-    (setq p2 (org-element-property :end link))
-
-    ;; org-ref-natmove is dynamically bound here
-    (when org-ref-natmove
-      (save-excursion
-       (goto-char (org-element-property :end link))
-       (skip-chars-backward " ")
-
-       (when (string-match-p "[[:punct:]]" (buffer-substring (point) (+ (point) 1)))
-         ;; Get the character
-         (setq replacement (concat (buffer-substring (org-element-property :end link)
-                                                     (+ 1 (org-element-property :end link)))
-                                   replacement)
-               p2 (+ 1 (org-element-property :end link))))))
-
-    (cl--set-buffer-substring p1 p2
-                             (concat replacement (make-string (org-element-property :post-blank link) ? )))))
-
-
-(defun org-ref-bbl-replace-bibliography (bib-link bibdata NATBIB-OPTIONS backend)
-  "Get a replacement bibliography string for BIBDATA and NATBIB-OPTIONS.
-BIBDATA comes from `org-ref-bbl-bibliography-data'.
-Argument BIB-LINK an org link for a bibliography.
-Argument BACKEND is the export format."
-  (cl--set-buffer-substring (org-element-property :begin bib-link)
-                           (org-element-property :end bib-link)
-                           (cond
-                            ((or (string-match-p "numbers" NATBIB-OPTIONS)
-                                 (string-match-p "super" NATBIB-OPTIONS))
-                             (concat "\n* Bibliography\n\n"
-                                     (string-join
-                                      (cl-loop for entry in bibdata collect
-                                               (format "%s. <<%s>> %s"
-                                                       (plist-get (cdr entry) :index)
-                                                       (plist-get (cdr entry) :index)
-                                                       (plist-get (cdr entry) :entry)))
-                                      "\n\n")))
-
-
-                            ((string-match-p "authoryear" NATBIB-OPTIONS)
-                             (concat "\n* Bibliography\n\n"
-                                     (string-join
-                                      (cl-loop for entry in bibdata collect
-                                               (cond
-                                                ((eq backend 'html)
-                                                 (format "- @@html:<a id=\"%s\"></a>@@(%s) %s\n"
-                                                         (plist-get (cdr entry) :bracket-data)
-                                                         (plist-get (cdr entry) :bracket-data)
-                                                         (plist-get (cdr entry) :entry)))
-                                                (t
-                                                 (format "- <<%s>> %s"
-                                                         (plist-get (cdr entry) :bracket-data)
-                                                         (plist-get (cdr entry) :entry)))))
-                                      
-                                      
-                                      "\n")))
-                            (t
-                             (error "%s not supported yet" NATBIB-OPTIONS)))))
-
-
-
-(defun org-ref-bbl-preprocess (&optional backend)
-  "Should work on a copy of the buffer.
-Meant to be used in `org-export-before-parsing-hook'.
-Optional argument BACKEND The export backend.
-
-You need a LaTeX file and a bbl file for it. This hook generates
-those, then gets the data, replaces the citations and the
-bibliography.
-"
-  (let* ((org-export-before-parsing-functions nil)
-        (tex-file (org-latex-export-to-latex))
-        (bbl-file (concat (file-name-sans-extension tex-file) ".bbl"))
-        natbib-options bibdata org-ref-natmove
-        buf)
-
-    (when-let (buf (find-buffer-visiting tex-file))
-      (kill-buffer buf))
-
-    (when-let (buf (find-buffer-visiting bbl-file))
-      (kill-buffer buf))
-
-    ;; refresh these
-    (call-process-shell-command (format "latex -shell-escape %s" tex-file))
-    (call-process-shell-command (format "bibtex %s" (file-name-sans-extension tex-file)))
-
-    (setq buf (find-file-noselect tex-file))
-    (with-current-buffer buf
-      (goto-char (point-min))
-      (setq natbib-options (org-ref-bbl-get-natbib-options))
-      (goto-char (point-min))
-      (setq org-ref-natmove (search-forward "\\usepackage{natmove}" nil t)))
-    (kill-buffer buf)
-
-    (setq buf (find-file-noselect bbl-file))
-    (with-current-buffer buf
-      (goto-char (point-min))
-      (setq bibdata (org-ref-bbl-bibliography-data)))
-    (kill-buffer buf)
-
-    ;; Replace all the cite links
-    (cl-loop for cl in (reverse (org-ref-get-cite-links)) do
-            (org-ref-replace-cite-link cl bibdata natbib-options backend))
-
-    (org-ref-bbl-replace-bibliography
-     (org-element-map (org-element-parse-buffer) 'link
-       (lambda (lnk)
-        (when (string= (org-element-property :type lnk) "bibliography")
-          lnk))
-       nil
-       t)
-     bibdata natbib-options backend)))
-
-
-(provide 'org-ref-natbib-bbl-citeproc)
-
-;;; org-ref-natbib-bbl-citeproc.el ends here
diff --git a/elpa/org-ref-20241124.2012/org-ref-pdf.el b/elpa/org-ref-20241124.2012/org-ref-pdf.el
deleted file mode 100644 (file)
index a5b73ad..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-;;; org-ref-pdf.el --- Drag-n-drop PDF onto bibtex files  -*- lexical-binding: t; -*-
-
-;; Copyright (C) 2015-2024  John Kitchin
-
-;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
-;; Keywords:
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;; This library provides functions to enable drag-n-drop of pdfs onto a bibtex
-;; buffer to add bibtex entries to it.
-;;
-;; [2021-08-29 Sun] I have not found drag-and-drop to be especially reliable,
-;; and don't recommend you use it. This code relies 'pdf-tools, which is slow to
-;; load for me. pdf-tools is no longer automatically installed, so if you use
-;; this, you should install it yourself.
-
-;; TODO: If no DOI is found, figure out a way to do a crossref/google query to
-;; get a doi. This needs a reliable title/citation.
-
-;;; Code:
-(require 'pdf-tools)
-
-(require 'f)
-
-
-(eval-when-compile
-  (require 'cl-lib))
-
-
-(defgroup org-ref-pdf nil
-  "Customization group for org-ref-pdf"
-  :tag "Org Ref PDF"
-  :group 'org-ref-pdf)
-
-
-(defcustom pdftotext-executable
-  "pdftotext"
-  "Executable for pdftotext. Set if the executable is not on your
-path, or you want to use another version."
-  :type 'file
-  :group 'org-ref-pdf)
-
-
-(defcustom org-ref-pdf-doi-regex
-  "10\\.[0-9]\\{4,9\\}/[-+._;()/:A-Z0-9]+"
-  "Regular expression to match DOIs in a pdf converted to text."
-  :type 'regexp
-  :group 'org-ref-pdf)
-
-
-(defcustom org-ref-pdf-to-bibtex-function
-  'copy-file
-  "Function for getting  a pdf to a directory.
-Defaults to `copy-file', but could also be `rename-file'."
-  :type 'File :group 'org-ref-pdf)
-
-
-(defun org-ref-extract-doi-from-pdf (pdf)
-  "Try to extract a doi from a PDF file.
-There may be more than one doi in the file. This function returns
-all the ones it finds based on two patterns: doi: up to a quote,
-bracket, space or end of line. dx.doi.org/up to a quote, bracket,
-space or end of line.
-
-If there is a trailing . we chomp it off. Returns a list of doi
-strings, or nil."
-  (with-temp-buffer
-    (insert (shell-command-to-string (format "%s %s -"
-                                            pdftotext-executable
-                                            (shell-quote-argument pdf))))
-    (goto-char (point-min))
-    (let ((matches '()))
-      (while (re-search-forward org-ref-pdf-doi-regex nil t)
-       ;; I don't know how to avoid a trailing . on some dois with the
-       ;; expression above, so if it is there, I chomp it off here.
-       (let ((doi (match-string 0)))
-         (when (or (s-ends-with? "." doi) (s-ends-with? ";" doi))
-           (setq doi (substring doi 0 (- (length doi) 1))))
-         (cl-pushnew doi matches :test #'equal)))
-      matches)))
-
-
-(defun org-ref-pdf-doi-candidates (dois)
-  "Generate candidate list for a completion source.
-Used when multiple dois are found in a pdf file."
-  (cl-loop for doi in dois
-          collect
-          (condition-case nil
-              (cons
-               (plist-get (doi-utils-get-json-metadata doi) :title)
-               doi)
-            (error (cons (format "%s read error" doi) doi)))))
-
-
-(defun org-ref-bibtex-key-from-doi (doi)
-  "Return a bibtex entry's key from a DOI.
-BIB is an optional filename to get the entry from."
-  (catch 'key
-    (cl-loop for bibfile in (if (stringp bibtex-completion-bibliography)
-                               (list bibtex-completion-bibliography)
-                             bibtex-completion-bibliography)
-            do
-            (with-temp-buffer
-              (insert-file-contents (expand-file-name bibfile))
-              (when (search-forward doi)
-                (bibtex-beginning-of-entry)
-                (throw 'key (cdr (assoc "=key=" (bibtex-parse-entry)))))))))
-
-
-;;;###autoload
-(defun org-ref-pdf-to-bibtex ()
-  "Add pdf of current buffer to bib file and save pdf. The pdf
-should be open in Emacs using the `pdf-tools' package."
-  (interactive)
-  (when (not (f-ext? (downcase (buffer-file-name)) "pdf"))
-    (error "Buffer is not a pdf file"))
-  ;; Get doi from pdf of current buffer
-  (let* ((dois (org-ref-extract-doi-from-pdf (buffer-file-name)))
-         (doi-utils-download-pdf nil)
-         (doi (if (= 1 (length dois))
-                  (car dois)
-                (completing-read "Select DOI: " dois))))
-    ;; Add bib entry from doi:
-    (doi-utils-add-bibtex-entry-from-doi doi)
-    ;; Copy pdf to a directory
-    (let ((key (org-ref-bibtex-key-from-doi doi)))
-      (funcall org-ref-pdf-to-bibtex-function
-              (buffer-file-name)
-               (expand-file-name (format "%s.pdf" key) (org-ref-library-path))))))
-
-
-;;;###autoload
-(defun org-ref-pdf-debug-pdf (pdf-file)
-  "Try to debug getting a doi from a pdf.
-Opens a buffer with the pdf converted to text, and `occur' on the
-variable `org-ref-pdf-doi-regex'."
-  (interactive "fPDF: ")
-  (switch-to-buffer (get-buffer-create "*org-ref-pdf debug*"))
-  (erase-buffer)
-  (insert (shell-command-to-string (format "%s %s -"
-                                          pdftotext-executable
-                                          (shell-quote-argument pdf-file))))
-  (goto-char (point-min))
-  (highlight-regexp org-ref-pdf-doi-regex)
-  (occur org-ref-pdf-doi-regex)
-  (switch-to-buffer-other-window "*Occur*"))
-
-
-;;;###autoload
-(defun org-ref-pdf-crossref-lookup ()
-  "Lookup highlighted text in PDFView in CrossRef."
-  (interactive)
-  (require 'pdf-view)
-  (unless (pdf-view-active-region-p)
-    (error "The region is not active"))
-  (let* ((txt (pdf-view-active-region-text)))
-    (pdf-view-deactivate-region)
-    (crossref-lookup (mapconcat 'identity txt "         \n"))))
-
-
-(provide 'org-ref-pdf)
-;;; org-ref-pdf.el ends here
diff --git a/elpa/org-ref-20241124.2012/org-ref-pgk.el b/elpa/org-ref-20241124.2012/org-ref-pgk.el
deleted file mode 100644 (file)
index d2febe7..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-(define-package "org-ref" "3.1.0" "citations, cross-references and bibliographies in org-mode"
-  '((dash "0")
-    (s "0")
-    (f "0")
-    (hydra "0")
-    (htmlize "0")
-    (parsebib "0")
-    (bibtex-completion "0")
-    (emacs "29")))
-
-
-;; Local Variables:
-;; no-byte-compile: t
-;; End:
diff --git a/elpa/org-ref-20241124.2012/org-ref-pkg.el b/elpa/org-ref-20241124.2012/org-ref-pkg.el
deleted file mode 100644 (file)
index 457dd0b..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-;; -*- no-byte-compile: t; lexical-binding: nil -*-
-(define-package "org-ref" "20241124.2012"
-  "Citations, cross-references and bibliographies in org-mode."
-  '((org               "9.4")
-    (dash              "0")
-    (s                 "0")
-    (f                 "0")
-    (htmlize           "0")
-    (hydra             "0")
-    (avy               "0")
-    (parsebib          "0")
-    (bibtex-completion "0")
-    (citeproc          "0")
-    (ox-pandoc         "0")
-    (request           "0"))
-  :url "https://github.com/jkitchin/org-ref"
-  :commit "a61fe2a76294dcf4b216c25f789c4dba15f5986d"
-  :revdesc "a61fe2a76294"
-  :keywords '("org-mode" "cite" "ref" "label")
-  :authors '(("John Kitchin" . "jkitchinNOSPAMandrew.cmu.edu"))
-  :maintainers '(("John Kitchin" . "jkitchinNOSPAMandrew.cmu.edu")))
diff --git a/elpa/org-ref-20241124.2012/org-ref-publish.el b/elpa/org-ref-20241124.2012/org-ref-publish.el
deleted file mode 100644 (file)
index 4efba6c..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-;;; org-ref-publish.el --- org-publish with org-ref -*- lexical-binding: t; -*-\r
-\r
-;;; Commentary:\r
-;; First draft proposed by madhu 230826 (Madhu <enomethNOSPAMmeer.net>)\r
-;; This code provides publishing capability that leverages \r
-\r
-;;; Code:\r
-\r
-;; modified from org-publish-org-to to call org-ref-process-buffer before\r
-;; calling org-export-to-file\r
-(defun org-ref-publish-org-to (backend filename extension plist &optional pub-dir)\r
-  "Publish an Org file to a specified backend using org-ref.\r
-\r
-BACKEND is a symbol representing the backend used for\r
-transcoding.  FILENAME is the filename of the Org file to be\r
-published.  EXTENSION is the extension used for the output\r
-string, with the leading dot.  PLIST is the property list for the\r
-given project.\r
-\r
-Optional argument PUB-DIR, when non-nil is the publishing\r
-directory.\r
-\r
-Return output file name."\r
-  (unless (or (not pub-dir) (file-exists-p pub-dir))\r
-    (make-directory pub-dir t))\r
-  ;; Check if a buffer visiting FILENAME is already open.\r
-  (let* ((org-inhibit-startup t)\r
-        (visiting (find-buffer-visiting filename))\r
-        (work-buffer (or visiting (find-file-noselect filename))))\r
-    (unwind-protect\r
-       (with-current-buffer work-buffer\r
-         (let* ((output (org-export-output-file-name extension nil pub-dir)))\r
-           (org-export-with-buffer-copy\r
-            (org-export-expand-include-keyword)\r
-            (goto-char (point-min))\r
-            (org-ref-process-buffer backend nil) ;no subtreep\r
-            (goto-char (point-min))\r
-            (org-export-to-file backend output\r
-              nil nil nil (plist-get plist :body-only)\r
-              ;; Add `org-publish--store-crossrefs' and\r
-              ;; `org-publish-collect-index' to final output filters.\r
-              ;; The latter isn't dependent on `:makeindex', since we\r
-              ;; want to keep it up-to-date in cache anyway.\r
-              (org-combine-plists\r
-               plist\r
-               `(:crossrefs\r
-                 ,(org-publish-cache-get-file-property\r
-                   ;; Normalize file names in cache.\r
-                   (file-truename filename) :crossrefs nil t)\r
-                 :filter-final-output\r
-                 (org-publish--store-crossrefs\r
-                  org-publish-collect-index\r
-                  ,@(plist-get plist :filter-final-output))))))))\r
-      ;; Remove opened buffer in the process.\r
-      (unless visiting (kill-buffer work-buffer)))))\r
-\r
-;; modified from org-html-publish-to-html to call org-ref-publish-org-to instead\r
-;; of org-publish-org-to\r
-(defun org-ref-publish-to-html (plist filename pub-dir)\r
-  "Publish an org file to HTML through org-ref.\r
-\r
-FILENAME is the filename of the Org file to be published.  PLIST\r
-is the property list for the given project.  PUB-DIR is the\r
-publishing directory.\r
-\r
-Return output file name."\r
-  (org-ref-publish-org-to 'html filename\r
-                         (concat (when (> (length org-html-extension) 0) ".")\r
-                                 (or (plist-get plist :html-extension)\r
-                                     org-html-extension\r
-                                     "html"))\r
-                         plist pub-dir))\r
-\r
-\r
-;; modified from org-latex-publish-to-latex to call org-ref-publish-org-to\r
-;; instead of org-publish-org-to\r
-(defun org-ref-publish-to-latex (plist filename pub-dir)\r
-  "Publish an Org file to LaTeX using org-ref.\r
-\r
-FILENAME is the filename of the Org file to be published.  PLIST\r
-is the property list for the given project.  PUB-DIR is the\r
-publishing directory.\r
-\r
-Return output file name."\r
-  (org-ref-publish-org-to 'latex filename ".tex" plist pub-dir))\r
-\r
-;; modified from org-latex-publish-to-pdf to call org-ref-publish-org-to instead of org-publish-org-to\r
-(defun org-ref-publish-to-pdf (plist filename pub-dir)\r
-  "Publish an Org file to PDF (via LaTeX) using org-ref.\r
-\r
-FILENAME is the filename of the Org file to be published.  PLIST\r
-is the property list for the given project.  PUB-DIR is the\r
-publishing directory.\r
-\r
-Return output file name."\r
-  (org-publish-attachment\r
-   plist\r
-   (let ((default-directory (file-name-directory filename)))\r
-     (org-latex-compile\r
-      (org-ref-publish-org-to\r
-       'latex filename ".tex" plist (file-name-directory filename))))\r
-   pub-dir))\r
-\r
-(provide 'org-ref-publish)\r
-\r
-;;; org-ref-publish.el ends here\r
-\r
diff --git a/elpa/org-ref-20241124.2012/org-ref-pubmed.el b/elpa/org-ref-20241124.2012/org-ref-pubmed.el
deleted file mode 100644 (file)
index 3a0cbd4..0000000
+++ /dev/null
@@ -1,266 +0,0 @@
-;;; org-ref-pubmed.el --- Links and functions for Pubmed and NIH databases  -*- lexical-binding: t; -*-
-
-;; Copyright (C) 2015-2024  John Kitchin
-
-;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
-;; Keywords: convenience
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;;* Introduction
-
-;; This document is an experiment at creating a literate program to provide
-;; functions for interacting with pubmed databases.
-
-;; This library provides links that go to pubmed resources, e.g.
-
-;; pmcid:PMC3498956
-;;
-;; pmid:23162369
-;;
-;; and nihmsid:NIHMS395714
-;;
-;; See http://www.ncbi.nlm.nih.gov/pmc/about/public-access-info/#p3 for details
-;; of these identifiers.
-;;
-;; For PMID there is one interactive function that inserts a bibtex entry:
-;; pubmed-insert-bibtex-from-pmid.
-
-;; This library is complementary to [[./doi-utils.org]].
-
-;;; Code:
-
-;;* PMID (from PubMed) link and functions
-
-;; A PMID is a number that identifies an entry in the Pubmed database.  The PMID
-;; is a unique reference number for PubMed citations. The PMID is a distinctly
-;; different number from the PMCID and is used only for PubMed records.
-
-(require 'dash)
-(require 'org)
-(require 'org-ref-utils)
-
-(org-link-set-parameters "pmid"
-                        :follow (lambda (link-string) (browse-url (format "http://www.ncbi.nlm.nih.gov/pubmed/%s" link-string)))
-                        :export (lambda (keyword desc format)
-                                  (cond
-                                   ((eq format 'html)
-                                    (format "<a href=\"http://www.ncbi.nlm.nih.gov/pmc/articles/mid/%s\">pmid:%s</a>" keyword (or desc keyword))) ; no output for html
-                                   ((eq format 'latex)
-                                    ;; write out the latex command
-                                    (format "\\url{http://www.ncbi.nlm.nih.gov/pmc/articles/mid/%s}{%s}" keyword (or desc keyword))))))
-
-;;** Get MEDLINE metadata
-
-;; We can get bibliographic metadata from a pmid. Here we get the MEDLINE
-;; text. The website wraps the data in <pre></pre> tags.
-
-(defun pubmed-get-medline (pmid)
-  "Get MEDLINE text for PMID as a string."
-  (with-current-buffer
-      (url-retrieve-synchronously
-       (format "https://pubmed.ncbi.nlm.nih.gov/%s/?format=pubmed" pmid))
-    (goto-char (point-min))
-    (let ((p1 (search-forward "<pre class=\"article-details\" id=\"article-details\">"))
-          (p2 (search-forward "</pre>")))
-      (replace-regexp-in-string "\r" "" (buffer-substring (+ 1 p1) (- p2 6))))))
-
-;;** Parse the PMID MEDLINE data
-
-;; We can parse this into a data structure.
-(defun pubmed-parse-medline (pmid)
-  "Parse the medline text for PMID and return a list of cons cells."
-  (let ((data '())
-        (p1)
-        (p2)
-        (tag)
-        (value))
-    (with-temp-buffer (insert (pubmed-get-medline pmid))
-                      (goto-char (point-min))
-                      (while (re-search-forward "\\(^[A-Z]\\{2,4\\}\\)\\s-*- "
-                                               nil t)
-                        (setq tag (match-string 1))
-                        ;; point is at end of the search
-                        (setq p1 (point))
-                        ;; now go to next tag
-                        (re-search-forward "\\(^[A-Z]\\{2,4\\}\\)\\s-*- " nil t)
-                        (setq p2 (- (match-beginning 1) 1))
-                        (setq value (buffer-substring p1 p2))
-                        (setq data (append data (list (cons tag value))))
-                        ;; now go back to last tag to get the next one
-                        (goto-char p1)))
-    data))
-
-;;** PMID to bibtex entry
-
-;; The point of parsing the MEDLINE text is so we can make bibtex entries. We
-;; only support Journal articles for now.
-
-(defun pubmed-pmid-to-bibtex (pmid)
-  "Convert a PMID to a bibtex entry."
-  (let* ((data (pubmed-parse-medline pmid))
-         (type (downcase (cdr (assoc "PT" data))))
-         (title (cdr (assoc "TI" data)))
-         (authors (mapconcat 'cdr
-                             (-filter (lambda (x)
-                                        (string= (car x) "FAU"))
-                                      data)
-                             " and "))
-         (abstract (cdr (assoc "AB" data)))
-         (volume (cdr (assoc "VI" data)))
-         (issue (cdr (assoc "IP" data)))
-         (journal (cdr (assoc "JT" data)))
-         (year (cdr (assoc "DP" data)))
-         (pages (cdr (assoc "PG" data)))
-         (aid (cdr (assoc "AID" data))))
-
-    (cond
-     ((string= type "journal article")
-      (concat "@article{,
- author = {" authors "},
- title = {" title "},
- abstract = {" abstract "},
- journal = {" journal "},
- volume = {" volume "},
- number = {" issue "},
- year = {" (car (split-string year)) "},
- pages = {" pages "},
- doi = {" (replace-regexp-in-string " \\[doi\\]" "" (or aid "")) "},
-}"))
-     (t
-      (message "No conversion for type: %s" type)))))
-
-;; And we probably want to be able to insert a bibtex entry
-
-;;;###autoload
-(defun pubmed-insert-bibtex-from-pmid (pmid)
-  "Insert a bibtex entry at point derived from PMID.
-You must clean the entry after insertion."
-  (interactive "sPMID: ")
-  (insert (pubmed-pmid-to-bibtex pmid)))
-
-
-;;* Pubmed Central (PMC) link
-
-;; A PMCID starts with PMC and is followed by numbers. The PMCID is a unique
-;; reference number or identifier that is assigned to every article that is
-;; accepted into PMC. The PMCID is also used by recipients of NIH funding to
-;; demonstrate compliance with the NIH Public Access policy. The PMCID can be
-;; found in both PMC and PubMed.
-
-;; Here we define a new link. Clicking on it simply opens a webpage to the
-;; article.
-
-(org-link-set-parameters "pmcid"
-                        :follow (lambda (link-string) (browse-url (format "http://www.ncbi.nlm.nih.gov/pmc/articles/%s" link-string)))
-                        :export (lambda (keyword desc format)
-                                  (cond
-                                   ((eq format 'html)
-                                    (format "<a href=\"http://www.ncbi.nlm.nih.gov/pmc/articles/%s\">pmcid:%s</a>" keyword (or desc keyword)))
-                                   ((eq format 'latex)
-                                    (format "\\url{http://www.ncbi.nlm.nih.gov/pmc/articles/%s}{%s}" keyword (or desc keyword))))))
-
-;;* NIHMSID
-
-;; The NIHMSID is a preliminary article identifier that applies only to
-;; manuscripts deposited through the NIHMS system. The NIHMSID is only valid for
-;; compliance reporting for 90 days after the publication date of an
-;; article. Once the Web version of the NIHMS submission is approved for
-;; inclusion in PMC and the corresponding citation is in PubMed, the article
-;; will also be assigned a PMCID.
-
-(org-link-set-parameters "nihmsid"
-                        :follow (lambda (link-string) (browse-url (format "http://www.ncbi.nlm.nih.gov/pmc/articles/mid/%s" link-string)))
-                        :export (lambda (keyword desc format)
-                                  (cond
-                                   ((eq format 'html)
-                                    (format "<a href=\"http://www.ncbi.nlm.nih.gov/pmc/articles/mid//%s\">nihmsid:%s</a>" keyword (or desc keyword)))
-                                   ((eq format 'latex)
-                                    ;; write out the latex command
-                                    (format "\\url{http://www.ncbi.nlm.nih.gov/pmc/articles/mid/%s}{%s}" keyword (or desc keyword))))))
-
-
-;;* Searching pubmed
-
-;;;###autoload
-(defun pubmed ()
-  "Open http://www.ncbi.nlm.nih.gov/pubmed in a browser."
-  (interactive)
-  (browse-url "http://www.ncbi.nlm.nih.gov/pubmed"))
-
-
-;;;###autoload
-(defun pubmed-advanced ()
-  "Open http://www.ncbi.nlm.nih.gov/pubmed/advanced in a browser."
-  (interactive)
-  (browse-url "http://www.ncbi.nlm.nih.gov/pubmed/advanced"))
-
-
-;;;###autoload
-(defun pubmed-simple-search (query)
-  "Open QUERY in Pubmed in a browser."
-  (interactive "sQuery: ")
-  (browse-url
-   (format "http://www.ncbi.nlm.nih.gov/pubmed/?term=%s" (url-hexify-string query))))
-
-
-(org-link-set-parameters "pubmed-search"
-                        :follow (lambda (query)
-                                  "Open QUERY in a `pubmed-simple-search'."
-                                  (pubmed-simple-search query))
-                        :export (lambda (query desc format)
-                                  (let ((url (format "http://www.ncbi.nlm.nih.gov/pubmed/?term=%s" (url-hexify-string query))))
-                                    (cond
-                                     ((eq format 'html)
-                                      (format "<a href=\"%s\">%s</a>" url (or desc (concat "pubmed-search:" query))))
-                                     ((eq format 'latex)
-                                      (format "\\href{%s}{%s}" url (or desc (concat "pubmed-search:" query))))))))
-
-;; ** Pubmed clinical
-;; These functions were suggested by Colin Melville <casm40NOSPAMgmail.com>.
-;;;###autoload
-(defun pubmed-clinical ()
-  "Open http://www.ncbi.nlm.nih.gov/pubmed/clinical in a browser."
-  (interactive)
-  (browse-url "http://www.ncbi.nlm.nih.gov/pubmed/clinical"))
-
-
-;;;###autoload
-(defun pubmed-clinical-search (query)
-  "Open QUERY in pubmed-clinical."
-  (interactive "sQuery: ")
-  (browse-url
-   (format "https://www.ncbi.nlm.nih.gov/pubmed/clinical?term=%s" (url-hexify-string query))))
-
-
-(org-link-set-parameters "pubmed-clinical"
-                        :follow (lambda (query)
-                                  "Open QUERY in a `pubmed-clinical-search'."
-                                  (pubmed-clinical-search query))
-                        :export (lambda (query desc format)
-                                  (let ((url (format "http://www.ncbi.nlm.nih.gov/pubmed/clinical?term=%s"
-                                                     (url-hexify-string query))))
-                                    (cond
-                                     ((eq format 'html)
-                                      (format "<a href=\"%s\">%s</a>" url
-                                              (or desc (concat "pubmed-clinical-search:" query))))
-                                     ((eq format 'latex)
-                                      (format "\\href{%s}{%s}" url
-                                              (or desc (concat "pubmed-clinical-search:" query))))))))
-
-
-(provide 'org-ref-pubmed)
-;;; org-ref-pubmed.el ends here
diff --git a/elpa/org-ref-20241124.2012/org-ref-ref-links.el b/elpa/org-ref-20241124.2012/org-ref-ref-links.el
deleted file mode 100644 (file)
index 9faef77..0000000
+++ /dev/null
@@ -1,631 +0,0 @@
-;;; org-ref-ref-links.el --- cross-reference links for org-ref -*- lexical-binding: t; -*-
-;;
-;; Copyright (C) 2021-2024  John Kitchin
-
-;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
-;; Keywords: convenience
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
-;;
-;;; Commentary:
-;;
-
-;;; Code:
-(eval-and-compile (require 'org-macs))
-(eval-and-compile (require 'ol))
-(require 'hydra)
-
-(defcustom org-ref-default-ref-type "ref"
-  "Default ref link type to use when inserting ref links."
-  :type 'string
-  :group 'org-ref)
-
-
-(defcustom org-ref-activate-ref-links t
-  "If non-nil use font lock to activate ref links.
-Activation can be slow in large documents with a lot of ref
-links. Set this to nil to turn off activation."
-  :type 'boolean
-  :group 'org-ref)
-
-
-(defface org-ref-ref-face
-  `((t (:inherit org-link :foreground "dark red")))
-  "Face for ref links in org-ref."
-  :group 'org-ref-faces)
-
-
-(defvar org-ref-label-re
-  (rx-to-string
-   '(group-n 1 (one-or-more (any word "-.:?!`'/*@+|(){}<>&_^$#%~"))))
-  "Regexp for labels.")
-
-
-(defvar org-ref-label-link-re
-  (rx-to-string
-   `(seq "label:" (group-n 1 (one-or-more (any word "-.:?!`'/*@+|(){}<>&_^$#%~")))))
-  "Regexp for label links.")
-
-
-(defvar org-ref-ref-label-regexps
-  (list
-   (concat ":ID:\\s-+" org-ref-label-re "\\_>")
-   ;; CUSTOM_ID in a heading
-   (concat ":CUSTOM_ID:\\s-+" org-ref-label-re "\\_>")
-   ;; #+name
-   (concat "^\\s-*#\\+name:\\s-+" org-ref-label-re "\\_>")
-   ;; labels in latex
-   (concat "\\\\label{" org-ref-label-re "}")
-   ;; A target, code copied from org-target-regexp and group 1 numbered.
-   (let ((border "[^<>\n\r \t]"))
-     (format "<<\\(?1:%s\\|%s[^<>\n\r]*%s\\)>>"
-            border border border))
-   ;; A label link
-   (concat "label:" org-ref-label-re "\\_>")
-   "\\\\lstset{.*label=\\(?1:.*?\\),.*}")
-  "List of regular expressions to labels.
-The label should always be in group 1.")
-
-
-(defvar org-ref-ref-types
-  '(("ref" "A regular cross-reference to a label")
-    ("eqref" "A cross-reference to an equation")
-    ("pageref" "to the page number a label is on")
-    ("nameref" "to the name associated with a label (e.g. a caption)")
-    ("autoref" "from hyperref, adds automatic prefixes")
-    ("Autoref" "from hyperref, capitalized version of autoref")
-    ("cref" "from cleveref, adds automatic prefixes, and condenses multiple refs")
-    ("Cref" "from cleveref, capitalized version of cref")
-    ("crefrange" "from cleveref, makes a range of refs from two refs with a prefix")
-    ("Crefrange" "from cleveref, capitalized prefix version of crefrange"))
-  "List of ref link types (type description).")
-
-
-(defun org-ref-select-ref-type ()
-  "Select a ref type with annotated completion."
-  (let* ((type-annotation (lambda (s)
-                           (let ((item (assoc s minibuffer-completion-table)))
-                             (when item (concat
-                                         (make-string (- 12 (length s)) ? )
-                                         "-- "
-                                         (cl-second item))))))
-        (completion-extra-properties `(:annotation-function ,type-annotation)))
-    (completing-read "Type: " org-ref-ref-types)))
-
-
-(defun org-ref-change-ref-type (new-type)
-  "Change the ref type to NEW-TYPE."
-  (interactive (list (org-ref-select-ref-type)))
-  (let* ((cite-link (org-element-context))
-        (old-type (org-element-property :type cite-link))
-        (begin (org-element-property :begin cite-link))
-        (end (org-element-property :end cite-link))
-        (bracketp (eq 'bracket (org-element-property :format cite-link)))
-        (path (org-element-property :path cite-link))
-        (deltap (- (point) begin)))
-    ;; note this does not respect brackets
-    (cl--set-buffer-substring begin end
-                             (concat
-                              (if bracketp "[[" "")
-                              new-type ":" path
-                              (if bracketp "]]" "")))
-    ;; try to preserve the character the point is on.
-    (goto-char (+ begin deltap (- (length new-type) (length old-type))))))
-
-
-(defvar-local org-ref-label-cache nil
-  "Buffer-local cache variable for labels.")
-
-
-(defvar-local org-ref-buffer-chars-modified-tick nil
-  "Buffer-local variable to hold `buffer-chars-modified-tick'.")
-
-
-(defun org-ref-get-labels ()
-  "Return a list of referenceable labels in the document.
-You can reference:
-A NAME keyword
-A CUSTOM_ID property on a heading
-A LaTeX label
-A target.
-A label link
-A setting in lstset
-
-See `org-ref-ref-label-regexps' for the patterns that find these.
-
-Returns a list of cons cells (label . context).
-
-It is important for this function to be fast, since we use it in
-font-lock."
-  (if (or
-       ;; if we have not checked we have to check
-       (null org-ref-buffer-chars-modified-tick)
-       ;; Now check if buffer has changed since last time we looked. We check
-       ;; this with the buffer-chars-modified-tick which keeps track of changes.
-       ;; If this hasn't changed, no chars have been modified.
-       (not (= (buffer-chars-modified-tick)
-              org-ref-buffer-chars-modified-tick)))
-      ;; We need to search for all the labels either because we don't have them,
-      ;; or the buffer has changed since we looked last time.
-      (let ((case-fold-search t)
-           (rx (string-join org-ref-ref-label-regexps "\\|"))
-           (labels '())
-           oe ;; org-element
-           context)
-       (save-excursion
-         (org-with-wide-buffer
-          (goto-char (point-min))
-          (while (re-search-forward rx nil t)
-            (save-match-data
-              ;; Here we try to get some relevant context for different things you
-              ;; might reference.
-              (setq oe (org-element-context)
-                    context (string-trim
-                             (pcase (car oe)
-                               ('latex-environment (buffer-substring
-                                                    (org-element-property :begin oe)
-                                                    (org-element-property :end oe)))
-                               ;; figure
-                               ('paragraph (buffer-substring
-                                            (org-element-property :begin oe)
-                                            (org-element-property :end oe)))
-                               ('table (buffer-substring
-                                        (org-element-property :begin oe)
-                                        (org-element-property :end oe)))
-                               ;; Headings fall here.
-                               (_ (buffer-substring (line-beginning-position)
-                                                    (line-end-position)))))))
-            (cl-pushnew (cons (match-string-no-properties 1) context)
-                        labels))))
-       
-       ;; reverse so they are in the order we find them.
-       (setq
-        org-ref-buffer-chars-modified-tick (buffer-chars-modified-tick)
-        org-ref-label-cache (delete-dups (reverse labels))))
-
-    ;; retrieve the cached data
-    org-ref-label-cache))
-
-
-(defun org-ref-ref-jump-to (&optional path)
-  "Jump to the target for the ref link at point."
-  (interactive)
-  (let ((case-fold-search t)
-       (label (get-text-property (point) 'org-ref-ref-label))
-       (labels (split-string path ","))
-       (rx (string-join org-ref-ref-label-regexps "\\|")))
-    (when (null label)
-      (pcase (length labels)
-       (1
-        (setq label (cl-first labels)))
-       (_
-        (setq label (completing-read "Label: " labels)))))
-    (when label
-      (org-mark-ring-push)
-      (widen)
-      (goto-char (point-min))
-      (catch 'found
-       (while (re-search-forward rx)
-         (when (string= label (match-string-no-properties 1))
-           (save-match-data (org-mark-ring-push))
-           (goto-char (match-beginning 1))
-           (org-fold-show-entry)
-           (substitute-command-keys
-            "Go back with (org-mark-ring-goto) \`\\[org-mark-ring-goto]'.")
-           (throw 'found t)))))))
-
-
-(defun org-ref-ref-help-echo (_win _obj position)
-  "Tooltip for context on a ref label.
-POSITION is the point under the mouse I think."
-  (cdr (assoc (get-text-property position 'org-ref-ref-label) (org-ref-get-labels))))
-
-
-(defun org-ref-ref-activate (start _end path _bracketp)
-  "Activate a ref link.
-The PATH should be a comma-separated list of labels.
-Argument START is the start of the link.
-Argument END is the end of the link."
-  (when org-ref-activate-ref-links
-    (let ((labels (mapcar 'car (org-ref-get-labels))))
-      (goto-char start)
-      (cl-loop for label in (split-string path ",") do
-              (search-forward label)
-              ;; store property so we can follow it later.
-              (put-text-property (match-beginning 0)
-                                 (match-end 0)
-                                 'org-ref-ref-label
-                                 label)
-
-              (unless (member label labels)
-                
-                (put-text-property (match-beginning 0)
-                                   (match-end 0)
-                                   'face
-                                   'font-lock-warning-face)
-                (put-text-property (match-beginning 0)
-                                   (match-end 0)
-                                   'help-echo
-                                   "Label not found"))))))
-
-
-(defun org-ref-ref-export (cmd keyword _desc backend)
-  "An export function for ref links.
-Argument CMD is the LaTeX command to export to.
-Argument KEYWORD is the path of the ref link.
-Argument BACKEND is the export backend.
-This is meant to be used with `apply-partially' in the link definitions."
-  (cond
-   ((eq backend 'latex)
-    (format "\\%s{%s}" cmd keyword))))
-
-
-(defun org-ref-complete-link (refstyle &optional _arg)
-  "Complete a ref link to an existing label."
-  (concat refstyle ":" (completing-read "Label: " (org-ref-get-labels))))
-
-
-(defun org-ref-store-ref-link (&optional reftype)
-  "Store a ref link to a label.  The output will be a ref to that label."
-  ;; First we have to make sure we are on a label link.
-  (unless reftype (setq reftype "ref"))
-  (let* ((object (and (eq major-mode 'org-mode) (org-element-context)))
-        (label (cond
-                ;; here literally on a label link.
-                ((and
-                  (equal (org-element-type object) 'link)
-                  (equal (org-element-property :type object) "label"))
-                 (org-element-property :path object))
-
-                ;; here on a file link. if it has a caption with a label in it, we store
-                ;; it.
-                ((and
-                  (equal (org-element-type object) 'link)
-                  (equal (org-element-property :type object) "file")
-                  (org-file-image-p (org-element-property :path object)))
-
-                 (if (org-element-property :name object)
-                     (org-element-property :name object)
-                   ;; maybe we have a caption to get it from.
-                   (let* ((parent (org-element-property :parent object)))
-                     (when (and parent
-                                (equal (org-element-type parent) 'paragraph))
-                       (if (org-element-property :name parent)
-                           ;; caption paragraph may have a name which we use if it is there
-                           (org-element-property :name parent)
-                         ;; else search caption
-                         (let ((caption (s-join
-                                         ""
-                                         (mapcar 'org-no-properties
-                                                 (org-export-get-caption parent))))) 
-                           (when (string-match org-ref-label-re caption)
-                             (match-string 1 caption))))))))
-
-                ;; here on a paragraph (eg in a caption of an image). it is a paragraph with a caption
-                ;; in a caption, with no name, but maybe a label
-                ((equal (org-element-type object) 'paragraph)
-                 (if (org-element-property :name object)
-                     (org-element-property :name object)
-
-                   ;; See if it is in the caption name
-                   (let ((caption (s-join "" (mapcar 'org-no-properties
-                                                     (org-export-get-caption object)))))
-                     (when (string-match org-ref-label-re caption)
-                       (match-string 1 caption)))))
-
-                ;; If you are in a table, we need to be at the beginning to
-                ;; make sure we get the name. Note when in a caption it appears
-                ;; you are in a table but org-at-table-p is nil there.
-                ((or (equal (org-element-type object) 'table) (org-at-table-p))
-                 (save-excursion
-                   (goto-char (org-table-begin))
-                   (let* ((table (org-element-context))
-                          (label (org-element-property :name table))
-                          (caption (s-join "" (mapcar 'org-no-properties
-                                                      (org-export-get-caption table)))))
-                     (when (null label)
-                       ;; maybe there is a label in the caption?
-                       (when (string-match org-ref-label-link-re caption)
-                         (match-string 1 caption))))))
-
-                ;; and to #+namel: lines
-                ((and (equal (org-element-type object) 'paragraph)
-                      (org-element-property :name object))
-                 (org-element-property :name object))
-
-                ;; in a latex environment
-                ((equal (org-element-type object) 'latex-environment)
-                 (let ((value (org-element-property :value object)))
-                   (when (string-match "\\\\label{\\(?1:[+a-zA-Z0-9:\\._-]*\\)}" value)
-                     (match-string-no-properties 1 value))))
-
-                ;; Match targets, like <<label>>
-                ((equal (org-element-type object) 'target)
-                 (org-element-property :value object))
-
-                (t
-                 nil))))
-    
-    (when label
-      (org-link-store-props
-       :type reftype
-       :link (concat reftype ":" label)) 
-      t)))
-
-
-;; ** ref link
-
-(org-link-set-parameters "ref"
-                        :store (defun org-ref-store-ref () (org-ref-store-ref-link "ref"))
-                        :complete (apply-partially #'org-ref-complete-link "ref")
-                        :activate-func #'org-ref-ref-activate
-                        :follow #'org-ref-ref-jump-to
-                        :export (apply-partially #'org-ref-ref-export "ref")
-                        :face 'org-ref-ref-face
-                        :help-echo #'org-ref-ref-help-echo)
-
-
-;;** pageref link
-
-(org-link-set-parameters "pageref"
-                        :store (defun org-ref-store-pageref () (org-ref-store-ref-link "pageref"))
-                        :complete (apply-partially #'org-ref-complete-link "pageref")
-                        :activate-func #'org-ref-ref-activate
-                        :follow #'org-ref-ref-jump-to
-                        :export (apply-partially #'org-ref-ref-export "pageref")
-                        :face 'org-ref-ref-face
-                        :complete (lambda (&optional arg) (org-ref-complete-link arg "pageref"))
-                        :help-echo #'org-ref-ref-help-echo)
-
-
-;;** nameref link
-
-(org-link-set-parameters "nameref"
-                        :store (defun org-ref-store-nameref () (org-ref-store-ref-link "nameref"))
-                        :complete (apply-partially #'org-ref-complete-link "nameref")
-                        :activate-func #'org-ref-ref-activate
-                        :follow #'org-ref-ref-jump-to
-                        :export (apply-partially #'org-ref-ref-export "nameref")
-                        :face 'org-ref-ref-face
-                        :help-echo #'org-ref-ref-help-echo)
-
-;;** eqref link
-
-(org-link-set-parameters "eqref"
-                        :store (defun org-ref-store-eqref () (org-ref-store-ref-link "eqref"))
-                        :complete (apply-partially #'org-ref-complete-link "eqref")
-                        :activate-func #'org-ref-ref-activate
-                        :follow #'org-ref-ref-jump-to
-                        :export (apply-partially #'org-ref-ref-export "eqref")
-                        :face 'org-ref-ref-face
-                        :help-echo #'org-ref-ref-help-echo)
-
-;;** autoref link
-
-(org-link-set-parameters "autoref"
-                        :store (defun org-ref-store-autoref () (org-ref-store-ref-link "autoref"))
-                        :complete (apply-partially #'org-ref-complete-link "autoref")
-                        :activate-func #'org-ref-ref-activate
-                        :follow #'org-ref-ref-jump-to
-                        :export (apply-partially #'org-ref-ref-export "autoref")
-                        :face 'org-ref-ref-face
-                        :help-echo #'org-ref-ref-help-echo)
-
-
-(org-link-set-parameters "Autoref"
-                        :store (defun org-ref-store-Autoref () (org-ref-store-ref-link "Autoref"))
-                        :complete (apply-partially #'org-ref-complete-link "Autoref")
-                        :activate-func #'org-ref-ref-activate
-                        :follow #'org-ref-ref-jump-to
-                        :export (apply-partially #'org-ref-ref-export "Autoref")
-                        :face 'org-ref-ref-face
-                        :help-echo #'org-ref-ref-help-echo)
-
-;;** cref link
-;; for LaTeX cleveref package:
-;; https://www.ctan.org/tex-archive/macros/latex/contrib/cleveref
-
-
-(org-link-set-parameters "cref"
-                        :store (defun org-ref-store-cref () (org-ref-store-ref-link "cref"))
-                        :complete (apply-partially #'org-ref-complete-link "cref")
-                        :activate-func #'org-ref-ref-activate
-                        :follow #'org-ref-ref-jump-to
-                        :export (apply-partially #'org-ref-ref-export "cref")
-                        :face 'org-ref-ref-face
-                        :help-echo #'org-ref-ref-help-echo)
-
-
-(org-link-set-parameters "Cref"
-                        :store (defun org-ref-store-Cref () (org-ref-store-ref-link "Cref"))
-                        :complete (apply-partially #'org-ref-complete-link "Cref")
-                        :activate-func #'org-ref-ref-activate
-                        :follow #'org-ref-ref-jump-to
-                        :export (apply-partially #'org-ref-ref-export "Cref")
-                        :face 'org-ref-ref-face
-                        :help-echo #'org-ref-ref-help-echo)
-
-
-(defun org-ref-crefrange-export (path _desc backend)
-  (pcase backend
-    ('latex
-     (let ((labels (split-string path ",")))
-       (format "\\crefrange{%s}{%s}" (cl-first labels) (cl-second labels))))))
-
-
-(defun org-ref-Crefrange-export (path _desc backend)
-  (pcase backend
-    ('latex
-     (let ((labels (split-string path ",")))
-       (format "\\Crefrange{%s}{%s}" (cl-first labels) (cl-second labels))))))
-
-
-(defun org-ref-crefrange-complete (cmd &optional _arg)
-  "Completing function for the c/Crefrange links."
-  (concat cmd ":"
-         (completing-read "Label 1: " (org-ref-get-labels))
-         ","
-         (completing-read "Label 2: " (org-ref-get-labels))))
-
-
-(org-link-set-parameters "crefrange"
-                        :complete (apply-partially #'org-ref-crefrange-complete "crefrange")
-                        :activate-func #'org-ref-ref-activate
-                        :follow #'org-ref-ref-jump-to
-                        :export #'org-ref-crefrange-export
-                        :face 'org-ref-ref-face
-                        :help-echo #'org-ref-ref-help-echo)
-
-
-(org-link-set-parameters "Crefrange"
-                        :complete (apply-partially #'org-ref-crefrange-complete "Crefrange")
-                        :activate-func #'org-ref-ref-activate
-                        :follow #'org-ref-ref-jump-to
-                        :export #'org-ref-Crefrange-export
-                        :face 'org-ref-ref-face
-                        :help-echo #'org-ref-ref-help-echo)
-
-
-;; ** remove store functions
-(defun org-ref-ref-remove-store ()
-  "Remove the store functions from ref links.
-These tend to clobber the org store links. You can use C-u C-u
-C-c C-l to not use them, but if you prefer not to use them, this
-function removes the store functions from the links."
-  (interactive)
-  (cl-loop for reflink in '("ref" "pageref" "nameref" "eqref" "autoref" "Autoref"
-                           "cref" "Cref" "crefrange" "Crefrange")
-          do
-          (setf (cdr (assoc reflink org-link-parameters))
-                (org-plist-delete (cdr (assoc reflink org-link-parameters)) :store))))
-
-;; * Insert link
-(defvar org-ref-equation-environments
-  '("equation"
-    "equation*"
-    "align"
-    "align*"
-    "multline"
-    "multline*")
-  "LaTeX environments that should be treated as equations when referencing.")
-
-
-(defvar org-ref-ref-type-inference-alist
-  '((org-ref-equation-label-p . "eqref"))
-  "Alist of predicate functions taking a label name and the
-  desired reference type if the predicate returns true.")
-
-
-(defun org-ref-enclosing-environment (label)
-  "Returns the name of the innermost LaTeX environment containing
-the first instance of the label, or nil of there is none."
-  (or
-   (save-excursion
-     (save-restriction
-       (widen)
-       (goto-char (point-min))
-       (let ((label-point (search-forward (format "\\label{%s}" label) nil t)))
-        (when label-point
-           (catch 'return
-             (let (last-begin-point last-env)
-               (while (setq
-                       last-begin-point (re-search-backward "\\\\begin{\\([^}]+\\)}" nil t)
-                       last-env (match-string-no-properties 1))
-                (let ((env-end-point
-                       (search-forward (format "\\end{%s}" last-env) nil t)))
-                   (if (and env-end-point
-                            (> env-end-point label-point))
-                       (throw 'return last-env)
-                     (goto-char last-begin-point))))))))))
-   ;; Check latex-environments for names, and matching environment
-   (org-element-map (org-element-parse-buffer) 'latex-environment
-     (lambda (le)
-       (when (and (string= label (org-element-property :name le))
-                 (string-match
-                  (concat "begin{\\("
-                          (regexp-opt org-ref-equation-environments)
-                          "\\)}")
-                  (org-element-property :value le)))
-        (match-string 1 (org-element-property :value le))))
-     nil t)))
-
-
-(defun org-ref-equation-label-p (label)
-  "Return non-nil if LABEL is an equation label."
-  (let ((maybe-env (org-ref-enclosing-environment label)))
-    (when maybe-env
-      (member maybe-env org-ref-equation-environments))))
-
-
-(defun org-ref-infer-ref-type (label)
-  "Return inferred type for LABEL."
-  (or (cl-dolist (pred-pair org-ref-ref-type-inference-alist)
-       (when (funcall (car pred-pair) label)
-         (cl-return (eval (cdr pred-pair)))))
-      org-ref-default-ref-type))
-
-
-(defun org-ref-ref-link-p ()
-  "Return the link at point if point is on a ref link."
-  (let ((el (org-element-context)))
-    (and (eq (org-element-type el) 'link)
-        (assoc (org-element-property :type el) org-ref-ref-types)
-        el)))
-
-
-(defun org-ref-select-label ()
-  "Select a label in the buffer with annotated completion."
-  (let*  ((type-annotation (lambda (s)
-                            (let ((item (assoc s minibuffer-completion-table))) 
-                              (when item
-                                (with-temp-buffer
-                                  (insert "\n" (cdr item))
-                                  (indent-rigidly (point-min) (point-max) 20)
-                                  (buffer-string))))))
-         (completion-extra-properties `(:annotation-function ,type-annotation)))
-    (completing-read "Label: " (org-ref-get-labels))))
-
-
-(defun org-ref-insert-ref-link (&optional set-type)
-  "Insert a ref link.
-If on a link, append a label to the end.
-With a prefix arg SET-TYPE choose the ref type."
-  (interactive "P")
-  (let* ((minibuffer-setup-hook '(org-ref-minibuffer-prefix))
-        (label (org-ref-select-label)) 
-        (type (if (or set-type org-ref-prefix-arg)
-                  (org-ref-select-ref-type)
-                ;; in general, we prefer to infer the type, so that equations
-                ;; get a better default. However, if you customize
-                ;; `org-ref-default-ref-type', we use that instead. The most
-                ;; common use case for this is setting that variable to cref,
-                ;; which does its own automatic inference of the type.
-                (if (string= "ref" org-ref-default-ref-type)
-                    (org-ref-infer-ref-type label)
-                  org-ref-default-ref-type))))
-    (if-let* ((lnk (org-ref-ref-link-p))
-             (path (org-element-property :path lnk))
-             (beg (org-element-property :begin lnk))
-             (end (org-element-property :end lnk)))
-       (progn
-         (setf (plist-get (cadr lnk) :path) (concat path "," label))
-         (cl--set-buffer-substring beg end (org-element-interpret-data lnk)))
-
-      (insert (format  "%s:%s" type label)))
-    (goto-char (org-element-property :end (org-element-context)))))
-
-
-(provide 'org-ref-ref-links)
-
-;;; org-ref-ref-links.el ends here
diff --git a/elpa/org-ref-20241124.2012/org-ref-refproc.el b/elpa/org-ref-20241124.2012/org-ref-refproc.el
deleted file mode 100644 (file)
index 4d79e9e..0000000
+++ /dev/null
@@ -1,481 +0,0 @@
-;;; org-ref-refproc.el --- refproc - for exporting ref links in non-LaTeX backends -*- lexical-binding: t; -*-
-
-;; For autoref and cref* links, a clever prefix is added at export.
-;; Prefixes are found in `org-ref-refproc-clever-prefixes'
-;; Use a keyword like this to set the style of clever prefixes. You can use a full or abbreviated prefix
-;;
-;; #+refproc: :abbreviate t :capitalize t
-
-
-;;; Commentary:
-;;
-
-;;; Code:
-(require 'org-ref-ref-links)
-
-
-(defcustom org-ref-refproc-clever-prefixes
-  '((section :full "section" :abbrv "sec." :org-element headline)
-    (figure :full "figure" :abbrv "fig." :org-element link)
-    (table :full "table" :abbrv "tab." :org-element table)
-    (equation :full "equation" :abbrv "eq." :org-element latex-environment)
-    (proof :full "proof" :abbrv "pf." :org-element latex-environment)
-    (listing :full "listing" :abbrv "lst." :org-element src-block)
-    (lemma :full "lemma" :abbrv "lem." :org-element special-block)
-    (theorem :full "theorem" :abbrv "thm." :org-element special-block)
-    (corollary :full "corollary" :abbrv "cor." :org-element special-block))
-  "Prefixes for cleveref links.
-plist with :full and :abbrv forms for each type.
-:org-element is the element these are defined in."
-  :type 'sexp
-  :group 'org-ref)
-
-
-
-;; * refproc
-;;
-
-(defun org-ref-refproc-get-options ()
-  "Return a plist of options from a #+refproc keyword.
-Supported options are:
-:abbreviate (nil or non-nil)
-:capitalize (nil or non-nil)
-
-These options only affect the cref* links."
-  (read (format "(%s)" (cadr (assoc "REFPROC"
-                                   (org-collect-keywords
-                                    '("REFPROC")))))))
-
-
-(defun org-ref-get-ref-links ()
-  "Return a list of ref links in the buffer."
-  (org-element-map (org-element-parse-buffer) 'link
-    (lambda (lnk)
-      (when (assoc (org-element-property :type lnk) org-ref-ref-types)
-       lnk))))
-
-
-(defun org-ref-refproc-referenceables ()
-  "Return a list of referenceable items, grouped by type.
-This will be a list of (type label1 label2 ...).
-
-Not all styles of target are currently supported. This supports
-named tables, figures and src-blocks, headlines with a custom_id,
-and latex_environments with a latex label or name (these are all
-considered equations, which might be wrong for other
-environments)."
-  (let* ((parse-data (org-element-parse-buffer))
-        type el
-        ;; for each type, we specify what org-element to get the labels from.
-        (referencables (cl-loop for entry in org-ref-refproc-clever-prefixes
-                                do
-                                (setq type (car entry)
-                                      el (plist-get (cdr entry) :org-element))
-                                collect
-                                (cons type
-                                      (org-element-map parse-data el
-                                        (lambda (e)
-                                          (pcase el
-                                            ;; Headlines
-                                            ('headline
-                                             (cond
-                                              ;; There is a custom_id, we use it.
-                                              ((org-element-property :CUSTOM_ID e)
-                                               (org-element-property :CUSTOM_ID e))
-                                              ;; See if there is a target in the heading
-                                              ((string-match org-target-regexp
-                                                             (org-element-property :raw-value e))
-                                               (match-string 1 (org-element-property :raw-value e)))
-                                              ;; Check for a label link
-                                              ((string-match (concat "label:" org-ref-label-re)
-                                                             (org-element-property :raw-value e))
-                                               (match-string 1 (org-element-property :raw-value e)))))
-
-                                            ;;  Figures
-                                            ('link
-                                             (cond
-                                              ;; file link with a name property
-                                              ((and (org-file-image-p (org-element-property :path e))
-                                                    (org-element-property
-                                                     :name (org-element-property :parent e)))
-                                               (org-element-property
-                                                :name (org-element-property :parent e)))
-                                              ;; a label link in the caption
-                                              ((and  (org-file-image-p (org-element-property :path e))
-                                                     (org-element-property
-                                                      :caption (org-element-property :parent e))
-
-                                                     (string-match (concat "label:" org-ref-label-re)
-                                                                   (org-element-interpret-data
-                                                                    (org-element-property
-                                                                     :caption
-                                                                     (org-element-property :parent e)))))
-                                               (match-string 1 (org-element-interpret-data
-                                                                (org-element-property
-                                                                 :caption
-                                                                 (org-element-property :parent e)))))))
-
-                                            ;; Tables
-                                            ('table
-                                             (cond
-                                              ;; A name keyword is preferred
-                                              ((org-element-property :name e)
-                                               (org-element-property :name e))
-                                              ;; a label link in a caption also works
-                                              ((string-match (concat "label:" org-ref-label-re)
-                                                             (or (org-element-interpret-data
-                                                                  (org-element-property :caption e))
-                                                                 ""))
-                                               (match-string 1 (org-element-interpret-data
-                                                                (org-element-property :caption e))))))
-
-                                            ;; equations, proofs, and other latex environments
-                                            ('latex-environment
-                                             (when (or (and (eq type 'equation)
-                                                            (string-match "\\\\begin{equation}"
-                                                                          (org-element-property :value e)))
-                                                       (and (eq type 'equation)
-                                                            (string-match "\\\\begin{align}"
-                                                                          (org-element-property :value e)))
-                                                       (and (eq type 'proof) (string-match "\\\\begin{proof}"
-                                                                                           (org-element-property :value e))))
-
-                                               (cond
-                                                ;; Name keyword
-                                                ((org-element-property :name e)
-                                                 (org-element-property :name e))
-
-                                                ;; latex label in the value
-                                                ((string-match "\\\\label{\\(.*\\)}" (org-element-property :value e))
-                                                 (save-match-data
-                                                   (let ((pos 1)
-                                                         matches)
-                                                     (while (string-match "\\\\label{\\(.*\\)}" (org-element-property :value e) pos)
-                                                       (push (match-string 1 (org-element-property :value e)) matches)
-                                                       (setq pos (match-end 0)))
-                                                     matches))))))
-
-                                            ;; special blocks
-                                            ('special-block
-                                             (cond
-                                              ((and (eq type 'lemma)
-                                                    (org-element-property :name e)
-                                                    (string= "lemma" (org-element-property :type e)))
-                                               (org-element-property :name e))
-                                              
-                                              ((and (eq type 'corollary)
-                                                    (org-element-property :name e)
-                                                    (string= "corollary" (org-element-property :type e)))
-                                               (org-element-property :name e))
-
-                                              ((and (eq type 'theorem)
-                                                    (org-element-property :name e)
-                                                    (string= "theorem" (org-element-property :type e)))
-                                               (org-element-property :name e))))
-
-
-                                            ;; Listings of code blocks
-                                            ('src-block
-                                             (when-let (name (org-element-property :name e))
-                                               name)))))))))
-    ;; the align equation environment needs to be flattened
-    (cl-loop for type in referencables
-            collect (cons (car type) (-flatten (cdr type))))))
-
-
-(defun org-ref-refproc-get-type (label referenceables)
-  "Get the type of reference LABEL refers to.
-REFERENCEABLES comes from `org-ref-refproc-referenceables'.
-Returns a plist (:type type :label label :index index)"
-  (cl-loop for type in referenceables
-          if (member label type)
-          return (list :type (car  type) :label label :index (seq-position (cdr type) label 'equal))))
-
-
-(defun org-ref-refproc-group-sort-labels (lbls referenceables)
-  "Group and sort the labels in LBLS.
-REFERENCEABLES comes from `org-ref-refproc-referenceables'.
-Returns a list of (list (type l1 i1) (type l2, i2)...) where l1
-is label1, i1 is index1, etc.
-
-This data structure has all the references from a single link
-grouped by type. For some links there will only be one type, and
-one label, because that is all that is allowed, e.g. for ref,
-eqref, pageref, nameref and autoref.
-
-For the cref* links though you can have many labels, even to
-different kinds of things, and these are why we do the fancy
-grouping and sorting here."
-
-  (cl-loop for entry in
-          (seq-group-by (lambda (el)
-                          (plist-get el :type))
-                        (cl-loop for label in lbls collect
-                                 (org-ref-refproc-get-type label referenceables)))
-          collect
-          (sort (cdr entry) (lambda (a b)
-                              (< (plist-get a :index) (plist-get b :index))))))
-
-
-;; * Refproc - a reference processor for org-mode
-;;
-;; The strategy is to compute string replacements that are just org-syntax, then
-;; replace each link with the replacement.
-(defun org-ref-refproc-replacement (ref-link referenceables backend)
-  "Compute a replacement for REF-LINK (an org-element).
-REFERENCEABLES comes from `org-ref-refproc-referenceables'.
-BACKEND is the export backend."
-  (let* ((ref-type (org-element-property :type ref-link))
-        (labels (split-string (org-element-property :path ref-link) ","))
-        (post-blanks (org-element-property :post-blank ref-link))
-        (data (cl-loop for label in labels collect (org-ref-refproc-get-type label referenceables))))
-
-    (pcase ref-type
-      ;; These types only allow one label in the reference
-      ("ref"
-       (when (>  (length data) 1)
-        (error "A ref link can only have one label in it"))
-       (setq data (cl-first data))
-       (format "[[%s%s]]%s"
-              (if (eq 'section (plist-get data :type))
-                  "#"
-                "")
-              (plist-get data :label)
-              ;; add back post blank spaces.
-              (make-string post-blanks ? )))
-
-      ("eqref"
-       (when (>  (length data) 1)
-        (error "An eqref link can only have one label in it"))
-       (setq data (cl-first data))
-       (format (if (eq backend 'html)
-                  "[[%s]]%s"
-                "([[%s]])%s")
-              (plist-get data :label)
-              ;; add back post blank spaces.
-              (make-string post-blanks ? )))
-
-      ;; This one doesn't make much sense in unpaginated exports, and I don't
-      ;; have a way to get a page number anyway, so we make this a regular ref.
-      ("pageref"
-       (when (>  (length data) 1)
-        (error "A pageref link can only have one label in it"))
-       (setq data (cl-first data))
-       (format "[[%s%s]]%s"
-              (if (eq 'section (plist-get data :type))
-                  "#"
-                "")
-              (plist-get data :label)
-              ;; add back post blank spaces.
-              (make-string post-blanks ? )))
-
-      ;; this will use the heading name, or caption of the ref
-      ("nameref"
-       (when (>  (length data) 1)
-        (error "A nameref link can only have one label in it"))
-       (setq data (cl-first data))
-
-       ;; Basically I follow the link, and depending on the ref type get a
-       ;; "name" for it. Right now there is no error if there is not a heading
-       ;; or caption, you would just get an empty string.
-       (save-excursion
-        (goto-char (org-element-property :begin ref-link))
-        (search-forward ":")
-        (org-ref-ref-jump-to (org-element-property :path ref-link))
-        (pcase (plist-get data :type)
-          ('section
-           (org-previous-visible-heading 1)
-           (format "[[#%s][%s]]%s"
-                   (plist-get data :label)
-                   (cl-fifth (org-heading-components))
-                   (make-string post-blanks ? )))
-
-          ('table
-           (format "[[%s][%s]]%s"
-                   (plist-get data :label)
-                   (org-element-interpret-data (org-element-property :caption (org-element-context)))
-                   (make-string post-blanks ? )))
-
-          ('figure
-           (format "[[%s][%s]]%s"
-                   (plist-get data :label)
-                   (org-element-interpret-data (org-element-property :caption (org-element-context)))
-                   (make-string post-blanks ? )))
-
-          ('listing
-           (format "[[%s][%s]]%s"
-                   (plist-get data :label)
-                   (org-element-interpret-data (org-element-property :caption (org-element-context)))
-                   (make-string post-blanks ? )))
-          ;; does equation even make sense? is there ever a caption?
-          (_
-           (error "The nameref link is not implemented for %S" data)))))
-
-      ;; autoref is the first place we have to be clever.
-      ("autoref"
-       (when (>  (length data) 1)
-        (error "A pageref link can only have one label in it"))
-       (setq data (cl-first data))
-
-       (let* ((prefix-data (cdr (assoc (plist-get data :type) org-ref-refproc-clever-prefixes)))
-             (options (org-ref-refproc-get-options))
-             (prefix (plist-get prefix-data  (if (plist-get options :abbreviate)
-                                                 :abbrv
-                                               :full))))
-        (when (plist-get options :capitalize) (setq prefix (capitalize prefix)))
-        (format "%s [[%s%s]]%s"
-                prefix
-                (if (eq 'section (plist-get data :type))
-                    "#"
-                  "")
-                (plist-get data :label)
-                (make-string post-blanks ? ))))
-
-      ;; Now we get to the cref* links. These are complicated, so I will pass
-      ;; this out to dedicated functions. At this point, I have the ref-link,
-      ("cref"
-       (org-ref-refproc-cref-replacement ref-link referenceables nil))
-
-      ("Cref"
-       (org-ref-refproc-cref-replacement ref-link referenceables t))
-
-      (_
-       (error "%s links are not supported yet" ref-type)))))
-
-
-(defun org-ref-refproc-cref-replacement (ref-link referenceables capitalize)
-  "Calculate a replacement for a REF-LINK.
-
-REFERENCEABLES comes from `org-ref-refproc-referenceables'.
-
-If CAPITALIZE is non-nil, capitalize the first entry (this is for
-Cref) and is different than the capitalize option in #+refproc:
-which capitalizes each prefix."
-  (let* ((options (org-ref-refproc-get-options)) 
-        (labels (split-string (org-element-property :path ref-link) ","))
-        (post-blanks (org-element-property :post-blank ref-link))
-        (data (cl-loop for label in labels collect (org-ref-refproc-get-type label referenceables)))
-        (groups (seq-group-by (lambda (entry)
-                                (plist-get entry :type))
-                              data))
-        ;; this will be a list of sorted entries.
-        (sorted-groups (cl-loop for group in groups collect
-                                (sort (cdr group) (lambda (a b)
-                                                    (< (plist-get a :index) (plist-get b :index))))))
-        ;; temp vars
-        prefix
-        prefix-data
-        ;; Now we have to be clever on each sorted group. One day I should add compression to the groups, e.g. 1,2,3 - > 1 to 3
-        ;; For each group we need a prefix, and it may have to be a plural prefix.
-        ;; If there are two members of a group, they are joined by and
-        ;; if there are more than two members of a group, they are separated by commas with and at the end.
-        (replacements (cl-loop for collection in sorted-groups collect
-                               (pcase (length collection)
-                                 ;; One thing in the list
-                                 (1
-                                  (setq collection (cl-first collection)
-                                        prefix-data (cdr (assoc (plist-get collection :type) org-ref-refproc-clever-prefixes))
-                                        prefix (plist-get  prefix-data (if (plist-get options :abbreviate)
-                                                                           :abbrv
-                                                                         :full)))
-                                  (when (plist-get options :capitalize)
-                                    (setq prefix (capitalize prefix)))
-                                  (format "%s %s"
-                                          ;; prefix
-                                          prefix
-                                          (concat
-                                           (cond
-                                            ((eq 'section (plist-get collection :type))
-                                             (format "[[#%s]]" (plist-get collection :label)))
-                                            ((eq 'equation (plist-get collection :type))
-                                             (format "\\ref{%s}" (plist-get collection :label)))
-                                            (t
-                                             (format "[[%s]]" (plist-get collection :label)))))))
-                                 (2
-                                  ;; the prefix can be found from the first label, but we have to make it plural.
-                                  (setq prefix-data (cdr (assoc (plist-get (cl-first collection) :type)
-                                                                org-ref-refproc-clever-prefixes))
-                                        prefix (plist-get  prefix-data (if (plist-get options :abbreviate)
-                                                                           :abbrv
-                                                                         :full)))
-                                  (when (plist-get options :capitalize)
-                                    (setq prefix (capitalize prefix)))
-
-                                  ;; Make it plural (substring "fig." -1)
-                                  (setq prefix (if (string= "." (substring prefix -1))
-                                                   (concat (substring prefix 0 -1) "s.")
-                                                 (concat prefix "s")))
-
-                                  (format "%s [[%s]] and [[%s]]"
-                                          prefix
-                                          (concat
-                                           (if (eq 'section (plist-get (cl-first collection) :type)) "#" "")
-                                           (plist-get (cl-first collection) :label))
-                                          (concat
-                                           (if (eq 'section (plist-get (cl-second collection) :type)) "#" "")
-                                           (plist-get (cl-second collection) :label))))
-
-                                 (_
-                                  ;; the prefix can be found from the first label, but we have to make it plural.
-                                  (setq prefix-data (cdr (assoc (plist-get (cl-first collection) :type)
-                                                                org-ref-refproc-clever-prefixes))
-                                        prefix (plist-get  prefix-data (if (plist-get options :abbreviate)
-                                                                           :abbrv
-                                                                         :full)))
-                                  (when (plist-get options :capitalize)
-                                    (setq prefix (capitalize prefix)))
-
-                                  ;; Make it plural. If the prefix ends in .
-                                  ;; (i.e. it is abbreviated) we remove it and
-                                  ;; add s.
-                                  (setq prefix (if (string= "." (substring prefix -1))
-                                                   (concat (substring prefix 0 -1) "s.")
-                                                 (concat prefix "s")))
-
-                                  ;; now get
-                                  (format "%s %s and [[%s]]"
-                                          prefix
-                                          (string-join
-                                           (cl-loop for entry in (butlast collection) collect
-                                                    (format "[[%s]]"
-                                                            (concat
-                                                             (if (eq 'section (plist-get entry :type)) "#" "")
-                                                             (plist-get entry :label))))
-                                           ", ")
-                                          ;; the last one
-                                          (concat
-                                           (if (eq 'section (plist-get (car (last collection)) :type)) "#" "")
-                                           (plist-get (car (last collection)) :label))))))))
-
-
-    (when capitalize (setf (car replacements) (concat (capitalize (substring (car replacements) 0 1)) (substring (car replacements) 1))))
-
-    ;; Finally, join them together with commas, and add post-blank spaces.
-    (concat
-     (pcase (length replacements)
-       (1
-       (cl-first replacements))
-       (2
-       (concat (cl-first replacements) " and " (cl-second replacements)))
-       (_
-       (concat (string-join (butlast replacements) ", ") " and " (car (last replacements)))))
-
-     (make-string post-blanks ? ))))
-
-
-(defun org-ref-refproc (&optional backend)
-  "Process the buffer replacing all ref links with org syntax.
-BACKEND is the
-Meant to be used in an `org-export-before-parsing-hook' on a copy
-of the buffer."
-  (let ((ref-links (org-ref-get-ref-links))
-       (referenceables (org-ref-refproc-referenceables)))
-
-    (cl-loop for ref in (reverse ref-links) do
-            (cl--set-buffer-substring (org-element-property :begin ref)
-                                      (org-element-property :end ref)
-                                      (org-ref-refproc-replacement ref referenceables backend)))))
-
-(provide 'org-ref-refproc)
-
-;;; org-ref-refproc.el ends here
diff --git a/elpa/org-ref-20241124.2012/org-ref-sci-id.el b/elpa/org-ref-20241124.2012/org-ref-sci-id.el
deleted file mode 100644 (file)
index 30b3cdd..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-;;; org-ref-sci-id.el --- org-mode links for scientific IDs  -*- lexical-binding: t; -*-
-
-;; Copyright (C) 2015-2024  John Kitchin
-
-;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
-;; Keywords:
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;; New org-mode links for scientific IDs like orcid (http://orcid.org) and researcherid (http://www.researcherid.com)
-;; orcid:0000-0003-2625-9232
-;; researcherid:A-2363-2010
-
-;;; Code:
-
-(require 'org)
-(require 'org-ref-utils)
-
-(org-link-set-parameters "orcid"
-                        :follow (lambda
-                                  (link-string)
-                                  (browse-url
-                                   (format "http://orcid.org/%s" link-string)))
-                        :export (lambda (keyword desc format)
-                                  (cond
-                                   ((eq format 'html)
-                                    (format "<a href=\"http://orcid.org/%s\">orcid:%s</a>" keyword (or desc keyword))))))
-
-(org-link-set-parameters "researcherid"
-                        :follow (lambda
-                                  (link-string)
-                                  (browse-url
-                                   (format "http://www.researcherid.com/rid/%s" link-string)))
-                        :export (lambda (keyword desc format)
-                                  (cond
-                                   ((eq format 'html)
-                                    (format "<a href=\"http://www.researcherid.com/rid/%s\">ResearcherID:%s</a>"
-                                            keyword (or desc keyword))))))
-
-(provide 'org-ref-sci-id)
-;;; org-ref-sci-id.el ends here
diff --git a/elpa/org-ref-20241124.2012/org-ref-scifinder.el b/elpa/org-ref-20241124.2012/org-ref-scifinder.el
deleted file mode 100644 (file)
index 68b6617..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-;;; org-ref-scifinder.el --- Emacs interface to SciFinder -*- lexical-binding: t; -*-
-
-;; Copyright (C) 2015-2024  John Kitchin
-
-;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
-;; Keywords:
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-;; Hopefully this eventually integrates the Scifinder API into Emacs. For now,
-;; there is just one function that opens Scifinder for you.
-
-;;; Code:
-
-;;;###autoload
-(defun scifinder ()
-  "Open https://scifinder.cas.org/scifinder/view/scifinder/scifinderExplore.jsf in a browser."
-  (interactive)
-  (browse-url "https://scifinder.cas.org/scifinder/view/scifinder/scifinderExplore.jsf"))
-
-(provide 'org-ref-scifinder)
-
-;;; org-ref-scifinder.el ends here
diff --git a/elpa/org-ref-20241124.2012/org-ref-scopus.el b/elpa/org-ref-20241124.2012/org-ref-scopus.el
deleted file mode 100644 (file)
index 66012d7..0000000
+++ /dev/null
@@ -1,222 +0,0 @@
-;;; org-ref-scopus.el --- Emacs-lisp interface to the Scopus API  -*- lexical-binding: t; -*-
-
-;; Copyright (C) 2015-2024  John Kitchin
-
-;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
-;; Keywords:
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-;;  See http://dev.elsevier.com/index.html for more information about the Scopus API
-;;
-;; New org-links:
-;; eid:2-s2.0-72649092395 with a hydra menu
-;; [[scopus-search:alloy Au segregation]]
-;; [[scopus-advanced-search:au-id(24176978500)]]
-
-;;; Code:
-
-(require 'org)
-(require 'hydra)
-(require 'xml)
-(require 'org-ref-utils)
-
-(defvar url-request-method)
-(defvar url-mime-accept-string)
-(defvar url-http-end-of-headers)
-(defvar url-request-extra-headers)
-
-(defvar *scopus-api-key* nil
-  "Your Scopus API key.
-You need to set this in your init files.  Get a key here:
-http://dev.elsevier.com/myapikey.html.")
-
-
-;; (defun scopus-doi-to-xml (doi)
-;;   "Return a parsed xml from the Scopus article retrieval api for DOI.
-;; This does not always seem to work for the most recent DOIs."
-;;   (let* ((url-request-method "GET")
-;;      (url-request-extra-headers  (list (cons "X-ELS-APIKey" *scopus-api-key*)))
-;;      (url (format  "http://api.elsevier.com/content/article/doi/%s" doi))
-;;      (xml))
-;;     (setq xml
-;;       (with-current-buffer  (url-retrieve-synchronously url)
-;;         (xml-parse-region url-http-end-of-headers (point-max))))
-;;     (if (eq 'service-error (caar xml))
-;;     (progn (message-box "%s\n%s\n%s" doi url xml)
-;;            nil)
-;;       xml)))
-
-(defun scopus-doi-to-eid (doi)
-  "Get a Scopus eid from a DOI.
-Requires `*scopus-api-key*' to be defined."
-  (unless *scopus-api-key* (error "You must define `*scopus-api-key*'"))
-  (let* ((url-request-method "GET")
-         (url-mime-accept-string "application/xml")
-         (url-request-extra-headers  (list (cons "X-ELS-APIKey" *scopus-api-key*)
-                                           '("field" . "eid")))
-         (url (format  "http://api.elsevier.com/content/search/scopus?query=doi(%s)" doi))
-         (xml (with-current-buffer  (url-retrieve-synchronously url)
-                (xml-parse-region url-http-end-of-headers (point-max))))
-         (results (car xml))
-         (entry (car (xml-get-children results 'entry))))
-    (car (xml-node-children (car (xml-get-children entry 'eid))))))
-
-
-;;;###autoload
-(defun scopus-related-by-keyword-url (doi)
-  "Return a Scopus url to articles related by keyword for DOI."
-  (interactive)
-  (unless *scopus-api-key* (error "You must define `*scopus-api-key*'"))
-  (let ((eid (scopus-doi-to-eid doi)))
-    (when eid (format "http://www.scopus.com/search/submit/mlt.url?eid=%s&src=s&all=true&origin=recordpage&method=key&zone=relatedDocuments" eid))))
-
-
-;;;###autoload
-(defun scopus-related-by-author-url (doi)
-  "Return a Scopus url to articles related by author for DOI."
-  (interactive)
-  (unless *scopus-api-key* (error "You must define `*scopus-api-key*'"))
-  (let ((eid (scopus-doi-to-eid doi)))
-    (when eid (format "http://www.scopus.com/search/submit/mlt.url?eid=%s&src=s&all=true&origin=recordpage&method=aut&zone=relatedDocuments" eid))))
-
-
-;;;###autoload
-(defun scopus-related-by-references-url (doi)
-  "Return a Scopus url to articles related by references for DOI."
-  (interactive)
-  (unless *scopus-api-key* (error "You must define `*scopus-api-key*'"))
-  (let ((eid (scopus-doi-to-eid doi)))
-    (when eid (format "http://www.scopus.com/search/submit/mlt.url?eid=%s&src=s&all=true&origin=recordpage&method=ref&zone=relatedDocuments" eid))))
-
-
-(defun scopus-citing-url (doi)
-  "Return a Scopus url to articles citing DOI."
-  (format "http://www.scopus.com/results/citedbyresults.url?sort=plf-f&cite=%s&src=s&imp=t&sot=cite&sdt=a&sl=0&origin=recordpage" (scopus-doi-to-eid doi)))
-
-
-;;;###autoload
-(defun scopus-open-eid (eid)
-  "Open article with EID in browser."
-  (interactive "sEID: ")
-  (browse-url (format "http://www.scopus.com/record/display.url?eid=%s&origin=resultslist" eid)))
-
-
-(defun scopus ()
-  "Open http://scopus.com is a browser."
-  (browse-url "http://www.scopus.com"))
-
-
-;;;###autoload
-(defun scopus-basic-search (query)
-  "Open QUERY as a basic title-abstract-keyword search at scopus.com."
-  (interactive "sQuery: ")
-  (browse-url
-   (format
-    "http://www.scopus.com/results/results.url?sort=plf-f&src=s&sot=b&sdt=b&sl=%s&s=TITLE-ABS-KEY%%28%s%%29&origin=searchbasic"
-    (length (url-unhex-string (concat "TITLE-ABS-KEY%28" (url-hexify-string query) "%29")))
-    (url-hexify-string query))))
-
-
-;;;###autoload
-(defun scopus-advanced-search (query)
-  "Open QUERY as an advanced search at scopus.com."
-  (interactive "sQuery: ")
-  (browse-url
-   (format
-    "http://www.scopus.com/results/results.url?sort=plf-f&src=s&sot=a&sdt=a&sl=%s&s=%s&origin=searchadvanced"
-    (length query)
-    (url-hexify-string query))))
-
-
-;;; Org-mode EID link and an action menu
-;; These functions use a global var *hydra-eid*
-(defvar *hydra-eid* nil
-  "Global variable to pass an EID from an ‘org-mode’ link to a hydra function.")
-
-
-(defhydra scopus-hydra (:color blue)
-  ("o" (scopus-open-eid *hydra-eid*) "Open in Scopus")
-  ("a" (browse-url (format "http://www.scopus.com/search/submit/mlt.url?eid=%s&src=s&all=true&origin=recordpage&method=aut&zone=relatedDocuments" *hydra-eid*))
-   "Related by author")
-  ("k" (browse-url (format "http://www.scopus.com/search/submit/mlt.url?eid=%s&src=s&all=true&origin=recordpage&method=key&zone=relatedDocuments" *hydra-eid*))
-   "Related by keyword")
-  ("r" (browse-url (format "http://www.scopus.com/search/submit/mlt.url?eid=%s&src=s&all=true&origin=recordpage&method=ref&zone=relatedDocuments" *hydra-eid*))
-   "Related by references")
-  ("c" (browse-url (format "http://www.scopus.com/results/citedbyresults.url?sort=plf-f&cite=%s&src=s&imp=t&sot=cite&sdt=a&sl=0&origin=recordpage" *hydra-eid*))
-   "Citing articles"))
-
-
-(org-link-set-parameters "eid"
-                        :follow (lambda (eid)
-                                  "Opens the hydra menu."
-                                  (setq *hydra-eid* eid)
-                                  (scopus-hydra/body))
-                        :export (lambda (keyword desc format)
-                                  (cond
-                                   ((eq format 'html)
-                                    (format "<a href=\" http://www.scopus.com/record/display.url?eid=%s&origin=resultslist\">%s</a>" keyword (or desc keyword)))
-                                   ((eq format 'latex)
-                                    (format "\\href{http://www.scopus.com/record/display.url?eid=%s&origin=resultslist}{%s}"
-                                            keyword (or desc keyword))))))
-
-
-(org-link-set-parameters "scopus-search"
-                        :follow (lambda (query)
-                                  (scopus-basic-search query))
-                        :export (lambda (query desc format)
-                                  (let ((url (format
-                                              "http://www.scopus.com/results/results.url?sort=plf-f&src=s&sot=b&sdt=b&sl=%s&s=TITLE-ABS-KEY%%28%s%%29&origin=searchbasic"
-                                              (length (url-unhex-string (concat "TITLE-ABS-KEY%28" (url-hexify-string query) "%29")))
-                                              (url-hexify-string query))))
-                                    (cond
-                                     ((eq format 'html)
-                                      (format "<a href=\"%s\">%s</a>" url (or desc query)))
-                                     ((eq format 'latex)
-                                      (format "\\href{%s}{%s}" url (or desc query)))))))
-
-(org-link-set-parameters "scopus-advanced-search"
-                        :follow (lambda (query)
-                                  (scopus-advanced-search query))
-                        :export (lambda (query desc format)
-                                  (let ((url (format
-                                              "http://www.scopus.com/results/results.url?sort=plf-f&src=s&sot=a&sdt=a&sl=%s&s=%s&origin=searchadvanced"
-                                              (length (url-hexify-string query))
-                                              (url-hexify-string query))))
-                                    (cond
-                                     ((eq format 'html)
-                                      (format "<a href=\"%s\">%s</a>" url (or desc query)))
-                                     ((eq format 'latex)
-                                      (format "\\href{%s}{%s}" url (or desc query)))))))
-
-(org-link-set-parameters "scopusid"
-                        :follow (lambda
-                                  (link-string)
-                                  (browse-url
-                                   (format
-                                    "http://www.scopus.com/authid/detail.url?origin=AuthorProfile&authorId=%s"
-                                    link-string)))
-                        :export (lambda (keyword desc format)
-                                  (cond
-                                   ((eq format 'latex)
-                                    (format "\\href{http://www.scopus.com/authid/detail.url?origin=AuthorProfile&authorId=%s}{%s}"
-                                            keyword (or desc (concat "scopusid:" keyword))))
-                                   ((eq format 'html)
-                                    (format "<a href=\"http://www.scopus.com/authid/detail.url?origin=AuthorProfile&authorId=%s\">%s</a>"
-                                            keyword (or desc (concat "scopusid:" keyword)))))))
-
-
-(provide 'org-ref-scopus)
-;;; org-ref-scopus.el ends here
diff --git a/elpa/org-ref-20241124.2012/org-ref-url-utils.el b/elpa/org-ref-20241124.2012/org-ref-url-utils.el
deleted file mode 100644 (file)
index 3481c42..0000000
+++ /dev/null
@@ -1,310 +0,0 @@
-;;; org-ref-url-utils.el --- Utility functions to scrape DOIs from urls  -*- lexical-binding: t; -*-
-
-;; Copyright (C) 2015-2024  John Kitchin
-
-;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
-;; Keywords:
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;; Drag a webpage onto a bibtex file to insert a bibtex entry.
-;;
-;; [2021-08-29 Sun] I have not found drag-and-drop reliable or convenient. I
-;; don't recommend using this, but I am also not deleting it (yet).
-
-;; This works by scraping DOIs from the content at the URL using patterns in
-;; `org-ref-doi-regexps'. If one DOI is found, it is added as an entry. If
-;; multiple DOIs are found, you will get a selection buffer to choose what
-;; you want to add. You can add new patterns to `org-ref-doi-regexps'.
-
-;; You can press Control to "debug" a URL, which will open a buffer of the
-;; content with the current DOI patterns highlighted. If you want to get all the
-;; DOIs at a URL, you can press Meta during the drag-n-drop.
-
-;; You can also insert formatted bibtex entries using the
-;; `org-ref-url-html-to-bibtex' command, which converts a web page to
-;; bibtex or biblatex entry using URL. The org-cliplink package can
-;; help cleanup HTML code. Installing it is recommended.
-
-;;; Code:
-(defvar org-ref-bibliography-entry-format)
-(defvar org-ref-cite-types)
-(defvar org-cliplink-escape-alist)
-
-(declare-function 'org-ref-get-bibtex-key-and-file "org-ref-core.el")
-(declare-function 'org-ref-find-bibliography "org-ref-core.el")
-
-(declare-function dnd-handle-one-url "dnd")
-(declare-function dnd--unescape-uri "dnd")
-
-(require 'doi-utils)
-(require 'f)
-(require 's)
-(eval-when-compile
-  (require 'cl-lib))
-
-
-(defgroup org-ref-url nil
-  "Customization group for org-ref-url-utils"
-  :tag "Org Ref URL"
-  :group 'org-ref-url-utils)
-
-
-(defcustom org-ref-doi-regexps
-  '("scheme=\"doi\" content=\"\\([^\"]*\\)\""
-    "citation_doi\" content=\"\\([^\"]*\\)\""
-    "data-doi=\"\\([^\"]*\\)\""
-    "content=\"\\([^\"]*\\)\" name=\"citation_doi"
-    "objectDOI\" : \"\\([^\"]*\\)\""
-    "doi = '\\([^']*\\)'"
-    "\"http://dx.doi.org/\\([^\"]*\\)\""
-    "/doi/\\([^\"]*\\)\">"
-    "doi/full/\\(.*\\)&"
-    "doi=\\([^&]*\\)&amp")
-  "List of regexps to match a DOI.
-The doi should be in group 1 so that (match-string 1) contains
-the DOI."
-  :type '(repeat regexp)
-  :group 'org-ref-url-utils)
-
-
-(defvar org-ref-url-title-re
-  "<title.?+?>\\([[:ascii:][:nonascii:]]*?\\|.+\\)</title>"
-  "Regular expression for matching title.")
-
-
-(defvar org-ref-url-author-re
-  "<meta name=\"author\" content=\"\\(.+\\)\"\s?/?>"
-  "Regular expression for matching author.")
-
-
-(defvar org-ref-url-date-re
-  "<[a-z].+ class=\\(.?+date.[^>]*\\)>\\([[:ascii:][:nonascii:]]*?\\)</[a-z].+>"
-  "Regular expression for matching date.")
-
-
-(defvar org-ref-url-bibtex-template
-  "@misc{key,
-  title        = {${:title}},
-  author       = {${:author}},
-  howpublished = {${:url}},
-  year         = {${:year}},
-  note         = {Online; accessed ${:urldate}}
-}"
-  "BibTeX entry template for online sources.")
-
-(defvar org-ref-url-biblatex-template
-  "@online{key,
-title   = {${:title}},
-author  = {${:author}},
-url     = {${:url}}
-year    = {${:year}},
-urldate = {Online; accessed ${:urldate}}
-}"
-  "Biblatex entry template for online sources.")
-
-
-;;* Scrape DOIs from a URL
-
-(defun org-ref-url-scrape-dois (url)
-  "Scrape all dois from a URL matching a pattern in `org-ref-doi-regexps'.
-Returns a list of collected DOIs in the order found."
-  (let ((dois '()))
-    (with-current-buffer (url-retrieve-synchronously url)
-      (cl-loop for doi-pattern in org-ref-doi-regexps
-              do
-              (goto-char (point-min))
-              (while (re-search-forward doi-pattern nil t)
-                (cl-pushnew (match-string 1) dois :test #'equal)))
-      (reverse dois))))
-
-
-(defun org-ref-url-dnd-protocol (url action)
-  "Protocol function for use in `dnd-protocol-alist'.
-We scrape DOIs from the url first. If there is one, we add it. If
-there is more than one, we offer a completion buffer of selections. If
-no DOI is found, we create a misc entry, with a prompt for a key."
-  ;; make sure we are on a bib-file
-  (if (and (buffer-file-name)
-          (f-ext? (buffer-file-name) "bib"))
-      (let ((dois (org-ref-url-scrape-dois url)))
-       (cond
-        ;; One doi found. Assume it is what we want.
-        ((= 1 (length dois))
-         (doi-utils-add-bibtex-entry-from-doi
-          (car dois)
-          (buffer-file-name))
-         action)
-        ;; Multiple DOIs found
-        ((> (length dois) 1)
-         (let ((doi (completing-read "Select a DOI: " dois)))
-           (doi-utils-add-bibtex-entry-from-doi doi (buffer-file-name))))
-        ;; No DOIs found, add a misc entry.
-        (t
-          (org-ref-url-html-to-bibtex (buffer-file-name) url)
-         action)))
-    ;; pass back to dnd. Copied from `org-download-dnd'. Apparently
-    ;; returning nil does not do this.
-    (let ((dnd-protocol-alist
-          (rassq-delete-all
-           'org-ref-url-dnd-protocol
-           (copy-alist dnd-protocol-alist))))
-      (dnd-handle-one-url nil action url))))
-
-
-(add-to-list 'dnd-protocol-alist '("^https?" . org-ref-url-dnd-protocol))
-
-;;* Enable a DOI to be dragged onto a bibtex buffer
-(defun org-ref-doi-dnd-protocol (doi action)
-  "Protocol for when a doi is dragged onto a bibtex file.
-A doi will be either doi:10.xxx  or 10.xxx."
-  (if (and (buffer-file-name)
-          (f-ext? (buffer-file-name) "bib"))
-      (let ((doi (dnd--unescape-uri doi)))
-       ;; Get the actual doi now
-       (string-match "\\(?:DOI\\|doi\\)?:? *\\(10.*\\)" doi)
-       (setq doi (match-string 1 doi))
-       (when doi
-         (doi-add-bibtex-entry doi (buffer-file-name))
-         (save-buffer)
-         action))
-    ;; not on a bib file
-    (let ((dnd-protocol-alist
-          (rassq-delete-all
-           'org-ref-url-dnd-protocol
-           (copy-alist dnd-protocol-alist))))
-      (dnd-handle-one-url nil action doi))))
-
-(add-to-list 'dnd-protocol-alist '("^doi" . org-ref-doi-dnd-protocol))
-(add-to-list 'dnd-protocol-alist '("^10" . org-ref-doi-dnd-protocol))
-
-
-;;* Debugging DOIs from a URL
-
-;; You can use this to see if there are any DOIs in a URL, and to use re-builder
-;; to add new patterns to `org-ref-doi-regexps'.
-;;;###autoload
-(defun org-ref-url-debug-url (url)
-  "Open a buffer to URL with all doi patterns highlighted."
-  (interactive "sURL: ")
-  (switch-to-buffer
-   (url-retrieve-synchronously url))
-  (highlight-regexp
-   (mapconcat 'identity org-ref-doi-regexps "\\|")))
-
-
-;;* HTML to BibTeX functions
-
-(defun org-ref-url-html-replace (string)
-  "Replace HTML entities in STRING with their unicode equivalent."
-  (let (result
-       (case-fold-search nil))
-    (with-temp-buffer
-      (insert string)
-      (mapc (lambda (char)
-             (goto-char (point-min))
-             (while (re-search-forward (car char) nil t)
-               (replace-match (cdr char))))
-           org-cliplink-escape-alist)
-      (setq result (buffer-substring (point-min) (point-max))))
-    result))
-
-
-(defun org-ref-url-add-nil (list)
-  "Add nil to all missing keys in LIST."
-  (let (newlist)
-    (mapc (lambda (key)
-           (unless (alist-get key list)
-             (push (cons key "nil") newlist)))
-         (list :title :author :url :urldate :year))
-    (append list newlist)))
-
-
-(defun org-ref-url-html-read (url)
-  "Read URL content and return fields.
-Fields include author, title, url, urldate, and year."
-  ;; Start with fields we already know
-  (let ((fields `((:url . ,url)
-                 (:urldate . ,(format-time-string "%d %B %Y")))))
-    (with-current-buffer
-       (url-retrieve-synchronously url t t)
-
-      ;; find pubdate
-      (goto-char (point-min))
-      (when (re-search-forward org-ref-url-date-re nil t)
-       (let ((string (match-string 2)))
-         (when (string-match "\\([0-9]\\{4\\}\\)" string)
-           (push (cons :year (match-string 1 string)) fields))))
-
-      ;; find author
-      (goto-char (point-min))
-      (let ((author (if (re-search-forward org-ref-url-author-re nil t)
-                        (match-string 1)
-                      "Unknown")))
-        (push (cons :author author) fields))
-
-      ;; find title
-      (goto-char (point-min))
-      (when (re-search-forward org-ref-url-title-re nil t)
-       (push (cons :title
-                   (s-trim (decode-coding-string (match-string 1) 'utf-8)))
-             fields)))
-
-    ;; Finally add nil value to missing fields
-    (org-ref-url-add-nil fields)))
-
-
-;;;###autoload
-(defun org-ref-url-html-to-bibtex (bibfile &optional url)
-  "Convert URL to a bibtex or biblatex entry in BIBFILE.
-If URL is the first in the kill ring, use it. Otherwise, prompt for
-one in the minibuffer."
-  (interactive (if (-contains? (org-ref-find-bibliography) (buffer-file-name))
-                  (list (buffer-file-name))
-                (list (completing-read "Bibtex file: " (org-ref-find-bibliography)))))
-  (let ((url (if url url
-              (if (s-match "^http" (current-kill 0 'do-not-move))
-                  (format "%s" (current-kill 0 'do-not-move))
-                (read-from-minibuffer "URL: ")))))
-    (with-current-buffer
-       (find-file-noselect bibfile)
-      ;; Maybe check dialect if set as local variable
-      (let* ((dialect bibtex-dialect)
-            (alist (org-ref-url-html-read url))
-            (entry (s-format
-                    ;; Check dialect and format entry accordingly
-                    (if (eq dialect 'biblatex)
-                        org-ref-url-biblatex-template
-                      org-ref-url-bibtex-template)
-                    'aget alist)))
-       (goto-char (point-max))
-       ;; Place new entry one line after the last entry. Sometimes we are in a
-       ;; new file though, in which case we don't want to do this.
-       (unless (bobp)
-         (while (not (looking-back "^}\n" 2))
-           (delete-char -1)))
-       (insert "\n")
-       (insert (if (require 'org-cliplink nil 'noerror)
-                   ;; Sanitize values by replacing html entities
-                   (org-ref-url-html-replace entry)
-                 entry))
-       (insert "\n")
-       (bibtex-beginning-of-entry)
-       (org-ref-clean-bibtex-entry)
-       (save-buffer)))))
-
-(provide 'org-ref-url-utils)
-;;; org-ref-url-utils.el ends here
diff --git a/elpa/org-ref-20241124.2012/org-ref-utils.el b/elpa/org-ref-20241124.2012/org-ref-utils.el
deleted file mode 100644 (file)
index 256febb..0000000
+++ /dev/null
@@ -1,1298 +0,0 @@
-;;; org-ref-utils.el --- Utility functions for org-ref  -*- lexical-binding: t; -*-
-
-;; Copyright (C) 2016-2024  John Kitchin
-
-;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
-;; Keywords:
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;;
-
-(eval-when-compile (require 'cl-lib))
-
-(require 'org)
-(eval-and-compile (require 'org-macs))
-
-
-(defvar org-ref-cite-types)
-(defvar pdftotext-executable)
-
-(declare-function 'org-ref-get-bibtex-key-and-file "org-ref-core.el")
-(declare-function 'org-ref-find-bibliography "org-ref-core.el")
-(declare-function 'org-ref-bib-citation "org-ref-core.el")
-(declare-function 'org-ref-get-bibtex-key-under-cursor "org-ref-core.el")
-
-;;; Code:
-;;;###autoload
-(defun org-ref-version ()
-  "Provide a version string for org-ref.
-Copies the string to the clipboard."
-  (interactive)
-  ;; version in the el file.
-  (let* ((org-ref-el (concat
-                     (file-name-sans-extension
-                      (locate-library "org-ref"))
-                     ".el"))
-        (org-ref-dir (file-name-directory org-ref-el))
-        org-version
-        git-commit
-        version-string)
-
-    (setq org-version (with-temp-buffer
-                       (insert-file-contents org-ref-el)
-                       (goto-char (point-min))
-                       (if
-                           (re-search-forward ";; Version:" nil t)
-                           (s-trim (buffer-substring (point)
-                                                     (line-end-position)))
-                         org-ref-dir)))
-
-    (setq git-commit
-         ;; If in git, get current commit
-         (let ((default-directory org-ref-dir))
-           (when (and
-                  ;; this is tricky, as a submodule, .git is a file
-                  (or (file-directory-p ".git") (file-exists-p ".git"))
-                  (= 0 (shell-command "git rev-parse --git-dir")))
-             (format "%s in %s"
-                     (s-trim (shell-command-to-string "git rev-parse HEAD"))
-                     (s-trim (shell-command-to-string "git rev-parse --show-toplevel"))))))
-
-    (setq version-string (format "org-ref: Version %s%s"
-                                org-version
-                                (if git-commit
-                                    (format " (git-commit %s)" git-commit)
-                                  "")))
-    (kill-new version-string)
-    (message version-string)))
-
-
-(defun org-ref-report-issue ()
-  "Report an issue in org-ref.
-Opens https://github.com/jkitchin/org-ref/issues/new."
-  (save-window-excursion
-    (org-ref-debug)
-    (kill-new (buffer-string)))
-  (message "org-ref-debug has been run. You can paste the results in the issue website if you like.")
-  (browse-url "https://github.com/jkitchin/org-ref/issues/new"))
-
-
-;;* Debug
-;; this is just for me to have a nicer debug statement.
-(defmacro ords (&rest body)
-  "Evaluate BODY and return a string."
-  `(format "%s" (progn ,@body)))
-
-
-;;;###autoload
-(defun org-ref-debug ()
-  "Print some debug information to a buffer."
-  (interactive)
-  (switch-to-buffer "*org-ref-debug*")
-  (erase-buffer)
-  (org-mode)
-  (insert
-   (s-format "#+TITLE: org-ref debug
-
-${org-ref-version}
-
-* System
-
-- system-type :: ${system}
-- system-configuration :: ${system-configuration}
-- window system :: ${window-system}
-- Emacs :: ${emacs-version}
-- org-version :: ${org-version}
-
-* about org-ref
-
-org-ref installed in [[${org-ref-location}]].
-
-* org-ref setup
-
--  org-ref-insert-link-function :: ${org-ref-insert-link-function}
--  org-ref-insert-cite-function :: ${org-ref-insert-cite-function}
--  org-ref-insert-label-function :: ${org-ref-insert-label-function}
--  org-ref-insert-ref-function :: ${org-ref-insert-ref-function}
--  org-ref-cite-onclick-function :: ${org-ref-cite-onclick-function}
-
-* bibtex-completion setup
-
-- bibtex-completion-bibliography :: ${bibtex-completion-bibliography}
-- bibtex-completion-library-path :: ${bibtex-completion-library-path}
-- bibtex-completion-notes-path :: ${bibtex-completion-notes-path}
-
-* org-ref libraries
-
-** org-ref-helm (loaded: ${org-ref-helm-p})
-** org-ref-ivy  (loaded: ${org-ref-ivy-p})
-** org-ref-pdf (loaded: ${org-ref-pdf-p})
-
-- system pdftotext :: ${pdftotext}
-
-You set =pdftotext-executable= to ${pdftotext-executable} (exists: ${pdftotext-executable-p})
-
-** org-ref-url-utils (loaded: ${org-ref-url-p})
-
-* export variables
-
-- org-latex-pdf-process :: ${org-latex-pdf-process}
-"
-            'aget
-            `(("org-ref-version" . ,(org-ref-version))
-              ("org-latex-pdf-process" . ,(format "%S" org-latex-pdf-process))
-              ("org-ref-location" . ,(format "%s" (locate-library "org-ref")))
-
-              ("system" . ,(format "System: %s" system-type))
-              ("system-configuration" . ,(ords system-configuration))
-              ("window-system" . ,(format "Window system: %s" window-system))
-              ("emacs-version" . ,(ords (emacs-version)))
-              ("org-version" . ,(org-version))
-
-              ("org-ref-pdf-p" . ,(ords (featurep 'org-ref-pdf)))
-              ("org-ref-helm-p" . ,(ords (featurep 'org-ref-helm)))
-              ("org-ref-ivy-p" . ,(ords (featurep 'org-ref-ivy)))
-
-              ("pdftotext" . ,(ords (if (featurep 'org-ref-pdf)
-                                        (executable-find "pdftotext")
-                                      "org-ref-pdf not loaded")))
-              ("pdftotext-executable" . ,(ords (if (featurep 'org-ref-pdf)
-                                                   pdftotext-executable
-                                                 "org-ref-pdf not loaded")))
-              ("pdftotext-executable-p" . ,(ords (if (boundp 'pdftotext-executable)
-                                                     (or
-                                                      (executable-find pdftotext-executable)
-                                                      (file-exists-p pdftotext-executable))
-                                                   "pdftotext-executable is not bound")))
-              ("org-ref-url-p" . ,(ords (featurep 'org-ref-url)))
-              ("org-ref-insert-link-function" . ,org-ref-insert-link-function)
-              ("org-ref-insert-cite-function" . ,org-ref-insert-cite-function)
-              ("org-ref-insert-label-function" . ,org-ref-insert-label-function)
-              ("org-ref-insert-ref-function" . ,org-ref-insert-ref-function)
-              ("org-ref-cite-onclick-function" . ,org-ref-cite-onclick-function)
-
-              ("bibtex-completion-bibliography" . ,bibtex-completion-bibliography)
-              ("bibtex-completion-library-path" . ,bibtex-completion-library-path)
-              ("bibtex-completion-notes-path" . ,bibtex-completion-notes-path)))))
-
-
-(defun org-ref-get-bibtex-entry-citation (key)
-  "Return a string for the bibliography entry corresponding to KEY."
-  (bibtex-completion-apa-format-reference key))
-
-
-(defun org-ref-get-bibtex-entry (key)
-  "Return the bibtex entry as a string."
-  (save-window-excursion
-    (bibtex-completion-show-entry (list key))
-    (bibtex-copy-entry-as-kill)
-    (pop bibtex-entry-kill-ring)))
-
-(defun org-ref-library-path ()
-  "return the library path"
-  (cond
-   ((stringp bibtex-completion-library-path)
-    bibtex-completion-library-path)
-   ((and (listp bibtex-completion-library-path)
-        (= 1 (length bibtex-completion-library-path)))
-    (car bibtex-completion-library-path))
-   (t
-    (completing-read "Dir: " bibtex-completion-library-path))))
-
-;;*** key at point functions
-(defun org-ref-get-pdf-filename (key)
-  "Return the pdf filename associated with a bibtex KEY.
-This searches for the pattern KEY*.pdf. If one result is found it
-is returned, but if multiple results are found, e.g. there are
-related files to the KEY you are prompted for which one you want."
-  (let ((results (bibtex-completion-find-pdf-in-library key)))
-    (cond
-     ((null results)
-      nil)
-     ((= 1 (length results))
-      (car results))
-     (t
-      (completing-read "PDF: " results)))))
-
-;; TODO: do we even need this?
-(defun org-ref-get-mendeley-filename (key)
-  "Return the pdf filename indicated by mendeley file field.
-Falls back to `org-ref-get-pdf-filename' if file field does not exist.
-Contributed by https://github.com/autosquid.
-Argument KEY is the bibtex key."
-  (let* ((results (org-ref-get-bibtex-key-and-file key))
-         (bibfile (cdr results)))
-    (with-temp-buffer
-      (insert-file-contents bibfile)
-      (bibtex-set-dialect (parsebib-find-bibtex-dialect) t)
-      (bibtex-search-entry key nil 0)
-      (let ((e (bibtex-autokey-get-field "file")))
-       (if (> (length e) 4)
-            (let ((clean-field (replace-regexp-in-string "{\\|}\\|\\\\" "" e)))
-              (let ((first-file (car (split-string clean-field ";" t))))
-               (format "/%s" (substring first-file 1
-                                        (- (length first-file) 4)))))
-          (expand-file-name (format "%s.pdf" key) (cond
-                                                  ((stringp bibtex-completion-library-path)
-                                                   bibtex-completion-library-path)
-                                                  ((= 1 (length bibtex-completion-library-path))
-                                                   (car bibtex-completion-library-path))
-                                                  (t
-                                                   (completing-read "PDF dir: " bibtex-completion-library-path)))))))))
-
-
-(defun org-ref-get-pdf-filename-bibtex-completion (key)
-  "Use bibtex-completion to retrieve a PDF filename for KEY.
-bibtex-completion looks in both the configured directory
-`bibtex-completion-library-path' and in the fields of the bibtex
-item for a filename. It understands file fields exported by
-Jabref, Mendeley and Zotero. See `bibtex-completion-find-pdf'."
-  (let ((bibtex-completion-bibliography (org-ref-find-bibliography)))
-    (or (car (bibtex-completion-find-pdf key)) "")))
-
-
-;;;###autoload
-(defun org-ref-open-pdf-at-point ()
-  "Open the pdf for bibtex key under point if it exists."
-  (interactive)
-  (let* ((bibtex-completion-bibliography (org-ref-find-bibliography))
-        (results (org-ref-get-bibtex-key-and-file))
-         (key (car results))
-         (pdf-file (bibtex-completion-find-pdf key t)))
-    (pcase (length pdf-file)
-      (0
-       (message "no pdf found for %s" key)
-       (save-window-excursion
-        (org-ref-open-citation-at-point) 
-        (doi-utils-get-bibtex-entry-pdf)))
-      (1
-       (funcall bibtex-completion-pdf-open-function (car pdf-file)))
-      (_
-       (funcall bibtex-completion-pdf-open-function
-               (completing-read "pdf: " pdf-file))))))
-
-
-;;;###autoload
-(defun org-ref-add-pdf-at-point (&optional prefix)
-  "Add the pdf for bibtex key under point if it exists.
-
-Similar to org-ref-bibtex-assoc-pdf-with-entry prompt for pdf
-associated with bibtex key at point and rename it.  Check whether a
-pdf already exists in `bibtex-completion-library' with the name
-'[bibtexkey].pdf'. If the file does not exist, rename it to
-'[bibtexkey].pdf' using
-`org-ref-bibtex-assoc-pdf-with-entry-move-function' and place it
-in a directory. Optional PREFIX argument toggles between
-`rename-file' and `copy-file'."
-
-  (interactive)
-  (let* ((bibtex-completion-bibliography (org-ref-find-bibliography))
-        (results (org-ref-get-bibtex-key-and-file))
-         (key (car results))
-         (pdf-file (bibtex-completion-find-pdf-in-library key)))
-    (if pdf-file
-        (message "PDF for key [%s] already exists %s" key pdf-file)
-      (let* ((source-file-name (read-file-name
-                               (format "Select pdf file associated with key [%s]: " key)
-                               org-ref-bibtex-pdf-download-dir))
-            (dest-file-name (expand-file-name (format "%s.pdf" key)
-                                              (org-ref-library-path)))
-            (file-move-func (org-ref-bibtex-get-file-move-func prefix)))
-        (progn
-          (funcall file-move-func source-file-name dest-file-name)
-          (message "added file %s to key %s" dest-file-name key))))))
-
-;;;###autoload
-(defun org-ref-open-url-at-point ()
-  "Open the url for bibtex key under point."
-  (interactive)
-  (let* ((bibtex-completion-bibliography (org-ref-find-bibliography))
-        (results (org-ref-get-bibtex-key-and-file))
-         (key (car results))
-         (bibfile (cdr results)))
-    (save-excursion
-      (with-temp-buffer
-        (insert-file-contents bibfile)
-        (bibtex-set-dialect (parsebib-find-bibtex-dialect) t)
-        (bibtex-search-entry key)
-        ;; I like this better than bibtex-url which does not always find
-        ;; the urls
-        (catch 'done
-          (let ((url (s-trim (bibtex-autokey-get-field "url"))))
-            (unless (s-blank? url)
-              (browse-url url)
-              (throw 'done nil)))
-
-          (let ((doi (s-trim (bibtex-autokey-get-field "doi"))))
-            (unless (s-blank? doi)
-              (if (string-match "^http" doi)
-                  (browse-url doi)
-                (browse-url (format "http://dx.doi.org/%s" doi)))
-              (throw 'done nil))))))))
-
-
-;;;###autoload
-(defun org-ref-open-notes-at-point (&optional thekey)
-  "Open the notes for bibtex key under point in a cite link in a buffer.
-Can also be called with THEKEY in a program."
-  (interactive)
-  (org-mark-ring-push)
-  (when (null thekey)
-    (setq thekey (org-ref-get-bibtex-key-under-cursor)))
-  (let ((bibtex-completion-bibliography (org-ref-find-bibliography)))
-    (bibtex-completion-edit-notes (list thekey))))
-
-
-;;;###autoload
-(defun org-ref-open-citation-at-point ()
-  "Open bibtex file to key at point."
-  (interactive)
-  (org-mark-ring-push)
-  (let ((bibtex-completion-bibliography (org-ref-find-bibliography)))
-    (bibtex-completion-show-entry (list (org-ref-get-bibtex-key-under-cursor)))))
-
-
-;;*** cite menu
-
-;;;###autoload
-(defun org-ref-copy-entry-as-summary ()
-  "Copy the bibtex entry for the citation at point as a summary."
-  (interactive)
-  (kill-new (org-ref-bib-citation)))
-
-
-(defun org-ref-get-doi-at-point ()
-  "Get doi for key at point."
-  (let* ((results (org-ref-get-bibtex-key-and-file))
-         (key (car results))
-         (bibfile (cdr results))
-         doi)
-    (save-excursion
-      (with-temp-buffer
-        (insert-file-contents bibfile)
-        (bibtex-set-dialect (parsebib-find-bibtex-dialect) t)
-        (bibtex-search-entry key)
-        (setq doi (bibtex-autokey-get-field "doi"))
-        ;; in case doi is a url, remove the url part.
-        (replace-regexp-in-string "^http://dx.doi.org/" "" doi)))))
-
-
-;;**** functions that operate on key at point for click menu
-
-;;;###autoload
-(defun org-ref-ads-at-point ()
-  "Open the doi in ADS for bibtex key under point."
-  (interactive)
-  (doi-utils-ads (org-ref-get-doi-at-point)))
-
-
-;;;###autoload
-(defun org-ref-wos-at-point ()
-  "Open the doi in wos for bibtex key under point."
-  (interactive)
-  (doi-utils-wos (org-ref-get-doi-at-point)))
-
-
-;;;###autoload
-(defun org-ref-wos-citing-at-point ()
-  "Open the doi in wos citing articles for bibtex key under point."
-  (interactive)
-  (doi-utils-wos-citing (org-ref-get-doi-at-point)))
-
-
-;;;###autoload
-(defun org-ref-wos-related-at-point ()
-  "Open the doi in wos related articles for bibtex key under point."
-  (interactive)
-  (doi-utils-wos-related (org-ref-get-doi-at-point)))
-
-
-;;;###autoload
-(defun org-ref-google-scholar-at-point ()
-  "Search google scholar for bibtex key under point using the title."
-  (interactive)
-  (browse-url
-   (url-encode-url
-    (format
-     "http://scholar.google.com/scholar?q=%s"
-     (bibtex-completion-get-value
-      "title"
-      (bibtex-completion-get-entry (org-ref-get-bibtex-key-under-cursor)))))))
-
-
-;;;###autoload
-(defun org-ref-biblio-at-point ()
-  "Do a biblio search for bibtex key under point using the title."
-  (interactive)
-  (biblio-lookup
-   nil
-   (bibtex-completion-get-value
-    "title"
-    (bibtex-completion-get-entry (org-ref-get-bibtex-key-under-cursor)))))
-
-
-;;;###autoload
-(defun org-ref-pubmed-at-point ()
-  "Open the doi in pubmed for bibtex key under point."
-  (interactive)
-  (doi-utils-pubmed (org-ref-get-doi-at-point)))
-
-
-;;;###autoload
-(defun org-ref-crossref-at-point ()
-  "Open the doi in crossref for bibtex key under point."
-  (interactive)
-  (doi-utils-crossref (org-ref-get-doi-at-point)))
-
-
-;;;###autoload
-(defun org-ref-email-at-point ()
-  "Email the citation(s) at point."
-  (interactive)
-  (let* ((cite (org-element-context))
-        (keys ()))
-    (compose-mail)
-    (message-goto-body)
-    (cl-loop for ref in (plist-get
-                        (org-ref-parse-cite-path (org-element-property :path cite))
-                        :references)
-            do
-            (let* ((key (plist-get ref :key))
-                   (entry (save-window-excursion
-                            (bibtex-completion-show-entry (list key))
-                            (bibtex-copy-entry-as-kill)
-                            (pop bibtex-entry-kill-ring)))
-                   (pdfs (bibtex-completion-find-pdf key)))
-              (setq keys (append keys (list key)))
-              (insert entry)
-              (cl-loop for pdf in pdfs do (mml-attach-file pdf))))
-
-    (message-goto-subject)
-    (insert "References: " (string-join keys ","))))
-
-
-;;* General org-ref utilities
-
-
-(defun org-ref-get-bibtex-keys (&optional sort)
-  "Return a list of unique keys in the buffer.
-Use SORT to specify alphabetical order by key."
-  (let ((keys '()))
-    (org-element-map (org-element-parse-buffer) 'link
-      (lambda (link)
-        (let ((plist (nth 1 link)))
-          (when (assoc (plist-get plist ':type) org-ref-cite-types)
-           (setq keys (append keys (cl-loop for ref in
-                                            (plist-get (org-ref-parse-cite-path
-                                                        (org-element-property :path link))
-                                                       :references)
-                                            collect (plist-get ref :key)))))))
-      ;; set with-affiliated to get keys in captions
-      nil nil nil t)
-    (when sort
-      ;; Sort keys alphabetically
-      (setq keys (cl-sort keys 'string-lessp :key 'downcase)))
-    (delete-dups keys)))
-
-
-(defun org-ref-pdf-p (filename)
-  "Check if FILENAME is PDF file.
-
-From the PDF specification 1.7:
-
-    The first line of a PDF file shall be a header consisting of
-    the 5 characters %PDF- followed by a version number of the
-    form 1.N, where N is a digit between 0 and 7."
-  (let* ((header (with-temp-buffer
-                  (set-buffer-multibyte nil)
-                  (insert-file-contents-literally filename nil 0 5)
-                  (buffer-string)))
-        (valid (string-equal (encode-coding-string header 'utf-8) "%PDF-")))
-    (if valid
-       valid
-      (message "Invalid pdf. Header = %s" header)
-      nil)))
-
-
-
-
-;; This section creates some code that should speed up org-ref for large files.
-;; I use org-element-parse-buffer a lot for getting information about labels
-;; etc. However, it gets called a lot, and this is slow in large documents. Here
-;; we try to use a cache that helps speed this up at least on loading. Some
-;; notes for the future: on loading, it seems like fontification triggers buffer
-;; changes, so here we only consider char changes. I am not sure this is the
-;; best strategy overall. It is faster to use regexps for finding this
-;; information, but those are substantially more difficult to debug in my
-;; experience. There is an unfortunate number of ways to reference things in
-;; org-mode, and so far this has been most reliable. An alternative might be to
-;; leveralge what happens in font-lock somehow to update local variables
-;; containing org-ref labels, refs, cites, etc. That would miss some #+names
-;; though, and maybe some other things like custom-ids.
-
-(defvar-local org-ref-char-change-tick nil
-  "Local variable to track character changes.")
-
-
-(defvar-local org-ref-parse-buffer-cache nil
-  "Local variable to store parse buffer data.")
-
-
-(defun org-ref-parse-buffer (&optional force)
-  "This is a thin wrapper around `org-element-parse-buffer'.
-The idea is to cache the data, and return it unless we can tell
-the buffer has been modified since the last time we ran it.
-if FORCE is non-nil reparse the buffer no matter what."
-  (if force
-      (progn
-       (message "Forcing update.")
-       (setq-local org-ref-char-change-tick (buffer-chars-modified-tick))
-       (setq-local org-ref-parse-buffer-cache (org-element-parse-buffer)))
-
-    (cond
-     ((null org-ref-parse-buffer-cache)
-      ;; (message "First parse.")
-      (setq-local org-ref-char-change-tick (buffer-chars-modified-tick))
-      (setq-local org-ref-parse-buffer-cache (org-element-parse-buffer)))
-
-     ((not (eq org-ref-char-change-tick (buffer-chars-modified-tick)))
-      ;; (message "Updating from a char change in the buffer.")
-      (setq-local org-ref-char-change-tick (buffer-chars-modified-tick))
-      (setq-local org-ref-parse-buffer-cache (org-element-parse-buffer)))
-
-     (t
-      ;; (message "Using cache.")
-      org-ref-parse-buffer-cache))))
-
-
-
-;;** bad citations, labels, refs and files in orgfile
-;;  These are used i
-(defvar bibtex-files)
-(defvar bibtex-file-path)
-(defun org-ref-bad-cite-candidates ()
-  "Return a list of conses (key . marker) where key does not exist in the known bibliography files, and marker points to the key."
-  (let* ((cp (point))                  ; save to return to later
-         (bibtex-files (cl-loop for f in (org-ref-find-bibliography)
-                               if (file-exists-p f)
-                               collect (file-truename f)))
-         (bibtex-file-path (mapconcat
-                            (lambda (x)
-                              (file-name-directory (file-truename x)))
-                            bibtex-files ":"))
-         (bibtex-keys (mapcar (lambda (x) (car x))
-                              (bibtex-global-key-alist)))
-         (bad-citations '()))
-
-    (org-element-map (org-ref-parse-buffer) 'link
-      (lambda (link)
-        (let ((plist (nth 1 link)))
-          (when (assoc (plist-get plist :type) org-ref-cite-types)
-           (when (not (string= "*" (plist-get plist :path)))
-             (cl-loop for ref in (plist-get (org-ref-parse-cite-path (plist-get plist :path)) :references)
-                      do
-                      (when (not (member (plist-get ref :key) bibtex-keys))
-                        (goto-char (org-element-property :begin link))
-                        (re-search-forward (plist-get ref :key))
-                        (push (cons (plist-get ref :key) (point-marker)) bad-citations)))))))
-      ;; add with-affiliates to get cites in caption
-      nil nil nil t)
-    (goto-char cp)
-    bad-citations))
-
-
-(defun org-ref-bad-ref-candidates ()
-  "Return a list of conses (ref . marker) where ref is a ref link that does not point to anything (i.e. a label)."
-  ;; first get a list of legitimate labels
-  (let ((cp (point))
-        (labels (mapcar 'car (org-ref-get-labels)))
-        (bad-refs '()))
-    ;; now loop over ref links
-    (goto-char (point-min))
-    (org-element-map (org-ref-parse-buffer) 'link
-      (lambda (link)
-        (let ((plist (nth 1 link)))
-         (when (assoc (plist-get plist ':type)  org-ref-ref-types)
-           (cl-loop for label in (split-string (plist-get plist :path) ",")
-                    do
-                    (unless (-contains? labels label)
-                      (goto-char (org-element-property :begin link))
-                      (add-to-list
-                       'bad-refs
-                       (cons label (point-marker)))))))))
-    (goto-char cp)
-    bad-refs))
-
-
-(defun org-ref-count-labels (label)
-  "Return the number of times LABEL appears in the buffer."
-  (let ((rx (string-join org-ref-ref-label-regexps "\\|"))
-       (labels '()))
-    (save-excursion
-      (org-with-wide-buffer
-       (goto-char (point-min))
-       (while (re-search-forward rx nil t)
-        (cl-pushnew (match-string-no-properties 1) labels))))
-    (-count (lambda (x) (and (stringp x) (string= x label))) labels)))
-
-
-(defun org-ref-bad-label-candidates ()
-  "Return a list of labels where label is multiply defined."
-  (let ((labels (mapcar 'car (org-ref-get-labels)))
-        (multiple-labels '()))
-    ;; labels should be a unique list.
-    (dolist (label labels)
-      (when (> (org-ref-count-labels label) 1)
-       (let ((cp (point)))
-          (goto-char (point-min))
-         ;; regular org label:tag links
-          (while (re-search-forward
-                  (format  "[^#+]label:%s\\s-" label) nil t)
-            (cl-pushnew (cons label (point-marker)) multiple-labels
-                       :test (lambda (a b)
-                               (and (string= (car a) (car b))
-                                    (= (marker-position (cdr a))
-                                       (marker-position (cdr b)))))))
-
-          (goto-char (point-min))
-         ;; latex style
-          (while (re-search-forward
-                  (format  "\\label{%s}\\s-?" label) nil t)
-            (cl-pushnew (cons label (point-marker)) multiple-labels
-                       :test (lambda (a b)
-                               (and (string= (car a) (car b))
-                                    (= (marker-position (cdr a))
-                                       (marker-position (cdr b)))))))
-
-         ;; keyword style
-          (goto-char (point-min))
-          (while (re-search-forward
-                  (format  "^\\( \\)*#\\+label:\\s-*%s" label) nil t)
-            (cl-pushnew (cons label (point-marker)) multiple-labels
-                       :test (lambda (a b)
-                               (and (string= (car a) (car b))
-                                    (= (marker-position (cdr a))
-                                       (marker-position (cdr b)))))))
-
-          (goto-char (point-min))
-          (while (re-search-forward
-                  (format "^\\( \\)*#\\+tblname:\\s-*%s" label) nil t)
-            (cl-pushnew (cons label (point-marker)) multiple-labels
-                       :test (lambda (a b)
-                               (and (string= (car a) (car b))
-                                    (= (marker-position (cdr a))
-                                       (marker-position (cdr b)))))))
-          (goto-char cp))))
-    multiple-labels))
-
-
-(defun org-ref-bad-file-link-candidates ()
-  "Return list of conses (link . marker) where the file in the link does not exist."
-  (let* ((bad-files '()))
-    (org-element-map (org-ref-parse-buffer) 'link
-      (lambda (link)
-        (let ((type (org-element-property :type link)))
-          (when (or  (string= "file" type)
-                     (string= "attachfile" type))
-            (unless (file-exists-p (org-element-property :path link))
-              (add-to-list 'bad-files
-                           (cons (org-element-property :path link)
-                                 (save-excursion
-                                   (goto-char
-                                    (org-element-property :begin link))
-                                   (point-marker)))))))))
-    ;; Let us also check \attachfile{fname}
-    (save-excursion
-      (goto-char (point-min))
-      (while (re-search-forward "\\\\attachfile{\\([^}]*\\)}" nil t)
-        (unless (file-exists-p (match-string 1))
-          (push  (cons (match-string 1) (point-marker)) bad-files))))
-    bad-files))
-
-
-;; * org-ref command
-(defun org-ref ()
-  "Check the current org-buffer for potential issues."
-  (interactive)
-  (let* ((buf (get-buffer-create "*org-ref*"))
-        (cb (current-buffer))
-        (fname (buffer-file-name))
-        ;; Check if elc is ok before anything else because if it is not, it
-        ;; causes problems in org-ref.
-        (elc-ok (let* ((org-ref-el (concat
-                                    (file-name-sans-extension
-                                     (locate-library "org-ref"))
-                                    ".el"))
-                       (orel-mod)
-                       (org-ref-elc (concat
-                                     (file-name-sans-extension
-                                      (locate-library "org-ref"))
-                                     ".elc"))
-                       (orelc-mod)
-                       (elc-version))
-                  (when (file-exists-p org-ref-el)
-                    (setq orel-mod (file-attribute-modification-time (file-attributes org-ref-el))))
-                  (when (file-exists-p org-ref-elc)
-                    (setq orelc-mod (file-attribute-modification-time (file-attributes org-ref-elc))))
-
-                  (with-current-buffer buf
-                    (read-only-mode -1)
-                    (erase-buffer)
-                    (org-mode)
-                    (insert (format "#+title: org-ref report on [[%s][%s]]\n\n" (buffer-file-name cb) (buffer-name cb)))
-                    (insert (format "org-ref called from %s\n\n" (buffer-file-name cb)))
-
-                    (unless (time-less-p orel-mod orelc-mod)
-                      (insert (format "org-ref.elc (%s) is older than org-ref.el (%s). That is probably not right. Please delete %s.\n"
-                                      (format-time-string "%Y-%m-%d %H:%M:%S" orelc-mod)
-                                      (format-time-string "%Y-%m-%d %H:%M:%S" orel-mod)
-                                      org-ref-elc))
-                      (insert (format "- load-prefer-newer = %s\n" load-prefer-newer))
-                      (insert (format  "  consider
-- deleting %s
-- [[elisp:(delete-file \"%s\")]]
-- add (setq load-prefer-newer t) to your init files
-- using https://github.com/emacscollective/auto-compile.\n" org-ref-elc org-ref-elc))
-
-                      ;; Check for byte-compiling compatibility with current emacs
-                      (when (and org-ref-elc
-                                 (file-exists-p org-ref-elc))
-                        (setq elc-version (with-temp-buffer
-                                            (insert-file-contents org-ref-elc)
-                                            (goto-char (point-min))
-                                            (when (re-search-forward ";;; in Emacs version \\([0-9]\\{2\\}\\.[0-9]+\\)"
-                                                                     nil t)
-                                              (match-string 1))))
-                        (unless (string= elc-version
-                                         (format "%s.%s" emacs-major-version emacs-minor-version))
-                          (insert (format "%s compiled with Emacs %s but you are running %s. That could be a problem.\n"
-                                          elc-version emacs-major-version emacs-minor-version))))))))
-        (bad-citations (org-ref-bad-cite-candidates))
-        (bad-refs (org-ref-bad-ref-candidates))
-        (bad-labels (org-ref-bad-label-candidates))
-        (bad-files (org-ref-bad-file-link-candidates))
-        (bib-candidates '())
-        (unreferenced-labels '())
-        natbib-required
-        natbib-used
-        cleveref-required
-        cleveref-used
-        biblatex-required
-        biblatex-used
-        mbuffer
-        mchar
-        (org-latex-prefer-user-labels (and (boundp 'org-latex-prefer-user-labels)
-                                           org-latex-prefer-user-labels)))
-
-    (when elc-ok nil)                  ; this is to silence a compiler error
-                                       ; about elc-ok not being used. I use it
-                                       ; as a side-effect above
-
-    ;; See if natbib, biblatex or cleveref are required
-    (org-element-map (org-element-parse-buffer) 'link
-      (lambda (link)
-       (when (member (org-element-property :type link) org-ref-natbib-types)
-         (setq natbib-required t))
-       (when (member (org-element-property :type link) org-ref-biblatex-types)
-         (setq biblatex-required t))
-       (when (member (org-element-property :type link) '("cref" "Cref"))
-         (setq cleveref-required t)))
-      nil t)
-
-    ;; See if natbib is probably used. This will miss a case where natbib is included somehow.
-    (setq natbib-used
-         (or
-          (member "natbib" (mapcar (lambda (x) (when (listp x) (nth 1 x))) org-latex-default-packages-alist))
-          (member "natbib" (mapcar (lambda (x) (when (listp x) (nth 1 x))) org-latex-packages-alist))
-          ;; see of something like \usepackage{natbib} exists.
-          (save-excursion
-            (goto-char (point-min))
-            (re-search-forward "{natbib}" nil t))))
-
-    (setq biblatex-used
-         (or
-          (member "biblatex" (mapcar (lambda (x) (when (listp x) (nth 1 x))) org-latex-default-packages-alist))
-          (member "biblatex" (mapcar (lambda (x) (when (listp x) (nth 1 x))) org-latex-packages-alist))
-          ;; see of something like \usepackage{biblatex} exists.
-          (save-excursion
-            (goto-char (point-min))
-            (re-search-forward "{biblatex}" nil t))))
-
-    (setq cleveref-used
-         (or
-          (member "cleveref" (mapcar (lambda (x) (when (listp x) (nth 1 x))) org-latex-default-packages-alist))
-          (member "cleveref" (mapcar (lambda (x) (when (listp x) (nth 1 x))) org-latex-packages-alist))
-          ;; see of something like \usepackage{cleveref} exists.
-          (save-excursion
-            (goto-char (point-min))
-            (re-search-forward  "{cleveref}" nil t))))
-
-    ;; setup bib-candidates. This checks a variety of things in the
-    ;; bibliography, bibtex files. check for which bibliographies are used
-
-    (cl-loop for bibfile in (org-ref-find-bibliography)
-            do
-            (let ((bibdialect))
-              (with-current-buffer (find-file-noselect bibfile)
-                (setq bibdialect bibtex-dialect))
-              (cl-pushnew
-               (format "[[%s]] (dialect = %s)\n" bibfile bibdialect)
-               bib-candidates)))
-
-
-    ;; Check bibliography style exists
-    (save-excursion
-      (goto-char 0)
-      (unless (re-search-forward "bibliographystyle:\\|\\\\bibliographystyle{" nil t)
-       (cl-pushnew
-        "No bibliography style found. This may be ok, if your latex class style sets that up, but if not this is an error. Try adding something like:
-    bibliographystyle:unsrt
-    at the end of your file.\n"
-        bib-candidates)))
-
-    ;; Check if latex knows of the bibliographystyle. We only check links here.
-    ;;  I also assume this style exists as a bst file that kpsewhich can find.
-    (save-excursion
-      (goto-char 0)
-      (when (re-search-forward "bibliographystyle:" nil t)
-       ;; on a link. get style
-       (let ((path (org-element-property :path (org-element-context))))
-          (unless (= 0 (shell-command (format "kpsewhich %s.bst" path)))
-            (cl-pushnew
-            (format "bibliographystyle \"%s\" may be unknown" path)
-            bib-candidates)))))
-
-    ;; check for multiple bibliography links
-    (let* ((bib-links (-filter
-                       (lambda (el)
-                        (string= (org-element-property :type el) "bibliography"))
-                       (org-element-map (org-element-parse-buffer) 'link 'identity)))
-           (n-bib-links (length bib-links)))
-
-      (when (> n-bib-links 1)
-       (mapc (lambda (link)
-               (setq
-                bib-candidates
-                (append
-                  bib-candidates
-                  (list (format  "Multiple bibliography link: %s"
-                                (org-element-property :raw-link link))))))
-              bib-links)))
-
-    ;; Check for bibliography files existence.
-    (mapc (lambda (bibfile)
-            (unless (file-exists-p bibfile)
-              (cl-pushnew
-              (format "%s does not exist." bibfile)
-              bib-candidates)))
-          (org-ref-find-bibliography))
-
-    ;; check for spaces in bibliography
-    (let ((bibfiles (mapcar 'expand-file-name
-                            (org-ref-find-bibliography))))
-      (mapc (lambda (bibfile)
-              (when (string-match " " bibfile)
-               (cl-pushnew
-                (format "One or more spaces found in path to %s. No spaces are allowed in bibtex file paths. We recommend replacing them with -. Underscores usually cause other problems." bibfile)
-                bib-candidates)))
-            bibfiles))
-
-    ;; validate bibtex files
-    (let ((bibfiles (mapcar 'expand-file-name
-                            (org-ref-find-bibliography))))
-      (mapc
-       (lambda (bibfile)
-        (unless (with-current-buffer
-                     (find-file-noselect bibfile)
-                   (bibtex-validate))
-           (cl-pushnew
-           (format  "Invalid bibtex file found. [[file:%s]]\n" bibfile)
-           bib-candidates)))
-       bibfiles)
-      ;; check types
-      (mapc
-       (lambda (bibfile)
-        (with-current-buffer
-             (find-file-noselect bibfile)
-          (goto-char (point-min))
-          (while (re-search-forward "^@\\(.*?\\)[({]" nil t)
-            (when (and (not (string= "string" (downcase (match-string-no-properties 1))))
-                       (not (member (s-trim (downcase (match-string-no-properties 1)))
-                                    (cdr (assoc bibtex-dialect
-                                                (list
-                                                 (cons 'BibTeX (mapcar (lambda (e) (downcase (car e)))
-                                                                       bibtex-BibTeX-entry-alist))
-                                                 (cons 'biblatex (mapcar (lambda (e) (downcase (car e)))
-                                                                         bibtex-biblatex-entry-alist))))))))
-              (cl-pushnew
-               (format  "Invalid bibtex entry type (%s) found in [[file:%s::%s]]\n" (match-string-no-properties 1)
-                        bibfile (line-number-at-pos))
-               bib-candidates)))))
-       bibfiles))
-
-    ;; unreferenced labels
-    (save-excursion
-      (save-restriction
-       (widen)
-       (goto-char (point-min))
-       (let ((matches '()))
-         ;; these are the org-ref label:stuff  kinds
-         (while (re-search-forward
-                 "[^#+]label:\\([a-zA-Z0-9:-]*\\)" nil t)
-           (cl-pushnew (cons
-                        (match-string-no-properties 1)
-                        (point))
-                       matches))
-         ;; now add all the other kinds of labels.
-         ;; #+label:
-         (save-excursion
-           (goto-char (point-min))
-           (while (re-search-forward "^#\\+label:\\s-+\\(.*\\)\\b" nil t)
-             ;; do not do this for tables. We get those in `org-ref-get-tblnames'.
-             ;; who would have thought you have save match data here? Trust me. When
-             ;; I wrote this, you did.
-             (unless (save-match-data  (equal (car (org-element-at-point)) 'table))
-               (cl-pushnew (cons (match-string-no-properties 1) (point)) matches))))
-
-         ;; \label{}
-         (save-excursion
-           (goto-char (point-min))
-           (while (re-search-forward "\\\\label{\\([a-zA-Z0-9:-]*\\)}"
-                                     nil t)
-             (cl-pushnew (cons (match-string-no-properties 1) (point)) matches)))
-
-         ;; #+tblname: and actually #+label
-         (cl-loop for cell in (org-element-map (org-element-parse-buffer 'element) 'table
-                                (lambda (table)
-                                  (cons (org-element-property :name table)
-                                        (org-element-property :begin table))))
-                  do
-                  (cl-pushnew cell matches))
-
-         ;; CUSTOM_IDs
-         (org-map-entries
-          (lambda ()
-            (let ((custom_id (org-entry-get (point) "CUSTOM_ID")))
-              (when (not (null custom_id))
-                (cl-pushnew (cons custom_id (point)) matches)))))
-
-         (goto-char (point-min))
-         (while (re-search-forward "^#\\+name:\\s-+\\(.*\\)" nil t)
-           (cl-pushnew (cons (match-string 1) (point)) matches))
-
-
-         ;; unreference labels
-         (let ((refs (org-element-map (org-element-parse-buffer) 'link
-                       (lambda (el)
-                         (when (or (string= "ref" (org-element-property :type el))
-                                   (string= "eqref" (org-element-property :type el))
-                                   (string= "pageref" (org-element-property :type el))
-                                   (string= "nameref" (org-element-property :type el))
-                                   (string= "autoref" (org-element-property :type el))
-                                   (string= "cref" (org-element-property :type el))
-                                   (string= "Cref" (org-element-property :type el)))
-                           (org-element-property :path el))))))
-           (cl-loop for (label . p) in matches
-                    do
-                    (when (and label (not (-contains? refs label)))
-                      (cl-pushnew
-                       (cons label (set-marker (make-marker) p))
-                       unreferenced-labels)))))))
-
-
-    (with-current-buffer buf
-      (when bad-citations
-       (insert "\n* Bad citations\n")
-       (cl-loop for (key . marker) in bad-citations
-                do
-                (setq mbuffer (buffer-name (marker-buffer marker))
-                      mchar (marker-position marker))
-                (insert (format "- [[elisp:(progn (switch-to-buffer %S) (goto-char %S)(org-show-entry))][%s]]\n"
-                                mbuffer mchar key))))
-      (when bad-refs
-       (insert "\n* Bad ref links\n")
-       (cl-loop for (key . marker) in bad-refs
-                do
-                (setq mbuffer (buffer-name (marker-buffer marker))
-                      mchar (marker-position marker))
-                (insert (format "- [[elisp:(progn (switch-to-buffer %S) (goto-char %S)(org-show-entry))][%s]]\n"
-                                mbuffer mchar key))))
-
-      (when bad-labels
-       (insert "\n* Multiply defined label links\n")
-       (cl-loop for (key . marker) in bad-labels
-                do
-                (setq mbuffer (buffer-name (marker-buffer marker))
-                      mchar (marker-position marker))
-                (insert (format "- [[elisp:(progn (switch-to-buffer %S) (goto-char %S)(org-show-entry))][%s]]\n"
-                                mbuffer mchar key))))
-
-      (when bad-files
-       (insert "\n* Bad files\n")
-       (cl-loop for (fname pos) in bad-files do
-                (insert (format "- [[elisp:(goto-char %s)][%s]]\n" pos fname))))
-
-      (when unreferenced-labels
-       (insert "\n* Unreferenced label links\n")
-       (cl-loop for (key . marker) in unreferenced-labels
-                when (not (string= key ""))
-                do
-                (setq mbuffer (buffer-name (marker-buffer marker))
-                      mchar (marker-position marker))
-                (insert (format "- [[elisp:(progn (switch-to-buffer %S) (goto-char %S)(org-show-entry))][%s]]\n"
-                                mbuffer mchar key))))
-
-      (when bib-candidates
-       (insert "\n* Bibliography\n\n")
-       (cl-loop for candidate in bib-candidates
-                do
-                (insert (format "- %s" candidate))))
-
-      (insert "\n* Miscellaneous\n\n")
-      (cl-loop for s in `(,(format "org-latex-prefer-user-labels = %s"
-                                  org-latex-prefer-user-labels)
-                         ,(format "bibtex-dialect = %s" bibtex-dialect)
-                         ,(format "biblatex is%srequired." (if biblatex-required " " " not "))
-                         ,(format "biblatex is%sused." (if biblatex-used " " " not "))
-                         ,(format "emacs-version = %s" (emacs-version))
-                         ,(format "org-version = %s" (org-version))
-                         ,(org-ref-version)
-                         ,(format "org-ref.el installed at %s" (concat
-                                                                (file-name-sans-extension
-                                                                 (locate-library "org-ref"))
-                                                                ".el"))
-                         ,(format "org-ref-insert-cite-function = %s" org-ref-insert-cite-function)
-                         ,(format "org-ref-insert-label-function = %s" org-ref-insert-label-function)
-                         ,(format "org-ref-insert-ref-function = %s" org-ref-insert-ref-function)
-                         ,(format "org-ref-cite-onclick-function = %s" org-ref-cite-onclick-function)
-                         ,(format "org-latex-pdf-process is defined as %s" org-latex-pdf-process)
-                         ,(format "natbib is%srequired." (if natbib-required " " " not "))
-                         ,(format "natbib is%sin %s or %s."
-                                  (if natbib-used " " " not ")
-                                  (propertize "org-latex-default-packages-alist"
-                                              'help-echo (format "%S" (mapconcat
-                                                                       (lambda (s)
-                                                                         (format "%s" s))
-                                                                       org-latex-default-packages-alist
-                                                                       "\n"))
-                                              'font-lock-face '(:foreground "red3"))
-                                  (propertize "org-latex-packages-alist"
-                                              'help-echo (format "%S" (mapconcat
-                                                                       (lambda (s)
-                                                                         (format "%s" s))
-                                                                       org-latex-packages-alist
-                                                                       "\n"))
-                                              'font-lock-face '(:foreground "red3")))
-                         ,(format "cleveref is%srequired." (if cleveref-required " " " not "))
-                         ,(format "cleveref is%sin %s or %s."
-                                  (if cleveref-used " " " not ")
-                                  (propertize "org-latex-default-packages-alist"
-                                              'help-echo (format "%S" (mapconcat
-                                                                       (lambda (s)
-                                                                         (format "%s" s))
-                                                                       org-latex-default-packages-alist
-                                                                       "\n"))
-                                              'font-lock-face '(:foreground "red3"))
-                                  (propertize "org-latex-packages-alist"
-                                              'help-echo (format "%S" (mapconcat
-                                                                       (lambda (s)
-                                                                         (format "%s" s))
-                                                                       org-latex-packages-alist
-                                                                       "\n"))
-                                              'font-lock-face '(:foreground "red3")))
-                         ,(format "bibtex-completion installed = %s" (featurep 'bibtex-completion))
-                         ,(format "bibtex-completion loaded = %s" (fboundp 'bibtex-completion-candidates)))
-              do
-              (insert "- " s "\n"))
-      (insert (format "- org-latex-default-packages-alist\n"))
-      (cl-loop for el in org-latex-default-packages-alist
-              do
-              (insert (format "  %S\n" el)))
-
-      (if (null org-latex-packages-alist)
-         (insert "-  org-latex-packages-alist is nil\n")
-       (insert "-  org-latex-packages-alist\n")
-       (cl-loop for el in org-latex-packages-alist
-                do
-                (insert (format "  %S\n" el))))
-
-
-      (insert (format "- ox-bibtex loaded = %s\n" (featurep 'ox-bibtex)))
-      (insert (format "- ox-bibtex loaded after org-ref = %s\n"
-                     (let ((org-ref-i (seq-position load-history (assoc (locate-library "org-ref") load-history)) )
-                           (ox-bibtex-i (seq-position load-history (assoc (locate-library "ox-bibtex") load-history))))
-                       (and org-ref-i ox-bibtex-i
-                            (> org-ref-i ox-bibtex-i)))))
-
-      (insert (format "- ebib loaded = %s\n" (featurep 'ebib)))
-      (insert (format "- ebib loaded after org-ref = %s\n"
-                     (let ((org-ref-i (seq-position load-history (assoc (locate-library "org-ref") load-history)) )
-                           (ebib-i (seq-position load-history (assoc (locate-library "ebib") load-history))))
-                       (and org-ref-i ebib-i
-                            (> org-ref-i ebib-i)))))
-
-
-
-      (insert "- cite link definition:\n" (with-temp-buffer
-                                           (insert (format "%S" (assoc "cite" org-link-parameters)))
-                                           (pp-buffer)
-                                           (buffer-string)))
-
-      (insert "\n* LaTeX setup\n\n")
-      (cl-loop for executable in '("latex" "pdflatex" "bibtex" "biblatex"
-                                  "makeindex" "makeglossaries")
-              do
-              (insert (format "%s is installed at %s\n" executable (executable-find executable))))
-
-      (insert "\n* Warnings\n")
-      (if (get-buffer "*Warnings*")
-         (cl-loop for line in (s-split "\n" (with-current-buffer "*Warnings*"
-                                              (buffer-string)))
-                  if (s-starts-with?  "Warning (org-ref):" line)
-                  do
-                  (insert " - " line "\n"))
-       (insert "- No (org-ref) Warnings found."))
-
-
-      (insert (format  "\n* Utilities
-
-- [[elisp:(progn (find-file %S) (ispell))][Spell check document]]
-- [[elisp:(progn (find-file %S) (org-ref))][recheck document with org-ref]]
-" fname fname))
-      (goto-char (point-min))
-
-      ;; (setq header-line-format "Press q to quit.")
-      ;; (local-set-key "q"
-      ;;                    #'(lambda ()
-      ;;                        (interactive)
-      ;;                        (delete-window)))
-      (read-only-mode))
-
-    (display-buffer-in-side-window buf '((side . right)))))
-
-
-
-;;** Find non-ascii characters
-;;;###autoload
-(defun org-ref-find-non-ascii-characters ()
-  "Find non-ascii characters in the buffer.  Useful for cleaning up bibtex files."
-  (interactive)
-  (occur "[^[:ascii:]]"))
-
-
-;;* Utilities
-
-;;** Extract bibtex entries in org-file
-
-;;;###autoload
-(defun org-ref-extract-bibtex-to-file (bibfile &optional clobber)
-  "Extract all bibtex entries for citations buffer to BIBFILE.
-If BIBFILE exists, append, unless you use a prefix arg (C-u),
-which will CLOBBER the file."
-  (interactive
-   (list (read-file-name "Bibfile: " nil nil nil
-                        (file-name-nondirectory
-                         (concat (file-name-sans-extension
-                                  (buffer-file-name))
-                                 ".bib")))
-        current-prefix-arg))
-
-  (let* ((bibtex-files (org-ref-find-bibliography))
-        (keys (reverse (org-ref-get-bibtex-keys)))
-        (bibtex-entry-kill-ring-max (length keys))
-        (bibtex-entry-kill-ring '())
-        (kill-cb (not (find-buffer-visiting bibfile)))
-        (cb (find-file-noselect bibfile))
-        (current-bib-entries (with-current-buffer cb
-                               (prog1
-                                   (buffer-string)
-                                 (when kill-cb (kill-buffer cb))))))
-
-    (save-window-excursion
-      (cl-loop for key in keys
-              do
-              (bibtex-search-entry key t)
-              (bibtex-kill-entry t)))
-
-    (with-temp-file bibfile
-      (unless clobber (insert current-bib-entries))
-      (insert (mapconcat
-              'identity
-              bibtex-entry-kill-ring
-              "\n\n")))))
-
-
-;;;###autoload
-(defun org-ref-extract-bibtex-entries ()
-  "Extract the bibtex entries in the current buffer into a bibtex src block."
-  (interactive)
-  (let* ((bibtex-files (org-ref-find-bibliography))
-        (keys (reverse (org-ref-get-bibtex-keys)))
-        (bibtex-entry-kill-ring-max (length keys))
-        (bibtex-entry-kill-ring '()))
-
-    (save-window-excursion
-      (cl-loop for key in keys
-              do
-              (bibtex-search-entry key t)
-              (bibtex-kill-entry t)))
-
-    (goto-char (point-max))
-    (insert "\n\n")
-    (org-insert-heading)
-    (insert (format " Bibtex entries
-
-#+BEGIN_SRC bibtex :tangle %s
-%s
-#+END_SRC"
-                   (let ((bibfile (concat (file-name-base
-                                           (or (buffer-file-name) "references"))
-                                          ".bib")))
-                     (if (file-exists-p bibfile)
-                         (file-name-nondirectory
-                          (read-file-name "Bibfile: " nil nil nil bibfile))
-                       bibfile))
-                   (mapconcat
-                    'identity
-                    bibtex-entry-kill-ring
-                    "\n\n")))))
-
-
-;;** Extract cited pdfs
-;;;###autoload
-(defun org-ref-extract-cited-pdfs (newdir)
-  "Copy PDFs in citations in current buffer to NEWDIR."
-  (interactive (list (read-directory-name "Copy to: ")))
-  ;; Make sure newdir exists
-  (unless (file-directory-p newdir)
-    (mkdir newdir t))
-  
-  (cl-loop for key in (org-ref-get-bibtex-keys) do
-          (let ((pdf (org-ref-get-pdf-filename key)))
-            (if (file-exists-p pdf)
-                (progn
-                  (message "Copying %s to %s." pdf newdir)
-                  (copy-file pdf newdir t))
-              (message "%s not found" pdf)))))
-
-
-(provide 'org-ref-utils)
-;;; org-ref-utils.el ends here
-
-;; Local Variables:
-;; byte-compile-warnings: (not docstrings-wide)
-;; End:
diff --git a/elpa/org-ref-20241124.2012/org-ref-worldcat.el b/elpa/org-ref-20241124.2012/org-ref-worldcat.el
deleted file mode 100644 (file)
index 1100e7a..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-;;; org-ref-worldcat.el --- Worldcat library -*- lexical-binding: t; -*-
-
-;;; Commentary:
-;; Provides a function to query world cat
-;; See:
-;; https://www.worldcat.org/wcpa/content/affiliate/default.jsp
-;; https://www.worldcat.org/affiliate/tools?atype=text
-
-;;; Code:
-
-(defun worldcat-query-all (query)
-  "Open browser to Worldcat QUERY."
-  (browse-url
-   (format
-    "http://www.worldcat.org/search?qt=worldcat_org_all&q=%s"
-    query)))
-
-(provide 'org-ref-worldcat)
-
-;;; org-ref-worldcat.el ends here
diff --git a/elpa/org-ref-20241124.2012/org-ref-wos.el b/elpa/org-ref-20241124.2012/org-ref-wos.el
deleted file mode 100644 (file)
index 19ef765..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-;;; org-ref-wos.el --- Web of Science functions              -*- lexical-binding: t; -*-
-
-;; Copyright (C) 2015-2024  John Kitchin
-
-;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
-;; Keywords:
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;; Adds a new org-mode link for a search in Web of Science.
-;;; and an org-mode link for a link to an Accession number.
-
-(require 'org)
-(require 's)
-(require 'org-ref-utils)
-
-;;; Code:
-(org-link-set-parameters "wos"
-                        :follow (lambda (accession-number)
-                                  (browse-url
-                                   (concat
-                                    "http://ws.isiknowledge.com/cps/openurl/service?url_ver=Z39.88-2004&rft_id=info:ut/"
-                                    accession-number)))
-                        :export (lambda (accession-number desc format)
-                                  (cond
-                                   ((eq format 'html)
-                                    (format "<a href=\"http://ws.isiknowledge.com/cps/openurl/service?url_ver=Z39.88-2004&rft_id=info:ut/%s\">%s</a>"
-                                            accession-number
-                                            (or desc (concat "wos:" accession-number)))))))
-
-(org-link-set-parameters "wos-search"
-                        :follow (lambda (path)
-                                  (browse-url
-                                   (format  "http://gateway.webofknowledge.com/gateway/Gateway.cgi?topic=%s&GWVersion=2&SrcApp=WEB&SrcAuth=HSB&DestApp=UA&DestLinkType=GeneralSearchSummary"
-                                            (s-join "+" (split-string path)))))
-                        :export (lambda (link desc format)
-                                  (cond
-                                   ((eq format 'html)
-                                    (format "<a href=\"%s\">%s</a>"
-                                            (format  "http://gateway.webofknowledge.com/gateway/Gateway.cgi?topic=%s&GWVersion=2&SrcApp=WEB&SrcAuth=HSB&DestApp=UA&DestLinkType=GeneralSearchSummary"
-                                                     (s-join "+" (split-string link)))
-                                            (or desc link))))))
-
-;;;###autoload
-(defun wos-search ()
-  "Open the word at point or selection in Web of Science as a topic query."
-  ;; the url was derived from this page: http://wokinfo.com/webtools/searchbox/
-  (interactive)
-  (browse-url
-   (format "http://gateway.webofknowledge.com/gateway/Gateway.cgi?topic=%s&GWVersion=2&SrcApp=WEB&SrcAuth=HSB&DestApp=UA&DestLinkType=GeneralSearchSummary"
-           (if (region-active-p)
-               (mapconcat 'identity (split-string
-                                     (buffer-substring (region-beginning)
-                                                       (region-end))) "+")
-             (thing-at-point 'word)))))
-
-
-;;;###autoload
-(defun wos ()
-  "Open Web of Science search page in a browser."
-  (interactive)
-  (browse-url "http://apps.webofknowledge.com"))
-
-;;* Accession numbers
-;; see http://kitchingroup.cheme.cmu.edu/blog/2015/06/08/Getting-a-WOS-Accession-number-from-a-DOI/
-(defvar *wos-redirect* nil
-  "Holds the redirect from a `url-retrieve' callback function.")
-
-(defvar *wos-waiting* nil
-  "Non-nil when waiting for a `url-retrieve' redirect.")
-
-
-(defun wos-get-wos-redirect (url)
-  "Return final redirect URL for open-url."
-  (setq *wos-waiting* t)
-  (url-retrieve
-   url
-   (lambda (status)
-     (setq *wos-redirect* (car (last status)))
-     (setq *wos-waiting* nil)))
-  (while *wos-waiting* (sleep-for 0.1))
-  (url-unhex-string *wos-redirect*))
-
-
-(defun wos-doi-to-accession-number (doi)
-  "Return a WOS Accession number for a DOI."
-  (let* ((open-url (concat "http://ws.isiknowledge.com/cps/openurl/service?url_ver=Z39.88-2004&rft_id=info:doi/" doi))
-         (redirect (wos-get-wos-redirect open-url)))
-    (message redirect)
-    (string-match "&KeyUT=WOS:\\([^&]*\\)&" redirect)
-    (match-string 1 redirect)))
-
-(provide 'org-ref-wos)
-;;; org-ref-wos.el ends here
diff --git a/elpa/org-ref-20241124.2012/org-ref.bib b/elpa/org-ref-20241124.2012/org-ref.bib
deleted file mode 100644 (file)
index 0526093..0000000
+++ /dev/null
@@ -1,333 +0,0 @@
-@book{Dominik201408,
-  keywords = {org-mode},
-  url = {http://amazon.com/o/ASIN/9881327709/},
-  isbn = 9789881327703,
-  year = 2014,
-  publisher = {Samurai Media Limited},
-  author = {Carsten Dominik},
-  title = {The Org Mode 8 Reference Manual - Organize your life with GNU
-                  Emacs},
-}
-@article{xu-2015-relat-between,
-  title =       {Relationships Between the Surface Electronic and Chemical
-                  Properties of Doped 4d and 5d Late Transition Metal Dioxides},
-  eid =                 104703,
-  url =
-                  "http://scitation.aip.org/content/aip/journal/jcp/142/10/10.1063/1.4914093",
-  doi =                 {10.1063/1.4914093},
-  year =        2015,
-  pages =       104703,
-  number =      10,
-  volume =      142,
-  journal =     "The Journal of Chemical Physics",
-  keywords =    {DESC0004031, early-career, orgmode},
-  author =      "Xu, Zhongnan and Kitchin, John R.",
-}
-
-@article{xu-2015-linear-respon,
-  title =       {A Linear Response {DFT}+{U} Study of Trends in the Oxygen
-                  Evolution Activity of Transition Metal Rutile Dioxides},
-  eprint =      { http://dx.doi.org/10.1021/jp511426q },
-  url =                 { http://dx.doi.org/10.1021/jp511426q },
-  doi =                 {10.1021/jp511426q},
-  year =        2015,
-  pages =       {4827-4833},
-  number =      9,
-  volume =      119,
-  journal =     {The Journal of Physical Chemistry C},
-  keywords =    {DESC0004031, early-career, orgmode, },
-  author =      {Xu, Zhongnan and Rossmeisl, Jan and Kitchin, John R.},
-}
-
-@article{boes-2015-suppor-infor,
-  title =       {Supporting Information: Estimating Bulk-Composition-Dependent
-                  \ce{H2} Adsorption Energies on \ce{Cu_{x}Pd_{1-x}} Alloy (111)
-                  Surfaces},
-  url =
-                  {http://pubs.acs.org/doi/suppl/10.1021/cs501585k/suppl_file/cs501585k_si_001.pdf},
-  doi =                 {10.1021/cs501585k},
-  year =        2015,
-  pages =       {1020-1026},
-  volume =      5,
-  journal =     {ACS Catalysis},
-  keywords =    {orgmode},
-  author =      {Jacob R. Boes and Gamze Gumuslu and James B. Miller and Andrew
-                  J. Gellman and John R. Kitchin},
-}
-
-@article{boes-2015-estim-bulk,
-  title =       {Estimating Bulk-Composition-Dependent \ce{H2} Adsorption
-                  Energies on \ce{Cu_{x}Pd_{1-x}} Alloy (111) Surfaces},
-  url =                 {http://dx.doi.org/10.1021/cs501585k},
-  doi =                 {10.1021/cs501585k},
-  year =        2015,
-  pages =       {1020-1026},
-  volume =      5,
-  keywords =    {orgmode},
-  journal =     {ACS Catalysis},
-  author =      {Jacob R. Boes and Gamze Gumuslu and James B. Miller and Andrew
-                  J. Gellman and John R. Kitchin},
-}
-
-@article{curnan-2014-effec-concen,
-  title =       {Effects of Concentration, Crystal Structure, Magnetism, and
-                  Electronic Structure Method on First-Principles Oxygen Vacancy
-                  Formation Energy Trends in Perovskites},
-  eprint =      { http://dx.doi.org/10.1021/jp507957n },
-  url =                 {http://dx.doi.org/10.1021/jp507957n},
-  doi =                 {10.1021/jp507957n},
-  year =        2014,
-  pages =       {28776-28790},
-  number =      49,
-  volume =      118,
-  journal =     {The Journal of Physical Chemistry C},
-  keywords =    {orgmode, },
-  author =      {Curnan, Matthew T. and Kitchin, John R.},
-}
-
-@article{miller-2014-simul-temper,
-  title =       {Simulating Temperature Programmed Desorption of Oxygen on
-                  {P}t(111) Using {DFT} Derived Coverage Dependent Desorption
-                  Barriers},
-  url =                 {http://dx.doi.org/10.1007/s11244-013-0166-3},
-  doi =                 {10.1007/s11244-013-0166-3},
-  year =        2014,
-  pages =       {106-117},
-  number =      {1-4},
-  volume =      57,
-  journal =     {Topics in Catalysis},
-  keywords =    {DESC0004031, early-career, orgmode, },
-  author =      {Spencer D. Miller and Vladimir V. Pushkarev and Andrew
-                  J. Gellman and John R. Kitchin},
-}
-
-@article{xu-2014-probin-cover,
-  title =       {Probing the Coverage Dependence of Site and Adsorbate
-                  Configurational Correlations on (111) Surfaces of Late
-                  Transition Metals},
-  url =                 {http://dx.doi.org/10.1021/jp508805h},
-  doi =                 {10.1021/jp508805h},
-  year =        2014,
-  pages =       {25597-25602},
-  number =      44,
-  volume =      118,
-  journal =     {J. Phys. Chem. C},
-  keywords =    {DESC0004031, early-career, orgmode, },
-  author =      {Zhongnan Xu and John R. Kitchin},
-}
-
-@article{xu-2014-relat-elect,
-  title =       {Relating the Electronic Structure and Reactivity of the 3d
-                  Transition Metal Monoxide Surfaces},
-  abstract =    "Abstract We performed a series of density functional theory
-                  calculations of dissociative oxygen adsorption on fcc metals
-                  and their corresponding rocksalt monoxides to elucidate the
-                  relationship between the oxide electronic structure and its
-                  corresponding reactivity. We decomposed the dissociative
-                  adsorption energy of oxygen on an oxide surface into a sum of
-                  the adsorption energy on the metal and a change in adsorption
-                  energy caused by both expanding and oxidizing the lattice. We
-                  were able to identify the key features of the electronic
-                  structure that explains the trends in adsorption energies on
-                  3d transition metal monoxide surfaces. ",
-  issn =        "1566-7367",
-  url =                 {http://dx.doi.org/10.1016/j.catcom.2013.10.028},
-  doi =                 {10.1016/j.catcom.2013.10.028},
-  year =        2014,
-  pages =       {60-64},
-  volume =      52,
-  journal =     {Catalysis Communications},
-  keywords =    {DESC0004031, early-career, orgmode, },
-  author =      {Zhongnan Xu and John R. Kitchin},
-}
-
-@article{mehta-2014-ident-poten,
-  title =       {Identifying Potential \ce{BO2} Oxide Polymorphs for Epitaxial
-                  Growth Candidates},
-  eprint =      {http://pubs.acs.org/doi/pdf/10.1021/am4059149},
-  url =                 {http://dx.doi.org/10.1021/am4059149},
-  doi =                 {10.1021/am4059149},
-  year =        2014,
-  pages =       {3630-3639},
-  number =      5,
-  volume =      6,
-  journal =     {ACS Appl. Mater. Interfaces},
-  keywords =    {orgmode, },
-  author =      {Prateek Mehta and Paul A. Salvador and John R. Kitchin},
-}
-
-@article{hallenbeck-2013-effec,
-  title =       {Effects of \ce{O_2} and \ce{SO_2} on the Capture Capacity of a
-                  Primary-Amine Based Polymeric \ce{CO_2} Sorbent},
-  eprint =      "http://pubs.acs.org/doi/pdf/10.1021/ie400582a",
-  url =                 "http://pubs.acs.org/doi/abs/10.1021/ie400582a",
-  doi =                 "10.1021/ie400582a",
-  year =        2013,
-  pages =       "10788-10794",
-  journal =     "Industrial \& Engineering Chemistry Research",
-  keywords =    {RUA, orgmode},
-  author =      "Hallenbeck, Alexander P. and Kitchin, John R.",
-}
-
-
-@article{kitchin-2016-autom-data,
-  abstract =    "In the current scientific publishing landscape, there is a
-                  need for an authoring workflow that easily integrates data and
-                  code into manuscripts and that enables the data and code to be
-                  published in reusable form. Automated embedding of data and
-                  code into published output will enable superior communication
-                  and data archiving. In this work, we demonstrate a proof of
-                  concept for a workflow, org-mode, which successfully provides
-                  this authoring capability and workflow integration. We
-                  illustrate this concept in a series of examples for potential
-                  uses of this workflow. First, we use data on citation counts
-                  to compute the h-index of an author, and show two code
-                  examples for calculating the h-index. The source for each
-                  example is automatically embedded in the PDF during the export
-                  of the document. We demonstrate how data can be embedded in
-                  image files, which themselves are embedded in the document.
-                  Finally, metadata about the embedded files can be
-                  automatically included in the exported PDF, and accessed by
-                  computer programs. In our customized export, we embedded
-                  metadata about the attached files in the PDF in an Info field.
-                  A computer program could parse this output to get a list of
-                  embedded files and carry out analyses on them. Authoring tools
-                  such as Emacs + org-mode can greatly facilitate the
-                  integration of data and code into technical writing. These
-                  tools can also automate the embedding of data into document
-                  formats intended for consumption.",
-  author =      "Kitchin, John R. and Van Gulick, Ana E. and Zilinski, Lisa D.",
-  keywords =    {orgmode},
-  doi =                 "10.1007/s00799-016-0173-7",
-  issn =        "1432-1300",
-  journal =     "International Journal on Digital Libraries",
-  pages =       "1--6",
-  title =       {Automating Data Sharing Through Authoring Tools},
-  url =                 "http://dx.doi.org/10.1007/s00799-016-0173-7",
-  year =        2016,
-}
-
-@article{kitchin-2015-data-surfac-scien,
-  author =      "John R. Kitchin",
-  title =       {Data Sharing in Surface Science},
-  journal =     "Surface Science ",
-  volume =      {647},
-  pages =       {103-107},
-  year =        2015,
-  doi =                 {10.1016/j.susc.2015.05.007},
-  url =
-                  "http://www.sciencedirect.com/science/article/pii/S0039602815001326",
-  issn =        "0039-6028",
-  keywords =    {DESC0004031, early-career, orgmode, Data sharing },
-}
-
-@article{kitchin-2015-examp,
-  author =      {Kitchin, John R.},
-  title =       {Examples of Effective Data Sharing in Scientific Publishing},
-  journal =     {ACS Catalysis},
-  volume =      {5},
-  number =      {6},
-  pages =       {3894-3899},
-  year =        2015,
-  doi =                 {10.1021/acscatal.5b00538},
-  url =                 { http://dx.doi.org/10.1021/acscatal.5b00538 },
-  keywords =    {DESC0004031, early-career, orgmode, Data sharing },
-  eprint =      { http://dx.doi.org/10.1021/acscatal.5b00538 },
-}
-
-@misc{jkitchin76:online,
-  author =      {John Kitchin},
-  title =       {jkitchin/org-ref: org-mode modules for citations,
-                  cross-references, bibliographies in org-mode and useful bibtex
-                  tools to go with it.},
-  url =                 {https://github.com/jkitchin/org-ref},
-  urldate =     {12/04/2016}
-}
-
-@book{chen-2006-handb-data-visual,
-  author =      {Hrsg. Chun-houh Chen ; Hrsg. Wolfgang H{\"a}rdle ; Hrsg.
-                  Antony Unwin},
-  title =       {Handbook of Data Visualization},
-  year =        2006,
-  publisher =   {Springer Berlin},
-  url =                 {http://www.worldcat.org/oclc/150289486?referer=xid},
-  city =        {Berlin},
-  ed =          {1. Ed.},
-  form =        {BA},
-  isbn =        9783540330363,
-  lang =        {eng},
-  lccn =        2007931825,
-  oclcnum =     {150289486 214357554 232302403 314615038 474712418 494787249
-                  645208009 743424036 751135412 76799021 804152581 849253364
-                  873514520 612218650},
-}
-
-@article{geng-2017-first-princ,
-  author =      {Feiyang Geng and Jacob R. Boes and John R. Kitchin},
-  title =       {First-Principles Study of the {Cu-Pd} Phase Diagram},
-  journal =     {Calphad},
-  volume =      56,
-  pages =       {224-229},
-  year =        2017,
-  doi =                 {10.1016/j.calphad.2017.01.009},
-  url =                 {https://doi.org/10.1016/j.calphad.2017.01.009},
-  DATE_ADDED =  {Wed Feb 22 09:13:55 2017},
-}
-
-@article{boes-2017-model-segreg,
-  author =       {Boes, Jacob Russell and Kitchin, John R.},
-  title =        {Modeling Segregation on {AuPd}(111) Surfaces With Density
-                  Functional Theory and Monte Carlo Simulations},
-  journal =      {The Journal of Physical Chemistry C},
-  volume =      {121},
-  number =      {6},
-  pages =       {3479-3487},
-  year =         2017,
-  doi =          {10.1021/acs.jpcc.6b12752},
-  url =          {https://doi.org/10.1021/acs.jpcc.6b12752},
-  eprint =       { http://dx.doi.org/10.1021/acs.jpcc.6b12752 },
-}
-
-@article{xu-2017-first-princ,
-  author =      {Xu, Zhongnan and Salvador, Paul A. and Kitchin, John R.},
-  title =       {First-Principles Investigation of the Epitaxial Stabilization
-                  of Oxide Polymorphs: \ce{TiO2} on \ce{(Sr{,}Ba)TiO3}},
-  journal =     {ACS Applied Materials \& Interfaces},
-  volume =      {9},
-  number =      {4},
-  pages =       {4106-4118},
-  year =        2017,
-  doi =                 {10.1021/acsami.6b11791},
-  url =                 {https://doi.org/10.1021/acsami.6b11791},
-  eprint =      { http://dx.doi.org/10.1021/acsami.6b11791 },
-  note =        {PMID: 28004912},
-}
-
-@article{boes-2017-neural-networ,
-  author =      {Jacob R. Boes and John R. Kitchin},
-  title =       {Neural Network Predictions of Oxygen Interactions on a Dynamic
-                  {Pd} Surface},
-  journal =     {Molecular Simulation},
-  pages =       {1-9},
-  year =        2017,
-  doi =                 {10.1080/08927022.2016.1274984},
-  url =                 {https://doi.org/10.1080/08927022.2016.1274984},
-  keywords =    {CBET-1506770, orgmode},
-}
-
-
-@article{boes-2016-neural-networ,
-  author =      {Jacob R. Boes and Mitchell C. Groenenboom and John A. Keith
-                  and John R. Kitchin},
-  title =       {Neural Network and {Reaxff} Comparison for {Au} Properties},
-  journal =     {Int. J. Quantum Chem.},
-  volume =      116,
-  number =      13,
-  pages =       {979-987},
-  year =        2016,
-  doi =                 {10.1002/qua.25115},
-  url =                 {http://dx.doi.org/10.1002/qua.25115},
-  issn =        {1097-461X},
-  keywords =    {Kohn-Sham density functional theory, neural networks, reactive
-                  force fields, potential energy surfaces, machine learning},
-}
\ No newline at end of file
diff --git a/elpa/org-ref-20241124.2012/org-ref.el b/elpa/org-ref-20241124.2012/org-ref.el
deleted file mode 100644 (file)
index 9720563..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-;;; org-ref.el --- citations, cross-references and bibliographies in org-mode -*- lexical-binding: t; -*-
-
-;; Copyright(C) 2014-2024 John Kitchin
-
-;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
-;; URL: https://github.com/jkitchin/org-ref
-;; Package-Version: 20241124.2012
-;; Package-Revision: a61fe2a76294
-;; Keywords: org-mode, cite, ref, label
-;; Package-Requires: ((org "9.4") (dash "0") (s "0") (f "0") (htmlize "0") (hydra "0") (avy "0") (parsebib "0") (bibtex-completion "0") (citeproc "0") (ox-pandoc "0") (request "0"))
-;; This file is not currently part of GNU Emacs.
-
-;; This program is free software; you can redistribute it and/or
-;; modify it under the terms of the GNU General Public License as
-;; published by the Free Software Foundation; either version 2, or (at
-;; your option) any later version.
-
-;; This program is distributed in the hope that it will be useful, but
-;; WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-;; General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program ; see the file COPYING.  If not, write to
-;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
-
-;;; Commentary:
-;;
-;; Lisp code to setup bibliography, cite, ref and label org-mode links. The
-;; links are clickable and do things that are useful.
-;;
-;; This uses vanilla completing-read in Emacs. You can customize by requiring
-;; `org-ref-helm' or `org-ref-ivy' after this.
-
-;; You should really read org-ref.org in this package for details.
-;;
-
-;;; Code:
-
-(require 'org-ref-core)
-
-
-(setq org-ref-insert-link-function 'org-ref-insert-link
-      org-ref-insert-cite-function 'org-ref-insert-cite-link
-      org-ref-insert-label-function 'org-ref-insert-label-link
-      org-ref-insert-ref-function 'org-ref-insert-ref-link
-      org-ref-cite-onclick-function (lambda (_) (org-ref-citation-hydra/body)))
-
-
-;;* The end
-(provide 'org-ref)
-
-;;; org-ref.el ends here
diff --git a/elpa/org-ref-20241124.2012/org-ref.org b/elpa/org-ref-20241124.2012/org-ref.org
deleted file mode 100644 (file)
index fe26e22..0000000
+++ /dev/null
@@ -1,1109 +0,0 @@
-#+TITLE: The org-ref manual (version 3)
-#+AUTHOR: John Kitchin
-#+DATE: [2021-08-25 Wed]
-#+OPTIONS: toc:nil ^:{}
-#+LATEX_HEADER: \usepackage{natbib}
-#+LATEX_HEADER: \usepackage[version=3]{mhchem}
-#+latex_header: \usepackage{makeidx}
-#+latex_header: \usepackage{cleveref}
-#+latex_header: \makeindex
-# This ridiculousness is to make the index start in the middle of a page.
-# https://tex.stackexchange.com/questions/23870/index-shouldnt-start-new-page
-#+latex_header: \makeatletter
-#+latex_header: \renewenvironment{theindex}
-#+latex_header:                {\section*{\indexname}%
-#+latex_header:                 \@mkboth{\MakeUppercase\indexname}%
-#+latex_header:                         {\MakeUppercase\indexname}%
-#+latex_header:                 \thispagestyle{plain}\parindent\z@
-#+latex_header:                 \parskip\z@ \@plus .3\p@\relax
-#+latex_header:                 \columnseprule \z@
-#+latex_header:                 \columnsep 35\p@
-#+latex_header:                 \let\item\@idxitem}
-#+latex_header:                {}
-#+latex_header: \makeatother
-
-#+latex_header: \usepackage{glossaries}
-#+latex_header: \makeglossaries
-#+latex_header_extra: \newglossaryentry{acronym}{name={acronym},description={An acronym is an abbreviation used as a word which is formed from the initial components in a phrase or a word. Usually these components are individual letters (as in NATO or laser) or parts of words or names (as in Benelux)}}
-#+latex_header_extra: \newacronym{tla}{TLA}{Three Letter Acronym}
-
-@@latex:\maketitle@@
-@@latex:\tableofcontents@@
-
-* Introduction to org-ref
-
-Org-ref is a library for org-mode [[cite:&Dominik201408]] that provides rich support for citations, labels and cross-references in org-mode. org-ref is especially suitable for org-mode documents destined for LaTeX export and scientific publication. org-ref is also extremely useful for research documents and notes. org-ref bundles several other libraries that provide functions to create and modify bibtex entries from a variety of sources, but most notably from a DOI.
-
-The basic idea of org-ref is that it defines a convenient interface to insert citations from a reference database (e.g. from a bibtex file(s)), cross-references to targets in the document, and a set of functional org-mode links for citations, cross-references and labels that export properly to LaTeX, and that provide clickable functionality to the user. org-ref uses [[https://github.com/tmalsburg/helm-bibtex][bibtex-completion]] for the candidates you can use for citations.
-
-org-ref provides a fairly large number of utilities for finding bad citations, extracting bibtex entries from citations in an org-file, and functions for interacting with bibtex entries. We find these utilities indispensable in scientific writing.
-
-org-ref has been in development since sometime in 2013. It was written to aid in the preparation of scientific manuscripts. These are the first dozen scientific articles we wrote with it:
-
-- cite:hallenbeck-2013-effec
-- cite:mehta-2014-ident-poten
-- cite:xu-2014-relat-elect
-- cite:xu-2014-probin-cover
-- cite:miller-2014-simul-temper
-- cite:curnan-2014-effec-concen
-- cite:boes-2015-estim-bulk
-- cite:xu-2015-linear-respon
-- cite:xu-2015-relat-between
-- cite:boes-2016-neural-networ
-- cite:boes-2017-neural-networ
-- cite:xu-2017-first-princ
-
-
-Be sure to check out the supporting information files for each of these. The org source for the supporting information is usually embedded in the supporting information. You may also find these two perspective articles cite:kitchin-2015-examp,kitchin-2015-data-surfac-scien interesting, as well as this article on data sharing cite:kitchin-2016-autom-data we wrote.
-
-
-Biblatex users should read section ref:sec-biblatex-users.
-
-If you want to export this document to another format like PDF or HTML, see section ref:sec-other-forms.
-
-** 2021 version 2 vs version 3
-
-A new citation syntax was recently (2021) integrated into org-mode. Initially I thought this would make at least the citation part of org-ref obsolete. I no longer think that is the case though. One of the goals of org-ref is to provide complete coverage of natbib/biblatex citation commands, with syntax that is close to what you would write in LaTeX, and that is close to what you would read in the LaTeX documentation. The new org-mode citation syntax does not do that. It uses a very different notion of citation and bibliography style syntax. I still think there is significant value to new writers, as well as more experienced writers who are very familiar with LaTeX to use the org-ref approach.
-
-An early criticism of org-ref was its limited capability to support prenote/postnote syntax, especially for multiple citations. It turns out to be reasonably straightforward to support this, and version 3 does fully support the same syntax as the org-mode citation syntax, and it supports common prefix/suffix text, as well as local prefix/suffix text on each citation reference. I have intentionally chosen to use =&= as the prefix for bibtex keys in org-ref, so that it is explicitly different than the one org-cite uses (=@=) to reduce confusion about which syntax you are using.
-
- [[citep:See; in &kitchin-2015-examp page 12; in &kitchin-2015-data-surfac-scien figure 6; for examples]]
-
-You can use both version 2 and version 3 syntax in the same document (although you should not mix them in the same citation). Here are the same citations from above in version 3 syntax.
-
-- cite:&hallenbeck-2013-effec
-- cite:&mehta-2014-ident-poten
-- cite:&xu-2014-relat-elect
-- cite:&xu-2014-probin-cover
-- cite:&miller-2014-simul-temper
-- cite:&curnan-2014-effec-concen
-- cite:&boes-2015-estim-bulk
-- cite:&xu-2015-linear-respon
-- cite:&xu-2015-relat-between
-- cite:&boes-2016-neural-networ
-- cite:&boes-2017-neural-networ
-- cite:&xu-2017-first-princ
-
-You should not mix org-ref links and org-cite citations. They are treated separately and you are not likely to get what you want.
-
-Another criticism was that non-LaTeX exports were usually not that good because org-ref either implemented a minimal formatting engine, and because my early effort at developing a citeproc in org-ref fizzled out. Now, there is citeproc-el, and org-ref supports that for export.
-
-The new citation syntax does not cover labels and cross-references, which are essential in our scientific writing. org-ref continues to support this. We anticipate a long life for org-ref.
-
-Should you use org-ref? If your main export target is LaTeX, and you want cross-references, then probably so.
-
-If you have no need for cross-references (either you don't use them, or vanilla org syntax is adequate), or if you don't like using ivy, and don't want to roll your own citation inserter, then you may not need org-ref.
-
-At this time, I have not integrated the org-cite capability I wrote in https://github.com/jkitchin/org-ref-cite into org-ref. I have not decided if that is a good or bad idea to do.
-
-
-** known issues with org-ref and org-citations
-
-You should not try to define a cite/*: (i.e. do not define a link type that starts with cite/) link. org-cite will probably think it is an org-citation.
-
-** Basic configuration <<basic-configuration>>
-
-You have to setup bibtex-completion variables if you want default bibliographies, notes, pdfs, and other features. You should also set the bibtex-autokey-* variables for generating bibtex keys if you use doi-utils.
-
-Here is the setup I use.
-
-#+BEGIN_SRC emacs-lisp
-(use-package ivy-bibtex
-  :init
-  (setq bibtex-completion-bibliography '("~/Dropbox/emacs/bibliography/references.bib"
-                                        "~/Dropbox/emacs/bibliography/dei.bib"
-                                        "~/Dropbox/emacs/bibliography/master.bib"
-                                        "~/Dropbox/emacs/bibliography/archive.bib")
-       bibtex-completion-library-path '("~/Dropbox/emacs/bibliography/bibtex-pdfs/")
-       bibtex-completion-notes-path "~/Dropbox/emacs/bibliography/notes/"
-       bibtex-completion-notes-template-multiple-files "* ${author-or-editor}, ${title}, ${journal}, (${year}) :${=type=}: \n\nSee [[cite:&${=key=}]]\n"
-
-       bibtex-completion-additional-search-fields '(keywords)
-       bibtex-completion-display-formats
-       '((article       . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${journal:40}")
-         (inbook        . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} Chapter ${chapter:32}")
-         (incollection  . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${booktitle:40}")
-         (inproceedings . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${booktitle:40}")
-         (t             . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*}"))
-       bibtex-completion-pdf-open-function
-       (lambda (fpath)
-         (call-process "open" nil 0 nil fpath))))
-
-(use-package org-ref
-  :ensure nil
-  :load-path (lambda () (expand-file-name "org-ref" scimax-dir))
-  :init
-  (add-to-list 'load-path
-              (expand-file-name "org-ref" scimax-dir))
-  (require 'bibtex)
-  (setq bibtex-autokey-year-length 4
-       bibtex-autokey-name-year-separator "-"
-       bibtex-autokey-year-title-separator "-"
-       bibtex-autokey-titleword-separator "-"
-       bibtex-autokey-titlewords 2
-       bibtex-autokey-titlewords-stretch 1
-       bibtex-autokey-titleword-length 5)
-  (define-key bibtex-mode-map (kbd "H-b") 'org-ref-bibtex-hydra/body)
-  (define-key org-mode-map (kbd "C-c ]") 'org-ref-insert-link)
-  (define-key org-mode-map (kbd "s-[") 'org-ref-insert-link-hydra/body)
-  (require 'org-ref-ivy)
-  (require 'org-ref-arxiv)
-  (require 'org-ref-scopus)
-  (require 'org-ref-wos))
-
-
-(use-package org-ref-ivy
-  :ensure nil
-  :load-path (lambda () (expand-file-name "org-ref" scimax-dir))
-  :init (setq org-ref-insert-link-function 'org-ref-insert-link-hydra/body
-             org-ref-insert-cite-function 'org-ref-cite-insert-ivy
-             org-ref-insert-label-function 'org-ref-insert-label-link
-             org-ref-insert-ref-function 'org-ref-insert-ref-link
-             org-ref-cite-onclick-function (lambda (_) (org-ref-citation-hydra/body))))
-#+END_SRC
-
-
-** Basic usage of org-ref
-
-*** Bibliography links
-index:bibliography index:bibliographystyle
-
-org-ref provides a bibliography link to specify which bibtex files to use in the document.
-
-1. A comma separated list of relative or absolute paths
-2. A comma separated list of files found in your BIBINPUTS environment variable
-
-This link is clickable; clicking on a filename will open the file. On export, the bibliography will appear at the position where the link is defined. Usually this link goes near the end of your document, e.g. like [[bibliography link][here]].
-
-There is also a nobibliography link, which is useful for specifying a bibliography file, but not listing a bibliography in the exported document.
-
-There is also a bibliographystyle link that specifies the style. This link does nothing but export to a LaTeX command. For LaTeX export a bibliography and bibliographystyle link is /required/ if you use bibtex. If you use biblatex see ref:sec-biblatex-users.
-
-These links support completion, so you can type C-c C-l, choose one of them, and it will help you complete the link.
-
-*** Citations <<citations>>
-
-index:cite
-
-org-ref uses the [[bibliography link]] to determine which bibtex files to get citations from, and falls back to the bibtex files defined in the variable ~bibtex-completion-bibliography~  if no bibliography link is found. Note that you *must* include a [[bibliography link]] in your document if you are exporting your document to pdf; ~bibtex-completion-bibliography~ is not used by the [[BibTeX users][LaTeX exporter]].
-
-For simple citation needs, org-ref is simple to use. At the point you want to insert a citation, you select the "Org -> org-ref -> Insert citation" menu (or use the key-binding you chose for inserting org-ref links), select the reference(s) you want in the completion buffer and press enter. The citation will be inserted automatically into your org-file. You "select" an entry by using the arrow keys (or ~C-n~ and ~C-p~) to move up and down to the entry you want. You can also narrow the selection by typing a pattern to match, e.g. author name, title words, year, BibTeX key and entry types. If you want to match any other field, you need to add it to the variable ~bibtex-completion-additional-search-fields~.
-
-If the cursor is on a citation key, you should see a tooltip that summarizes which citation it refers to. If you click on a key, you should get a hydra menu with some actions to choose, including opening the bibtex entry, opening/getting a pdf for the entry, searching the entry in Web of Science, etc...
-
-The default citation type is customizable (=org-ref-default-citation-link=), and set to "cite".
-
-See http://tug.ctan.org/macros/latex/contrib/natbib/natnotes.pdf for the cite commands supported in bibtex index:natbib, and http://ctan.mirrorcatalogs.com/macros/latex/contrib/biblatex/doc/biblatex.pdf for the commands supported in biblatex. index:biblatex.
-
-If the cursor is on a citation, or at the end of the citation, and you add another citation, it will be appended to the current citation.
-
-[[index:cite!shift]]
-Finally, if you do not like the order of the keys in a citation, you can put your cursor on a key and use shift-arrows (left or right) to move the key around. Alternatively, you can use shift-up or you can run the command ~org-ref-sort-citation-link~ which will sort the keys by year, oldest to newest.
-
-Alternatively, there is a keymap defined on cite links. By default this map is defined in the variable ~org-ref-cite-keymap~.
-
-There are navigation bindings that work on a cite link.
-
-| C-left  | Jump to previous key  |
-| C-right | Jump to next key      |
-| S-left  | move key to the left  |
-| S-right | move key to the right |
-
-You can also sort a cite link with multiple keys by year.
-
-| S-up | sort keys by ascending year |
-
-*** Pre/post text support
-
-org-ref has two versions of syntax. In version 2 there is very limited support for pre/post text in citations. You can get pre/post text by using a description in a cite link, with pre/post text separated by ::. For example, [[citep:Dominik201408][See page 20::, for example]]. I do not recommend you use this anymore.
-
-version 3 is much more capable, similar to the new org-cite syntax. The general syntax is:
-
-=Common prefix; prenote 1 &key1 postnote1; prenote n &keyn postnote n; Common suffix=
-
-The tradeoff is you have to prefix the keys with &, separate them by semicolons, and the links have to be bracketed if you put spaces in the notes. The previous citation in version 3 looks like  [[citep:See page 20 &Dominik201408, for example]] as "local" pre/postnotes, or  [[citep:See page 20 ;&Dominik201408;, for example]], as "common" or "global" pre/post notes. You can do this with multiple keys too: [[citep:See &Dominik201408 pg. 2;and &kitchin-2015-examp for examples]]. Note in this example, the internal prefix on the second reference is ignored, because the cite command does not support it; use biblatex with a multicite if you need that in your citations. There are still a few caveats. Natbib only supports a single set of pre/post notes; some citation styles with biblatex support the full syntax. Not all cite types in LaTeX support pre/post text (e.g. cite, citenum do not support them), so be careful when you use them.
-
-
-*** labels
-    :PROPERTIES:
-    :CUSTOM_ID: sec-label-link
-    :END:
-index:label
-
-LaTeX uses labels to define places you can refer to. These can be labels in the captions of figures and tables, or labels in sections. We illustrate some uses here. You can use label links, but it is preferred to use name keywords or other native org label mechanisms.
-
-Here is a way to use a label link:
-
-#+caption: Another simple table. label:tab-ydata
-| y |
-| 4 |
-| 5 |
-
-This is the preferred way to label a table.
-
-#+name: tab-ydata-name
-#+caption: Another simple table. 
-| y |
-| 4 |
-| 5 |
-
-org-ref can help you insert unique labels with the command =org-ref-insert-label-link=. This will show you the existing labels, and insert your new label as a link. There is no default key-binding for this.
-
-*** ref links <<ref-links>>
-index:ref
-
-A ref link refers to a label of some sort. You can use the label in a name keyword, a LaTeX label, a CUSTOM_ID property, a label link (ref:sec-label-link), or a radio target.
-
-
-For example, you can refer to a table name, e.g. Table ref:table-1. You have to provide the context before the ref link, e.g. Table, Figure, Equation, Section, and so on.
-
-#+name: table-1
-#+caption: A simple table.
-| x |
-| 1 |
-| 2 |
-
-Or you can refer to an org-mode label as in Table ref:table-3.
-
-
-Note: You may need to set org-latex-prefer-user-labels to t if you refer to things by their "name" for the export to use the name you create.
-
-#+BEGIN_SRC emacs-lisp :results silent
-(setq org-latex-prefer-user-labels t)
-#+END_SRC
-
-
-#+caption: Another simple table. label:table-3
-| y |
-|---|
-| 3 |
-| 2 |
-
-You can also refer to an org-ref label link as in Table ref:tab-ydata.
-
-To help you insert ref links, use the "Org -> org-ref -> Insert ref" menu, or run the command = org-ref-insert-ref-link=.
-
-ref links are functional. If you put the cursor on a ref link, you will see a tooltip with some context of the corresponding label. If you click on the ref link, you will get a hydra to jump to it or change the ref type.
-
-You can make a ref link to a section with a CUSTOM_ID. For this to work, you should set ~org-latex-prefer-user-labels~ to t.
-
-Also note that "#+tblname:" and "#+label:" are deprecated in org-mode now, and "#+name:" is preferred.
-
-**** Miscellaneous ref links  label:sec-misc
-index:ref!pageref index:ref!nameref index:ref!eqref
-
-org-ref also provides these links:
-
-- pageref :: The page a label is on
-- nameref :: The name of a section a label is in
-- eqref :: Puts the equation number in parentheses
-- autoref :: A command from hyperref that automatically prefixes the reference number. (requires hyperref)
-- cref & Cref :: [[https://www.ctan.org/tex-archive/macros/latex/contrib/cleveref?lang=en][cleveref – Intelligent cross-referencing]]
-- crefrange & Crefrange ::  [[https://www.ctan.org/tex-archive/macros/latex/contrib/cleveref?lang=en][cleveref – Intelligent cross-referencing]]
-
-Note for eqref, you must use a LaTeX label like this:
-
-\begin{equation} \label{eq:1}
-e^x = 4
-\end{equation}
-
-or a named equation like this:
-
-#+name: eq-in-name
-\begin{equation}
-e^x = 4
-\end{equation}
-
-Then you can refer to Eq. eqref:eq:1 or ref:eq-in-name in your documents.
-
-Autoref works like this: autoref:table-3, autoref:sec-misc.
-
-The crefranges require two labels to define the range: Crefrange:table-1,table-3  and crefrange:table-1,table-3
-
-These links do not have much meaning outside of LaTeX.
-
-*** Some other links
-[[index:list of tables]] [[index:list of figures]]
-
-org-ref provides clickable links for a =[[list-of-tables:]]= and =[[list-of-figures:]]=. These links don't need a path, so you have to put them in brackets. These export as listoftables and listoffigures LaTeX commands, and they are clickable links that open a mini table of contents with links to the tables and figures in the buffer. There are also interactive commands for this: elisp:org-ref-list-of-tables and elisp:org-ref-list-of-figures.
-
-
-** Some basic org-ref utilities
-[[index:bibtex!clean entry]]
-
-The command ~org-ref~ does a lot for you automatically. It will check the buffer for errors, e.g. multiply-defined labels, bad citations or ref links, and provide easy access to a few commands through a side-window buffer.
-
-~org-ref-clean-bibtex-entry~ will sort the fields of a bibtex entry, clean it, and give it a bibtex key. By default, this function does a lot of cleaning:
-
-1. adds a comma if needed in the first line of the entry
-2. makes sure the DOI field is an actual DOI, and not a URL
-3. fixes bad year entries
-4. fixes empty pages
-5. escapes ampersand and percentage signs
-6. generate a key according to your setup
-7. runs your hook functions
-8. sorts the fields in the entry
-9. checks the entry for non-ascii characters
-10. converts article title to title case (note: see below to convert titles in other entry types)
-
-
-
-This function has a hook ~org-ref-clean-bibtex-entry-hook~, which you can add functions to of your own. Each function must work on a bibtex entry at point. (Note: the default behavior can be changed by removing the relevant functions from the initial value of ~org-ref-clean-bibtex-entry-hook~.)
-
-Here are the functions run on cleaning:
-
-#+BEGIN_SRC emacs-lisp :exports both
-org-ref-clean-bibtex-entry-hook
-#+END_SRC
-
-#+RESULTS:
-| org-ref-bibtex-format-url-if-doi | orcb-key-comma | org-ref-replace-nonascii | orcb-& | orcb-% | org-ref-title-case-article | orcb-clean-year | orcb-key | orcb-clean-doi | orcb-clean-pages | orcb-check-journal | org-ref-sort-bibtex-entry | orcb-fix-spacing |
-
-You can add your own function to the hook like this.
-
-#+BEGIN_SRC emacs-lisp
-(add-hook 'org-ref-clean-bibtex-entry-hook 'org-ref-replace-nonascii)
-#+END_SRC
-
-~org-ref-extract-bibtex-entries~ will create a bibtex file from the citations in the current buffer.
-
-** LaTeX export
-index:export!LaTeX
-
-All org-ref links are designed to export to the corresponding LaTeX commands for citations, labels, refs and the bibliography/bibliography style. Once you have the LaTeX file, you have to build it, using the appropriate latex and bibtex commands. You can have org-mode do this for you with a setup like:
-
-#+BEGIN_SRC emacs-lisp
-(setq org-latex-pdf-process
-      '("pdflatex -interaction nonstopmode -output-directory %o %f"
-       "bibtex %b"
-       "pdflatex -interaction nonstopmode -output-directory %o %f"
-       "pdflatex -interaction nonstopmode -output-directory %o %f"))
-#+END_SRC
-
-I have also had success with this setup:
-
-#+BEGIN_SRC emacs-lisp
-(setq org-latex-pdf-process (list "latexmk -shell-escape -bibtex -f -pdf %f"))
-#+END_SRC
-
-*** BibTeX users
-
-To have your citations compiled by BibTex, you *must* include a [[bibliography link]].  You will also need to include a [[bibliographystyle link]], unless you are using a LaTeX style that includes that for you.
-
-Note that some citation types may require additional LaTeX packages to be included in your export settings.
-
-Here are the natbib types (these will export in LaTeX with the unsrtnat style). These will export differently in author-year styles.
-
-Here are some examples of the pre/post note syntax for each natbib type. Not all of these make sense. For example the plain cite command does not take pre/post notes, even with natbib. If you use these a lot, you should use citet/citep. Not all of the commands take pre/post notes, e.g. citenum.
-
-
-- =[[citet:See &kitchin-2015-examp page 2]]= :: [[citet:See &kitchin-2015-examp page 2]]
-- =[[citet*:See &kitchin-2015-examp page 2]]= :: [[citet*:See &kitchin-2015-examp page 2]]
-- =[[citep:See &kitchin-2015-examp page 2]]= :: [[citep:See &kitchin-2015-examp page 2]]
-- =[[citep*:See &kitchin-2015-examp page 2]]= :: [[citep*:See &kitchin-2015-examp page 2]]
-- =[[citealt:See &kitchin-2015-examp page 2]]= :: [[citealt:See &kitchin-2015-examp page 2]]
-- =[[citealt*:See &kitchin-2015-examp page 2]]= :: [[citealt*:See &kitchin-2015-examp page 2]]
-- =[[citealp:See &kitchin-2015-examp page 2]]= :: [[citealp:See &kitchin-2015-examp page 2]]
-- =[[citealp*:See &kitchin-2015-examp page 2]]= :: [[citealp*:See &kitchin-2015-examp page 2]]
-- =[[citenum:&kitchin-2015-examp]]= :: [[citenum:&kitchin-2015-examp]]
-- =[[citetext:See &kitchin-2015-examp page 2]]= :: [[citetext:See &kitchin-2015-examp page 2]]
-- =[[citeauthor:See &kitchin-2015-examp page 2]]= :: [[citeauthor:See &kitchin-2015-examp page 2]]
-- =[[citeauthor*:See &kitchin-2015-examp page 2]]= :: [[citeauthor*:See &kitchin-2015-examp page 2]]
-- =[[citeyear:See &kitchin-2015-examp page 2]]= :: [[citeyear:See &kitchin-2015-examp page 2]]
-- =[[citeyearpar:See &kitchin-2015-examp page 2]]= :: [[citeyearpar:See &kitchin-2015-examp page 2]]
-- =[[Citet:See &kitchin-2015-examp page 2]]= :: [[Citet:See &kitchin-2015-examp page 2]]
-- =[[Citet*:See &kitchin-2015-examp page 2]]= :: [[Citet*:See &kitchin-2015-examp page 2]]
-- =[[Citep:See &kitchin-2015-examp page 2]]= :: [[Citep:See &kitchin-2015-examp page 2]]
-- =[[Citep*:See &kitchin-2015-examp page 2]]= :: [[Citep*:See &kitchin-2015-examp page 2]]
-- =[[Citealt:See &kitchin-2015-examp page 2]]= :: [[Citealt:See &kitchin-2015-examp page 2]]
-- =[[Citealt*:See &kitchin-2015-examp page 2]]= :: [[Citealt*:See &kitchin-2015-examp page 2]]
-- =[[Citealp:See &kitchin-2015-examp page 2]]= :: [[Citealp:See &kitchin-2015-examp page 2]]
-- =[[Citealp*:See &kitchin-2015-examp page 2]]= :: [[Citealp*:See &kitchin-2015-examp page 2]]
-- =[[Citeauthor:See &kitchin-2015-examp page 2]]= :: [[Citeauthor:See &kitchin-2015-examp page 2]]
-- =[[Citeauthor*:See &kitchin-2015-examp page 2]]= :: [[Citeauthor*:See &kitchin-2015-examp page 2]]
-
-
-*** biblatex users  <<sec-biblatex-users>>
-
-In the latex header you specify the style and bibliography file using addbibresource. Here is an example:
-
-#+BEGIN_EXAMPLE
-#+latex_header: \usepackage[citestyle=authoryear-icomp,bibstyle=authoryear, hyperref=true,backref=true,maxcitenames=3,url=true,backend=biber,natbib=true] {biblatex}
-#+latex_header: \addbibresource{tests/test-1.bib}
-#+END_EXAMPLE
-
-Sometimes it is necessary to tell bibtex what dialect you are using to support the different bibtex entries that are possible in biblatex. You can do it like this globally.
-
-#+BEGIN_SRC emacs-lisp
-(setq bibtex-dialect 'biblatex)
-#+END_SRC
-
-#+RESULTS:
-: biblatex
-
-Or like this in a bibtex file:
-#+BEGIN_EXAMPLE
-% -*- mode:bibtex; eval: (bibtex-set-dialect 'biblatex); -*-
-#+END_EXAMPLE
-
-Make sure you invoke biblatex in the org-latex-pdf-process. Here is one way to do it.
-
-#+BEGIN_SRC emacs-lisp
-(setq  org-latex-pdf-process '("latexmk -shell-escape -bibtex -pdf %f"))
-#+END_SRC
-
-Finally, where you want the bibliography put this empty link:
-
-#+BEGIN_EXAMPLE
-[[printbibliography:]]
-#+END_EXAMPLE
-
-The regular biblatex cite links support common pre/post notes, and multiple keys. These are:
-
-#+BEGIN_SRC emacs-lisp :exports both
-org-ref-biblatex-types
-#+END_SRC
-
-#+RESULTS:
-| Cite         |
-| parencite    |
-| Parencite    |
-| footcite     |
-| footcitetext |
-| textcite     |
-| Textcite     |
-| smartcite    |
-| Smartcite    |
-| cite*        |
-| parencite*   |
-| supercite    |
-| autocite     |
-| Autocite     |
-| autocite*    |
-| Autocite*    |
-| Citeauthor*  |
-| citetitle    |
-| citetitle*   |
-| citedate     |
-| citedate*    |
-| citeurl      |
-| fullcite     |
-| footfullcite |
-| notecite     |
-| Notecite     |
-| pnotecite    |
-| Pnotecite    |
-| fnotecite    |
-
-The multitype links support common pre/postnotes, and individual pre/post notes.  These are the multicite commands:
-
-#+BEGIN_SRC emacs-lisp :exports both
-org-ref-biblatex-multitypes
-#+END_SRC
-
-#+RESULTS:
-| cites         |
-| Cites         |
-| parencites    |
-| Parencites    |
-| footcites     |
-| footcitetexts |
-| smartcites    |
-| Smartcites    |
-| textcites     |
-| Textcites     |
-| supercites    |
-| autocites     |
-| Autocites     |
-
-
-Here is a full example. This only exports correctly in biblatex or with CSL, so I include it as an example here.
-
-#+BEGIN_EXAMPLE
- [[cites:See; in &kitchin-2015-examp page 1;in &kitchin-2015-data-surfac-scien page 2;and in &kitchin-2016-autom-data page 3; for examples]]
-#+END_EXAMPLE
-
-
-** Other exports
-index:export!html index:export!ascii  index:export!latex  index:export!markdown  index:export!odt
-
-All other exports are handled by citeproc now. This is done by preprocessing in a dedicated exporter called org-ref. There is a new entry in the export menu
-
-| C-c C-e r h | html       |
-| C-c C-e r m | md         |
-| C-c C-e r a | ascii      |
-| C-c C-c r o | odt        |
-| C-c C-e r l | latex      |
-| C-c C-c r O | org buffer |
-
-
-* org-ref-export
-
-org-ref now supports the use of citeproc-el to export citations to non-LaTeX backends. See section [[sec-other-forms]] for more details. You can also use [[./org-ref-natbib-bbl-citeproc.el]]
-
-* org-refproc
-
-org-ref also supports exporting cross-references to other formats using [[./org-ref-refproc.el]]. This library also works by pre-processing a copy of the buffer to convert org-ref cross-reference links to org-syntax before exporting to the target backend. This even support cleveref style links with automatic prefixing and sorting. Compression of the references is not yet supported.
-
-See  [[./examples/refproc.org]] for a pretty comprehensive set of examples.
-
-* Other libraries in org-ref
-
-These are mostly functions for adding entries to bibtex files, modifying entries or for operating on bibtex files. Some new org-mode links are defined.
-
-** doi-utils
-index:doi
-
-This library adds two extremely useful tools for getting bibtex entries and pdf files of journal manuscripts. Add this to your emacs setup:
-#+BEGIN_SRC emacs-lisp
-(require 'doi-utils)
-#+END_SRC
-
-This provides two important commands:
-
-- ~doi-utils-add-bibtex-entry-from-doi~
-This will prompt you for a DOI, and a bibtex file, and then try to get the bibtex entry. Adds the entry to the bibtex file if successful. Automatically calls ~org-ref-clean-bibtex-entry~.
-
-- ~doi-utils-add-entry-from-crossref-query~
-This will prompt you for a query string, which is usually the title of an article, or a free-form text citation of an article. Searches using [[https://www.crossref.org/][Crossref.org]], then prompts in the minibuffer with a list of matching items, which you can choose from to insert a new bibtex entry into a bibtex file. Also calls ~org-ref-clean-bibtex-entry~.
-
-This library also redefines the org-mode doi link. Now, when you click on this link you will get a menu of options, e.g. to open a bibtex entry or a pdf if you have it, or to search the doi in some scientific search engines. Try it out  doi:10.1021/jp511426q.
-
-*** Bibtex key format
-
-The key is formatted according to the settings of bibtex-autokey-* variables. I use these settings. Look at the documentation of them to see how to get the format you want. The function (bibtex-generate-autokey) does this.
-
-The settings I use are:
-
-#+BEGIN_SRC emacs-lisp
-(setq bibtex-autokey-year-length 4
-       bibtex-autokey-name-year-separator "-"
-       bibtex-autokey-year-title-separator "-"
-       bibtex-autokey-titleword-separator "-"
-       bibtex-autokey-titlewords 2
-       bibtex-autokey-titlewords-stretch 1
-       bibtex-autokey-titleword-length 5)
-#+END_SRC
-
-*** Troubleshooting doi-utils
-
-Occasionally weird things happen with a DOI. The first thing you should check is if the json data for the DOI can be retrieved. You can do that at the command line, or in a sh block like this:
-
-#+BEGIN_SRC sh
-curl -LH "Accept: application/citeproc+json" "http://doi.org/10.1021/jp511426q"
-#+END_SRC
-
-If you do not get json data, doi-utils will not be able to generate the bibtex entry.
-
-Not all PDFs can be retrieved. doi-utils uses a set of functions to attempt this. Here is the list.
-
-#+BEGIN_SRC emacs-lisp :exports both
-doi-utils-pdf-url-functions
-#+END_SRC
-
-#+RESULTS:
-| aps-pdf-url                 |
-| science-pdf-url             |
-| nature-pdf-url              |
-| wiley-pdf-url               |
-| springer-chapter-pdf-url    |
-| springer-pdf-url            |
-| acs-pdf-url-1               |
-| acs-pdf-url-2               |
-| acs-pdf-url-3               |
-| iop-pdf-url                 |
-| jstor-pdf-url               |
-| aip-pdf-url                 |
-| science-direct-pdf-url      |
-| linkinghub-elsevier-pdf-url |
-| tandfonline-pdf-url         |
-| ecs-pdf-url                 |
-| ecst-pdf-url                |
-| rsc-pdf-url                 |
-| pnas-pdf-url                |
-| copernicus-pdf-url          |
-| sage-pdf-url                |
-| jneurosci-pdf-url           |
-| ieee-pdf-url                |
-| ieee2-pdf-url               |
-| ieee3-pdf-url               |
-| acm-pdf-url                 |
-| osa-pdf-url                 |
-| asme-biomechanical-pdf-url  |
-| siam-pdf-url                |
-| agu-pdf-url                 |
-| plos-pdf-url                |
-| generic-full-pdf-url        |
-
-You can check if a url for the PDF can be found like this. If you get a url, you can probably download a pdf.
-
-#+BEGIN_SRC emacs-lisp :exports both
-(doi-utils-get-pdf-url "10.1021/jp511426q")
-#+END_SRC
-
-#+RESULTS:
-: https://pubs.acs.org/doi/pdf/10.1021/jp511426q
-
-** org-ref-bibtex
-
-These are functions I use often in bibtex files.
-
-*** Generate new bibtex files with adapted journal names
-
-The variable ~org-ref-bibtex-journal-abbreviations~ contains a mapping of a short string to a full journal title, and an abbreviated journal title. We can use these to create new versions of a bibtex file with full or abbreviated journal titles. You can add new strings like this:
-
-#+BEGIN_SRC emacs-lisp
-(add-to-list 'org-ref-bibtex-journal-abbreviations
-  '("JIR" "Journal of Irreproducible Research" "J. Irrep. Res."))
-#+END_SRC
-
-- org-ref-bibtex-generate-longtitles :: Generate a bib file with long titles as
-     defined in `org-ref-bibtex-journal-abbreviations'
-- org-ref-bibtex-generate-shorttitles :: Generate a bib file with short titles as
-     defined in `org-ref-bibtex-journal-abbreviations'
-
-*** Modifying bibtex entries
-
-- org-ref-stringify-journal-name :: replace a journal name with a string in
-     `org-ref-bibtex-journal-abbreviations'
-- org-ref-set-journal-string :: in a bibtex entry run this to replace the journal
-     with a string selected interactively.
-
-- org-ref-title-case-article :: title case the title in an article entry.
-- org-ref-title-case :: title case the title for entries listed in `org-ref-title-case-types'.
-- org-ref-sentence-case-article :: sentence case the title in an article entry.
-
-- org-ref-replace-nonascii :: replace nonascii characters in a bibtex
-     entry. Replacements are in `org-ref-nonascii-latex-replacements'. This
-     function is a hook function in org-ref-clean-bibtex-entry.
-
-The non-ascii characters are looked up in a list of cons cells. You can add your own non-ascii replacements like this. Note backslashes must be escaped doubly, so one =\= is =\\\\= in the cons cell.
-
-#+BEGIN_SRC emacs-lisp
-(add-to-list 'org-ref-nonascii-latex-replacements
-  '("æ" . "{\\\\ae}"))
-#+END_SRC
-
-These functions are compatible with ~bibtex-map-entries~, so it is possible to conveniently apply them to all the entries in a file like this:
-
-#+BEGIN_SRC emacs-lisp
-(bibtex-map-entries 'org-ref-title-case-article)
-#+END_SRC
-
-*** Bibtex entry navigation
-
-- org-ref-bibtex-next-entry :: bound to M-n
-- org-ref-bibtex-previous-entry :: bound to M-p
-
-*** Hydra menus for bibtex entries and files
-
-- Functions to act on a bibtex entry or file
-  - org-ref-bibtex-hydra/body :: gives a hydra menu to a lot of useful functions
-       like opening the pdf, or the entry in a browser, or searching in a
-       variety of scientific search engines.
-  - org-ref-bibtex-new-entry/body :: gives a hydra menu to add new bibtex entries.
-  - org-ref-bibtex-file/body :: gives a hydra menu of actions for the bibtex file.
-
-You will want to bind the hydra menus to a key. You only need to bind the first one, as the second and third can be accessed from the first hydra.
-
-*** Formatted bibtex entry citations
-
-If you click on a citation link, there should be a menu option to copy a formatted citation, which will copy the citation string to the clipboard. This is a lightly formatted version using bibtex-completion.
-
-If you are on a bibtex entry, the `org-ref-bibtex-hydra/body' has an option to copy a formatted citation for the entry your cursor is in.
-
-
-** org-ref-wos
-This is a small utility for Web of Science/Knowledge (WOK) (http://apps.webofknowledge.com).
-
-#+BEGIN_SRC emacs-lisp
-(require 'org-ref-wos)
-#+END_SRC
-
-#+RESULTS:
-: org-ref-wos
-
-- wos :: Convenience function to open WOK in a browser.
-- wos-search :: Search WOK with the selected text or word at point
-
-There is also a new org-mode link that opens a search: [[wos-search:alloy and segregation]]
-
-** org-ref-scopus
-This is a small utility to interact with Scopus (http://www.scopus.com). Scopus is search engine for scientific literature. It is owned by Elsevier. You must have a license to use it (usually provided by your research institution).
-
-#+BEGIN_SRC emacs-lisp
-(require 'org-ref-scopus)
-#+END_SRC
-
-#+RESULTS:
-: org-ref-scopus
-
-Interactive functions:
-
-- scopus :: Convenience function to open Scopus in a browser.
-- scopus-basic-search :: Prompts for a query and opens it in a browser.
-- scopus-advanced-search :: Prompts for an advanced query and opens it in a browser.
-
-Some new links:
-Open a basic search in Scopus: [[scopus-search:alloy Au segregation]]
-
-Open an advanced search in Scopus: scopus-advanced-search:au-id(7004212771). See http://www.scopus.com/search/form.url?display=advanced&clear=t for details on the codes and syntax, and http://help.elsevier.com/app/answers/detail/a_id/2347/p/8150/incidents.c$portal_account_name/26389.
-
-A functional link to a document in Scopus by its "EID": eid:2-s2.0-72649092395. Clicking on this link will open a hydra menu to open the document in Scopus, find different kinds of related documents by keywords, authors or references, and to open a page in Scopus of citing documents.
-
-There is also a scopusid link for authors that will open their author page in Scopus: scopusid:7004212771
-
-** org-ref-isbn
-index:isbn
-
-#+BEGIN_SRC emacs-lisp
-(require 'org-ref-isbn)
-#+END_SRC
-
-#+RESULTS:
-: org-ref-isbn
-
-This library provides some functions to get bibtex entries for books from their ISBN.
-
-- isbn-to-bibtex
-- isbn-to-bibtex-lead
-
-It also provides some variables for customizing the bibtex entry.
-
-- org-ref-isbn-clean-bibtex-entry-hook
-- org-ref-isbn-exclude-fields
-- org-ref-isbn-field-name-replacements
-
-** org-ref-pubmed
-index:pubmed
-
-[[http://www.ncbi.nlm.nih.gov/pubmed][PubMed]] comprises more than 24 million citations for biomedical literature from MEDLINE, life science journals, and online books. Citations may include links to full-text content from PubMed Central and publisher web sites. This library provides some functions to initiate searches of PubMed from Emacs, and to link to PubMed content.
-
-#+BEGIN_SRC emacs-lisp
-(require 'org-ref-pubmed)
-#+END_SRC
-
-#+RESULTS:
-: org-ref-pubmed
-
-This library provides a number of new org-mode links to PubMed entries. See http://www.ncbi.nlm.nih.gov/pmc/about/public-access-info/#p3 for details of these identifiers. These links open the page in PubMed for the identifier.
-
-pmcid:PMC3498956
-
-pmid:23162369
-
-nihmsid:NIHMS395714
-
-Also, you can retrieve a bibtex entry for a PMID with
-
-- ~pubmed-insert-bibtex-from-pmid~
-
-There are some utility functions that may be helpful.
-
-- pubmed :: Open [[http://www.ncbi.nlm.nih.gov/pubmed][PubMed]] in a browser
-- pubmed-advanced :: Open [[http://www.ncbi.nlm.nih.gov/pubmed/advanced][PubMed]] at advanced search page.
-- pubmed-simple-search :: Prompts you for a simple query and opens it in PubMed.
-
-There is a new org-mode link to PubMed searches: [[pubmed-search:alloy segregation]]
-
-** org-ref-arxiv
-index:arxiv
-
-This library provides an org-mode link to http://arxiv.org entries:  arxiv:cond-mat/0410285, and a function to get a bibtex entry and pdfs for arxiv entries:
-
-#+BEGIN_SRC emacs-lisp
-(require 'org-ref-arxiv)
-#+END_SRC
-
-#+RESULTS:
-: org-ref-arxiv
-
-- ~arxiv-add-bibtex-entry~
-- ~arxiv-get-pdf~
-
-** org-ref-sci-id
-
-index:orcid [[index:researcher id]]
-
-#+BEGIN_SRC emacs-lisp
-(require 'org-ref-sci-id)
-#+END_SRC
-
-#+RESULTS:
-: org-ref-sci-id
-
-This package just defines two new org-mode links for http://www.orcid.org, and http://www.researcherid.com. Here are two examples:
-
-orcid:0000-0003-2625-9232
-
-researcherid:A-2363-2010
-
-** x2bib
-index:bibtex!conversion
-
-#+BEGIN_SRC emacs-lisp
-(require 'x2bib)
-#+END_SRC
-
-#+RESULTS:
-: x2bib
-
-If you find you need to convert some bibliographies in some format into bibtex, this library is a starting point. This code is mostly wrappers around the command line utilities at http://sourceforge.net/p/bibutils/home/Bibutils. I thankfully have not had to use this often, but it is here when I need it again.
-
-- ris2bib :: Convert an RIS file to a bibtex file.
-- medxml2bib :: Convert PubMed XML to bibtex.
-- clean-entries :: Map over a converted bibtex file and "clean it".
-
-** org-ref-latex
-
-This provides some org-ref like capabilities in LaTeX files, e.g. the links are clickable with tooltips.
-
-** org-ref-pdf
-
-=org-ref-pdf= allows Emacs to get bibliography information from pdf files that contain a DOI. You must have =pdftotext= installed where Emacs can find it. This library is known to not work on Windows very well.
-
-** org-ref-url-utils
-
-Allows you to drag-n-drop a webpage from a browser onto a bibtex file to add a bibtex entry (as long as it is from a recognized publisher that org-ref knows about). This library does not work well on Windows.
-
-* Appendix
-
-** Other things org-ref supports
-
-*** org-completion
-index:completion index:link!completion
-
-Most org-ref links support org-mode completion. You can type ~C-c C-l~ to insert a link. You will get completion of the link type, type some characters and press tab. When you select the type, press tab to see the completion options. This works for the following link types:
-
-- bibliography
-- bibliographystyle
-- all cite types
-- ref
-
-*** Indexes
-index:index
-
-org-ref provides links to support making an index in LaTeX. (http://en.wikibooks.org/wiki/LaTeX/Indexing).
-
-- index :: creates an index entry.
-- printindex :: Generates a temporary index of clickable entries. Exports to the LaTeX command.
-
-You will need to use the makeidx package, and use this in the LaTeX header.
-
-#+begin_example
-#+LATEX_HEADER: \usepackage{makeidx}
-#+LATEX_HEADER: \makeindex
-#+end_example
-
-You will have to incorporate running makeindex into your PDF build command.
-
-This is not supported in anything but LaTeX export.
-
-*** Glossaries and acronyms
-index:glossary
-
-org-ref provides some support for glossary and acronym definitions.
-- gls :: a reference to a term
-- glspl :: plural reference to a term
-- Gsl :: capitalized reference to a term
-- Glspl :: capitalized plural reference to a term
-- gslink :: Link to alternative text in the link description.
-- glssymbol :: The symbol term
-- glsdesc :: The description of the term
-
-- ac :: a reference to an acronym
-- Ac :: capitalized reference to an acronym
-- acp :: a plural reference to an acronym
-- Acp :: capitalized plural reference to an acronym
-- acrshort :: Short version of the acronym
-- acrfull :: The full definition of the acronym
-- acrlong :: The full definition of the acronym with (abbrv).
-
-There are two useful commands:
-- org-ref-add-glossary-entry :: Add a new entry to the file
-- org-ref-add-acronym-entry :: Add a new acronym to the file
-
-Here is an example of glossary link for an [[gls:acronym][acronym]] and an actual [[acrshort:tla][TLA]]. Each link has a tool tip on it that shows up when you hover the mouse over it. These links will export as the LaTeX commands need by the glossaries package.
-
-You will need to incorporate running the command makeglossaries into your PDF build command. You also need use the glossaries LaTeX package.
-
-Here is a minimal working example of an org file that makes a glossary.
-
-#+BEGIN_SRC org
-,#+latex_header: \usepackage{glossaries}
-,#+latex_header: \makeglossaries
-
-,#+latex_header_extra: \newglossaryentry{computer}{name=computer,description={A machine}}
-,#+latex_header_extra: \newacronym{tla}{TLA}{Three letter acronym}
-
-A gls:computer is good for computing. Gls:computer is capitalized. We can also use a bunch of glspl:computer to make a cluster. Glspl:computer are the wave of the future. Don't forget what a ac:tla is.
-
-\printglossaries
-#+END_SRC
-
-This is not supported in anything but LaTeX export.
-
-If you have a lot of glossary entries and you want to have them in an external file, you can put them in a tex file, and then include them in the org file like this. Here the glossary entries are saved in a file in the same directory as glossary.tex. This should still work with the tooltips.
-
-#+BEGIN_EXAMPLE
-#+latex_header: \loadglsentries[main]{glossary}
-#+END_EXAMPLE
-
-Finally, you can define the glossary entries in org tables like this. They will be deleted before a LaTeX export.
-
-#+BEGIN_EXAMPLE
-,#+title: Test
-,#+latex_header: \usepackage{glossaries}
-,#+latex_header: \makeglossaries
-
-
-# This will not show in your export. It must be named glossary
-,#+name: glossary
-| label | name  | description   |
-|-------+-------+---------------|
-| tree  | Tree  | A woody plant |
-| shrub | Shrub | A woody bush  |
-
-Checkout how a gls:tree differs from a gls:shrub.
-
-
-,#+name: acronyms
-| Key  | Short | Long                           |
-|------+-------+--------------------------------|
-| mimo |       | multiple-input multiple output |
-| qos  | QoS   | quality-of-service             |
-| bb   | BB    | branch and bound               |
-
-
-First ac:bb. Second ac:bb. First ac:qos. Second ac:qos.
-
-# This is where your glossary and acronym entries will be put.
-,#+latex: \printglossaries
-#+END_EXAMPLE
-
-\glsaddall
-\printglossaries
-
-
-** Other forms of this document <<sec-other-forms>>
-
-*** Build notes
-
-Before building this file you need to require the following libraries so the links will be resolved.
-
- #+BEGIN_SRC emacs-lisp :results silent
-(require 'org-ref-wos)
-(require 'org-ref-scopus)
-(require 'org-ref-pubmed)
-(require 'org-ref-sci-id)
- #+END_SRC
-
-
-*** PDF
-
-You may want to build a pdf of this file. Here is an emacs-lisp block that will create and open the PDF.
-
- #+BEGIN_SRC emacs-lisp :results silent
-(let ((org-export-with-broken-links t)
-      (org-latex-pdf-process
-       '("pdflatex -interaction nonstopmode -shell-escape -output-directory %o %f"
-        "bibtex %b"
-        "makeindex %b"
-        "pdflatex -interaction nonstopmode -shell-escape -output-directory %o %f"
-        "pdflatex -interaction nonstopmode -shell-escape -output-directory %o %f")))
-  (org-open-file (org-latex-export-to-pdf)))
- #+END_SRC
-
-*** Best practices for other formats
-
-org-ref relies on bibtex entries for bibliographies. Bibtex was designed for LaTeX export, and it is common to have LaTeX markup in the BibTeX entries to get the highest quality output in LaTeX (e.g. properly formatted equations, chemical formulas, accents in author names, etc.). This markup will usually not export correctly to other formats without some translation efforts.
-
-It is not generally possible to have a single BibTeX file that easily, and correctly exports to all backends. If perfection in your exports is needed, you need separate bibtex files for each backend, where the markup is intended for that backend. For example you might have "\ce{H2O}" in an entry intended for LaTeX export, but "H<sub>2</sub>O" in an entry for HTML export, and "H_{2}O" for org export.
-
-Maybe you could try an approach where your bibtex file is only org-mode, and then generate a bibtex file by "export" so that at export time it would be in the right format. I haven't tried that yet. It sounds complicated.
-
-
-*** Other formats using CSL
-
-org-ref supports export to other formats using [[https://github.com/andras-simonyi/citeproc-el][citeproc]] in a preprocessing filter. This works by modifying a copy of your org-file during the export to replace the citation and bibliography links with formatted text using the CSL. These functions are defined in [[./org-ref-export.el]]. You set the style with `org-ref-csl-default-style' or with a =CSL-KEYWORD=. See  [[./examples/basic-csl.org]] for an example.
-
-org-ref provides a new exporter for convenience with the following export options: After C-c C-e r
-
-| a | to ascii and open      |                                                                 |
-| h | to html and open       |                                                                 |
-| l | to latex and open      | all cite links and bibliography are exported to latex           |
-| o | to OpenOffice and open |                                                                 |
-| O | to org buffer          | only goes to a buffer so you don't overwrite the current buffer |
-| e | to email               |                                                                 |
-
-These links will run export commands to get this document in different formats. It is worth noting that if your bibtex entries use LaTeX markup (e.g. subscripts, superscripts, chemical equations, etc.) in them, it will probably not render faithfully in the alternative backend. It is in general difficult to have a single format in bibtex that correctly renders in all backends. I don't know of a great solution for this, since LaTeX and CSL use different citation processors.
-
-[[elisp:(org-ref-export-to-html)]]
-
-[[elisp:(org-ref-export-to-latex)]]
-
-[[elisp:(org-ref-export-to-ascii)]]
-
-[[elisp:(org-ref-export-to-odt)]]
-
-[[elisp:(org-ref-export-to-message)]] export to body of an ascii email message
-
-Some basic styles are provide in [[./citeproc/csl-locales/]], and a US-English locale in [[./citeproc/csl-locales/]].
-
-#+BEGIN_SRC sh :exports both
-ls citeproc/csl-styles
-#+END_SRC
-
-#+RESULTS:
-| apa-5th-edition.csl                  |
-| apa-numeric-superscript-brackets.csl |
-| chicago-author-date-16th-edition.csl |
-| elsevier-harvard.csl                 |
-| elsevier-with-titles.csl             |
-
-
-An alternative to this exporter is to use an  `org-export-before-parsing-hook' to do the pre-processing like this. This should work for most backends with the usual export keys and commands.
-
-#+BEGIN_SRC emacs-lisp
-(add-hook 'org-export-before-parsing-hook 'org-ref-csl-preprocess-buffer)
-#+END_SRC
-
-Here is an example to generate a docx file from this document!
-
-#+BEGIN_SRC emacs-lisp
-(require 'ox-pandoc)
-(let ((org-export-before-parsing-hook '(org-ref-csl-preprocess-buffer)))
-  (org-open-file (plist-get (org-pandoc-export-to-docx) 'output-file) 'system))
-#+END_SRC
-
-#+RESULTS:
-
-*** Other formats without using CSL
-
-An alternative approach to using citeproc is to use LaTeX/bibtex more directly. [[./org-ref-natbib-bbl-citeproc.el]] defines another pre-processor that uses LaTeX and natbib/bibtex to create citations and bibliographies. The bbl file is still intended for consumption by LaTeX. org-ref does some light processing to remove LaTeX artifacts, but it is not complete so some artifacts may still appear in your export (e.g. LaTeX commands that are not handled, some backslashes, etc).
-
-Here is an example how to export to HTML with the bbl file produced by LaTeX and bibtex. Your org-file must compile without error once with LaTeX and once with bibtex.
-
-#+BEGIN_SRC emacs-lisp :exports none :results silent
-(let ((org-export-before-parsing-hook '(org-ref-bbl-preprocess)))
-  (org-open-file (org-html-export-to-html)))
-#+END_SRC
-
-The natbib options for [super, numbers, authoryear] are supported, and citation options [square, round, angle, curly], and separators [comma, colon, semicolon] are supported. You can also use [sort, compress, sort&compress] for numeric styles. The longnamesfirst option is not currently supported.
-
-The bibliography entries are formatted from the bbl file. See these examples [[./examples/bbl-super.org]], [[./examples/bbl-numbers.org]] and [[./examples/bbl-authoryear.org]].
-
-* Index
-
-This is a functional link that will open a buffer of clickable index entries:
-# This eliminates the duplicate Index section name
-@@latex:\renewcommand{\indexname}{}@@
-[[printindex:]]
-
-* References
-
-<<bibliographystyle link>>
-bibliographystyle:unsrtnat
-
-<<bibliography link>>
-bibliography:org-ref.bib
diff --git a/elpa/org-ref-20241124.2012/x2bib.el b/elpa/org-ref-20241124.2012/x2bib.el
deleted file mode 100644 (file)
index 4b9c2d4..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-;;; x2bib.el --- Bibliography conversion to Bibtex -*- lexical-binding: t; -*-
-
-;;; Header:
-
-;;; Commentary:
-
-;; This module is more for my convenience to convert bibliography files to
-;; bibtex. This can be done at the command line, for example, but I want to do
-;; it in Emacs. There are a few scenarios where this happens.
-
-;; 1. Someone sends me a non-Bibtex file (Endnote, etc...)
-;; 2. From some online search I select many references and there is no export to
-;; Bibtex option, e.g. from Web of Science.
-
-;; This code is mostly wrappers around the command line utilities at
-;; http://sourceforge.net/p/bibutils/home/Bibutils.
-;;
-;; on a Mac: brew install bibutils
-
-;; Here are the commands that are available.
-
-;; bib2xml       - convert BibTeX to MODS XML intermediate
-;; biblatex2xml  - convert BibLaTeX to MODS XML intermediate
-;; copac2xml     - convert COPAC format references to MODS XML intermediate
-;; end2xml       - convert EndNote (Refer format) to MODS XML intermediate
-;; endx2xml      - convert EndNote XML to MODS XML intermediate
-;; isi2xml       - convert ISI web of science to MODS XML intermediate
-;; med2xml       - convert Pubmed XML references to MODS XML intermediate
-;; modsclean     - a MODS to MODS converter for testing puposes mostly
-;; ris2xml       - convert RIS format to MODS XML intermediate
-;; xml2ads       - convert MODS XML intermediate into Smithsonian Astrophysical
-;;                 Observatory (SAO)/National Aeronautics and Space
-;;                 Administration (NASA) Astrophyics Data System or ADS
-;;                 reference format (converter submitted by Richard Mathar)
-;;                 xml2bib - convert MODS XML intermediate into BibTeX
-;; xml2end       - convert MODS XML intermediate into format for EndNote
-;; xml2isi       - convert MODS XML intermediate to ISI format
-;; xml2ris       - convert MODS XML intermediate into RIS format
-;; xml2wordbib   - convert MODS XML intermediate into Word 2007 bibliography format
-
-
-;;; Code:
-(require 'bibtex)
-
-
-;;* RIS to bibtex
-
-;; RIS can be pretty easily exported from Endnote. Here is a function to read an
-;; RIS file and convert it to bibtex which is inserted at point. Note that there
-;; is often other output from the commands. We try to comment them out here, but
-;; you should probably inspect the entries, and do other bibtex file compliance
-;; checks.
-
-;;;###autoload
-(defun ris2bib (risfile &optional verbose)
-  "Convert RISFILE to bibtex and insert at point.
-Without a prefix arg, stderr is diverted.
-If VERBOSE is non-nil show command output.
-If the region is active, assume it is a ris entry
-and convert it to bib format in place."
-  (interactive
-   (list (if (not (region-active-p))
-             (read-file-name "RIS file:"))
-         (prefix-numeric-value current-prefix-arg)))
-  (let ((result
-         (if risfile
-             (shell-command-to-string
-              (concat
-               (format
-                "ris2xml %s | xml2bib -w"
-                risfile)
-               (unless verbose " 2> /dev/null")))
-           (progn
-             (shell-command-on-region (region-beginning) (region-end)
-                                      "ris2xml 2> /dev/null | xml2bib -w 2> /dev/null" nil
-                                      t)
-             nil))))
-    ;; make some lines into comments.
-    (when result
-      (setq result (replace-regexp-in-string
-                    "^xml2bib:"
-                    "% xml2bib:"
-                    result))
-      (setq result (replace-regexp-in-string
-                    "^ris2xml:"
-                    "% ris2xml"
-                    result))
-      (setq result (replace-regexp-in-string
-                    "^ Defaulting"
-                    "% Defaulting"
-                    result))
-      (insert result))))
-
-;;* Pubmed XML to bibtex
-
-;; In http://www.ncbi.nlm.nih.gov/pubmed/ you can select entries, and then send
-;; them to a file. If you choose Pubmed XML as the format, then you can use this
-;; function to convert it to bibtex.
-
-;;;###autoload
-(defun medxml2bib (medfile &optional verbose)
-  "Convert MEDFILE (in Pubmed xml) to bibtex and insert at point.
-Without a prefix arg, stderr is diverted.
-Display output if VERBOSE is non-nil."
-  (interactive
-   (list (read-file-name "MED file:")
-         (prefix-numeric-value current-prefix-arg)))
-  (let ((result (shell-command-to-string
-                 (concat
-                  (format
-                   "med2xml %s | xml2bib -w"
-                   medfile)
-                  (unless verbose " 2> /dev/null")))))
-    ;; make some lines into comments.
-    (setq result (replace-regexp-in-string
-                  "^xml2bib:"
-                  "% xml2bib:"
-                  result))
-    (setq result (replace-regexp-in-string
-                  "^med2xml:"
-                  "% med2xml"
-                  result))
-    (setq result (replace-regexp-in-string
-                  "^   Defaulting"
-                  "%   Defaulting"
-                  result))
-    (insert result)))
-
-;;* Clean up all the entries
-
-;; Finally, after you put the new entries in, you probably need to do some clean
-;; up actions. This little function does that.
-
-;;;###autoload
-(defun clean-entries ()
-  "Map over bibtex entries and clean them."
-  (interactive)
-  (bibtex-map-entries
-   (lambda (_ _ _)
-     (ignore-errors
-       (org-ref-clean-bibtex-entry)))))
-
-(provide 'x2bib)
-
-;;; x2bib.el ends here
diff --git a/elpa/org-ref-20251206.1422/citeproc/csl-locales/locales-en-US.xml b/elpa/org-ref-20251206.1422/citeproc/csl-locales/locales-en-US.xml
new file mode 100644 (file)
index 0000000..be78c5e
--- /dev/null
@@ -0,0 +1,357 @@
+<?xml version="1.0" encoding="utf-8"?>
+<locale xmlns="http://purl.org/net/xbiblio/csl" version="1.0" xml:lang="en-US">
+  <info>
+    <translator>
+      <name>Andrew Dunning</name>
+    </translator>
+    <translator>
+      <name>Sebastian Karcher</name>
+    </translator>
+    <translator>
+      <name>Rintze M. Zelle</name>
+    </translator>
+    <rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
+    <updated>2015-10-10T23:31:02+00:00</updated>
+  </info>
+  <style-options punctuation-in-quote="true"/>
+  <date form="text">
+    <date-part name="month" suffix=" "/>
+    <date-part name="day" suffix=", "/>
+    <date-part name="year"/>
+  </date>
+  <date form="numeric">
+    <date-part name="month" form="numeric-leading-zeros" suffix="/"/>
+    <date-part name="day" form="numeric-leading-zeros" suffix="/"/>
+    <date-part name="year"/>
+  </date>
+  <terms>
+    <term name="accessed">accessed</term>
+    <term name="and">and</term>
+    <term name="and others">and others</term>
+    <term name="anonymous">anonymous</term>
+    <term name="anonymous" form="short">anon.</term>
+    <term name="at">at</term>
+    <term name="available at">available at</term>
+    <term name="by">by</term>
+    <term name="circa">circa</term>
+    <term name="circa" form="short">c.</term>
+    <term name="cited">cited</term>
+    <term name="edition">
+      <single>edition</single>
+      <multiple>editions</multiple>
+    </term>
+    <term name="edition" form="short">ed.</term>
+    <term name="et-al">et al.</term>
+    <term name="forthcoming">forthcoming</term>
+    <term name="from">from</term>
+    <term name="ibid">ibid.</term>
+    <term name="in">in</term>
+    <term name="in press">in press</term>
+    <term name="internet">internet</term>
+    <term name="interview">interview</term>
+    <term name="letter">letter</term>
+    <term name="no date">no date</term>
+    <term name="no date" form="short">n.d.</term>
+    <term name="online">online</term>
+    <term name="presented at">presented at the</term>
+    <term name="reference">
+      <single>reference</single>
+      <multiple>references</multiple>
+    </term>
+    <term name="reference" form="short">
+      <single>ref.</single>
+      <multiple>refs.</multiple>
+    </term>
+    <term name="retrieved">retrieved</term>
+    <term name="scale">scale</term>
+    <term name="version">version</term>
+
+    <!-- ANNO DOMINI; BEFORE CHRIST -->
+    <term name="ad">AD</term>
+    <term name="bc">BC</term>
+
+    <!-- PUNCTUATION -->
+    <term name="open-quote">“</term>
+    <term name="close-quote">”</term>
+    <term name="open-inner-quote">‘</term>
+    <term name="close-inner-quote">’</term>
+    <term name="page-range-delimiter">–</term>
+
+    <!-- ORDINALS -->
+    <term name="ordinal">th</term>
+    <term name="ordinal-01">st</term>
+    <term name="ordinal-02">nd</term>
+    <term name="ordinal-03">rd</term>
+    <term name="ordinal-11">th</term>
+    <term name="ordinal-12">th</term>
+    <term name="ordinal-13">th</term>
+
+    <!-- LONG ORDINALS -->
+    <term name="long-ordinal-01">first</term>
+    <term name="long-ordinal-02">second</term>
+    <term name="long-ordinal-03">third</term>
+    <term name="long-ordinal-04">fourth</term>
+    <term name="long-ordinal-05">fifth</term>
+    <term name="long-ordinal-06">sixth</term>
+    <term name="long-ordinal-07">seventh</term>
+    <term name="long-ordinal-08">eighth</term>
+    <term name="long-ordinal-09">ninth</term>
+    <term name="long-ordinal-10">tenth</term>
+
+    <!-- LONG LOCATOR FORMS -->
+    <term name="book">
+      <single>book</single>
+      <multiple>books</multiple>
+    </term>
+    <term name="chapter">
+      <single>chapter</single>
+      <multiple>chapters</multiple>
+    </term>
+    <term name="column">
+      <single>column</single>
+      <multiple>columns</multiple>
+    </term>
+    <term name="figure">
+      <single>figure</single>
+      <multiple>figures</multiple>
+    </term>
+    <term name="folio">
+      <single>folio</single>
+      <multiple>folios</multiple>
+    </term>
+    <term name="issue">
+      <single>number</single>
+      <multiple>numbers</multiple>
+    </term>
+    <term name="line">
+      <single>line</single>
+      <multiple>lines</multiple>
+    </term>
+    <term name="note">
+      <single>note</single>
+      <multiple>notes</multiple>
+    </term>
+    <term name="opus">
+      <single>opus</single>
+      <multiple>opera</multiple>
+    </term>
+    <term name="page">
+      <single>page</single>
+      <multiple>pages</multiple>
+    </term>
+    <term name="number-of-pages">
+      <single>page</single>
+      <multiple>pages</multiple>
+    </term>
+    <term name="paragraph">
+      <single>paragraph</single>
+      <multiple>paragraphs</multiple>
+    </term>
+    <term name="part">
+      <single>part</single>
+      <multiple>parts</multiple>
+    </term>
+    <term name="section">
+      <single>section</single>
+      <multiple>sections</multiple>
+    </term>
+    <term name="sub verbo">
+      <single>sub verbo</single>
+      <multiple>sub verbis</multiple>
+    </term>
+    <term name="verse">
+      <single>verse</single>
+      <multiple>verses</multiple>
+    </term>
+    <term name="volume">
+      <single>volume</single>
+      <multiple>volumes</multiple>
+    </term>
+
+    <!-- SHORT LOCATOR FORMS -->
+    <term name="book" form="short">
+      <single>bk.</single>
+      <multiple>bks.</multiple>
+    </term>
+    <term name="chapter" form="short">
+      <single>chap.</single>
+      <multiple>chaps.</multiple>
+    </term>
+    <term name="column" form="short">
+      <single>col.</single>
+      <multiple>cols.</multiple>
+    </term>
+    <term name="figure" form="short">
+      <single>fig.</single>
+      <multiple>figs.</multiple>
+    </term>
+    <term name="folio" form="short">
+      <single>fol.</single>
+      <multiple>fols.</multiple>
+    </term>
+    <term name="issue" form="short">
+      <single>no.</single>
+      <multiple>nos.</multiple>
+    </term>
+    <term name="line" form="short">
+      <single>l.</single>
+      <multiple>ll.</multiple>
+    </term>
+    <term name="note" form="short">
+      <single>n.</single>
+      <multiple>nn.</multiple>
+    </term>
+    <term name="opus" form="short">
+      <single>op.</single>
+      <multiple>opp.</multiple>
+    </term>
+    <term name="page" form="short">
+      <single>p.</single>
+      <multiple>pp.</multiple>
+    </term>
+    <term name="number-of-pages" form="short">
+      <single>p.</single>
+      <multiple>pp.</multiple>
+    </term>
+    <term name="paragraph" form="short">
+      <single>para.</single>
+      <multiple>paras.</multiple>
+    </term>
+    <term name="part" form="short">
+      <single>pt.</single>
+      <multiple>pts.</multiple>
+    </term>
+    <term name="section" form="short">
+      <single>sec.</single>
+      <multiple>secs.</multiple>
+    </term>
+    <term name="sub verbo" form="short">
+      <single>s.v.</single>
+      <multiple>s.vv.</multiple>
+    </term>
+    <term name="verse" form="short">
+      <single>v.</single>
+      <multiple>vv.</multiple>
+    </term>
+    <term name="volume" form="short">
+      <single>vol.</single>
+      <multiple>vols.</multiple>
+    </term>
+
+    <!-- SYMBOL LOCATOR FORMS -->
+    <term name="paragraph" form="symbol">
+      <single>¶</single>
+      <multiple>¶¶</multiple>
+    </term>
+    <term name="section" form="symbol">
+      <single>§</single>
+      <multiple>§§</multiple>
+    </term>
+
+    <!-- LONG ROLE FORMS -->
+    <term name="director">
+      <single>director</single>
+      <multiple>directors</multiple>
+    </term>
+    <term name="editor">
+      <single>editor</single>
+      <multiple>editors</multiple>
+    </term>
+    <term name="editorial-director">
+      <single>editor</single>
+      <multiple>editors</multiple>
+    </term>
+    <term name="illustrator">
+      <single>illustrator</single>
+      <multiple>illustrators</multiple>
+    </term>
+    <term name="translator">
+      <single>translator</single>
+      <multiple>translators</multiple>
+    </term>
+    <term name="editortranslator">
+      <single>editor &amp; translator</single>
+      <multiple>editors &amp; translators</multiple>
+    </term>
+
+    <!-- SHORT ROLE FORMS -->
+    <term name="director" form="short">
+      <single>dir.</single>
+      <multiple>dirs.</multiple>
+    </term>
+    <term name="editor" form="short">
+      <single>ed.</single>
+      <multiple>eds.</multiple>
+    </term>
+    <term name="editorial-director" form="short">
+      <single>ed.</single>
+      <multiple>eds.</multiple>
+    </term>
+    <term name="illustrator" form="short">
+      <single>ill.</single>
+      <multiple>ills.</multiple>
+    </term>
+    <term name="translator" form="short">
+      <single>tran.</single>
+      <multiple>trans.</multiple>
+    </term>
+    <term name="editortranslator" form="short">
+      <single>ed. &amp; tran.</single>
+      <multiple>eds. &amp; trans.</multiple>
+    </term>
+
+    <!-- VERB ROLE FORMS -->
+    <term name="container-author" form="verb">by</term>
+    <term name="director" form="verb">directed by</term>
+    <term name="editor" form="verb">edited by</term>
+    <term name="editorial-director" form="verb">edited by</term>
+    <term name="illustrator" form="verb">illustrated by</term>
+    <term name="interviewer" form="verb">interview by</term>
+    <term name="recipient" form="verb">to</term>
+    <term name="reviewed-author" form="verb">by</term>
+    <term name="translator" form="verb">translated by</term>
+    <term name="editortranslator" form="verb">edited &amp; translated by</term>
+
+    <!-- SHORT VERB ROLE FORMS -->
+    <term name="director" form="verb-short">dir. by</term>
+    <term name="editor" form="verb-short">ed. by</term>
+    <term name="editorial-director" form="verb-short">ed. by</term>
+    <term name="illustrator" form="verb-short">illus. by</term>
+    <term name="translator" form="verb-short">trans. by</term>
+    <term name="editortranslator" form="verb-short">ed. &amp; trans. by</term>
+
+    <!-- LONG MONTH FORMS -->
+    <term name="month-01">January</term>
+    <term name="month-02">February</term>
+    <term name="month-03">March</term>
+    <term name="month-04">April</term>
+    <term name="month-05">May</term>
+    <term name="month-06">June</term>
+    <term name="month-07">July</term>
+    <term name="month-08">August</term>
+    <term name="month-09">September</term>
+    <term name="month-10">October</term>
+    <term name="month-11">November</term>
+    <term name="month-12">December</term>
+
+    <!-- SHORT MONTH FORMS -->
+    <term name="month-01" form="short">Jan.</term>
+    <term name="month-02" form="short">Feb.</term>
+    <term name="month-03" form="short">Mar.</term>
+    <term name="month-04" form="short">Apr.</term>
+    <term name="month-05" form="short">May</term>
+    <term name="month-06" form="short">Jun.</term>
+    <term name="month-07" form="short">Jul.</term>
+    <term name="month-08" form="short">Aug.</term>
+    <term name="month-09" form="short">Sep.</term>
+    <term name="month-10" form="short">Oct.</term>
+    <term name="month-11" form="short">Nov.</term>
+    <term name="month-12" form="short">Dec.</term>
+
+    <!-- SEASONS -->
+    <term name="season-01">Spring</term>
+    <term name="season-02">Summer</term>
+    <term name="season-03">Autumn</term>
+    <term name="season-04">Winter</term>
+  </terms>
+</locale>
diff --git a/elpa/org-ref-20251206.1422/citeproc/csl-styles/apa-5th-edition.csl b/elpa/org-ref-20251206.1422/citeproc/csl-styles/apa-5th-edition.csl
new file mode 100644 (file)
index 0000000..186557d
--- /dev/null
@@ -0,0 +1,341 @@
+<?xml version="1.0" encoding="utf-8"?>
+<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="sort-only">
+  <info>
+    <title>American Psychological Association 5th edition</title>
+    <title-short>APA (5th ed.)</title-short>
+    <id>http://www.zotero.org/styles/apa-5th-edition</id>
+    <link href="http://www.zotero.org/styles/apa-5th-edition" rel="self"/>
+    <link href="http://rdc.libguides.com/content.php?pid=63487" rel="documentation"/>
+    <author>
+      <name>Simon Kornblith</name>
+      <email>simonNOSPAMsimonster.com</email>
+    </author>
+    <contributor>
+      <name>Bruce D'Arcus</name>
+    </contributor>
+    <contributor>
+      <name>Curtis M. Humphrey</name>
+    </contributor>
+    <contributor>
+      <name>Richard Karnesky</name>
+      <email>karnesky+zoteroNOSPAMgmail.com</email>
+      <uri>http://arc.nucapt.northwestern.edu/Richard_Karnesky</uri>
+    </contributor>
+    <contributor>
+      <name>Sebastian Karcher</name>
+    </contributor>
+    <category citation-format="author-date"/>
+    <category field="psychology"/>
+    <category field="generic-base"/>
+    <updated>2020-03-23T14:28:18+00:00</updated>
+    <rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
+  </info>
+  <locale xml:lang="fr">
+    <terms>
+      <term name="editor" form="short">
+        <single>éd.</single>
+        <multiple>éds.</multiple>
+      </term>
+    </terms>
+  </locale>
+  <macro name="container-contributors">
+    <choose>
+      <if type="chapter paper-conference" match="any">
+        <text term="in" text-case="capitalize-first" suffix=" "/>
+        <names variable="editor" delimiter=", " suffix=", ">
+          <name and="symbol" initialize-with=". " delimiter=", "/>
+          <label form="short" prefix=" (" text-case="capitalize-first" suffix=")"/>
+          <substitute>
+            <names variable="translator"/>
+          </substitute>
+        </names>
+      </if>
+    </choose>
+  </macro>
+  <macro name="secondary-contributors">
+    <choose>
+      <if type="chapter paper-conference" match="none">
+        <names variable="translator" delimiter=", " prefix=" (" suffix=")">
+          <name and="symbol" initialize-with=". " delimiter=", "/>
+          <label form="short" prefix=", " text-case="capitalize-first"/>
+          <substitute>
+            <names variable="editor"/>
+          </substitute>
+        </names>
+      </if>
+    </choose>
+  </macro>
+  <macro name="author">
+    <names variable="author">
+      <name name-as-sort-order="all" and="symbol" sort-separator=", " initialize-with=". " delimiter=", " delimiter-precedes-last="always"/>
+      <label form="short" prefix=" (" suffix=")" text-case="capitalize-first"/>
+      <substitute>
+        <names variable="editor"/>
+        <names variable="translator"/>
+        <text macro="title"/>
+      </substitute>
+    </names>
+  </macro>
+  <macro name="author-short">
+    <names variable="author">
+      <name form="short" and="symbol" delimiter=", " initialize-with=". "/>
+      <substitute>
+        <names variable="editor"/>
+        <names variable="translator"/>
+        <choose>
+          <if type="bill book graphic legal_case legislation motion_picture report song" match="any">
+            <text variable="title" form="short" font-style="italic"/>
+          </if>
+          <else>
+            <text variable="title" form="short" quotes="true"/>
+          </else>
+        </choose>
+      </substitute>
+    </names>
+  </macro>
+  <macro name="access">
+    <choose>
+      <if type="thesis">
+        <choose>
+          <if variable="archive" match="any">
+            <group>
+              <text term="retrieved" text-case="capitalize-first" suffix=" "/>
+              <text term="from" suffix=" "/>
+              <text variable="archive" suffix="."/>
+              <text variable="archive_location" prefix=" (" suffix=")"/>
+            </group>
+          </if>
+          <else>
+            <group>
+              <text term="retrieved" text-case="capitalize-first" suffix=" "/>
+              <date variable="accessed" suffix=", ">
+                <date-part name="month" suffix=" "/>
+                <date-part name="day" suffix=", "/>
+                <date-part name="year"/>
+              </date>
+              <text term="from" suffix=" "/>
+              <text variable="URL"/>
+            </group>
+          </else>
+        </choose>
+      </if>
+      <else>
+        <choose>
+          <if variable="URL">
+            <choose>
+              <if variable="archive">
+                <group>
+                  <text term="retrieved" text-case="capitalize-first" suffix=" "/>
+                  <text term="from" suffix=" "/>
+                  <text variable="archive" suffix="."/>
+                </group>
+              </if>
+              <else>
+                <group>
+                  <text term="retrieved" text-case="capitalize-first" suffix=" "/>
+                  <date variable="accessed" suffix=", ">
+                    <date-part name="month" suffix=" "/>
+                    <date-part name="day" suffix=", "/>
+                    <date-part name="year"/>
+                  </date>
+                  <group>
+                    <text term="from" suffix=" "/>
+                    <text variable="URL"/>
+                  </group>
+                </group>
+              </else>
+            </choose>
+          </if>
+        </choose>
+      </else>
+    </choose>
+  </macro>
+  <macro name="title">
+    <choose>
+      <if type="report thesis" match="any">
+        <text variable="title" font-style="italic"/>
+        <group prefix=" (" suffix=")">
+          <text variable="genre"/>
+          <text variable="number" prefix=" No. "/>
+        </group>
+      </if>
+      <else-if type="bill book graphic legal_case legislation manuscript motion_picture report song speech" match="any">
+        <text variable="title" font-style="italic"/>
+      </else-if>
+      <else>
+        <text variable="title"/>
+      </else>
+    </choose>
+  </macro>
+  <macro name="publisher">
+    <choose>
+      <if type="report" match="any">
+        <group delimiter=": ">
+          <text variable="publisher-place"/>
+          <text variable="publisher"/>
+        </group>
+      </if>
+      <else-if type="thesis" match="any">
+        <group delimiter=", ">
+          <text variable="publisher"/>
+          <text variable="publisher-place"/>
+        </group>
+      </else-if>
+      <else>
+        <choose>
+          <if variable="event" match="none">
+            <text variable="genre" suffix=", "/>
+          </if>
+        </choose>
+        <group delimiter=": ">
+          <text variable="publisher-place"/>
+          <text variable="publisher"/>
+        </group>
+      </else>
+    </choose>
+  </macro>
+  <macro name="event">
+    <choose>
+      <if variable="event">
+        <choose>
+          <if variable="genre" match="none">
+            <text term="presented at" text-case="capitalize-first" suffix=" "/>
+            <text variable="event"/>
+          </if>
+          <else>
+            <group delimiter=" ">
+              <text variable="genre" text-case="capitalize-first"/>
+              <text term="presented at"/>
+              <text variable="event"/>
+            </group>
+          </else>
+        </choose>
+      </if>
+    </choose>
+  </macro>
+  <macro name="issued">
+    <choose>
+      <if variable="issued">
+        <group prefix=" (" suffix=").">
+          <date variable="issued">
+            <date-part name="year"/>
+          </date>
+          <choose>
+            <if type="article-journal bill book chapter graphic legal_case legislation motion_picture paper-conference report song" match="none">
+              <date variable="issued">
+                <date-part prefix=", " name="month"/>
+                <date-part prefix=" " name="day"/>
+              </date>
+            </if>
+          </choose>
+        </group>
+      </if>
+      <else>
+        <text prefix=" (" term="no date" suffix=")." form="short"/>
+      </else>
+    </choose>
+  </macro>
+  <macro name="issued-year">
+    <choose>
+      <if variable="issued">
+        <date variable="issued">
+          <date-part name="year"/>
+        </date>
+      </if>
+      <else>
+        <text term="no date" form="short"/>
+      </else>
+    </choose>
+  </macro>
+  <macro name="edition">
+    <choose>
+      <if is-numeric="edition">
+        <group delimiter=" ">
+          <number variable="edition" form="ordinal"/>
+          <text term="edition" form="short"/>
+        </group>
+      </if>
+      <else>
+        <text variable="edition" suffix="."/>
+      </else>
+    </choose>
+  </macro>
+  <macro name="locators">
+    <choose>
+      <if type="article-journal article-magazine article-newspaper" match="any">
+        <group prefix=", " delimiter=", ">
+          <group>
+            <text variable="volume" font-style="italic"/>
+            <text variable="issue" prefix="(" suffix=")"/>
+          </group>
+          <text variable="page"/>
+        </group>
+      </if>
+      <else-if type="bill book chapter graphic legal_case legislation motion_picture paper-conference report song" match="any">
+        <group prefix=" (" suffix=")" delimiter=", ">
+          <text macro="edition"/>
+          <group>
+            <text term="volume" form="short" plural="true" text-case="capitalize-first" suffix=" "/>
+            <number variable="number-of-volumes" form="numeric" prefix="1-"/>
+          </group>
+          <group>
+            <text term="volume" form="short" text-case="capitalize-first" suffix=" "/>
+            <number variable="volume" form="numeric"/>
+          </group>
+          <group>
+            <label variable="page" form="short" suffix=" "/>
+            <text variable="page"/>
+          </group>
+        </group>
+      </else-if>
+    </choose>
+  </macro>
+  <macro name="citation-locator">
+    <group>
+      <label variable="locator" form="short"/>
+      <text variable="locator" prefix=" "/>
+    </group>
+  </macro>
+  <citation et-al-min="6" et-al-use-first="1" et-al-subsequent-min="3" et-al-subsequent-use-first="1" disambiguate-add-year-suffix="true" disambiguate-add-names="true" disambiguate-add-givenname="true" givenname-disambiguation-rule="primary-name" collapse="year">
+    <sort>
+      <key macro="author"/>
+      <key macro="issued-year"/>
+    </sort>
+    <layout prefix="(" suffix=")" delimiter="; ">
+      <group delimiter=", ">
+        <text macro="author-short"/>
+        <text macro="issued-year"/>
+        <text macro="citation-locator"/>
+      </group>
+    </layout>
+  </citation>
+  <bibliography hanging-indent="true" et-al-min="8" et-al-use-first="7" entry-spacing="0" line-spacing="2">
+    <sort>
+      <key macro="author"/>
+      <key macro="issued-year" sort="ascending"/>
+    </sort>
+    <layout>
+      <group suffix=".">
+        <text macro="author" suffix="."/>
+        <text macro="issued" suffix=" "/>
+        <group delimiter=". ">
+          <text macro="title"/>
+          <group>
+            <text macro="container-contributors"/>
+            <text macro="secondary-contributors"/>
+            <group delimiter=", ">
+              <text variable="container-title" font-style="italic"/>
+              <text variable="collection-title"/>
+            </group>
+          </group>
+        </group>
+        <text macro="locators"/>
+        <group delimiter=", " prefix=". ">
+          <text macro="event"/>
+          <text macro="publisher"/>
+        </group>
+      </group>
+      <text macro="access" prefix=". "/>
+    </layout>
+  </bibliography>
+</style>
diff --git a/elpa/org-ref-20251206.1422/citeproc/csl-styles/apa-numeric-superscript-brackets.csl b/elpa/org-ref-20251206.1422/citeproc/csl-styles/apa-numeric-superscript-brackets.csl
new file mode 100644 (file)
index 0000000..e1a2a18
--- /dev/null
@@ -0,0 +1,1711 @@
+<?xml version="1.0" encoding="utf-8"?>
+<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="never" page-range-format="expanded">
+  <info>
+    <title>American Psychological Association 7th edition (numeric, brackets)</title>
+    <title-short>APA (numeric, superscript, brackets)</title-short>
+    <id>http://www.zotero.org/styles/apa-numeric-superscript-brackets</id>
+    <link href="http://www.zotero.org/styles/apa-numeric-superscript-brackets" rel="self"/>
+    <link href="http://www.zotero.org/styles/apa" rel="template"/>
+    <link href="https://apastyle.apa.org/style-grammar-guidelines/references/examples" rel="documentation"/>
+    <author>
+      <name>Brenton M. Wiernik</name>
+      <email>zoteroNOSPAMwiernik.org</email>
+    </author>
+    <category citation-format="numeric"/>
+    <category field="psychology"/>
+    <category field="generic-base"/>
+    <summary>APA style, with numeric in-text citations in brackets</summary>
+    <updated>2021-03-11T05:11:56+00:00</updated>
+    <rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
+  </info>
+  <locale xml:lang="en">
+    <terms>
+      <term name="editortranslator" form="short">
+        <single>ed. &amp; trans.</single>
+        <multiple>eds. &amp; trans.</multiple>
+      </term>
+      <term name="translator" form="short">trans.</term>
+      <term name="interviewer" form="short">
+        <single>interviewer</single>
+        <multiple>interviewers</multiple>
+      </term>
+      <term name="collection-editor" form="short">
+        <single>ed.</single>
+        <multiple>eds.</multiple>
+      </term>
+      <term name="circa" form="short">ca.</term>
+      <term name="bc"> B.C.E.</term>
+      <term name="ad"> C.E.</term>
+      <term name="letter">personal communication</term>
+      <term name="letter" form="short">letter</term>
+      <term name="issue" form="long">
+        <single>issue</single>
+        <multiple>issues</multiple>
+      </term>
+    </terms>
+  </locale>
+  <locale xml:lang="af">
+    <terms>
+      <term name="letter">persoonlike kommunikasie</term>
+      <term name="letter" form="short">brief</term>
+    </terms>
+  </locale>
+  <locale xml:lang="ar">
+    <terms>
+      <term name="letter">اتصال شخصي</term>
+      <term name="letter" form="short">خطاب</term>
+    </terms>
+  </locale>
+  <locale xml:lang="da">
+    <terms>
+      <term name="et-al">et al.</term>
+      <term name="letter">personlig kommunikation</term>
+      <term name="letter" form="short">brev</term>
+    </terms>
+  </locale>
+  <locale xml:lang="de">
+    <terms>
+      <term name="et-al">et al.</term>
+      <term name="letter">persönliche Kommunikation</term>
+      <term name="letter" form="short">Brief</term>
+    </terms>
+  </locale>
+  <locale xml:lang="es">
+    <terms>
+      <term name="from">de</term>
+      <term name="letter">comunicación personal</term>
+      <term name="letter" form="short">carta</term>
+    </terms>
+  </locale>
+  <locale xml:lang="fr">
+    <terms>
+      <term name="letter">communication personnelle</term>
+      <term name="letter" form="short">lettre</term>
+      <term name="editor" form="short">
+        <single>éd.</single>
+        <multiple>éds.</multiple>
+      </term>
+    </terms>
+  </locale>
+  <locale xml:lang="nb">
+    <terms>
+      <term name="et-al">et al.</term>
+      <term name="letter">personlig kommunikasjon</term>
+      <term name="letter" form="short">brev</term>
+    </terms>
+  </locale>
+  <locale xml:lang="nl">
+    <terms>
+      <term name="et-al">et al.</term>
+      <term name="letter">persoonlijke communicatie</term>
+      <term name="letter" form="short">brief</term>
+    </terms>
+  </locale>
+  <locale xml:lang="nn">
+    <terms>
+      <term name="et-al">et al.</term>
+      <term name="letter">personlig kommunikasjon</term>
+      <term name="letter" form="short">brev</term>
+    </terms>
+  </locale>
+  <locale xml:lang="ru">
+    <terms>
+      <term name="letter">личная переписка</term>
+      <term name="letter" form="short">письмо</term>
+    </terms>
+  </locale>
+  <locale xml:lang="tr">
+    <terms>
+      <term name="letter">kişisel iletişim</term>
+      <term name="letter" form="short">mektup</term>
+    </terms>
+  </locale>
+  <!-- General categories of item types:
+       Periodical: article-journal article-magazine article-newspaper post-weblog review review-book
+       Periodical or Booklike: paper-conference
+       Booklike: article book broadcast chapter dataset entry entry-dictionary entry-encyclopedia figure 
+                 graphic interview manuscript map motion_picture musical_score pamphlet patent 
+                 personal_communication report song speech thesis post webpage
+       Legal: bill legal_case legislation treaty
+  -->
+  <!-- APA references contain four parts: author, date, title, source -->
+  <macro name="author-bib">
+    <names variable="composer" delimiter=", ">
+      <name name-as-sort-order="all" and="symbol" sort-separator=", " initialize-with=". " delimiter=", " delimiter-precedes-last="always"/>
+      <substitute>
+        <names variable="author"/>
+        <names variable="illustrator"/>
+        <names variable="director">
+          <name name-as-sort-order="all" and="symbol" sort-separator=", " initialize-with=". " delimiter=", " delimiter-precedes-last="always"/>
+          <label form="long" prefix=" (" suffix=")" text-case="title"/>
+        </names>
+        <choose>
+          <if variable="container-title">
+            <choose>
+              <if type="book entry entry-dictionary entry-encyclopedia" match="any">
+                <choose>
+                  <if variable="title">
+                    <group delimiter=" ">
+                      <text macro="title"/>
+                      <text macro="parenthetical"/>
+                    </group>
+                  </if>
+                  <else>
+                    <text macro="title-and-descriptions"/>
+                  </else>
+                </choose>
+              </if>
+            </choose>
+          </if>
+        </choose>
+        <!-- Test for editortranslator and put that first as that becomes available -->
+        <names variable="editor" delimiter=", ">
+          <name name-as-sort-order="all" and="symbol" sort-separator=", " initialize-with=". " delimiter=", " delimiter-precedes-last="always"/>
+          <label form="short" prefix=" (" suffix=")" text-case="title"/>
+        </names>
+        <names variable="editorial-director">
+          <name name-as-sort-order="all" and="symbol" sort-separator=", " initialize-with=". " delimiter=", " delimiter-precedes-last="always"/>
+          <label form="short" prefix=" (" suffix=")" text-case="title"/>
+        </names>
+        <names variable="collection-editor">
+          <name name-as-sort-order="all" and="symbol" sort-separator=", " initialize-with=". " delimiter=", " delimiter-precedes-last="always"/>
+          <label form="short" prefix=" (" suffix=")" text-case="title"/>
+        </names>
+        <choose>
+          <if variable="title">
+            <group delimiter=" ">
+              <text macro="title"/>
+              <text macro="parenthetical"/>
+            </group>
+          </if>
+          <else>
+            <text macro="title-and-descriptions"/>
+          </else>
+        </choose>
+      </substitute>
+    </names>
+  </macro>
+  <macro name="author-intext">
+    <choose>
+      <if type="bill legal_case legislation treaty" match="any">
+        <text macro="title-intext"/>
+      </if>
+      <else-if type="interview personal_communication" match="any">
+        <choose>
+          <!-- These variables indicate that the letter is retrievable by the reader. 
+                If not, then use the APA in-text-only personal communication format -->
+          <if variable="archive container-title DOI publisher URL" match="none">
+            <group delimiter=", ">
+              <names variable="author">
+                <name and="symbol" delimiter=", " initialize-with=". "/>
+                <substitute>
+                  <text macro="title-intext"/>
+                </substitute>
+              </names>
+              <!-- Replace with term="personal-communication" if that becomes available -->
+              <text term="letter"/>
+            </group>
+          </if>
+          <else>
+            <names variable="author" delimiter=", ">
+              <name form="short" and="symbol" delimiter=", " initialize-with=". "/>
+              <substitute>
+                <text macro="title-intext"/>
+              </substitute>
+            </names>
+          </else>
+        </choose>
+      </else-if>
+      <else>
+        <names variable="composer" delimiter=", ">
+          <name form="short" and="symbol" delimiter=", " initialize-with=". "/>
+          <substitute>
+            <names variable="author"/>
+            <names variable="illustrator"/>
+            <names variable="director"/>
+            <choose>
+              <if variable="container-title">
+                <choose>
+                  <if type="book entry entry-dictionary entry-encyclopedia" match="any">
+                    <text macro="title-intext"/>
+                  </if>
+                </choose>
+              </if>
+            </choose>
+            <names variable="editor"/>
+            <names variable="editorial-director"/>
+            <text macro="title-intext"/>
+          </substitute>
+        </names>
+      </else>
+    </choose>
+  </macro>
+  <macro name="date-bib">
+    <group delimiter=" " prefix="(" suffix=")">
+      <choose>
+        <if is-uncertain-date="issued">
+          <text term="circa" form="short"/>
+        </if>
+      </choose>
+      <group>
+        <choose>
+          <if variable="issued">
+            <date variable="issued">
+              <date-part name="year"/>
+            </date>
+            <text variable="year-suffix"/>
+            <choose>
+              <if type="article-magazine article-newspaper broadcast interview motion_picture pamphlet personal_communication post post-weblog song speech webpage" match="any">
+                <!-- Many video and audio examples in manual give full dates. Err on the side of too much information. -->
+                <date variable="issued">
+                  <date-part prefix=", " name="month"/>
+                  <date-part prefix=" " name="day"/>
+                </date>
+              </if>
+              <else-if type="paper-conference">
+                <!-- Capture 'speech' stored as 'paper-conference' -->
+                <choose>
+                  <if variable="collection-editor editor editorial-director issue page volume" match="none">
+                    <date variable="issued">
+                      <date-part prefix=", " name="month"/>
+                      <date-part prefix=" " name="day"/>
+                    </date>
+                  </if>
+                </choose>
+              </else-if>
+              <!-- Only year: article article-journal book chapter entry entry-dictionary entry-encyclopedia dataset figure graphic 
+                   manuscript map musical_score paper-conference[published] patent report review review-book thesis -->
+            </choose>
+          </if>
+          <else-if variable="status">
+            <group>
+              <text variable="status" text-case="lowercase"/>
+              <text variable="year-suffix" prefix="-"/>
+            </group>
+          </else-if>
+          <else>
+            <group>
+              <text term="no date" form="short"/>
+              <text variable="year-suffix" prefix="-"/>
+            </group>
+          </else>
+        </choose>
+      </group>
+    </group>
+  </macro>
+  <macro name="date-sort-group">
+    <choose>
+      <if variable="issued">
+        <text value="1"/>
+      </if>
+      <else-if variable="status">
+        <text value="2"/>
+      </else-if>
+      <else>
+        <text value="0"/>
+      </else>
+    </choose>
+  </macro>
+  <macro name="date-sort-date">
+    <choose>
+      <if type="article-magazine article-newspaper broadcast interview pamphlet personal_communication post post-weblog speech treaty webpage" match="any">
+        <date variable="issued" form="numeric"/>
+      </if>
+      <else-if type="paper-conference">
+        <!-- Capture 'speech' stored as 'paper-conference' -->
+        <choose>
+          <if variable="collection-editor editor editorial-director issue page volume" match="none">
+            <date variable="issued" form="numeric"/>
+          </if>
+        </choose>
+      </else-if>
+      <else>
+        <date variable="issued" form="numeric"/>
+      </else>
+    </choose>
+  </macro>
+  <macro name="date-intext">
+    <choose>
+      <if variable="issued">
+        <group delimiter="/">
+          <group delimiter=" ">
+            <choose>
+              <if is-uncertain-date="original-date">
+                <text term="circa" form="short"/>
+              </if>
+            </choose>
+            <date variable="original-date">
+              <date-part name="year"/>
+            </date>
+          </group>
+          <group delimiter=" ">
+            <choose>
+              <if is-uncertain-date="issued">
+                <text term="circa" form="short"/>
+              </if>
+            </choose>
+            <group>
+              <choose>
+                <if type="interview personal_communication" match="any">
+                  <choose>
+                    <if variable="archive container-title DOI publisher URL" match="none">
+                      <!-- These variables indicate that the communication is retrievable by the reader. 
+                           If not, then use the in-text-only personal communication format -->
+                      <date variable="issued" form="text"/>
+                    </if>
+                    <else>
+                      <date variable="issued">
+                        <date-part name="year"/>
+                      </date>
+                    </else>
+                  </choose>
+                </if>
+                <else>
+                  <date variable="issued">
+                    <date-part name="year"/>
+                  </date>
+                </else>
+              </choose>
+              <text variable="year-suffix"/>
+            </group>
+          </group>
+        </group>
+      </if>
+      <else-if variable="status">
+        <text variable="status" text-case="lowercase"/>
+        <text variable="year-suffix" prefix="-"/>
+      </else-if>
+      <else>
+        <text term="no date" form="short"/>
+        <text variable="year-suffix" prefix="-"/>
+      </else>
+    </choose>
+  </macro>
+  <!-- APA has two description elements following the title:
+       title (parenthetical) [bracketed]  -->
+  <macro name="title-and-descriptions">
+    <choose>
+      <if variable="title">
+        <group delimiter=" ">
+          <text macro="title"/>
+          <text macro="parenthetical"/>
+          <text macro="bracketed"/>
+        </group>
+      </if>
+      <else>
+        <group delimiter=" ">
+          <text macro="bracketed"/>
+          <text macro="parenthetical"/>
+        </group>
+      </else>
+    </choose>
+  </macro>
+  <macro name="title">
+    <choose>
+      <if type="post webpage" match="any">
+        <!-- Webpages are always italicized -->
+        <text variable="title" font-style="italic"/>
+      </if>
+      <else-if variable="container-title" match="any">
+        <!-- Other types are italicized based on presence of container-title.
+             Assume that review and review-book are published in periodicals/blogs,
+             not just on a web page (ex. 69) -->
+        <text variable="title"/>
+      </else-if>
+      <else>
+        <choose>
+          <if type="article-journal article-magazine article-newspaper post-weblog review review-book" match="any">
+            <text variable="title" font-style="italic"/>
+          </if>
+          <else-if type="paper-conference">
+            <choose>
+              <if variable="collection-editor editor editorial-director" match="any">
+                <group delimiter=": " font-style="italic">
+                  <text variable="title"/>
+                  <!-- Replace with volume-title as that becomes available -->
+                  <choose>
+                    <if is-numeric="volume" match="none">
+                      <group delimiter=" ">
+                        <label variable="volume" form="short" text-case="capitalize-first"/>
+                        <text variable="volume"/>
+                      </group>
+                    </if>
+                  </choose>
+                </group>
+              </if>
+              <else>
+                <text variable="title" font-style="italic"/>
+              </else>
+            </choose>
+          </else-if>
+          <else>
+            <group delimiter=": " font-style="italic">
+              <text variable="title"/>
+              <!-- Replace with volume-title as that becomes available -->
+              <choose>
+                <if is-numeric="volume" match="none">
+                  <group delimiter=" ">
+                    <label variable="volume" form="short" text-case="capitalize-first"/>
+                    <text variable="volume"/>
+                  </group>
+                </if>
+              </choose>
+            </group>
+          </else>
+        </choose>
+      </else>
+    </choose>
+  </macro>
+  <macro name="title-intext">
+    <choose>
+      <if variable="title" match="none">
+        <text macro="bracketed-intext" prefix="[" suffix="]"/>
+      </if>
+      <else-if type="bill">
+        <!-- If a bill has no number or container-title, assume it is a hearing; italic and title case -->
+        <choose>
+          <if variable="number container-title" match="none">
+            <text variable="title" form="short" font-style="italic" text-case="title"/>
+          </if>
+          <else-if variable="title">
+            <text variable="title" form="short"/>
+          </else-if>
+          <else>
+            <group delimiter=" ">
+              <text variable="genre"/>
+              <group delimiter=" ">
+                <choose>
+                  <if variable="chapter-number container-title" match="none">
+                    <!-- Replace with label variable="number" as that becomes available -->
+                    <text term="issue" form="short"/>
+                  </if>
+                </choose>
+                <text variable="number"/>
+              </group>
+            </group>
+          </else>
+        </choose>
+      </else-if>
+      <else-if type="legal_case" match="any">
+        <!-- Cases are italicized -->
+        <text variable="title" font-style="italic"/>
+      </else-if>
+      <else-if type="legislation treaty" match="any">
+        <!-- Legislation and treaties not italicized or quoted -->
+        <text variable="title" form="short"/>
+      </else-if>
+      <else-if type="post webpage" match="any">
+        <!-- Webpages are always italicized -->
+        <text variable="title" form="short" font-style="italic"/>
+      </else-if>
+      <else-if variable="container-title" match="any">
+        <!-- Other types are italicized or quoted based on presence of container-title. As in title macro. -->
+        <text variable="title" form="short" quotes="true"/>
+      </else-if>
+      <else>
+        <text variable="title" form="short" font-style="italic"/>
+      </else>
+    </choose>
+  </macro>
+  <macro name="parenthetical">
+    <!-- (Secondary contributors; Database location; Genre no. 123; Report Series 123, Version, Edition, Volume, Page) -->
+    <group prefix="(" suffix=")">
+      <choose>
+        <if type="patent">
+          <!-- authority: U.S. ; genre: patent ; number: 123,445 -->
+          <group delimiter=" ">
+            <text variable="authority" form="short"/>
+            <choose>
+              <if variable="genre">
+                <text variable="genre" text-case="capitalize-first"/>
+              </if>
+              <else>
+                <!-- This should be localized -->
+                <text value="patent" text-case="capitalize-first"/>
+              </else>
+            </choose>
+            <group delimiter=" ">
+              <!-- Replace with label variable="number" if that becomes available -->
+              <text term="issue" form="short" text-case="capitalize-first"/>
+              <text variable="number"/>
+            </group>
+          </group>
+        </if>
+        <else-if type="post webpage" match="any">
+          <!-- For post webpage, container-title is treated as publisher -->
+          <group delimiter="; ">
+            <text macro="secondary-contributors"/>
+            <text macro="database-location"/>
+            <text macro="number"/>
+            <text macro="locators-booklike"/>
+          </group>
+        </else-if>
+        <else-if variable="container-title">
+          <group delimiter="; ">
+            <text macro="secondary-contributors"/>
+            <choose>
+              <if type="broadcast graphic map motion_picture song" match="any">
+                <!-- For audiovisual media, number information comes after title, not container-title -->
+                <text macro="number"/>
+              </if>
+            </choose>
+          </group>
+        </else-if>
+        <else>
+          <group delimiter="; ">
+            <text macro="secondary-contributors"/>
+            <text macro="database-location"/>
+            <text macro="number"/>
+            <text macro="locators-booklike"/>
+          </group>
+        </else>
+      </choose>
+    </group>
+  </macro>
+  <macro name="parenthetical-container">
+    <choose>
+      <if variable="container-title" match="any">
+        <group prefix="(" suffix=")">
+          <group delimiter="; ">
+            <text macro="database-location"/>
+            <choose>
+              <if type="broadcast graphic map motion_picture song" match="none">
+                <!-- For audiovisual media, number information comes after title, not container-title -->
+                <text macro="number"/>
+              </if>
+            </choose>
+            <text macro="locators-booklike"/>
+          </group>
+        </group>
+      </if>
+    </choose>
+  </macro>
+  <macro name="bracketed">
+    <!-- [Descriptive information] -->
+    <!-- If there is a number, genre is already printed in macro="number" -->
+    <group prefix="[" suffix="]">
+      <choose>
+        <if variable="reviewed-author reviewed-title" type="review review-book" match="any">
+          <!-- Reviewed item -->
+          <group delimiter="; ">
+            <group delimiter=", ">
+              <group delimiter=" ">
+                <!-- Assume that genre is entered as 'Review of the book' or similar -->
+                <choose>
+                  <if variable="number" match="none">
+                    <choose>
+                      <if variable="genre">
+                        <text variable="genre" text-case="capitalize-first"/>
+                      </if>
+                      <else-if variable="medium">
+                        <text variable="medium" text-case="capitalize-first"/>
+                      </else-if>
+                      <else>
+                        <!-- Replace with term="review" as that becomes available -->
+                        <text value="Review of"/>
+                      </else>
+                    </choose>
+                  </if>
+                  <else>
+                    <choose>
+                      <if variable="medium">
+                        <text variable="medium" text-case="capitalize-first"/>
+                      </if>
+                      <else>
+                        <!-- Replace with term="review" as that becomes available -->
+                        <text value="Review of"/>
+                      </else>
+                    </choose>
+                  </else>
+                </choose>
+                <text macro="reviewed-title"/>
+              </group>
+              <names variable="reviewed-author">
+                <label form="verb-short" suffix=" "/>
+                <name and="symbol" initialize-with=". " delimiter=", "/>
+              </names>
+            </group>
+            <choose>
+              <if variable="genre" match="any">
+                <choose>
+                  <if variable="number" match="none">
+                    <text variable="medium" text-case="capitalize-first"/>
+                  </if>
+                </choose>
+              </if>
+            </choose>
+          </group>
+        </if>
+        <else-if type="thesis">
+          <!-- Thesis type and institution -->
+          <group delimiter="; ">
+            <choose>
+              <if variable="number" match="none">
+                <group delimiter=", ">
+                  <text variable="genre" text-case="capitalize-first"/>
+                  <choose>
+                    <if variable="archive DOI URL" match="any">
+                      <!-- Include the university in brackets if thesis is published -->
+                      <text variable="publisher"/>
+                    </if>
+                  </choose>
+                </group>
+              </if>
+            </choose>
+            <text variable="medium" text-case="capitalize-first"/>
+          </group>
+        </else-if>
+        <else-if variable="interviewer" type="interview" match="any">
+          <!-- Interview information -->
+          <choose>
+            <if variable="title">
+              <text macro="format"/>
+            </if>
+            <else-if variable="genre">
+              <group delimiter="; ">
+                <group delimiter=" ">
+                  <text variable="genre" text-case="capitalize-first"/>
+                  <group delimiter=" ">
+                    <text term="author" form="verb"/>
+                    <names variable="interviewer">
+                      <name and="symbol" initialize-with=". " delimiter=", "/>
+                    </names>
+                  </group>
+                </group>
+              </group>
+            </else-if>
+            <else-if variable="interviewer">
+              <group delimiter="; ">
+                <names variable="interviewer">
+                  <label form="verb" suffix=" " text-case="capitalize-first"/>
+                  <name and="symbol" initialize-with=". " delimiter=", "/>
+                </names>
+                <text variable="medium" text-case="capitalize-first"/>
+              </group>
+            </else-if>
+            <else>
+              <text macro="format"/>
+            </else>
+          </choose>
+        </else-if>
+        <else-if type="personal_communication">
+          <!-- Letter information -->
+          <choose>
+            <if variable="recipient">
+              <group delimiter="; ">
+                <group delimiter=" ">
+                  <choose>
+                    <if variable="number" match="none">
+                      <choose>
+                        <if variable="genre">
+                          <text variable="genre" text-case="capitalize-first"/>
+                        </if>
+                        <else-if variable="medium">
+                          <text variable="medium" text-case="capitalize-first"/>
+                        </else-if>
+                        <else>
+                          <text term="letter" form="short" text-case="capitalize-first"/>
+                        </else>
+                      </choose>
+                    </if>
+                    <else>
+                      <choose>
+                        <if variable="medium">
+                          <text variable="medium" text-case="capitalize-first"/>
+                        </if>
+                        <else>
+                          <text term="letter" form="short" text-case="capitalize-first"/>
+                        </else>
+                      </choose>
+                    </else>
+                  </choose>
+                  <names variable="recipient" delimiter=", ">
+                    <label form="verb" suffix=" "/>
+                    <name and="symbol" delimiter=", "/>
+                  </names>
+                </group>
+                <choose>
+                  <if variable="genre" match="any">
+                    <choose>
+                      <if variable="number" match="none">
+                        <text variable="medium" text-case="capitalize-first"/>
+                      </if>
+                    </choose>
+                  </if>
+                </choose>
+              </group>
+            </if>
+            <else>
+              <text macro="format"/>
+            </else>
+          </choose>
+        </else-if>
+        <else-if variable="composer" type="song" match="all">
+          <!-- Performer of classical music works -->
+          <group delimiter="; ">
+            <choose>
+              <if variable="number" match="none">
+                <group delimiter=" ">
+                  <choose>
+                    <if variable="genre">
+                      <text variable="genre" text-case="capitalize-first"/>
+                      <!-- Replace prefix with performer label as that becomes available -->
+                      <names variable="author" prefix="recorded by ">
+                        <name and="symbol" initialize-with=". " delimiter=", "/>
+                      </names>
+                    </if>
+                    <else-if variable="medium">
+                      <text variable="medium" text-case="capitalize-first"/>
+                      <!-- Replace prefix with performer label as that becomes available -->
+                      <names variable="author" prefix="recorded by ">
+                        <name and="symbol" initialize-with=". " delimiter=", "/>
+                      </names>
+                    </else-if>
+                    <else>
+                      <!-- Replace prefix with performer label as that becomes available -->
+                      <names variable="author" prefix="Recorded by ">
+                        <name and="symbol" initialize-with=". " delimiter=", "/>
+                      </names>
+                    </else>
+                  </choose>
+                </group>
+              </if>
+              <else>
+                <group delimiter=" ">
+                  <choose>
+                    <if variable="medium">
+                      <text variable="medium" text-case="capitalize-first"/>
+                      <!-- Replace prefix with performer label as that becomes available -->
+                      <names variable="author" prefix="recorded by ">
+                        <name and="symbol" initialize-with=". " delimiter=", "/>
+                      </names>
+                    </if>
+                    <else>
+                      <!-- Replace prefix with performer label as that becomes available -->
+                      <names variable="author" prefix="Recorded by ">
+                        <name and="symbol" initialize-with=". " delimiter=", "/>
+                      </names>
+                    </else>
+                  </choose>
+                </group>
+              </else>
+            </choose>
+            <choose>
+              <if variable="genre" match="any">
+                <choose>
+                  <if variable="number" match="none">
+                    <text variable="medium" text-case="capitalize-first"/>
+                  </if>
+                </choose>
+              </if>
+            </choose>
+          </group>
+        </else-if>
+        <else-if variable="container-title" match="none">
+          <!-- Other description -->
+          <text macro="format"/>
+        </else-if>
+        <else>
+          <!-- For conference presentations, chapters in reports, software, place bracketed after the container title -->
+          <choose>
+            <if type="paper-conference speech" match="any">
+              <choose>
+                <if variable="collection-editor editor editorial-director issue page volume" match="any">
+                  <text macro="format"/>
+                </if>
+              </choose>
+            </if>
+            <else-if type="book">
+              <choose>
+                <if variable="version" match="none">
+                  <text macro="format"/>
+                </if>
+              </choose>
+            </else-if>
+            <else-if type="report" match="none">
+              <text macro="format"/>
+            </else-if>
+          </choose>
+        </else>
+      </choose>
+    </group>
+  </macro>
+  <macro name="bracketed-intext">
+    <group prefix="[" suffix="]">
+      <choose>
+        <if variable="reviewed-author reviewed-title" type="review review-book" match="any">
+          <!-- This should be localized -->
+          <text macro="reviewed-title-intext" prefix="Review of "/>
+        </if>
+        <else-if variable="interviewer" type="interview" match="any">
+          <names variable="interviewer">
+            <label form="verb" suffix=" " text-case="capitalize-first"/>
+            <name and="symbol" initialize-with=". " delimiter=", "/>
+            <substitute>
+              <text macro="format-intext"/>
+            </substitute>
+          </names>
+        </else-if>
+        <else-if type="personal_communication">
+          <!-- Letter information -->
+          <choose>
+            <if variable="recipient">
+              <group delimiter=" ">
+                <choose>
+                  <if variable="number" match="none">
+                    <text variable="genre" text-case="capitalize-first"/>
+                  </if>
+                  <else>
+                    <text term="letter" form="short" text-case="capitalize-first"/>
+                  </else>
+                </choose>
+                <names variable="recipient" delimiter=", ">
+                  <label form="verb" suffix=" "/>
+                  <name and="symbol" delimiter=", "/>
+                </names>
+              </group>
+            </if>
+            <else>
+              <text macro="format-intext"/>
+            </else>
+          </choose>
+        </else-if>
+        <else>
+          <text macro="format-intext"/>
+        </else>
+      </choose>
+    </group>
+  </macro>
+  <macro name="bracketed-container">
+    <group prefix="[" suffix="]">
+      <choose>
+        <if type="paper-conference speech" match="any">
+          <!-- Conference presentations should describe the session [container] in bracketed unless published in a proceedings -->
+          <choose>
+            <if variable="collection-editor editor editorial-director issue page volume" match="none">
+              <text macro="format"/>
+            </if>
+          </choose>
+        </if>
+        <else-if type="book" variable="version" match="all">
+          <!-- For entries in mobile app reference works, place bracketed after the container-title -->
+          <text macro="format"/>
+        </else-if>
+        <else-if type="report">
+          <!-- For chapters in reports, place bracketed after the container title -->
+          <text macro="format"/>
+        </else-if>
+      </choose>
+    </group>
+  </macro>
+  <macro name="secondary-contributors">
+    <choose>
+      <if type="article-journal article-magazine article-newspaper post-weblog review review-book" match="any">
+        <text macro="secondary-contributors-periodical"/>
+      </if>
+      <else-if type="paper-conference">
+        <choose>
+          <if variable="collection-editor editor editorial-director" match="any">
+            <text macro="secondary-contributors-booklike"/>
+          </if>
+          <else>
+            <text macro="secondary-contributors-periodical"/>
+          </else>
+        </choose>
+      </else-if>
+      <else>
+        <text macro="secondary-contributors-booklike"/>
+      </else>
+    </choose>
+  </macro>
+  <macro name="secondary-contributors-periodical">
+    <group delimiter="; ">
+      <choose>
+        <if variable="title">
+          <names variable="interviewer" delimiter="; ">
+            <name and="symbol" initialize-with=". " delimiter=", "/>
+            <label form="short" prefix=", " text-case="title"/>
+          </names>
+        </if>
+      </choose>
+      <names variable="translator" delimiter="; ">
+        <name and="symbol" initialize-with=". " delimiter=", "/>
+        <label form="short" prefix=", " text-case="title"/>
+      </names>
+    </group>
+  </macro>
+  <macro name="secondary-contributors-booklike">
+    <group delimiter="; ">
+      <choose>
+        <if variable="title">
+          <names variable="interviewer">
+            <name and="symbol" initialize-with=". " delimiter=", "/>
+            <label form="short" prefix=", " text-case="title"/>
+          </names>
+        </if>
+      </choose>
+      <!-- When editortranslator becomes available, add a test: variable="editortranslator" match="none"; then print translator -->
+      <choose>
+        <if type="post webpage" match="none">
+          <!-- Webpages treat container-title like publisher -->
+          <choose>
+            <if variable="container-title" match="none">
+              <group delimiter="; ">
+                <names variable="container-author">
+                  <label form="verb-short" suffix=" " text-case="title"/>
+                  <name and="symbol" initialize-with=". " delimiter=", "/>
+                </names>
+                <names variable="editor translator" delimiter="; ">
+                  <name and="symbol" initialize-with=". " delimiter=", "/>
+                  <label form="short" prefix=", " text-case="title"/>
+                </names>
+              </group>
+            </if>
+          </choose>
+        </if>
+        <else>
+          <group delimiter="; ">
+            <names variable="container-author">
+              <label form="verb-short" suffix=" " text-case="title"/>
+              <name and="symbol" initialize-with=". " delimiter=", "/>
+            </names>
+            <names variable="editor translator" delimiter="; ">
+              <name and="symbol" initialize-with=". " delimiter=", "/>
+              <label form="short" prefix=", " text-case="title"/>
+            </names>
+          </group>
+        </else>
+      </choose>
+    </group>
+  </macro>
+  <macro name="database-location">
+    <choose>
+      <if variable="archive-place" match="none">
+        <!-- With `archive-place`: physical archives. Without: online archives. -->
+        <!-- Add archive_collection as that becomes available -->
+        <text variable="archive_location"/>
+      </if>
+    </choose>
+  </macro>
+  <macro name="number">
+    <choose>
+      <if variable="number">
+        <group delimiter=", ">
+          <group delimiter=" ">
+            <text variable="genre" text-case="title"/>
+            <choose>
+              <if is-numeric="number">
+                <!-- Replace with label variable="number" if that becomes available -->
+                <text term="issue" form="short" text-case="capitalize-first"/>
+                <text variable="number"/>
+              </if>
+              <else>
+                <text variable="number"/>
+              </else>
+            </choose>
+          </group>
+          <choose>
+            <if type="thesis">
+              <choose>
+                <!-- Include the university in brackets if thesis is published -->
+                <if variable="archive DOI URL" match="any">
+                  <text variable="publisher"/>
+                </if>
+              </choose>
+            </if>
+          </choose>
+        </group>
+      </if>
+    </choose>
+  </macro>
+  <macro name="locators-booklike">
+    <choose>
+      <if type="article-journal article-magazine article-newspaper broadcast interview patent post post-weblog review review-book speech webpage" match="any"/>
+      <else-if type="paper-conference">
+        <choose>
+          <if variable="collection-editor editor editorial-director" match="any">
+            <group delimiter=", ">
+              <text macro="version"/>
+              <text macro="edition"/>
+              <text macro="volume-booklike"/>
+            </group>
+          </if>
+        </choose>
+      </else-if>
+      <else>
+        <group delimiter=", ">
+          <text macro="version"/>
+          <text macro="edition"/>
+          <text macro="volume-booklike"/>
+        </group>
+      </else>
+    </choose>
+  </macro>
+  <macro name="version">
+    <choose>
+      <if is-numeric="version">
+        <group delimiter=" ">
+          <!-- replace with label variable="version" if that becomes available -->
+          <text term="version" text-case="capitalize-first"/>
+          <text variable="version"/>
+        </group>
+      </if>
+      <else>
+        <text variable="version"/>
+      </else>
+    </choose>
+  </macro>
+  <macro name="edition">
+    <choose>
+      <if is-numeric="edition">
+        <group delimiter=" ">
+          <number variable="edition" form="ordinal"/>
+          <label variable="edition" form="short"/>
+        </group>
+      </if>
+      <else>
+        <text variable="edition"/>
+      </else>
+    </choose>
+  </macro>
+  <macro name="volume-booklike">
+    <group delimiter=", ">
+      <!-- Report series [ex. 52] -->
+      <choose>
+        <if type="report">
+          <group delimiter=" ">
+            <text variable="collection-title" text-case="title"/>
+            <text variable="collection-number"/>
+          </group>
+        </if>
+      </choose>
+      <choose>
+        <if variable="volume" match="any">
+          <choose>
+            <!-- Non-numeric volumes are already printed as part of the book title -->
+            <if is-numeric="volume" match="none"/>
+            <else>
+              <group delimiter=" ">
+                <label variable="volume" form="short" text-case="capitalize-first"/>
+                <number variable="volume" form="numeric"/>
+              </group>
+            </else>
+          </choose>
+        </if>
+        <else>
+          <group>
+            <!-- Replace with label variable="number-of-volumes" if that becomes available -->
+            <text term="volume" form="short" text-case="capitalize-first" suffix=" "/>
+            <text term="page-range-delimiter" prefix="1"/>
+            <number variable="number-of-volumes" form="numeric"/>
+          </group>
+        </else>
+      </choose>
+      <group delimiter=" ">
+        <label variable="issue" text-case="capitalize-first"/>
+        <text variable="issue"/>
+      </group>
+      <group delimiter=" ">
+        <label variable="page" form="short" suffix=" "/>
+        <text variable="page"/>
+      </group>
+    </group>
+  </macro>
+  <macro name="reviewed-title">
+    <choose>
+      <if variable="reviewed-title">
+        <!-- Not possible to distinguish TV series episode from other reviewed 
+              works [Ex. 69] -->
+        <text variable="reviewed-title" font-style="italic"/>
+      </if>
+      <else>
+        <!-- Assume title is title of reviewed work -->
+        <text variable="title" font-style="italic"/>
+      </else>
+    </choose>
+  </macro>
+  <macro name="reviewed-title-intext">
+    <choose>
+      <if variable="reviewed-title">
+        <!-- Not possible to distinguish TV series episode from other reviewed works [Ex. 69] -->
+        <text variable="reviewed-title" form="short" font-style="italic"/>
+      </if>
+      <else>
+        <!-- Assume title is title of reviewed work -->
+        <text variable="title" form="short" font-style="italic"/>
+      </else>
+    </choose>
+  </macro>
+  <macro name="format">
+    <choose>
+      <if variable="genre medium" match="any">
+        <group delimiter="; ">
+          <choose>
+            <if variable="number" match="none">
+              <text variable="genre" text-case="capitalize-first"/>
+            </if>
+          </choose>
+          <text variable="medium" text-case="capitalize-first"/>
+        </group>
+      </if>
+      <!-- Generic labels for specific types -->
+      <!-- These should be localized when possible -->
+      <else-if type="dataset">
+        <text value="Data set"/>
+      </else-if>
+      <else-if type="book" variable="version" match="all">
+        <!-- Replace with type="software" and term="software" as that becomes available -->
+        <text value="Computer software"/>
+      </else-if>
+      <else-if type="interview personal_communication" match="any">
+        <choose>
+          <if variable="archive container-title DOI publisher URL" match="none">
+            <text term="letter" text-case="capitalize-first"/>
+          </if>
+          <else-if type="interview">
+            <text term="interview" text-case="capitalize-first"/>
+          </else-if>
+        </choose>
+      </else-if>
+      <else-if type="map">
+        <text value="Map"/>
+      </else-if>
+    </choose>
+  </macro>
+  <macro name="format-intext">
+    <choose>
+      <if variable="genre" match="any">
+        <text variable="genre" text-case="capitalize-first"/>
+      </if>
+      <else-if variable="medium">
+        <text variable="medium" text-case="capitalize-first"/>
+      </else-if>
+      <!-- Generic labels for specific types -->
+      <!-- These should be localized when possible -->
+      <else-if type="dataset">
+        <text value="Data set"/>
+      </else-if>
+      <else-if type="book" variable="version" match="all">
+        <!-- Replace with type="software" and term="software" as that becomes available -->
+        <text value="Computer software"/>
+      </else-if>
+      <else-if type="interview personal_communication" match="any">
+        <choose>
+          <if variable="archive container-title DOI publisher URL" match="none">
+            <text term="letter" text-case="capitalize-first"/>
+          </if>
+          <else-if type="interview">
+            <text term="interview" text-case="capitalize-first"/>
+          </else-if>
+        </choose>
+      </else-if>
+      <else-if type="map">
+        <text value="Map"/>
+      </else-if>
+    </choose>
+  </macro>
+  <!-- APA 'source' element contains four parts:
+       container, event, publisher, access -->
+  <macro name="container">
+    <choose>
+      <if type="article-journal article-magazine article-newspaper post-weblog review review-book" match="any">
+        <!-- Periodical items -->
+        <text macro="container-periodical"/>
+      </if>
+      <else-if type="paper-conference">
+        <!-- Determine if paper-conference is a periodical or booklike -->
+        <choose>
+          <if variable="editor editorial-director collection-editor container-author" match="any">
+            <text macro="container-booklike"/>
+          </if>
+          <else>
+            <text macro="container-periodical"/>
+          </else>
+        </choose>
+      </else-if>
+      <else-if type="post webpage" match="none">
+        <!-- post and webpage treat container-title like publisher -->
+        <text macro="container-booklike"/>
+      </else-if>
+    </choose>
+  </macro>
+  <macro name="container-periodical">
+    <group delimiter=". ">
+      <group delimiter=", ">
+        <text variable="container-title" font-style="italic" text-case="title"/>
+        <choose>
+          <if variable="volume">
+            <group>
+              <text variable="volume" font-style="italic"/>
+              <text variable="issue" prefix="(" suffix=")"/>
+            </group>
+          </if>
+          <else>
+            <text variable="issue" font-style="italic"/>
+          </else>
+        </choose>
+        <choose>
+          <if variable="page">
+            <text variable="page"/>
+          </if>
+          <else>
+            <!-- Ex. 6: Journal article with article number or eLocator -->
+            <!-- This should be localized -->
+            <text variable="number" prefix="Article "/>
+          </else>
+        </choose>
+      </group>
+      <choose>
+        <if variable="issued">
+          <choose>
+            <if variable="issue page volume" match="none">
+              <text variable="status" text-case="capitalize-first"/>
+            </if>
+          </choose>
+        </if>
+      </choose>
+    </group>
+  </macro>
+  <macro name="container-booklike">
+    <choose>
+      <if variable="container-title" match="any">
+        <group delimiter=" ">
+          <text term="in" text-case="capitalize-first"/>
+          <group delimiter=", ">
+            <names variable="editor translator" delimiter=", &amp; ">
+              <!-- Change to editortranslator and move editor to substitute as that becomes available -->
+              <name and="symbol" initialize-with=". " delimiter=", "/>
+              <label form="short" text-case="title" prefix=" (" suffix=")"/>
+              <substitute>
+                <names variable="editorial-director"/>
+                <names variable="collection-editor"/>
+                <names variable="container-author"/>
+              </substitute>
+            </names>
+            <group delimiter=": " font-style="italic">
+              <text variable="container-title"/>
+              <!-- Replace with volume-title as that becomes available -->
+              <choose>
+                <if is-numeric="volume" match="none">
+                  <group delimiter=" ">
+                    <label variable="volume" form="short" text-case="capitalize-first"/>
+                    <text variable="volume"/>
+                  </group>
+                </if>
+              </choose>
+            </group>
+          </group>
+          <text macro="parenthetical-container"/>
+          <text macro="bracketed-container"/>
+        </group>
+      </if>
+    </choose>
+  </macro>
+  <macro name="publisher">
+    <group delimiter="; ">
+      <choose>
+        <if type="thesis">
+          <choose>
+            <if variable="archive DOI URL" match="none">
+              <text variable="publisher"/>
+            </if>
+          </choose>
+        </if>
+        <else-if type="post webpage" match="any">
+          <!-- For websites, treat container title like publisher -->
+          <group delimiter="; ">
+            <text variable="container-title" text-case="title"/>
+            <text variable="publisher"/>
+          </group>
+        </else-if>
+        <else-if type="paper-conference">
+          <!-- For paper-conference, don't print publisher if in a journal-like proceedings -->
+          <choose>
+            <if variable="collection-editor editor editorial-director" match="any">
+              <text variable="publisher"/>
+            </if>
+          </choose>
+        </else-if>
+        <else-if type="article-journal article-magazine article-newspaper post-weblog" match="none">
+          <text variable="publisher"/>
+        </else-if>
+      </choose>
+      <group delimiter=", ">
+        <choose>
+          <if variable="archive-place">
+            <!-- With `archive-place`: physical archives. Without: online archives. -->
+            <!-- For physical archives, print the location before the archive name.
+                For electronic archives, these are printed in macro="description". -->
+            <!-- Split "archive_location" into "archive_collection" and "archive_location" as that becomes available -->
+            <!-- Must test for archive_collection:
+                With collection: archive_collection (archive_location), archive, archive-place
+                No collection: archive (archive_location), archive-place
+            -->
+            <text variable="archive_location"/>
+          </if>
+        </choose>
+        <text variable="archive"/>
+        <text variable="archive-place"/>
+      </group>
+    </group>
+  </macro>
+  <macro name="access">
+    <choose>
+      <if variable="DOI" match="any">
+        <text variable="DOI" prefix="https://doi.org/"/>
+      </if>
+      <else-if variable="URL">
+        <group delimiter=" ">
+          <choose>
+            <if variable="issued status" match="none">
+              <group delimiter=" ">
+                <text term="retrieved" text-case="capitalize-first"/>
+                <date variable="accessed" form="text" suffix=","/>
+                <text term="from"/>
+              </group>
+            </if>
+          </choose>
+          <text variable="URL"/>
+        </group>
+      </else-if>
+    </choose>
+  </macro>
+  <macro name="event">
+    <choose>
+      <if variable="event">
+        <!-- To prevent Zotero from printing event-place due to its double-mapping of all 'place' to
+             both publisher-place and event-place. Remove this 'choose' when that is changed. -->
+        <choose>
+          <if variable="collection-editor editor editorial-director issue page volume" match="none">
+            <!-- Don't print event info if published in a proceedings -->
+            <group delimiter=", ">
+              <text variable="event"/>
+              <text variable="event-place"/>
+            </group>
+          </if>
+        </choose>
+      </if>
+    </choose>
+  </macro>
+  <!-- After 'source', APA also prints publication history (original publication, reprint info, retraction info) -->
+  <macro name="publication-history">
+    <choose>
+      <if type="patent" match="none">
+        <group prefix="(" suffix=")">
+          <choose>
+            <if variable="references">
+              <!-- This provides the option for more elaborate description 
+                   of publication history, such as full "reprinted" references
+                   (examples 11, 43, 44) or retracted references -->
+              <text variable="references"/>
+            </if>
+            <else>
+              <group delimiter=" ">
+                <text value="Original work published"/>
+                <choose>
+                  <if is-uncertain-date="original-date">
+                    <text term="circa" form="short"/>
+                  </if>
+                </choose>
+                <date variable="original-date">
+                  <date-part name="year"/>
+                </date>
+              </group>
+            </else>
+          </choose>
+        </group>
+      </if>
+      <else>
+        <text variable="references" prefix="(" suffix=")"/>
+      </else>
+    </choose>
+  </macro>
+  <!-- Legal citations have their own rules -->
+  <macro name="legal-cites">
+    <choose>
+      <if type="legal_case">
+        <group delimiter=". ">
+          <group delimiter=", ">
+            <text variable="title"/>
+            <group delimiter=" ">
+              <text macro="container-legal"/>
+              <text macro="date-legal"/>
+            </group>
+            <text variable="references"/>
+          </group>
+          <text macro="access"/>
+        </group>
+      </if>
+      <else-if type="bill">
+        <!-- Currently designed to handle bills, resolutions, hearings, rederal reports. -->
+        <group delimiter=". ">
+          <group delimiter=", ">
+            <choose>
+              <if variable="number container-title" match="none">
+                <!-- If no number or container-title, then assume it is a hearing -->
+                <text variable="title" font-style="italic"/>
+              </if>
+              <else>
+                <text variable="title"/>
+              </else>
+            </choose>
+            <group delimiter=" ">
+              <text macro="container-legal"/>
+              <text macro="date-legal"/>
+              <choose>
+                <if variable="number container-title" match="none">
+                  <!-- If no number or container-title, then assume it is a hearing -->
+                  <names variable="author" prefix="(testimony of " suffix=")">
+                    <name and="symbol" delimiter=", "/>
+                  </names>
+                </if>
+                <else>
+                  <text variable="status" prefix="(" suffix=")"/>
+                </else>
+              </choose>
+            </group>
+            <text variable="references"/>
+          </group>
+          <text macro="access"/>
+        </group>
+      </else-if>
+      <else-if type="legislation">
+        <!-- Currently designed to handle statutes, codified regulations, executive orders.
+             For uncodified regulations, assume future code section is in status. -->
+        <group delimiter=". ">
+          <group delimiter=", ">
+            <text variable="title"/>
+            <group delimiter=" ">
+              <text macro="container-legal"/>
+              <text macro="date-legal"/>
+              <text variable="status" prefix="(" suffix=")"/>
+            </group>
+            <text variable="references"/>
+          </group>
+          <text macro="access"/>
+        </group>
+      </else-if>
+      <else-if type="treaty">
+        <!-- APA generally defers to Bluebook for legal citations, but diverges without
+             explanation for treaty items. The Bluebook format that was used in APA 6th
+             ed. is used here. -->
+        <group delimiter=", ">
+          <text variable="title" text-case="title"/>
+          <names variable="author">
+            <name initialize-with="." form="short" delimiter="-"/>
+          </names>
+          <text macro="date-legal"/>
+          <text macro="container-legal"/>
+          <text macro="access"/>
+        </group>
+      </else-if>
+    </choose>
+  </macro>
+  <macro name="date-legal">
+    <choose>
+      <if type="legal_case">
+        <group prefix="(" suffix=")" delimiter=" ">
+          <text variable="authority"/>
+          <choose>
+            <if variable="container-title" match="any">
+              <!-- Print only year for cases published in reporters-->
+              <date variable="issued" form="numeric" date-parts="year"/>
+            </if>
+            <else>
+              <date variable="issued" form="text"/>
+            </else>
+          </choose>
+        </group>
+      </if>
+      <else-if type="bill legislation" match="any">
+        <group prefix="(" suffix=")" delimiter=" ">
+          <group delimiter=" ">
+            <date variable="original-date">
+              <date-part name="year"/>
+            </date>
+            <text term="and" form="symbol"/>
+          </group>
+          <date variable="issued">
+            <date-part name="year"/>
+          </date>
+        </group>
+      </else-if>
+      <else-if type="treaty">
+        <date variable="issued" form="text"/>
+      </else-if>
+    </choose>
+  </macro>
+  <macro name="container-legal">
+    <!-- Expect legal item container-titles to be stored in short form -->
+    <choose>
+      <if type="legal_case">
+        <group delimiter=" ">
+          <choose>
+            <if variable="container-title">
+              <group delimiter=" ">
+                <text variable="volume"/>
+                <text variable="container-title"/>
+                <group delimiter=" ">
+                  <!-- Change to label variable="section" as that becomes available -->
+                  <text term="section" form="symbol"/>
+                  <text variable="section"/>
+                </group>
+                <choose>
+                  <if variable="page page-first" match="any">
+                    <text variable="page-first"/>
+                  </if>
+                  <else>
+                    <text value="___"/>
+                  </else>
+                </choose>
+              </group>
+            </if>
+            <else>
+              <group delimiter=" ">
+                <choose>
+                  <if is-numeric="number">
+                    <!-- Replace with label variable="number" if that becomes available -->
+                    <text term="issue" form="short" text-case="capitalize-first"/>
+                  </if>
+                </choose>
+                <text variable="number"/>
+              </group>
+            </else>
+          </choose>
+        </group>
+      </if>
+      <else-if type="bill">
+        <group delimiter=", ">
+          <group delimiter=" ">
+            <text variable="genre"/>
+            <group delimiter=" ">
+              <choose>
+                <if variable="chapter-number container-title" match="none">
+                  <!-- Replace with label variable="number" as that becomes available -->
+                  <text term="issue" form="short"/>
+                </if>
+              </choose>
+              <text variable="number"/>
+            </group>
+          </group>
+          <text variable="authority"/>
+          <text variable="chapter-number"/>
+          <group delimiter=" ">
+            <text variable="volume"/>
+            <text variable="container-title"/>
+            <text variable="page-first"/>
+          </group>
+        </group>
+      </else-if>
+      <else-if type="legislation">
+        <choose>
+          <if variable="number">
+            <!--There's a public law number-->
+            <group delimiter=", ">
+              <text variable="number" prefix="Pub. L. No. "/>
+              <group delimiter=" ">
+                <text variable="volume"/>
+                <text variable="container-title"/>
+                <text variable="page-first"/>
+              </group>
+            </group>
+          </if>
+          <else>
+            <group delimiter=" ">
+              <text variable="volume"/>
+              <text variable="container-title"/>
+              <choose>
+                <if variable="section">
+                  <group delimiter=" ">
+                    <!-- Change to label variable="section" as that becomes available -->
+                    <text term="section" form="symbol"/>
+                    <text variable="section"/>
+                  </group>
+                </if>
+                <else>
+                  <text variable="page-first"/>
+                </else>
+              </choose>
+            </group>
+          </else>
+        </choose>
+      </else-if>
+      <else-if type="treaty">
+        <group delimiter=" ">
+          <number variable="volume"/>
+          <text variable="container-title"/>
+          <choose>
+            <if variable="page page-first" match="any">
+              <text variable="page-first"/>
+            </if>
+            <else>
+              <group delimiter=" ">
+                <!-- Replace with label variable="number" if that becomes available -->
+                <text term="issue" form="short" text-case="capitalize-first"/>
+                <text variable="number"/>
+              </group>
+            </else>
+          </choose>
+        </group>
+      </else-if>
+    </choose>
+  </macro>
+  <macro name="citation-locator">
+    <group delimiter=" ">
+      <choose>
+        <if locator="chapter">
+          <label variable="locator" text-case="capitalize-first"/>
+        </if>
+        <else>
+          <label variable="locator" form="short"/>
+        </else>
+      </choose>
+      <text variable="locator"/>
+    </group>
+  </macro>
+  <citation collapse="citation-number">
+    <sort>
+      <key variable="citation-number"/>
+    </sort>
+    <layout delimiter="," prefix="[" suffix="]" vertical-align="sup">
+      <group>
+        <text variable="citation-number"/>
+        <text macro="citation-locator" prefix="(" suffix=")"/>
+      </group>
+    </layout>
+  </citation>
+  <bibliography hanging-indent="true" et-al-min="21" et-al-use-first="19" et-al-use-last="true" entry-spacing="0" line-spacing="2">
+    <layout>
+      <group delimiter=". ">
+        <text variable="citation-number"/>
+        <choose>
+          <if type="bill legal_case legislation treaty" match="any">
+            <!-- Legal items have different orders and delimiters -->
+            <choose>
+              <if variable="DOI URL" match="any">
+                <text macro="legal-cites"/>
+              </if>
+              <else>
+                <text macro="legal-cites" suffix="."/>
+              </else>
+            </choose>
+          </if>
+          <else>
+            <group delimiter=" ">
+              <group delimiter=". " suffix=".">
+                <text macro="author-bib"/>
+                <text macro="date-bib"/>
+                <text macro="title-and-descriptions"/>
+                <text macro="container"/>
+                <text macro="event"/>
+                <text macro="publisher"/>
+              </group>
+              <text macro="access"/>
+              <text macro="publication-history"/>
+            </group>
+          </else>
+        </choose>
+      </group>
+    </layout>
+  </bibliography>
+</style>
diff --git a/elpa/org-ref-20251206.1422/citeproc/csl-styles/chicago-author-date-16th-edition.csl b/elpa/org-ref-20251206.1422/citeproc/csl-styles/chicago-author-date-16th-edition.csl
new file mode 100644 (file)
index 0000000..6ff1f0b
--- /dev/null
@@ -0,0 +1,657 @@
+<?xml version="1.0" encoding="utf-8"?>
+<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="display-and-sort" page-range-format="chicago">
+  <info>
+    <title>Chicago Manual of Style 16th edition (author-date)</title>
+    <id>http://www.zotero.org/styles/chicago-author-date-16th-edition</id>
+    <link href="http://www.zotero.org/styles/chicago-author-date-16th-edition" rel="self"/>
+    <link href="http://www.chicagomanualofstyle.org/tools_citationguide.html" rel="documentation"/>
+    <author>
+      <name>Julian Onions</name>
+      <email>julian.onionsNOSPAMgmail.com</email>
+    </author>
+    <contributor>
+      <name>Sebastian Karcher</name>
+    </contributor>
+    <contributor>
+      <name>Richard Karnesky</name>
+      <email>karnesky+zotero@gmail.com</email>
+      <uri>http://arc.nucapt.northwestern.edu/Richard_Karnesky</uri>
+    </contributor>
+    <contributor>
+      <name>Andrew Dunning</name>
+      <email>andrew.dunningNOSPAMutoronto.ca</email>
+    </contributor>
+    <contributor>
+      <name>Brenton M. Wiernik</name>
+    </contributor>
+    <category citation-format="author-date"/>
+    <category field="generic-base"/>
+    <summary>The author-date variant of the Chicago style</summary>
+    <updated>2020-04-26T18:22:50+00:00</updated>
+    <rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
+  </info>
+  <locale xml:lang="en">
+    <terms>
+      <term name="editor" form="verb-short">ed.</term>
+      <term name="container-author" form="verb">by</term>
+      <term name="translator" form="verb-short">trans.</term>
+      <term name="editortranslator" form="verb">edited and translated by</term>
+      <term name="translator" form="short">trans.</term>
+    </terms>
+  </locale>
+  <macro name="secondary-contributors">
+    <choose>
+      <if type="chapter entry-dictionary entry-encyclopedia paper-conference" match="none">
+        <group delimiter=". ">
+          <names variable="editor translator" delimiter=". ">
+            <label form="verb" text-case="capitalize-first" suffix=" "/>
+            <name and="text" delimiter=", "/>
+          </names>
+          <names variable="director" delimiter=". ">
+            <label form="verb" text-case="capitalize-first" suffix=" "/>
+            <name and="text" delimiter=", "/>
+          </names>
+        </group>
+      </if>
+    </choose>
+  </macro>
+  <macro name="container-contributors">
+    <choose>
+      <if type="chapter entry-dictionary entry-encyclopedia paper-conference" match="any">
+        <group prefix=", " delimiter=", ">
+          <names variable="container-author" delimiter=", ">
+            <label form="verb" suffix=" "/>
+            <name and="text" delimiter=", "/>
+          </names>
+          <names variable="editor translator" delimiter=", ">
+            <label form="verb" suffix=" "/>
+            <name and="text" delimiter=", "/>
+          </names>
+        </group>
+      </if>
+    </choose>
+  </macro>
+  <macro name="editor">
+    <names variable="editor">
+      <name name-as-sort-order="first" and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/>
+      <label form="short" prefix=", "/>
+    </names>
+  </macro>
+  <macro name="translator">
+    <names variable="translator">
+      <name name-as-sort-order="first" and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/>
+      <label form="short" prefix=", "/>
+    </names>
+  </macro>
+  <macro name="recipient">
+    <choose>
+      <if type="personal_communication">
+        <choose>
+          <if variable="genre">
+            <text variable="genre" text-case="capitalize-first"/>
+          </if>
+          <else>
+            <text term="letter" text-case="capitalize-first"/>
+          </else>
+        </choose>
+      </if>
+    </choose>
+    <names variable="recipient" delimiter=", ">
+      <label form="verb" prefix=" " text-case="lowercase" suffix=" "/>
+      <name and="text" delimiter=", "/>
+    </names>
+  </macro>
+  <macro name="substitute-title">
+    <choose>
+      <if type="article-magazine article-newspaper review review-book" match="any">
+        <text macro="container-title"/>
+      </if>
+    </choose>
+  </macro>
+  <macro name="contributors">
+    <group delimiter=". ">
+      <names variable="author">
+        <name and="text" name-as-sort-order="first" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/>
+        <label form="short" prefix=", "/>
+        <substitute>
+          <names variable="editor"/>
+          <names variable="translator"/>
+          <names variable="director"/>
+          <text macro="substitute-title"/>
+          <text macro="title"/>
+        </substitute>
+      </names>
+      <text macro="recipient"/>
+    </group>
+  </macro>
+  <macro name="contributors-short">
+    <names variable="author">
+      <name form="short" and="text" delimiter=", " initialize-with=". "/>
+      <substitute>
+        <names variable="editor"/>
+        <names variable="translator"/>
+        <names variable="director"/>
+        <text macro="substitute-title"/>
+        <text macro="title"/>
+      </substitute>
+    </names>
+  </macro>
+  <macro name="interviewer">
+    <names variable="interviewer" delimiter=", ">
+      <label form="verb" prefix=" " text-case="capitalize-first" suffix=" "/>
+      <name and="text" delimiter=", "/>
+    </names>
+  </macro>
+  <macro name="archive">
+    <group delimiter=". ">
+      <text variable="archive_location" text-case="capitalize-first"/>
+      <text variable="archive"/>
+      <text variable="archive-place"/>
+    </group>
+  </macro>
+  <macro name="access">
+    <group delimiter=". ">
+      <choose>
+        <if type="graphic report" match="any">
+          <text macro="archive"/>
+        </if>
+        <else-if type="article-journal bill book chapter legal_case legislation motion_picture paper-conference" match="none">
+          <text macro="archive"/>
+        </else-if>
+      </choose>
+      <choose>
+        <if type="webpage post-weblog" match="any">
+          <date variable="issued" delimiter=" ">
+            <date-part name="month"/>
+            <date-part name="day"/>
+          </date>
+        </if>
+      </choose>
+      <choose>
+        <if variable="issued" match="none">
+          <group delimiter=" ">
+            <text term="accessed" text-case="capitalize-first"/>
+            <date variable="accessed" delimiter=" ">
+              <date-part name="month"/>
+              <date-part name="day"/>
+            </date>
+          </group>
+        </if>
+      </choose>
+      <choose>
+        <if type="legal_case" match="none">
+          <choose>
+            <if variable="DOI">
+              <text variable="DOI" prefix="doi:"/>
+            </if>
+            <else>
+              <text variable="URL"/>
+            </else>
+          </choose>
+        </if>
+      </choose>
+    </group>
+  </macro>
+  <macro name="title">
+    <choose>
+      <if variable="title" match="none">
+        <choose>
+          <if type="personal_communication" match="none">
+            <text variable="genre" text-case="capitalize-first"/>
+          </if>
+        </choose>
+      </if>
+      <else-if type="bill book graphic legislation motion_picture song" match="any">
+        <text variable="title" text-case="title" font-style="italic"/>
+        <group prefix=" (" suffix=")" delimiter=" ">
+          <text term="version"/>
+          <text variable="version"/>
+        </group>
+      </else-if>
+      <else-if variable="reviewed-author">
+        <choose>
+          <if variable="reviewed-title">
+            <group delimiter=". ">
+              <text variable="title" text-case="title" quotes="true"/>
+              <group delimiter=", ">
+                <text variable="reviewed-title" text-case="title" font-style="italic" prefix="Review of "/>
+                <names variable="reviewed-author">
+                  <label form="verb-short" text-case="lowercase" suffix=" "/>
+                  <name and="text" delimiter=", "/>
+                </names>
+              </group>
+            </group>
+          </if>
+          <else>
+            <group delimiter=", ">
+              <text variable="title" text-case="title" font-style="italic" prefix="Review of "/>
+              <names variable="reviewed-author">
+                <label form="verb-short" text-case="lowercase" suffix=" "/>
+                <name and="text" delimiter=", "/>
+              </names>
+            </group>
+          </else>
+        </choose>
+      </else-if>
+      <else-if type="legal_case interview patent" match="any">
+        <text variable="title"/>
+      </else-if>
+      <else>
+        <text variable="title" text-case="title" quotes="true"/>
+      </else>
+    </choose>
+  </macro>
+  <macro name="edition">
+    <choose>
+      <if type="bill book graphic legal_case legislation motion_picture report song" match="any">
+        <choose>
+          <if is-numeric="edition">
+            <group delimiter=" " prefix=". ">
+              <number variable="edition" form="ordinal"/>
+              <text term="edition" form="short" strip-periods="true"/>
+            </group>
+          </if>
+          <else>
+            <text variable="edition" text-case="capitalize-first" prefix=". "/>
+          </else>
+        </choose>
+      </if>
+      <else-if type="chapter entry-dictionary entry-encyclopedia paper-conference" match="any">
+        <choose>
+          <if is-numeric="edition">
+            <group delimiter=" " prefix=", ">
+              <number variable="edition" form="ordinal"/>
+              <text term="edition" form="short"/>
+            </group>
+          </if>
+          <else>
+            <text variable="edition" prefix=", "/>
+          </else>
+        </choose>
+      </else-if>
+    </choose>
+  </macro>
+  <macro name="locators">
+    <choose>
+      <if type="article-journal">
+        <choose>
+          <if variable="volume">
+            <text variable="volume" prefix=" "/>
+            <group prefix=" (" suffix=")">
+              <choose>
+                <if variable="issue">
+                  <text variable="issue"/>
+                </if>
+                <else>
+                  <date variable="issued">
+                    <date-part name="month"/>
+                  </date>
+                </else>
+              </choose>
+            </group>
+          </if>
+          <else-if variable="issue">
+            <group delimiter=" " prefix=", ">
+              <text term="issue" form="short"/>
+              <text variable="issue"/>
+              <date variable="issued" prefix="(" suffix=")">
+                <date-part name="month"/>
+              </date>
+            </group>
+          </else-if>
+          <else>
+            <date variable="issued" prefix=", ">
+              <date-part name="month"/>
+            </date>
+          </else>
+        </choose>
+      </if>
+      <else-if type="legal_case">
+        <text variable="volume" prefix=", "/>
+        <text variable="container-title" prefix=" "/>
+        <text variable="page" prefix=" "/>
+      </else-if>
+      <else-if type="bill book graphic legal_case legislation motion_picture report song" match="any">
+        <group prefix=". " delimiter=". ">
+          <group>
+            <text term="volume" form="short" text-case="capitalize-first" suffix=" "/>
+            <number variable="volume" form="numeric"/>
+          </group>
+          <group>
+            <number variable="number-of-volumes" form="numeric"/>
+            <text term="volume" form="short" prefix=" " plural="true"/>
+          </group>
+        </group>
+      </else-if>
+      <else-if type="chapter entry-dictionary entry-encyclopedia paper-conference" match="any">
+        <choose>
+          <if variable="page" match="none">
+            <group prefix=". ">
+              <text term="volume" form="short" text-case="capitalize-first" suffix=" "/>
+              <number variable="volume" form="numeric"/>
+            </group>
+          </if>
+        </choose>
+      </else-if>
+    </choose>
+  </macro>
+  <macro name="locators-chapter">
+    <choose>
+      <if type="chapter entry-dictionary entry-encyclopedia paper-conference" match="any">
+        <choose>
+          <if variable="page">
+            <group prefix=", ">
+              <text variable="volume" suffix=":"/>
+              <text variable="page"/>
+            </group>
+          </if>
+        </choose>
+      </if>
+    </choose>
+  </macro>
+  <macro name="locators-article">
+    <choose>
+      <if type="article-newspaper">
+        <group prefix=", " delimiter=", ">
+          <group delimiter=" ">
+            <text variable="edition"/>
+            <text term="edition"/>
+          </group>
+          <group>
+            <text term="section" form="short" suffix=" "/>
+            <text variable="section"/>
+          </group>
+        </group>
+      </if>
+      <else-if type="article-journal">
+        <choose>
+          <if variable="volume issue" match="any">
+            <text variable="page" prefix=": "/>
+          </if>
+          <else>
+            <text variable="page" prefix=", "/>
+          </else>
+        </choose>
+      </else-if>
+    </choose>
+  </macro>
+  <macro name="point-locators">
+    <choose>
+      <if variable="locator">
+        <choose>
+          <if locator="page" match="none">
+            <choose>
+              <if type="bill book graphic legal_case legislation motion_picture report song" match="any">
+                <choose>
+                  <if variable="volume">
+                    <group>
+                      <text term="volume" form="short" suffix=" "/>
+                      <number variable="volume" form="numeric"/>
+                      <label variable="locator" form="short" prefix=", " suffix=" "/>
+                    </group>
+                  </if>
+                  <else>
+                    <label variable="locator" form="short" suffix=" "/>
+                  </else>
+                </choose>
+              </if>
+              <else>
+                <label variable="locator" form="short" suffix=" "/>
+              </else>
+            </choose>
+          </if>
+          <else-if type="bill book graphic legal_case legislation motion_picture report song" match="any">
+            <number variable="volume" form="numeric" suffix=":"/>
+          </else-if>
+        </choose>
+        <text variable="locator"/>
+      </if>
+    </choose>
+  </macro>
+  <macro name="container-prefix">
+    <text term="in" text-case="capitalize-first"/>
+  </macro>
+  <macro name="container-title">
+    <choose>
+      <if type="chapter entry-dictionary entry-encyclopedia paper-conference" match="any">
+        <text macro="container-prefix" suffix=" "/>
+      </if>
+    </choose>
+    <choose>
+      <if type="legal_case" match="none">
+        <text variable="container-title" text-case="title" font-style="italic"/>
+      </if>
+    </choose>
+  </macro>
+  <macro name="publisher">
+    <group delimiter=": ">
+      <text variable="publisher-place"/>
+      <text variable="publisher"/>
+    </group>
+  </macro>
+  <macro name="date">
+    <choose>
+      <if variable="issued">
+        <group delimiter=" ">
+          <date variable="original-date" form="text" date-parts="year" prefix="(" suffix=")"/>
+          <date variable="issued">
+            <date-part name="year"/>
+          </date>
+        </group>
+      </if>
+      <else-if variable="accessed">
+        <date variable="accessed">
+          <date-part name="year"/>
+        </date>
+      </else-if>
+      <else-if variable="status">
+        <text variable="status" text-case="capitalize-first"/>
+      </else-if>
+      <else>
+        <text term="no date" form="short"/>
+      </else>
+    </choose>
+  </macro>
+  <macro name="date-in-text">
+    <choose>
+      <if variable="issued">
+        <group delimiter=" ">
+          <date variable="original-date" form="text" date-parts="year" prefix="[" suffix="]"/>
+          <date variable="issued">
+            <date-part name="year"/>
+          </date>
+        </group>
+      </if>
+      <else-if variable="accessed">
+        <date variable="accessed">
+          <date-part name="year"/>
+        </date>
+      </else-if>
+      <else-if variable="status">
+        <text variable="status"/>
+      </else-if>
+      <else>
+        <text term="no date" form="short"/>
+      </else>
+    </choose>
+  </macro>
+  <macro name="day-month">
+    <date variable="issued">
+      <date-part name="month"/>
+      <date-part name="day" prefix=" "/>
+    </date>
+  </macro>
+  <macro name="collection-title">
+    <choose>
+      <if match="none" type="article-journal">
+        <choose>
+          <if match="none" is-numeric="collection-number">
+            <group delimiter=", ">
+              <text variable="collection-title" text-case="title"/>
+              <text variable="collection-number"/>
+            </group>
+          </if>
+          <else>
+            <group delimiter=" ">
+              <text variable="collection-title" text-case="title"/>
+              <text variable="collection-number"/>
+            </group>
+          </else>
+        </choose>
+      </if>
+    </choose>
+  </macro>
+  <macro name="collection-title-journal">
+    <choose>
+      <if type="article-journal">
+        <group delimiter=" ">
+          <text variable="collection-title"/>
+          <text variable="collection-number"/>
+        </group>
+      </if>
+    </choose>
+  </macro>
+  <macro name="event">
+    <group delimiter=" ">
+      <choose>
+        <if variable="genre">
+          <text term="presented at"/>
+        </if>
+        <else>
+          <text term="presented at" text-case="capitalize-first"/>
+        </else>
+      </choose>
+      <text variable="event"/>
+    </group>
+  </macro>
+  <macro name="description">
+    <choose>
+      <if type="interview">
+        <group delimiter=". ">
+          <text macro="interviewer"/>
+          <text variable="medium" text-case="capitalize-first"/>
+        </group>
+      </if>
+      <else-if type="patent">
+        <group delimiter=" " prefix=". ">
+          <text variable="authority"/>
+          <text variable="number"/>
+        </group>
+      </else-if>
+      <else>
+        <text variable="medium" text-case="capitalize-first" prefix=". "/>
+      </else>
+    </choose>
+    <choose>
+      <if variable="title" match="none"/>
+      <else-if type="thesis personal_communication speech" match="any"/>
+      <else>
+        <group delimiter=" " prefix=". ">
+          <text variable="genre" text-case="capitalize-first"/>
+          <choose>
+            <if type="report">
+              <text variable="number"/>
+            </if>
+          </choose>
+        </group>
+      </else>
+    </choose>
+  </macro>
+  <macro name="issue">
+    <choose>
+      <if type="legal_case">
+        <text variable="authority" prefix=". "/>
+      </if>
+      <else-if type="speech">
+        <group prefix=". " delimiter=", ">
+          <group delimiter=" ">
+            <text variable="genre" text-case="capitalize-first"/>
+            <text macro="event"/>
+          </group>
+          <text variable="event-place"/>
+          <text macro="day-month"/>
+        </group>
+      </else-if>
+      <else-if type="article-newspaper article-magazine personal_communication" match="any">
+        <text macro="day-month" prefix=", "/>
+      </else-if>
+      <else-if type="patent">
+        <group delimiter=", " prefix=", ">
+          <group delimiter=" ">
+            <!--Needs Localization-->
+            <text value="filed"/>
+            <date variable="submitted" form="text"/>
+          </group>
+          <group delimiter=" ">
+            <choose>
+              <if variable="issued submitted" match="all">
+                <text term="and"/>
+              </if>
+            </choose>
+            <!--Needs Localization-->
+            <text value="issued"/>
+            <date variable="issued" form="text"/>
+          </group>
+        </group>
+      </else-if>
+      <else>
+        <group prefix=". " delimiter=", ">
+          <choose>
+            <if type="thesis">
+              <text variable="genre" text-case="capitalize-first"/>
+            </if>
+          </choose>
+          <text macro="publisher"/>
+        </group>
+      </else>
+    </choose>
+  </macro>
+  <citation et-al-min="4" et-al-use-first="1" disambiguate-add-year-suffix="true" disambiguate-add-names="true" disambiguate-add-givenname="true" givenname-disambiguation-rule="primary-name" collapse="year">
+    <layout prefix="(" suffix=")" delimiter="; ">
+      <group delimiter=", ">
+        <choose>
+          <if variable="issued accessed" match="any">
+            <group delimiter=" ">
+              <text macro="contributors-short"/>
+              <text macro="date-in-text"/>
+            </group>
+          </if>
+          <!---comma before forthcoming and n.d.-->
+          <else>
+            <group delimiter=", ">
+              <text macro="contributors-short"/>
+              <text macro="date-in-text"/>
+            </group>
+          </else>
+        </choose>
+        <text macro="point-locators"/>
+      </group>
+    </layout>
+  </citation>
+  <bibliography hanging-indent="true" et-al-min="11" et-al-use-first="7" subsequent-author-substitute="&#8212;&#8212;&#8212;" entry-spacing="0">
+    <sort>
+      <key macro="contributors"/>
+      <key variable="issued"/>
+      <key variable="title"/>
+    </sort>
+    <layout suffix=".">
+      <group delimiter=". ">
+        <text macro="contributors"/>
+        <text macro="date"/>
+        <text macro="title"/>
+      </group>
+      <text macro="description"/>
+      <text macro="secondary-contributors" prefix=". "/>
+      <text macro="container-title" prefix=". "/>
+      <text macro="container-contributors"/>
+      <text macro="edition"/>
+      <text macro="locators-chapter"/>
+      <text macro="collection-title-journal" prefix=", " suffix=", "/>
+      <text macro="locators"/>
+      <text macro="collection-title" prefix=". "/>
+      <text macro="issue"/>
+      <text macro="locators-article"/>
+      <text macro="access" prefix=". "/>
+    </layout>
+  </bibliography>
+</style>
diff --git a/elpa/org-ref-20251206.1422/citeproc/csl-styles/chicago-fullnote-bibliography-16th-edition.csl b/elpa/org-ref-20251206.1422/citeproc/csl-styles/chicago-fullnote-bibliography-16th-edition.csl
new file mode 100644 (file)
index 0000000..862ad97
--- /dev/null
@@ -0,0 +1,1368 @@
+<?xml version="1.0" encoding="utf-8"?>
+<style xmlns="http://purl.org/net/xbiblio/csl" class="note" version="1.0" demote-non-dropping-particle="display-and-sort" page-range-format="chicago">
+  <info>
+    <title>Chicago Manual of Style 16th edition (full note)</title>
+    <id>http://www.zotero.org/styles/chicago-fullnote-bibliography-16th-edition</id>
+    <link href="http://www.zotero.org/styles/chicago-fullnote-bibliography-16th-edition" rel="self"/>
+    <link href="http://www.chicagomanualofstyle.org/tools_citationguide.html" rel="documentation"/>
+    <author>
+      <name>Julian Onions</name>
+      <email>julian.onionsNOSPAMgmail.com</email>
+    </author>
+    <contributor>
+      <name>Simon Kornblith</name>
+      <email>simonNOSPAMsimonster.com</email>
+    </contributor>
+    <contributor>
+      <name>Elena Razlogova</name>
+      <email>elena.razlogovaNOSPAMgmail.com</email>
+    </contributor>
+    <contributor>
+      <name>Frank Bennett</name>
+      <email>biercenatorNOSPAMgmail.com</email>
+    </contributor>
+    <contributor>
+      <name>Andrew Dunning</name>
+      <email>andrew.dunningNOSPAMutoronto.ca</email>
+    </contributor>
+    <contributor>
+      <name>Brenton M. Wiernik</name>
+    </contributor>
+    <category citation-format="note"/>
+    <category field="generic-base"/>
+    <summary>Chicago format with full notes and bibliography</summary>
+    <updated>2020-04-26T18:22:50+00:00</updated>
+    <rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
+  </info>
+  <locale xml:lang="en">
+    <terms>
+      <term name="editor" form="verb-short">ed.</term>
+      <term name="translator" form="verb-short">trans.</term>
+      <term name="translator" form="short">trans.</term>
+      <term name="editortranslator" form="verb-short">ed. and trans.</term>
+      <term name="editortranslator" form="verb">Edited and translated by</term>
+      <term name="translator" form="short">trans.</term>
+    </terms>
+  </locale>
+  <macro name="editor-translator">
+    <group delimiter=", ">
+      <group delimiter=" ">
+        <choose>
+          <if variable="container-author reviewed-author" match="any">
+            <group>
+              <names variable="container-author reviewed-author">
+                <label form="verb-short" text-case="lowercase" suffix=" "/>
+                <name and="text" delimiter=", "/>
+              </names>
+            </group>
+          </if>
+        </choose>
+      </group>
+      <names variable="editor translator" delimiter=", ">
+        <label form="verb-short" text-case="lowercase" suffix=" "/>
+        <name and="text" delimiter=", "/>
+      </names>
+    </group>
+  </macro>
+  <macro name="secondary-contributors-note">
+    <choose>
+      <if type="chapter entry-dictionary entry-encyclopedia paper-conference" match="none">
+        <text macro="editor-translator"/>
+      </if>
+    </choose>
+  </macro>
+  <macro name="container-contributors-note">
+    <choose>
+      <if type="chapter entry-dictionary entry-encyclopedia paper-conference" match="any">
+        <text macro="editor-translator"/>
+      </if>
+    </choose>
+  </macro>
+  <macro name="secondary-contributors">
+    <choose>
+      <if type="chapter entry-dictionary entry-encyclopedia paper-conference" match="none">
+        <names variable="editor translator" delimiter=". ">
+          <label form="verb" text-case="capitalize-first" suffix=" "/>
+          <name and="text" delimiter=", "/>
+        </names>
+      </if>
+    </choose>
+  </macro>
+  <macro name="container-contributors">
+    <choose>
+      <if type="chapter entry-dictionary entry-encyclopedia paper-conference" match="any">
+        <group delimiter=", ">
+          <choose>
+            <if variable="author">
+              <choose>
+                <if variable="container-author" match="any">
+                  <names variable="container-author">
+                    <label form="verb-short" text-case="lowercase" suffix=" "/>
+                    <name and="text" delimiter=", "/>
+                  </names>
+                </if>
+              </choose>
+              <!--This includes page numers after the container author, e.g. for Introductions -->
+              <choose>
+                <if variable="container-author author" match="all">
+                  <group delimiter=". ">
+                    <text variable="page"/>
+                    <names variable="editor translator" delimiter=", ">
+                      <label form="verb" suffix=" "/>
+                      <name and="text" delimiter=", "/>
+                    </names>
+                  </group>
+                </if>
+                <else>
+                  <names variable="editor translator" delimiter=", ">
+                    <label form="verb" text-case="lowercase" suffix=" "/>
+                    <name and="text" delimiter=", "/>
+                  </names>
+                </else>
+              </choose>
+            </if>
+          </choose>
+        </group>
+      </if>
+    </choose>
+  </macro>
+  <macro name="recipient-note">
+    <names variable="recipient" delimiter=", ">
+      <label form="verb" text-case="lowercase" suffix=" "/>
+      <name and="text" delimiter=", "/>
+    </names>
+  </macro>
+  <macro name="contributors-note">
+    <group delimiter=" ">
+      <names variable="author">
+        <name and="text" sort-separator=", " delimiter=", "/>
+        <label form="short" prefix=", "/>
+        <substitute>
+          <names variable="editor"/>
+          <names variable="translator"/>
+        </substitute>
+      </names>
+      <text macro="recipient-note"/>
+    </group>
+  </macro>
+  <macro name="editor">
+    <names variable="editor">
+      <name name-as-sort-order="first" and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/>
+      <label form="short" prefix=", "/>
+    </names>
+  </macro>
+  <macro name="translator">
+    <names variable="translator">
+      <name name-as-sort-order="first" and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/>
+      <label form="verb-short" prefix=", "/>
+    </names>
+  </macro>
+  <macro name="recipient">
+    <group delimiter=" ">
+      <choose>
+        <if type="personal_communication">
+          <choose>
+            <if variable="genre">
+              <text variable="genre" text-case="capitalize-first"/>
+            </if>
+            <else>
+              <text term="letter" text-case="capitalize-first"/>
+            </else>
+          </choose>
+        </if>
+      </choose>
+      <text macro="recipient-note"/>
+    </group>
+  </macro>
+  <macro name="contributors">
+    <group delimiter=". ">
+      <names variable="author">
+        <name name-as-sort-order="first" and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/>
+        <substitute>
+          <text macro="editor"/>
+          <text macro="translator"/>
+        </substitute>
+      </names>
+      <text macro="recipient"/>
+    </group>
+  </macro>
+  <macro name="recipient-short">
+    <names variable="recipient">
+      <label form="verb" text-case="lowercase" suffix=" "/>
+      <name form="short" and="text" delimiter=", "/>
+    </names>
+  </macro>
+  <macro name="contributors-short">
+    <group delimiter=" ">
+      <names variable="author">
+        <name form="short" and="text" delimiter=", "/>
+        <substitute>
+          <names variable="editor"/>
+          <names variable="translator"/>
+        </substitute>
+      </names>
+      <text macro="recipient-short"/>
+    </group>
+  </macro>
+  <macro name="contributors-sort">
+    <names variable="author">
+      <name name-as-sort-order="all" and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/>
+      <substitute>
+        <names variable="editor"/>
+        <names variable="translator"/>
+        <text macro="title"/>
+      </substitute>
+    </names>
+  </macro>
+  <macro name="interviewer-note">
+    <names variable="interviewer" delimiter=", ">
+      <label form="verb" text-case="lowercase" suffix=" "/>
+      <name and="text" delimiter=", "/>
+    </names>
+  </macro>
+  <macro name="interviewer">
+    <names variable="interviewer" delimiter=", ">
+      <label form="verb" text-case="capitalize-first" suffix=" "/>
+      <name and="text" delimiter=", "/>
+    </names>
+  </macro>
+  <macro name="title-note">
+    <choose>
+      <if variable="title" match="none">
+        <text variable="genre"/>
+      </if>
+      <else-if type="book graphic motion_picture song" match="any">
+        <text variable="title" text-case="title" font-style="italic"/>
+        <group delimiter=" " prefix=", ">
+          <text term="version"/>
+          <text variable="version"/>
+        </group>
+      </else-if>
+      <else-if type="legal_case interview patent" match="any">
+        <text variable="title"/>
+      </else-if>
+      <else-if variable="reviewed-author">
+        <text variable="title" font-style="italic" prefix="review of "/>
+      </else-if>
+      <else>
+        <text variable="title" text-case="title" quotes="true"/>
+      </else>
+    </choose>
+  </macro>
+  <macro name="title">
+    <choose>
+      <if variable="title" match="none">
+        <choose>
+          <if type="personal_communication" match="none">
+            <text variable="genre" text-case="capitalize-first"/>
+          </if>
+        </choose>
+      </if>
+      <else-if type="book graphic motion_picture song" match="any">
+        <text variable="title" text-case="title" font-style="italic"/>
+        <group prefix=" (" suffix=")" delimiter=" ">
+          <text term="version"/>
+          <text variable="version"/>
+        </group>
+      </else-if>
+      <else-if variable="reviewed-author">
+        <group delimiter=", ">
+          <text variable="title" font-style="italic" prefix="Review of "/>
+          <names variable="reviewed-author">
+            <label form="verb-short" text-case="lowercase" suffix=" "/>
+            <name and="text" delimiter=", "/>
+          </names>
+        </group>
+      </else-if>
+      <else-if type="bill legislation legal_case interview patent" match="any">
+        <text variable="title"/>
+      </else-if>
+      <else>
+        <text variable="title" text-case="title" quotes="true"/>
+      </else>
+    </choose>
+  </macro>
+  <macro name="title-short">
+    <choose>
+      <if variable="title" match="none">
+        <choose>
+          <if type="interview">
+            <text term="interview"/>
+          </if>
+          <else-if type="manuscript speech" match="any">
+            <text variable="genre" form="short"/>
+          </else-if>
+          <else-if type="personal_communication">
+            <text macro="issued"/>
+          </else-if>
+        </choose>
+      </if>
+      <else-if type="book graphic motion_picture song" match="any">
+        <text variable="title" text-case="title" form="short" font-style="italic"/>
+      </else-if>
+      <else-if type="legal_case" variable="title-short" match="all">
+        <text variable="title" font-style="italic" form="short"/>
+      </else-if>
+      <else-if type="patent interview" match="any">
+        <text variable="title" form="short"/>
+      </else-if>
+      <else-if type="legal_case bill legislation" match="any">
+        <text variable="title"/>
+      </else-if>
+      <else>
+        <text variable="title" text-case="title" form="short" quotes="true"/>
+      </else>
+    </choose>
+  </macro>
+  <macro name="date-disambiguate">
+    <choose>
+      <if disambiguate="true">
+        <text macro="issued"/>
+      </if>
+    </choose>
+  </macro>
+  <macro name="description-note">
+    <group delimiter=", ">
+      <text macro="interviewer-note"/>
+      <text variable="medium"/>
+      <choose>
+        <if variable="title" match="none"/>
+        <else-if type="manuscript thesis speech" match="any"/>
+        <else-if type="patent">
+          <group delimiter=" ">
+            <text variable="authority"/>
+            <text variable="number"/>
+          </group>
+        </else-if>
+        <else>
+          <text variable="genre"/>
+        </else>
+      </choose>
+    </group>
+  </macro>
+  <macro name="description">
+    <group delimiter=", ">
+      <group delimiter=". ">
+        <text macro="interviewer"/>
+        <text variable="medium" text-case="capitalize-first"/>
+      </group>
+      <choose>
+        <if variable="title" match="none"/>
+        <else-if type="thesis speech" match="any"/>
+        <else-if type="patent">
+          <group delimiter=" ">
+            <text variable="authority"/>
+            <text variable="number"/>
+          </group>
+        </else-if>
+        <else>
+          <text variable="genre" text-case="capitalize-first"/>
+        </else>
+      </choose>
+    </group>
+  </macro>
+  <macro name="container-title-note">
+    <group delimiter=" ">
+      <choose>
+        <if type="chapter entry-dictionary entry-encyclopedia paper-conference" match="any">
+          <text term="in"/>
+        </if>
+      </choose>
+      <choose>
+        <if type="bill legislation legal_case" match="none">
+          <text variable="container-title" text-case="title" font-style="italic"/>
+        </if>
+      </choose>
+    </group>
+  </macro>
+  <macro name="container-title">
+    <group delimiter=" ">
+      <choose>
+        <if type="chapter entry-dictionary entry-encyclopedia paper-conference" match="any">
+          <text term="in" text-case="capitalize-first"/>
+        </if>
+      </choose>
+      <choose>
+        <if type="bill legislation legal_case" match="none">
+          <text variable="container-title" text-case="title" font-style="italic"/>
+        </if>
+      </choose>
+    </group>
+  </macro>
+  <macro name="collection-title">
+    <choose>
+      <if match="none" type="article-journal">
+        <choose>
+          <if match="none" is-numeric="collection-number">
+            <group delimiter=", ">
+              <text variable="collection-title" text-case="title"/>
+              <text variable="collection-number"/>
+            </group>
+          </if>
+          <else>
+            <group delimiter=" ">
+              <text variable="collection-title" text-case="title"/>
+              <text variable="collection-number"/>
+            </group>
+          </else>
+        </choose>
+      </if>
+    </choose>
+  </macro>
+  <macro name="collection-title-journal">
+    <choose>
+      <if type="article-journal">
+        <group delimiter=" ">
+          <text variable="collection-title"/>
+          <text variable="collection-number"/>
+        </group>
+      </if>
+    </choose>
+  </macro>
+  <macro name="edition-note">
+    <choose>
+      <if type="book chapter graphic motion_picture paper-conference report song" match="any">
+        <choose>
+          <if is-numeric="edition">
+            <group delimiter=" ">
+              <number variable="edition" form="ordinal"/>
+              <text term="edition" form="short"/>
+            </group>
+          </if>
+          <else>
+            <text variable="edition"/>
+          </else>
+        </choose>
+      </if>
+    </choose>
+  </macro>
+  <macro name="edition">
+    <choose>
+      <if type="book chapter graphic motion_picture paper-conference report song" match="any">
+        <choose>
+          <if is-numeric="edition">
+            <group delimiter=" ">
+              <number variable="edition" form="ordinal"/>
+              <text term="edition" form="short"/>
+            </group>
+          </if>
+          <else>
+            <text variable="edition" text-case="capitalize-first" suffix="."/>
+          </else>
+        </choose>
+      </if>
+    </choose>
+  </macro>
+  <macro name="locators-note-join-with-space">
+    <choose>
+      <if type="article-journal" variable="volume" match="all">
+        <choose>
+          <if match="none" variable="collection-title">
+            <text macro="locators-note"/>
+          </if>
+        </choose>
+      </if>
+    </choose>
+  </macro>
+  <macro name="locators-note-join-with-comma">
+    <choose>
+      <if type="article-journal" match="none">
+        <text macro="locators-note"/>
+      </if>
+      <else-if type="article-journal">
+        <choose>
+          <if variable="volume" match="none">
+            <text macro="locators-note"/>
+          </if>
+          <else-if match="any" variable="collection-title">
+            <text macro="locators-note"/>
+          </else-if>
+        </choose>
+      </else-if>
+    </choose>
+  </macro>
+  <macro name="locators-note">
+    <choose>
+      <if type="article-journal">
+        <group delimiter=", ">
+          <text macro="collection-title-journal"/>
+          <number variable="volume"/>
+          <group delimiter=" ">
+            <text term="issue" form="short"/>
+            <number variable="issue"/>
+          </group>
+        </group>
+      </if>
+      <else-if type="bill legislation legal_case" match="any">
+        <text macro="legal-cites"/>
+      </else-if>
+      <else-if type="book chapter graphic motion_picture paper-conference report song" match="any">
+        <group delimiter=", ">
+          <text macro="edition-note"/>
+          <group delimiter=" ">
+            <text term="volume" form="short"/>
+            <number variable="volume" form="numeric"/>
+          </group>
+          <choose>
+            <if variable="locator" match="none">
+              <group delimiter=" ">
+                <number variable="number-of-volumes" form="numeric"/>
+                <text term="volume" form="short" plural="true"/>
+              </group>
+            </if>
+          </choose>
+        </group>
+      </else-if>
+    </choose>
+  </macro>
+  <macro name="legal-cites">
+    <choose>
+      <if type="legal_case" match="any">
+        <group delimiter=" ">
+          <choose>
+            <if variable="container-title">
+              <text variable="volume"/>
+              <text variable="container-title"/>
+              <group delimiter=" ">
+                <!--change to label variable="section" as that becomes available -->
+                <text term="section" form="symbol"/>
+                <text variable="section"/>
+              </group>
+              <text variable="page"/>
+            </if>
+            <else>
+              <text variable="number" prefix="No. "/>
+            </else>
+          </choose>
+        </group>
+      </if>
+      <else-if type="bill legislation" match="any">
+        <group delimiter=", ">
+          <choose>
+            <if variable="number">
+              <!--There's a public law number-->
+              <text variable="number" prefix="Pub. L. No. "/>
+              <group delimiter=" ">
+                <!--change to label variable="section" as that becomes available -->
+                <text term="section" form="symbol"/>
+                <text variable="section"/>
+              </group>
+              <group delimiter=" ">
+                <text variable="volume"/>
+                <text variable="container-title"/>
+                <text variable="page-first"/>
+              </group>
+            </if>
+            <else>
+              <group delimiter=" ">
+                <text variable="volume"/>
+                <text variable="container-title"/>
+                <!--change to label variable="section" as that becomes available -->
+                <text term="section" form="symbol"/>
+                <text variable="section"/>
+              </group>
+            </else>
+          </choose>
+        </group>
+      </else-if>
+    </choose>
+  </macro>
+  <macro name="locators-join-with-space">
+    <choose>
+      <if type="article-journal" variable="volume" match="all">
+        <choose>
+          <if match="none" variable="collection-title">
+            <text macro="locators"/>
+          </if>
+        </choose>
+      </if>
+    </choose>
+  </macro>
+  <macro name="locators-join-with-comma">
+    <choose>
+      <if type="bill chapter legislation legal_case paper-conference" match="any">
+        <text macro="locators"/>
+      </if>
+      <else-if type="article-journal">
+        <choose>
+          <if variable="volume" match="none">
+            <text macro="locators"/>
+          </if>
+          <else-if match="any" variable="collection-title">
+            <text macro="locators"/>
+          </else-if>
+        </choose>
+      </else-if>
+    </choose>
+  </macro>
+  <macro name="locators-join-with-period">
+    <choose>
+      <if type="bill legislation legal_case article-journal chapter paper-conference" match="none">
+        <text macro="locators"/>
+      </if>
+    </choose>
+  </macro>
+  <macro name="locators">
+    <choose>
+      <if type="article-journal">
+        <group delimiter=", ">
+          <text macro="collection-title-journal"/>
+          <number variable="volume"/>
+          <group delimiter=" ">
+            <text term="issue" form="short"/>
+            <number variable="issue"/>
+          </group>
+        </group>
+      </if>
+      <else-if type="bill legislation legal_case" match="any">
+        <text macro="legal-cites"/>
+      </else-if>
+      <else-if type="book graphic motion_picture report song" match="any">
+        <group delimiter=". ">
+          <text macro="edition"/>
+          <group delimiter=" ">
+            <text term="volume" form="short" text-case="capitalize-first"/>
+            <number variable="volume" form="numeric"/>
+          </group>
+          <group delimiter=" ">
+            <number variable="number-of-volumes" form="numeric"/>
+            <text term="volume" form="short" plural="true"/>
+          </group>
+        </group>
+      </else-if>
+      <else-if type="chapter entry-dictionary entry-encyclopedia paper-conference" match="any">
+        <group delimiter=". ">
+          <text macro="edition"/>
+          <choose>
+            <if variable="page" match="none">
+              <group delimiter=" ">
+                <text term="volume" form="short" text-case="capitalize-first"/>
+                <number variable="volume" form="numeric"/>
+              </group>
+            </if>
+          </choose>
+        </group>
+      </else-if>
+    </choose>
+  </macro>
+  <macro name="locators-newspaper">
+    <choose>
+      <if type="article-newspaper">
+        <group delimiter=", ">
+          <group delimiter=" ">
+            <number variable="edition"/>
+            <text term="edition"/>
+          </group>
+          <group delimiter=" ">
+            <text term="section" form="short"/>
+            <text variable="section"/>
+          </group>
+        </group>
+      </if>
+    </choose>
+  </macro>
+  <macro name="event-note">
+    <text variable="event"/>
+  </macro>
+  <macro name="event">
+    <choose>
+      <if variable="title">
+        <group delimiter=" ">
+          <choose>
+            <if variable="genre">
+              <text term="presented at"/>
+            </if>
+            <else>
+              <text term="presented at" text-case="capitalize-first"/>
+            </else>
+          </choose>
+          <text variable="event"/>
+        </group>
+      </if>
+      <else>
+        <group delimiter=" ">
+          <text term="presented at" text-case="capitalize-first"/>
+          <text variable="event"/>
+        </group>
+      </else>
+    </choose>
+  </macro>
+  <macro name="originally-published">
+    <group delimiter=", ">
+      <group delimiter=": ">
+        <text variable="original-publisher-place"/>
+        <text variable="original-publisher"/>
+      </group>
+      <date variable="original-date" form="text" date-parts="year"/>
+    </group>
+  </macro>
+  <macro name="reprint-note">
+    <!--needs localization-->
+    <choose>
+      <if variable="original-date issued" match="all">
+        <choose>
+          <!--for whatever reason in notes, when we have both original and new publishers, reprint doesn't appear-->
+          <if variable="original-publisher original-publisher-place" match="none">
+            <text value="repr."/>
+          </if>
+        </choose>
+      </if>
+    </choose>
+  </macro>
+  <macro name="reprint">
+    <!--needs localization-->
+    <choose>
+      <if variable="original-date issued" match="all">
+        <text value="reprint" text-case="capitalize-first"/>
+      </if>
+    </choose>
+  </macro>
+  <macro name="publisher">
+    <choose>
+      <if type="thesis">
+        <text variable="publisher"/>
+      </if>
+      <else-if type="speech">
+        <text variable="event-place"/>
+      </else-if>
+      <else>
+        <group delimiter=": ">
+          <text variable="publisher-place"/>
+          <text variable="publisher"/>
+        </group>
+      </else>
+    </choose>
+  </macro>
+  <macro name="issued">
+    <choose>
+      <if variable="issued">
+        <choose>
+          <if type="graphic report" match="any">
+            <date variable="issued" form="text"/>
+          </if>
+          <else-if type="legal_case">
+            <group delimiter=" ">
+              <text variable="authority"/>
+              <choose>
+                <if variable="container-title" match="any">
+                  <!--Only print year for cases published in reporters-->
+                  <date variable="issued" form="numeric" date-parts="year"/>
+                </if>
+                <else>
+                  <date variable="issued" form="text"/>
+                </else>
+              </choose>
+            </group>
+          </else-if>
+          <else-if type="book bill chapter graphic legislation motion_picture paper-conference report song thesis" match="any">
+            <date variable="issued">
+              <date-part name="year"/>
+            </date>
+          </else-if>
+          <else-if type="patent">
+            <group delimiter=", ">
+              <group delimiter=" ">
+                <!--Needs Localization-->
+                <text value="filed"/>
+                <date variable="submitted" form="text"/>
+              </group>
+              <group delimiter=" ">
+                <choose>
+                  <if variable="issued submitted" match="all">
+                    <text term="and"/>
+                  </if>
+                </choose>
+                <!--Needs Localization-->
+                <text value="issued"/>
+                <date variable="issued" form="text"/>
+              </group>
+            </group>
+          </else-if>
+          <else>
+            <date variable="issued" form="text"/>
+          </else>
+        </choose>
+      </if>
+      <else-if variable="status">
+        <text variable="status"/>
+      </else-if>
+      <else-if variable="accessed URL" match="all"/>
+      <else>
+        <text term="no date" form="short"/>
+      </else>
+    </choose>
+  </macro>
+  <macro name="point-locators-subsequent">
+    <choose>
+      <if type="legal_case" variable="locator" match="all">
+        <choose>
+          <if locator="page">
+            <group delimiter=":">
+              <number variable="volume"/>
+              <text variable="locator"/>
+            </group>
+          </if>
+          <else>
+            <group delimiter=" ">
+              <label variable="locator" form="short"/>
+              <text variable="locator"/>
+            </group>
+          </else>
+        </choose>
+      </if>
+      <else-if variable="locator">
+        <choose>
+          <if locator="page" match="none">
+            <group delimiter=" ">
+              <choose>
+                <if type="book graphic motion_picture report song" match="any">
+                  <choose>
+                    <if variable="volume">
+                      <group delimiter=", ">
+                        <group delimiter=" ">
+                          <text term="volume" form="short"/>
+                          <number variable="volume" form="numeric"/>
+                        </group>
+                        <label variable="locator" form="short"/>
+                      </group>
+                    </if>
+                    <else>
+                      <label variable="locator" form="short"/>
+                    </else>
+                  </choose>
+                </if>
+                <else>
+                  <label variable="locator" form="short"/>
+                </else>
+              </choose>
+              <text variable="locator"/>
+            </group>
+          </if>
+          <else-if type="book graphic motion_picture report song" match="any">
+            <group delimiter=":">
+              <number variable="volume" form="numeric"/>
+              <text variable="locator"/>
+            </group>
+          </else-if>
+          <else>
+            <text variable="locator"/>
+          </else>
+        </choose>
+      </else-if>
+    </choose>
+  </macro>
+  <macro name="point-locators-join-with-colon">
+    <choose>
+      <if type="article-journal">
+        <choose>
+          <if variable="locator page" match="any">
+            <choose>
+              <if variable="volume issue" match="any">
+                <text macro="point-locators"/>
+              </if>
+            </choose>
+          </if>
+        </choose>
+      </if>
+    </choose>
+  </macro>
+  <macro name="point-locators-join-with-comma">
+    <choose>
+      <if type="article-journal" match="none">
+        <text macro="point-locators"/>
+      </if>
+      <else-if variable="volume issue" match="none">
+        <text macro="point-locators"/>
+      </else-if>
+    </choose>
+  </macro>
+  <macro name="point-locators">
+    <choose>
+      <if variable="locator" match="none">
+        <choose>
+          <if type="article-journal chapter paper-conference" match="any">
+            <text variable="page"/>
+          </if>
+        </choose>
+      </if>
+      <else-if type="article-journal">
+        <group delimiter=" ">
+          <choose>
+            <if locator="page" match="none">
+              <label variable="locator" form="short" suffix=" "/>
+            </if>
+          </choose>
+          <text variable="locator"/>
+        </group>
+      </else-if>
+      <else-if type="legal_case"/>
+      <else>
+        <group delimiter=" ">
+          <choose>
+            <if locator="page" match="none">
+              <label variable="locator" form="short"/>
+            </if>
+          </choose>
+          <text variable="locator"/>
+        </group>
+      </else>
+    </choose>
+  </macro>
+  <macro name="locators-chapter">
+    <choose>
+      <if type="chapter entry-dictionary entry-encyclopedia paper-conference" match="any">
+        <choose>
+          <if variable="author container-author" match="all"/>
+          <else>
+            <choose>
+              <if variable="page">
+                <number variable="volume" suffix=":"/>
+                <text variable="page"/>
+              </if>
+            </choose>
+          </else>
+        </choose>
+      </if>
+    </choose>
+  </macro>
+  <macro name="locators-journal-join-with-colon">
+    <choose>
+      <if type="article-journal">
+        <choose>
+          <if variable="volume issue" match="any">
+            <text variable="page"/>
+          </if>
+        </choose>
+      </if>
+    </choose>
+  </macro>
+  <macro name="locators-journal-join-with-comma">
+    <choose>
+      <if type="article-journal">
+        <choose>
+          <if variable="volume issue" match="none">
+            <text variable="page"/>
+          </if>
+        </choose>
+      </if>
+    </choose>
+  </macro>
+  <macro name="archive-note">
+    <choose>
+      <if type="thesis">
+        <group delimiter=" ">
+          <text variable="archive"/>
+          <text variable="archive_location" prefix="(" suffix=")"/>
+        </group>
+      </if>
+      <else>
+        <group delimiter=", ">
+          <text variable="archive_location"/>
+          <text variable="archive"/>
+          <text variable="archive-place"/>
+        </group>
+      </else>
+    </choose>
+  </macro>
+  <macro name="archive">
+    <choose>
+      <if type="thesis">
+        <group delimiter=" ">
+          <text variable="archive"/>
+          <text variable="archive_location" prefix="(" suffix=")"/>
+        </group>
+      </if>
+      <else>
+        <group delimiter=". ">
+          <text variable="archive_location" text-case="capitalize-first"/>
+          <text variable="archive"/>
+          <text variable="archive-place"/>
+        </group>
+      </else>
+    </choose>
+  </macro>
+  <macro name="issue-note-join-with-space">
+    <choose>
+      <if type="article-journal bill legislation legal_case manuscript thesis" variable="publisher-place publisher" match="any">
+        <!--Chicago doesn't use publisher/place for Newspapers and we want the date delimited by a comma-->
+        <choose>
+          <if type="article-newspaper" match="none">
+            <choose>
+              <if type="article-journal" match="none">
+                <text macro="issue-note"/>
+              </if>
+              <else-if variable="issue volume" match="any">
+                <text macro="issue-note"/>
+              </else-if>
+            </choose>
+          </if>
+        </choose>
+      </if>
+    </choose>
+  </macro>
+  <macro name="issue-note-join-with-comma">
+    <choose>
+      <if type="article-journal bill legislation legal_case manuscript thesis" variable="publisher-place publisher" match="none">
+        <text macro="issue-note"/>
+      </if>
+      <else-if type="article-newspaper">
+        <text macro="issue-note"/>
+      </else-if>
+      <else-if type="article-journal">
+        <choose>
+          <if variable="volume issue" match="none">
+            <text macro="issue-note"/>
+          </if>
+        </choose>
+      </else-if>
+    </choose>
+  </macro>
+  <macro name="issue-note">
+    <choose>
+      <if type="bill legislation legal_case" match="any">
+        <text macro="issued" prefix="(" suffix=")"/>
+      </if>
+      <else-if type="article-journal">
+        <choose>
+          <if variable="volume issue" match="any">
+            <text macro="issued" prefix="(" suffix=")"/>
+          </if>
+          <else>
+            <text macro="issued"/>
+          </else>
+        </choose>
+      </else-if>
+      <else-if type="article-newspaper">
+        <text macro="issued"/>
+      </else-if>
+      <else-if variable="publisher-place event-place publisher genre" match="any">
+        <group prefix="(" suffix=")" delimiter=", ">
+          <choose>
+            <if variable="title" match="none"/>
+            <else-if type="manuscript thesis speech" match="any">
+              <text variable="genre"/>
+            </else-if>
+          </choose>
+          <text macro="event-note"/>
+          <group delimiter="; ">
+            <text macro="originally-published"/>
+            <group delimiter=", ">
+              <text macro="reprint-note"/>
+              <text macro="publisher"/>
+            </group>
+          </group>
+          <text macro="issued"/>
+        </group>
+      </else-if>
+      <else>
+        <text macro="issued"/>
+      </else>
+    </choose>
+  </macro>
+  <macro name="issue-join-with-space">
+    <choose>
+      <if type="article-journal" match="any">
+        <choose>
+          <if variable="issue volume" match="any">
+            <text macro="issue"/>
+          </if>
+        </choose>
+      </if>
+      <else-if type="bill legislation legal_case" match="any">
+        <text macro="issue"/>
+      </else-if>
+    </choose>
+  </macro>
+  <macro name="issue-join-with-period">
+    <choose>
+      <if type="article-journal bill legislation legal_case" match="none">
+        <choose>
+          <if type="speech" variable="publisher publisher-place" match="any">
+            <text macro="issue"/>
+          </if>
+        </choose>
+      </if>
+    </choose>
+  </macro>
+  <macro name="issue-join-with-comma">
+    <choose>
+      <if type="bill legislation legal_case" match="none">
+        <choose>
+          <if type="article-journal" match="none">
+            <choose>
+              <if type="speech" variable="publisher publisher-place" match="none">
+                <text macro="issue"/>
+              </if>
+            </choose>
+          </if>
+          <else-if variable="volume issue" match="none">
+            <text macro="issue"/>
+          </else-if>
+        </choose>
+      </if>
+    </choose>
+  </macro>
+  <macro name="issue">
+    <choose>
+      <if type="bill legislation legal_case" match="any">
+        <text macro="issued" prefix="(" suffix=")"/>
+      </if>
+      <else-if type="article-journal">
+        <choose>
+          <if variable="issue volume" match="any">
+            <text macro="issued" prefix="(" suffix=")"/>
+          </if>
+          <else>
+            <text macro="issued"/>
+          </else>
+        </choose>
+      </else-if>
+      <else-if type="speech">
+        <group delimiter=", ">
+          <group delimiter=" ">
+            <choose>
+              <if variable="title" match="none"/>
+              <else>
+                <text variable="genre" text-case="capitalize-first"/>
+              </else>
+            </choose>
+            <text macro="event"/>
+          </group>
+          <text variable="event-place"/>
+          <text macro="issued"/>
+        </group>
+      </else-if>
+      <!--Chicago doesn't use publisher/place for Newspapers -->
+      <else-if type="article-newspaper">
+        <text macro="issued"/>
+      </else-if>
+      <else-if variable="publisher-place publisher" match="any">
+        <group delimiter=", ">
+          <choose>
+            <if type="thesis">
+              <text variable="genre" text-case="capitalize-first"/>
+            </if>
+          </choose>
+          <group delimiter=". ">
+            <text macro="originally-published"/>
+            <group delimiter=", ">
+              <text macro="reprint"/>
+              <text macro="publisher"/>
+            </group>
+          </group>
+          <text macro="issued"/>
+        </group>
+      </else-if>
+      <else>
+        <text macro="issued"/>
+      </else>
+    </choose>
+  </macro>
+  <macro name="access-note">
+    <group delimiter=", ">
+      <choose>
+        <if type="graphic report" match="any">
+          <text macro="archive-note"/>
+        </if>
+        <else-if type="article-journal bill book chapter legal_case legislation motion_picture paper-conference" match="none">
+          <text macro="archive-note"/>
+        </else-if>
+      </choose>
+      <choose>
+        <if variable="issued" match="none">
+          <group delimiter=" ">
+            <text term="accessed"/>
+            <date variable="accessed" form="text"/>
+          </group>
+        </if>
+      </choose>
+      <choose>
+        <if type="legal_case" match="none">
+          <choose>
+            <if variable="DOI">
+              <text variable="DOI" prefix="doi:"/>
+            </if>
+            <else>
+              <text variable="URL"/>
+            </else>
+          </choose>
+        </if>
+      </choose>
+    </group>
+  </macro>
+  <macro name="access">
+    <group delimiter=". ">
+      <choose>
+        <if type="graphic report" match="any">
+          <text macro="archive"/>
+        </if>
+        <else-if type="article-journal bill book chapter legal_case legislation motion_picture paper-conference" match="none">
+          <text macro="archive"/>
+        </else-if>
+      </choose>
+      <choose>
+        <if variable="issued" match="none">
+          <group delimiter=" ">
+            <text term="accessed" text-case="capitalize-first"/>
+            <date variable="accessed" form="text"/>
+          </group>
+        </if>
+      </choose>
+      <choose>
+        <if type="legal_case" match="none">
+          <choose>
+            <if variable="DOI">
+              <text variable="DOI" prefix="doi:"/>
+            </if>
+            <else>
+              <text variable="URL"/>
+            </else>
+          </choose>
+        </if>
+      </choose>
+    </group>
+  </macro>
+  <macro name="case-locator-subsequent">
+    <choose>
+      <if type="legal_case">
+        <group delimiter=" ">
+          <text variable="volume"/>
+          <text variable="container-title"/>
+        </group>
+      </if>
+    </choose>
+  </macro>
+  <macro name="case-pinpoint-subsequent">
+    <choose>
+      <if type="legal_case">
+        <group delimiter=" ">
+          <choose>
+            <if locator="page">
+              <text term="at"/>
+              <text variable="locator"/>
+            </if>
+            <else>
+              <label variable="locator"/>
+              <text variable="locator"/>
+            </else>
+          </choose>
+        </group>
+      </if>
+    </choose>
+  </macro>
+  <citation et-al-min="4" et-al-use-first="1" disambiguate-add-names="true">
+    <layout suffix="." delimiter="; ">
+      <choose>
+        <if position="ibid-with-locator">
+          <group delimiter=", ">
+            <text term="ibid"/>
+            <text macro="point-locators-subsequent"/>
+          </group>
+        </if>
+        <else-if position="ibid">
+          <text term="ibid"/>
+        </else-if>
+        <else-if position="subsequent">
+          <group delimiter=", ">
+            <text macro="contributors-short"/>
+            <group delimiter=" ">
+              <group delimiter=", ">
+                <text macro="title-short"/>
+                <!--if title & author are the same: -->
+                <text macro="date-disambiguate"/>
+                <text macro="case-locator-subsequent"/>
+              </group>
+              <text macro="case-pinpoint-subsequent"/>
+            </group>
+            <choose>
+              <if match="none" type="legal_case">
+                <text macro="point-locators-subsequent"/>
+              </if>
+            </choose>
+          </group>
+        </else-if>
+        <else>
+          <group delimiter=", ">
+            <group delimiter=": ">
+              <group delimiter=", ">
+                <group delimiter=" ">
+                  <group delimiter=", ">
+                    <group delimiter=" ">
+                      <group delimiter=", ">
+                        <group delimiter=", ">
+                          <text macro="contributors-note"/>
+                          <text macro="title-note"/>
+                        </group>
+                        <text macro="description-note"/>
+                        <text macro="secondary-contributors-note"/>
+                        <text macro="container-title-note"/>
+                        <text macro="container-contributors-note"/>
+                      </group>
+                      <text macro="locators-note-join-with-space"/>
+                    </group>
+                    <text macro="locators-note-join-with-comma"/>
+                    <text macro="collection-title"/>
+                    <text macro="issue-note-join-with-comma"/>
+                  </group>
+                  <text macro="issue-note-join-with-space"/>
+                </group>
+                <text macro="locators-newspaper"/>
+                <text macro="point-locators-join-with-comma"/>
+              </group>
+              <text macro="point-locators-join-with-colon"/>
+            </group>
+            <text macro="access-note"/>
+          </group>
+        </else>
+      </choose>
+    </layout>
+  </citation>
+  <bibliography hanging-indent="true" et-al-min="11" et-al-use-first="7" subsequent-author-substitute="&#8212;&#8212;&#8212;" entry-spacing="0">
+    <sort>
+      <key macro="contributors-sort"/>
+      <key variable="title"/>
+      <key variable="genre"/>
+      <key variable="issued"/>
+    </sort>
+    <layout suffix=".">
+      <group delimiter=". ">
+        <group delimiter=": ">
+          <group delimiter=", ">
+            <group delimiter=" ">
+              <group delimiter=". ">
+                <group delimiter=" ">
+                  <group delimiter=", ">
+                    <group delimiter=". ">
+                      <group delimiter=". ">
+                        <text macro="contributors"/>
+                        <text macro="title"/>
+                      </group>
+                      <text macro="description"/>
+                      <text macro="secondary-contributors"/>
+                      <group delimiter=", ">
+                        <text macro="container-title"/>
+                        <text macro="container-contributors"/>
+                      </group>
+                      <text macro="locators-join-with-period"/>
+                    </group>
+                    <text macro="locators-join-with-comma"/>
+                    <text macro="locators-chapter"/>
+                  </group>
+                  <text macro="locators-join-with-space"/>
+                </group>
+                <text macro="collection-title"/>
+                <text macro="issue-join-with-period"/>
+              </group>
+              <text macro="issue-join-with-space"/>
+            </group>
+            <text macro="issue-join-with-comma"/>
+            <text macro="locators-journal-join-with-comma"/>
+            <text macro="locators-newspaper"/>
+          </group>
+          <text macro="locators-journal-join-with-colon"/>
+        </group>
+        <text macro="access"/>
+      </group>
+    </layout>
+  </bibliography>
+</style>
diff --git a/elpa/org-ref-20251206.1422/citeproc/csl-styles/elsevier-harvard.csl b/elpa/org-ref-20251206.1422/citeproc/csl-styles/elsevier-harvard.csl
new file mode 100644 (file)
index 0000000..cc97857
--- /dev/null
@@ -0,0 +1,239 @@
+<?xml version="1.0" encoding="utf-8"?>
+<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="never" default-locale="en-US">
+  <info>
+    <title>Elsevier - Harvard (with titles)</title>
+    <id>http://www.zotero.org/styles/elsevier-harvard</id>
+    <link href="http://www.zotero.org/styles/elsevier-harvard" rel="self"/>
+    <link href="http://www.zotero.org/styles/ecology-letters" rel="template"/>
+    <link href="http://www.elsevier.com/journals/biological-conservation/0006-3207/guide-for-authors#68000" rel="documentation"/>
+    <author>
+      <name>David Kaplan</name>
+      <email>david.kaplanNOSPAMird.fr</email>
+    </author>
+    <contributor>
+      <name>Simon Kornblith</name>
+      <email>simonNOSPAMsimonster.com</email>
+    </contributor>
+    <contributor>
+      <name>Bruce D'Arcus</name>
+    </contributor>
+    <contributor>
+      <name>Curtis M. Humphrey</name>
+    </contributor>
+    <contributor>
+      <name>Richard Karnesky</name>
+      <email>karnesky+zoteroNOSPAMgmail.com</email>
+      <uri>http://arc.nucapt.northwestern.edu/Richard_Karnesky</uri>
+    </contributor>
+    <contributor>
+      <name>Sebastian Karcher</name>
+    </contributor>
+    <category citation-format="author-date"/>
+    <category field="biology"/>
+    <category field="generic-base"/>
+    <updated>2014-03-04T00:09:00+00:00</updated>
+    <rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
+  </info>
+  <macro name="container">
+    <choose>
+      <if type="chapter paper-conference" match="any">
+        <text term="in" prefix=", " suffix=": "/>
+        <names variable="editor translator" delimiter=", " suffix=", ">
+          <name name-as-sort-order="all" sort-separator=", " initialize-with="." delimiter=", " delimiter-precedes-last="always"/>
+          <label form="short" text-case="capitalize-first" prefix=" (" suffix=")"/>
+        </names>
+        <group delimiter=", ">
+          <text variable="container-title" text-case="title"/>
+          <text variable="collection-title" text-case="title"/>
+        </group>
+      </if>
+      <else-if type="bill book graphic legal_case legislation motion_picture report song" match="any">
+        <group prefix=", " delimiter=", ">
+          <text variable="container-title"/>
+          <text variable="collection-title"/>
+        </group>
+      </else-if>
+      <else>
+        <group prefix=". " delimiter=", ">
+          <text variable="container-title" form="short"/>
+          <text variable="collection-title"/>
+        </group>
+      </else>
+    </choose>
+  </macro>
+  <macro name="author">
+    <names variable="author">
+      <name name-as-sort-order="all" sort-separator=", " initialize-with="." delimiter=", " delimiter-precedes-last="always"/>
+      <label form="short" prefix=" (" suffix=")" text-case="capitalize-first"/>
+      <substitute>
+        <names variable="editor"/>
+        <names variable="translator"/>
+        <text macro="title"/>
+      </substitute>
+    </names>
+  </macro>
+  <macro name="author-short">
+    <names variable="author">
+      <name form="short" and="text" delimiter=", " initialize-with=". "/>
+      <substitute>
+        <names variable="editor"/>
+        <names variable="translator"/>
+        <choose>
+          <if type="bill book graphic legal_case legislation motion_picture report song" match="any">
+            <text variable="title" form="short" font-style="italic"/>
+          </if>
+          <else>
+            <text variable="title" form="short" quotes="true"/>
+          </else>
+        </choose>
+      </substitute>
+    </names>
+  </macro>
+  <macro name="access">
+    <choose>
+      <if variable="DOI">
+        <text variable="DOI" prefix="https://doi.org/"/>
+      </if>
+      <else-if type="webpage post-weblog" match="any">
+        <group delimiter=" ">
+          <text value="URL"/>
+          <text variable="URL"/>
+          <group prefix="(" suffix=").">
+            <text term="accessed" suffix=" "/>
+            <date variable="accessed">
+              <date-part name="month" form="numeric" suffix="."/>
+              <date-part name="day" suffix="."/>
+              <date-part name="year" form="short"/>
+            </date>
+          </group>
+        </group>
+      </else-if>
+    </choose>
+  </macro>
+  <macro name="title">
+    <choose>
+      <if type="report thesis" match="any">
+        <text variable="title"/>
+        <group prefix=" (" suffix=")" delimiter=" ">
+          <text variable="genre"/>
+          <text variable="number" prefix="No. "/>
+        </group>
+      </if>
+      <else-if type="bill book graphic legal_case legislation motion_picture report song speech" match="any">
+        <text variable="title"/>
+        <text macro="edition" prefix=", "/>
+      </else-if>
+      <else-if type="webpage">
+        <text variable="title"/>
+        <text value="WWW Document" prefix=" [" suffix="]"/>
+      </else-if>
+      <else>
+        <text variable="title"/>
+      </else>
+    </choose>
+  </macro>
+  <macro name="publisher">
+    <group delimiter=", ">
+      <text variable="publisher"/>
+      <text variable="publisher-place"/>
+    </group>
+  </macro>
+  <macro name="event">
+    <choose>
+      <if variable="event">
+        <text term="presented at" text-case="capitalize-first" suffix=" "/>
+        <text variable="event"/>
+      </if>
+    </choose>
+  </macro>
+  <macro name="issued">
+    <choose>
+      <if variable="issued">
+        <date variable="issued">
+          <date-part name="year"/>
+        </date>
+      </if>
+      <else>
+        <text term="no date" form="short"/>
+      </else>
+    </choose>
+  </macro>
+  <macro name="edition">
+    <group delimiter=" ">
+      <choose>
+        <if is-numeric="edition">
+          <number variable="edition" form="ordinal"/>
+        </if>
+        <else>
+          <text variable="edition" suffix="."/>
+        </else>
+      </choose>
+      <text value="ed"/>
+    </group>
+  </macro>
+  <macro name="locators">
+    <choose>
+      <if type="article-journal article-magazine article-newspaper" match="any">
+        <group prefix=" " delimiter=", ">
+          <group>
+            <text variable="volume"/>
+          </group>
+          <text variable="page"/>
+        </group>
+      </if>
+      <else-if type="bill book graphic legal_case legislation motion_picture report song thesis" match="any">
+        <group delimiter=", " prefix=". ">
+          <text macro="event"/>
+          <text macro="publisher"/>
+        </group>
+      </else-if>
+      <else-if type="chapter paper-conference" match="any">
+        <group delimiter=", " prefix=". ">
+          <text macro="event"/>
+          <text macro="publisher"/>
+          <group>
+            <label variable="page" form="short" suffix=" "/>
+            <text variable="page"/>
+          </group>
+        </group>
+      </else-if>
+      <else-if type="patent">
+        <text variable="number" prefix=". "/>
+      </else-if>
+    </choose>
+  </macro>
+  <citation et-al-min="3" et-al-use-first="1" disambiguate-add-givenname="true" disambiguate-add-year-suffix="true" collapse="year" cite-group-delimiter=", ">
+    <sort>
+      <key macro="author"/>
+      <key macro="issued" sort="descending"/>
+    </sort>
+    <layout prefix="(" suffix=")" delimiter="; ">
+      <group delimiter=", ">
+        <text macro="author-short"/>
+        <text macro="issued"/>
+        <group delimiter=" ">
+          <label variable="locator" form="short"/>
+          <text variable="locator"/>
+        </group>
+      </group>
+    </layout>
+  </citation>
+  <bibliography hanging-indent="true" entry-spacing="0" line-spacing="1">
+    <sort>
+      <key macro="author"/>
+      <key macro="issued" sort="descending"/>
+    </sort>
+    <layout>
+      <group suffix=".">
+        <text macro="author" suffix=","/>
+        <text macro="issued" prefix=" "/>
+        <group prefix=". ">
+          <text macro="title"/>
+          <text macro="container"/>
+          <text macro="locators"/>
+        </group>
+      </group>
+      <text macro="access" prefix=". "/>
+    </layout>
+  </bibliography>
+</style>
\ No newline at end of file
diff --git a/elpa/org-ref-20251206.1422/citeproc/csl-styles/elsevier-with-titles.csl b/elpa/org-ref-20251206.1422/citeproc/csl-styles/elsevier-with-titles.csl
new file mode 100644 (file)
index 0000000..135329d
--- /dev/null
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="utf-8"?>
+<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="sort-only" default-locale="en-US">
+  <info>
+    <title>Elsevier (numeric, with titles)</title>
+    <id>http://www.zotero.org/styles/elsevier-with-titles</id>
+    <link href="http://www.zotero.org/styles/elsevier-with-titles" rel="self"/>
+    <link href="http://www.zotero.org/styles/elsevier-without-titles" rel="template"/>
+    <link href="http://www.elsevier.com/journals/journal-of-hazardous-materials/0304-3894/guide-for-authors#68001" rel="documentation"/>
+    <author>
+      <name>Richard Karnesky</name>
+      <email>karnesky+zotero@gmail.com</email>
+      <uri>http://arc.nucapt.northwestern.edu/Richard_Karnesky</uri>
+    </author>
+    <contributor>
+      <name>Rintze Zelle</name>
+      <uri>http://twitter.com/rintzezelle</uri>
+    </contributor>
+    <category citation-format="numeric"/>
+    <category field="generic-base"/>
+    <summary>A style for many of Elsevier's journals that includes article titles in the reference list</summary>
+    <updated>2019-10-15T15:14:08+00:00</updated>
+    <rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
+  </info>
+  <macro name="author">
+    <names variable="author">
+      <name initialize-with="." delimiter=", " delimiter-precedes-last="always"/>
+      <label form="short" prefix=", "/>
+      <substitute>
+        <names variable="editor"/>
+        <names variable="translator"/>
+      </substitute>
+    </names>
+  </macro>
+  <macro name="editor">
+    <names variable="editor">
+      <name initialize-with="." delimiter=", " delimiter-precedes-last="always"/>
+      <label form="short" prefix=" (" text-case="capitalize-first" suffix=")"/>
+    </names>
+  </macro>
+  <macro name="year-date">
+    <choose>
+      <if variable="issued">
+        <date variable="issued">
+          <date-part name="year"/>
+        </date>
+      </if>
+      <else>
+        <text term="no date" form="short"/>
+      </else>
+    </choose>
+  </macro>
+  <macro name="publisher">
+    <text variable="publisher" suffix=", "/>
+    <text variable="publisher-place" suffix=", "/>
+    <text macro="year-date"/>
+  </macro>
+  <macro name="edition">
+    <!--TODO: CSL should have low numeric be text (e.g. '3'->'third')-->
+    <choose>
+      <if is-numeric="edition">
+        <group delimiter=" ">
+          <number variable="edition" form="ordinal"/>
+          <text term="edition" form="short"/>
+        </group>
+      </if>
+      <else>
+        <text variable="edition"/>
+      </else>
+    </choose>
+  </macro>
+  <macro name="access">
+    <choose>
+      <if variable="URL">
+        <text variable="URL"/>
+        <group prefix=" (" suffix=")" delimiter=" ">
+          <text term="accessed"/>
+          <date variable="accessed" form="text"/>
+        </group>
+      </if>
+    </choose>
+  </macro>
+  <citation collapse="citation-number">
+    <sort>
+      <key variable="citation-number"/>
+    </sort>
+    <layout prefix="[" suffix="]" delimiter=",">
+      <text variable="citation-number"/>
+    </layout>
+  </citation>
+  <bibliography entry-spacing="0" second-field-align="flush">
+    <layout suffix=".">
+      <text variable="citation-number" prefix="[" suffix="]"/>
+      <text macro="author" suffix=", "/>
+      <choose>
+        <if type="bill book graphic legal_case legislation motion_picture report song" match="any">
+          <group delimiter=", ">
+            <text variable="title"/>
+            <text macro="edition"/>
+            <text macro="publisher"/>
+          </group>
+        </if>
+        <else-if type="chapter paper-conference" match="any">
+          <text variable="title" suffix=", "/>
+          <text term="in" suffix=": "/>
+          <text macro="editor" suffix=", "/>
+          <text variable="container-title" form="short" text-case="title" suffix=", "/>
+          <text macro="edition" suffix=", "/>
+          <text macro="publisher"/>
+          <group delimiter=" ">
+            <label variable="page" form="short" prefix=": "/>
+            <text variable="page"/>
+          </group>
+        </else-if>
+        <else-if type="patent">
+          <group delimiter=", ">
+            <text variable="title"/>
+            <text variable="number"/>
+            <text macro="year-date"/>
+          </group>
+        </else-if>
+        <else-if type="thesis">
+          <group delimiter=", ">
+            <text variable="title"/>
+            <text variable="genre"/>
+            <text variable="publisher"/>
+            <text macro="year-date"/>
+          </group>
+        </else-if>
+        <else>
+          <group delimiter=" ">
+            <text variable="title" suffix=","/>
+            <text variable="container-title" form="short" text-case="title" suffix="."/>
+            <text variable="volume"/>
+            <text macro="year-date" prefix="(" suffix=")"/>
+            <text variable="page" form="short"/>
+          </group>
+        </else>
+      </choose>
+      <choose>
+        <if variable="DOI">
+          <text variable="DOI" prefix=". https://doi.org/"/>
+        </if>
+        <else>
+          <text macro="access" prefix=". "/>
+        </else>
+      </choose>
+    </layout>
+  </bibliography>
+</style>
diff --git a/elpa/org-ref-20251206.1422/contrib.el b/elpa/org-ref-20251206.1422/contrib.el
new file mode 100644 (file)
index 0000000..f1dcec0
--- /dev/null
@@ -0,0 +1,81 @@
+;;; contrib.el --- Code contributed by users -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; 
+
+;;; Code:
+(defvar org-ref-cite-types)
+(declare-function org-element-context "org-element")
+(declare-function org-element-type "org-element")
+(declare-function org-element-property "org-element")
+(declare-function bibtex-completion-apa-format-reference "bibtex-completion")
+(declare-function org-ref-parse-cite-path "org-ref-citation-links")
+
+
+;; * Add messages in minibuffer
+;; Contributed in https://github.com/jkitchin/org-ref/issues/938 by @DiogoFerrari
+
+
+(defun org-ref-get-bibtex-key-under-cursor--display ()
+  "Return key under the cursor in `org-mode'.
+If not on a key, but on a cite, prompt for key."
+  (if-let* ((key (get-text-property (point) 'cite-key)))
+      ;; Point is on a key, so we get it directly
+      key
+    ;; point is not on a key, but may still be on a cite link
+    (let ((el (org-element-context))
+         data text
+         keys)
+      (cond
+       ;; on a cite-link type
+       ((and
+        (eq (org-element-type el) 'link)
+        (assoc (org-element-property :type el) org-ref-cite-types))
+
+       (goto-char (org-element-property :begin el))
+       (setq data (org-ref-parse-cite-path (org-element-property :path el))
+             keys (cl-loop for ref in (plist-get data :references)
+                           collect (plist-get ref :key)))
+       (setq text nil)
+       (dolist (key keys)
+         (search-forward key)
+         (goto-char (match-beginning 0))
+         ;; (get-text-property (point) 'cite-key)
+         ;; (message (bibtex-completion-apa-format-reference key))
+         (setq text (concat text "\n" (bibtex-completion-apa-format-reference key))))))))
+  (message (string-trim-left text)))
+
+
+(defvar org-ref-message-timer nil
+  "Stores the idle timer for cite minibuffer messages.")
+
+
+(defcustom org-ref-message-interval 0.5
+  "Time in seconds to wait for the idle timer that displays the cite message."
+  :group 'org-ref
+  :type 'float)
+
+
+(defun org-ref-link-message ()
+  "Display a message in the minibuffer when point is on a cite link."
+  (when (and (eq major-mode 'org-mode) (eq (get-text-property (point) 'help-echo) 'org-ref-cite-tooltip))
+    (save-excursion (org-ref-get-bibtex-key-under-cursor--display))))
+
+
+(defun org-ref-messages-on ()
+  "Turn cite messages to minibuffer on."
+  (interactive)
+  (setq org-ref-message-timer (run-with-idle-timer org-ref-message-interval 0 'org-ref-link-message)))
+
+
+(defun org-ref-messages-off ()
+  "Turn cite messages to minibuffer off."
+  (interactive)
+  (when org-ref-message-timer
+    (cancel-timer org-ref-message-timer)
+    (setq org-ref-message-timer nil)))
+
+
+(provide 'contrib)
+
+;;; contrib.el ends here
diff --git a/elpa/org-ref-20251206.1422/doi-utils.el b/elpa/org-ref-20251206.1422/doi-utils.el
new file mode 100644 (file)
index 0000000..8cd8de4
--- /dev/null
@@ -0,0 +1,1737 @@
+;;; doi-utils.el --- DOI utilities for making bibtex entries -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2015-2021  John Kitchin
+
+;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
+;; Keywords: convenience
+;; Package-Requires: ((org-ref))
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This package provides functionality to download PDFs and bibtex entries from
+;; a DOI, as well as to update a bibtex entry from a DOI.  It depends slightly
+;; on org-ref, to determine where to save pdf files too, and where to insert
+;; bibtex entries in the default bibliography.
+
+;; The principle commands you will use from here are:
+
+;; - doi-utils-get-bibtex-entry-pdf with the cursor in a bibtex entry.
+;; - doi-utils-insert-bibtex-entry-from-doi to insert a bibtex entry at your cursor, clean it and try to get a pdf.
+;; - doi-utils-add-bibtex-entry-from-doi to add an entry to your default bibliography (cleaned with pdf if possible).
+;; - doi-utils-update-bibtex-entry-from-doi with cursor in an entry to update its fields.
+
+;;; Code:
+
+(defvar url-http-end-of-headers)
+(declare-function org-ref-find-bibliography "org-ref-core")
+(declare-function org-ref-clean-bibtex-entry "org-ref-core")
+(declare-function bibtex-completion-edit-notes "bibtex-completion")
+(declare-function org-bibtex-yank "org-bibtex")
+(declare-function org-ref-possible-bibfiles "org-ref-core")
+(declare-function org-ref-normalize-bibtex-completion-bibliography "org-ref-utils")
+
+(declare-function org-ref--file-ext-p "org-ref-utils")
+(declare-function org-ref--directory-files "org-ref-utils")
+
+(eval-when-compile
+  (require 'cl-lib))
+(require 'bibtex)
+(require 'json)
+(require 'org)                          ; org-add-link-type
+
+(or (require 'ol-bibtex nil t)
+    (require 'org-bibtex)) ; org-bibtex-yank
+
+(require 'url-http)
+(require 'url-handlers)
+(require 'org-ref-utils)
+(require 'transient)
+
+;;* Customization
+(defgroup doi-utils nil
+  "Customization group for doi-utils."
+  :tag "DOI utils"
+  :group 'doi-utils)
+
+
+(defcustom doi-utils-download-pdf
+  t
+  "Try to download PDFs when adding bibtex entries when non-nil."
+  :type 'boolean
+  :group 'doi-utils)
+
+(defcustom doi-utils-open-pdf-after-download
+  nil
+  "Open PDF after adding bibtex entries."
+  :type 'boolean
+  :group 'doi-utils)
+
+
+(defcustom doi-utils-timestamp-field
+  "DATE_ADDED"
+  "The bibtex field to store the date when an entry has been added."
+  :type 'string
+  :group 'doi-utils)
+
+(defcustom doi-utils-timestamp-format-function
+  'current-time-string
+  "The function to format the timestamp for a bibtex entry.
+Set to a function that returns nil to avoid setting timestamps in the entries.
+e.g. (lambda () nil)"
+  :type 'function
+  :group 'doi-utils)
+
+
+(defcustom doi-utils-dx-doi-org-url
+  "https://doi.org/"
+  "Base url to retrieve doi metadata from. A trailing / is required."
+  :type 'string
+  :group 'doi-utils)
+
+
+(defcustom doi-utils-metadata-function 'doi-utils-get-json-metadata
+  "Function for retrieving json metadata from `doi-utils-dx-doi-org-url'.
+The default is `doi-utils-get-json-metadata', but it sometimes
+fails with a proxy. An alternative is
+`doi-utils-get-json-metadata-curl' which requires an external
+program to use curl."
+  :type 'function
+  :group 'doi-utils)
+
+
+(defcustom doi-utils-async-download t
+  "Use `doi-utils-async-download-pdf' to get pdfs asynchrounously.
+If nil use `doi-utils-get-bibtex-entry-pdf' synchronously."
+  :type 'boolean
+  :group 'doi-utils)
+
+
+(defun doi-utils-pdf-filename-from-key ()
+  "Generate PDF filename from bibtex entry key.
+This is the default function for `doi-utils-pdf-filename-function'.
+Returns the bibtex entry key as the filename (without extension or path)."
+  (cdr (assoc "=key=" (bibtex-parse-entry))))
+
+
+(defcustom doi-utils-pdf-filename-function
+  'doi-utils-pdf-filename-from-key
+  "Function to generate PDF filename from bibtex entry.
+The function is called with no arguments while point is in the bibtex
+entry, and should return a string to use as the PDF filename (without
+the .pdf extension or directory path).
+
+The directory path is determined separately by `bibtex-completion-library-path'.
+
+The default function uses the bibtex entry key as the filename.
+
+Example: To use the title field as the filename:
+  (setq doi-utils-pdf-filename-function
+        (lambda () (bibtex-autokey-get-field \"title\")))
+
+Note: The function is responsible for ensuring the returned filename
+is valid for the filesystem. Special characters in fields like title
+may cause issues on some systems."
+  :type 'function
+  :group 'doi-utils)
+
+
+;;* Getting pdf files from a DOI
+
+;; The idea here is simple. When you visit http://dx.doi.org/doi or
+;; https://doi.org/doi, you get redirected to the journal site. Once you have
+;; the url for the article, you can usually compute the url to the pdf, or find
+;; it in the page. Then you simply download it.
+
+;; There are some subtleties in doing this that are described here. To get the
+;; redirect, we have to use url-retrieve, and a callback function. The callback
+;; does not return anything, so we communicate through global variables.
+;; url-retrieve is asynchronous, so we have to make sure to wait for it to
+;; finish.
+
+(defvar *doi-utils-waiting* t
+  "Stores waiting state for url retrieval.")
+
+(defvar *doi-utils-redirect* nil
+  "Stores redirect url from a callback function.")
+
+(defun doi-utils-redirect-callback (&optional status)
+  "Callback for `url-retrieve' to set the redirect.
+Optional argument STATUS Unknown why this is optional."
+  (when (plist-get status :error)
+    (signal (car (plist-get status :error)) (cdr(plist-get status :error))))
+  (when (plist-get status :redirect) ;  is nil if there none
+    (setq *doi-utils-redirect* (plist-get status :redirect)))
+  ;; we have done our job, so we are not waiting any more.
+  (setq *doi-utils-waiting* nil))
+
+;; To actually get the redirect we use url-retrieve like this.
+
+(defun doi-utils-get-redirect (doi)
+  "Get redirect url from `doi-utils-dx-doi-org-url'/doi."
+  ;; we are going to wait until the url-retrieve is done
+  (setq *doi-utils-waiting* t)
+  ;; start with no redirect. it will be set in the callback.
+  (setq *doi-utils-redirect* nil)
+  (url-retrieve
+   (format "%s%s" doi-utils-dx-doi-org-url doi)
+   'doi-utils-redirect-callback)
+  ;; I suspect we need to wait here for the asynchronous process to
+  ;; finish. we loop and sleep until the callback says it is done via
+  ;; `*doi-utils-waiting*'. this works as far as i can tell. Before I
+  ;; had to run this a few times to get it to work, which i suspect
+  ;; just gave the first one enough time to finish.
+  (while *doi-utils-waiting* (sleep-for 0.1)))
+
+;; Once we have a redirect for a particular doi, we need to compute the url to
+;; the pdf. We do this with a series of functions. Each function takes a single
+;; argument, the redirect url. If it knows how to compute the pdf url it does,
+;; and returns it. We store the functions in a variable:
+
+(defvar doi-utils-pdf-url-functions nil
+  "Functions that return a url to a pdf from a redirect url.
+Each function takes one argument, the redirect url.  The function
+must return a pdf-url, or nil.")
+
+
+;;** APS journals
+
+(defun aps-pdf-url (*doi-utils-redirect*)
+  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
+  (when (string-match "^http\\(s*\\)://journals.aps.org" *doi-utils-redirect*)
+    (replace-regexp-in-string "/abstract/" "/pdf/" *doi-utils-redirect*)))
+
+
+;;** Science
+
+(defun science-pdf-url (*doi-utils-redirect*)
+  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
+  (when (string-match "^http\\(s?\\)://www.sciencemag.org" *doi-utils-redirect*)
+    (concat *doi-utils-redirect* ".full.pdf")))
+
+
+;;** Nature
+
+(defun nature-pdf-url (*doi-utils-redirect*)
+  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
+  (when (string-match "^http\\(s?\\)://www.nature.com" *doi-utils-redirect*)
+    (concat *doi-utils-redirect* ".pdf")))
+
+
+;;** Elsevier/ScienceDirect
+;; You cannot compute these pdf links; they are embedded in the redirected pages.
+
+(defvar *doi-utils-pdf-url* nil
+  "Stores url to pdf download from a callback function.")
+
+;;** Wiley
+;; Wiley have changed the url structure from
+;; http://onlinelibrary.wiley.com/doi/10.1002/anie.201402680/abstract
+;; http://onlinelibrary.wiley.com/doi/10.1002/anie.201402680/pdf
+;; to
+;; http://onlinelibrary.wiley.com/doi/abs/10.1002/anie.201402680
+;; http://onlinelibrary.wiley.com/doi/pdf/10.1002/anie.201402680
+;; Hence fewer steps are now required.
+
+;; https://onlinelibrary.wiley.com/doi/10.1002/adts.202200926
+;; https://onlinelibrary.wiley.com/doi/epdf/10.1002/adts.202200926
+
+;; (defun wiley-pdf-url (*doi-utils-redirect*)
+;;   "Get url to the pdf from *DOI-UTILS-REDIRECT*."
+;;   (when (string-match "^http\\(s?\\)://onlinelibrary.wiley.com" *doi-utils-redirect*)
+;;     (replace-regexp-in-string "doi/abs" "doi/pdf" *doi-utils-redirect*)))
+
+
+(defun wiley-pdf-url-2 (*doi-utils-redirect*)
+  "Get url to the pdf from *DOI-UTILS-REDIRECT*.
+[2023-04-10 Mon] updated a new rule.
+https://onlinelibrary.wiley.com/doi/pdfdirect/10.1002/anie.201310461?download=true"
+  (when (string-match "^http\\(s?\\)://onlinelibrary.wiley.com" *doi-utils-redirect*)
+    (concat
+     (replace-regexp-in-string "doi/" "doi/pdfdirect/" *doi-utils-redirect*)
+     "?download=true")))
+
+
+(defun agu-pdf-url (*doi-utils-redirect*)
+  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
+  (when (string-match "https://agupubs.onlinelibrary.wiley.com"
+                     *doi-utils-redirect*)
+    (replace-regexp-in-string "/full/" "/pdfdirect/" *doi-utils-redirect*)))
+
+
+;;** Springer
+
+(defun springer-chapter-pdf-url (*doi-utils-redirect*)
+  (when (string-match "^http\\(s?\\)://link.springer.com/chapter/" *doi-utils-redirect*)
+    (replace-regexp-in-string "/chapter" "/content/pdf"
+                             (concat *doi-utils-redirect* ".pdf"))))
+
+
+(defun springer-pdf-url (*doi-utils-redirect*)
+  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
+  (when (string-match "^http\\(s?\\)://link.springer.com" *doi-utils-redirect*)
+    (replace-regexp-in-string "/article/" "/content/pdf/"
+                             (concat *doi-utils-redirect* ".pdf"))))
+
+
+;;** ACS
+;; here is a typical url http://pubs.acs.org/doi/abs/10.1021/nl500037x
+;; the pdf is found at http://pubs.acs.org/doi/pdf/10.1021/nl500037x
+
+;; we just change /abs/ to /pdf/.
+
+(defun acs-pdf-url-1 (*doi-utils-redirect*)
+  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
+  (when (string-match "^http\\(s?\\)://pubs.acs.org/doi/abs/" *doi-utils-redirect*)
+    (replace-regexp-in-string "/abs/" "/pdf/" *doi-utils-redirect*)))
+
+;; 1/20/2016 I noticed this new pattern in pdf urls, where there is no abs in
+;; the url
+(defun acs-pdf-url-2 (*doi-utils-redirect*)
+  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
+  (when (string-match "^http\\(s?\\)://pubs.acs.org/doi/" *doi-utils-redirect*)
+    (replace-regexp-in-string "/doi/" "/doi/pdf/" *doi-utils-redirect*)))
+
+;; 1/18/2019: It looks like they are using https now
+(defun acs-pdf-url-3 (*doi-utils-redirect*)
+  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
+  (when (string-match "^https://pubs.acs.org/doi/" *doi-utils-redirect*)
+    (replace-regexp-in-string "/doi/" "/doi/pdf/" *doi-utils-redirect*)))
+
+
+;;** IOP
+
+(defun iop-pdf-url (*doi-utils-redirect*)
+  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
+  (when (string-match "^http\\(s?\\)://iopscience.iop.org" *doi-utils-redirect*)
+    (concat *doi-utils-redirect* "/pdf")))
+
+;;** JSTOR
+
+(defun jstor-pdf-url (*doi-utils-redirect*)
+  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
+  (when (string-match "^http\\(s?\\)://www.jstor.org" *doi-utils-redirect*)
+    (concat (replace-regexp-in-string "/stable/" "/stable/pdfplus/" *doi-utils-redirect*) ".pdf")))
+
+
+;;** AIP
+
+(defun aip-pdf-url (*doi-utils-redirect*)
+  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
+  (when (string-match "^http\\(s?\\)://scitation.aip.org" *doi-utils-redirect*)
+    ;; get stuff after content
+    (let (p1 p2 s p3)
+      (setq p2 (replace-regexp-in-string
+                "^http\\(s?\\)://scitation.aip.org/" "" *doi-utils-redirect*))
+      (setq s (split-string p2 "/"))
+      (setq p1 (mapconcat 'identity (org-ref--remove-at-indices '(0 6) s) "/"))
+      (setq p3 (concat "/" (nth 0 s) (nth 1 s) "/" (nth 2 s) "/" (nth 3 s)))
+      (format "http://scitation.aip.org/deliver/fulltext/%s.pdf?itemId=/%s&mimeType=pdf&containerItemId=%s"
+              p1 p2 p3))))
+
+(defun aip-pdf-url-2 (*doi-utils-redirect*)
+  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
+  ;; [2021-08-28 Sat] Seems like they changed the link a little?
+  ;; https://aip.scitation.org/doi/10.1063/1.5019667
+  ;; to
+  ;; https://aip.scitation.org/doi/pdf/10.1063/1.5019667
+  (when (string-match "^http\\(s?\\)://aip.scitation.org" *doi-utils-redirect*)
+    (concat "https://aip.scitation.org/doi/pdf" (cl-second (split-string *doi-utils-redirect* "doi")))))
+
+;;** Taylor and Francis
+
+(defun tandfonline-pdf-url (*doi-utils-redirect*)
+  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
+  (when (string-match "^http\\(s?\\)://www.tandfonline.com" *doi-utils-redirect*)
+    (replace-regexp-in-string "/abs/\\|/full/" "/pdf/" *doi-utils-redirect*)))
+
+;;** ECS
+
+(defun ecs-pdf-url (*doi-utils-redirect*)
+  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
+  (when (string-match "^http\\(s?\\)://jes.ecsdl.org" *doi-utils-redirect*)
+    (replace-regexp-in-string "\\.abstract$" ".full.pdf" *doi-utils-redirect*)))
+
+;; http://ecst.ecsdl.org/content/25/2/2769
+;; http://ecst.ecsdl.org/content/25/2/2769.full.pdf
+
+
+(defun ecst-pdf-url (*doi-utils-redirect*)
+  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
+  (when (string-match "^http\\(s?\\)://ecst.ecsdl.org" *doi-utils-redirect*)
+    (concat *doi-utils-redirect* ".full.pdf")))
+
+
+
+;;** RSC
+
+(defun rsc-pdf-url (*doi-utils-redirect*)
+  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
+  (when (string-match "^http\\(s?\\)://pubs.rsc.org" *doi-utils-redirect*)
+    (let ((url (downcase *doi-utils-redirect*)))
+      (setq url (replace-regexp-in-string "articlelanding" "articlepdf" url))
+      url)))
+
+;;** Science Direct
+
+;; https://www.sciencedirect.com/science/article/pii/S001085452200577X?via%3Dihub
+;; https://www.sciencedirect.com/science/article/pii/S001085452200577X/pdfft?isDTMRedir=true&download=true
+
+(defun science-direct-pdf-url (*doi-utils-redirect*)
+  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
+  (when (string-match "^http\\(s?\\)://www.sciencedirect.com" *doi-utils-redirect*)
+    (replace-string "?via%3Dihub" "/pdfft?isDTMRedir=true&download=true" *doi-utils-redirect*)))
+
+;; (defun doi-utils-get-science-direct-pdf-url (redirect-url)
+;;   "Science direct hides the pdf url in html.  We get it out here.
+;; REDIRECT-URL is where the pdf url will be in."
+;;   (let ((first-url
+;;          (with-current-buffer (url-retrieve-synchronously redirect-url)
+;;            (goto-char (point-min))
+;;            (when (re-search-forward "pdf_url\" content=\"\\([^\"]*\\)\"" nil t)
+;;              (match-string-no-properties 1)))))
+;;     (and first-url
+;;          (with-current-buffer (url-retrieve-synchronously first-url)
+;;            (goto-char (point-min))
+;;            (when (re-search-forward "or click <a href=\"\\([^\"]*\\)\">" nil t)
+;;              (match-string-no-properties 1))))))
+
+;; (defun science-direct-pdf-url (*doi-utils-redirect*)
+;;   "Get url to the pdf from *DOI-UTILS-REDIRECT*."
+;;   (when (string-match "^http\\(s?\\)://www.sciencedirect.com" *doi-utils-redirect*)
+;;     (doi-utils-get-science-direct-pdf-url *doi-utils-redirect*)))
+
+;; sometimes I get
+;; http://linkinghub.elsevier.com/retrieve/pii/S0927025609004558
+;; which actually redirect to
+;; http://www.sciencedirect.com/science/article/pii/S0927025609004558
+
+;; https://www.sciencedirect.com/science/article/pii/S001085452200577X?via%3Dihub
+;; https://www.sciencedirect.com/science/article/pii/S001085452200577X/pdfft?isDTMRedir=true&download=true
+
+;; (defun linkinghub-elsevier-pdf-url (*doi-utils-redirect*)
+;;   "Get url to the pdf from *DOI-UTILS-REDIRECT*."
+;;   (when (string-match
+;;      "^https://linkinghub.elsevier.com/retrieve" *doi-utils-redirect*)
+;;     (science-direct-pdf-url
+;;      (replace-regexp-in-string
+;;       ;; change URL to science direct and use function to get pdf URL
+;;       "https://linkinghub.elsevier.com/retrieve"
+;;       "https://www.sciencedirect.com/science/article"
+;;       *doi-utils-redirect*))))
+
+;; https://www.sciencedirect.com/science/article/pii/S1385894723014973/pdfft?isDTMRedir=true&download=true
+
+(defun linkinghub-elsevier-pdf-url (*doi-utils-redirect*)
+  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
+  (when (string-match
+        "^https://linkinghub.elsevier.com/retrieve" *doi-utils-redirect*)
+    (concat
+     (replace-regexp-in-string
+      ;; change URL to science direct and use function to get pdf URL
+      "https://linkinghub.elsevier.com/retrieve"
+      "https://www.sciencedirect.com/science/article"
+      *doi-utils-redirect*)
+     "/pdfft?isDTMRedir=true")))
+
+;;** PNAS
+;; http://www.pnas.org/content/early/2014/05/08/1319030111
+;; http://www.pnas.org/content/early/2014/05/08/1319030111.full.pdf
+
+;; with supporting info
+;; http://www.pnas.org/content/early/2014/05/08/1319030111.full.pdf+html?with-ds=yes
+
+(defun pnas-pdf-url (*doi-utils-redirect*)
+  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
+  (when (string-match "^http\\(s?\\)://www.pnas.org" *doi-utils-redirect*)
+    (concat *doi-utils-redirect* ".full.pdf?with-ds=yes")))
+
+
+;;** Copernicus Publications
+(defvar copernicus-journal-urls '(
+                                  "^https://www.adv-geosci.net/"
+                                  "^https://www.adv-radio-sci.net/"
+                                  "^https://www.adv-sci-res.net/"
+                                  "^https://www.adv-stat-clim-meteorol-oceanogr.net/"
+                                  "^https://www.ann-geophys.net/"
+                                  "^https://www.arch-anim-breed.net/"
+                                  "^https://www.astra-proc.net/"
+                                  "^https://www.atmos-chem-phys.net/"
+                                  "^https://www.atmos-chem-phys-discuss.net/"
+                                  "^https://www.atmos-meas-tech.net/"
+                                  "^https://www.atmos-meas-tech-discuss.net/"
+                                  "^https://www.biogeosciences.net/"
+                                  "^https://www.biogeosciences-discuss.net/"
+                                  "^https://www.clim-past.net/recent_papers.html"
+                                  "^https://www.clim-past-discuss.net/"
+                                  "^https://www.drink-water-eng-sci.net/"
+                                  "^https://www.drink-water-eng-sci-discuss.net/"
+                                  "^https://www.eg-quaternary-sci-j.net/"
+                                  "^https://www.earth-surf-dynam.net/"
+                                  "^https://www.earth-surf-dynam-discuss.net/"
+                                  "^https://www.earth-syst-dynam.net/"
+                                  "^https://www.earth-syst-dynam-discuss.net/"
+                                  "^https://www.earth-syst-sci-data.net/"
+                                  "^https://www.earth-syst-sci-data-discuss.net/"
+                                  "^https://www.foss-rec.net/"
+                                  "^https://www.geogr-helv.net/"
+                                  "^https://www.geosci-instrum-method-data-syst.net/"
+                                  "^https://www.geosci-instrum-method-data-syst-discuss.net/"
+                                  "^https://www.geosci-model-dev.net/"
+                                  "^https://www.geosci-model-dev-discuss.net/"
+                                  "^https://www.hist-geo-space-sci.net/"
+                                  "^https://www.hydrol-earth-syst-sci.net/"
+                                  "^https://www.hydrol-earth-syst-sci-discuss.net/"
+                                  "^https://www.j-sens-sens-syst.net/"
+                                  "^https://www.mech-sci.net/"
+                                  "^https://www.nat-hazards-earth-syst-sci.net/"
+                                  "^https://www.nonlin-processes-geophys-discuss.net/"
+                                  "^https://www.ocean-sci.net/"
+                                  "^https://www.ocean-sci-discuss.net/"
+                                  "^https://www.primate-biol.net/"
+                                  "^https://www.proc-iahs.net/"
+                                  "^https://www.sci-dril.net/"
+                                  "^https://www.soil-journal.net/"
+                                  "^https://www.soil-discuss.net/"
+                                  "^https://www.solid-earth.net/"
+                                  "^https://www.solid-earth-discuss.net/"
+                                  "^https://www.stephan-mueller-spec-publ-ser.net/"
+                                  "^https://www.the-cryosphere.net/"
+                                  "^https://www.the-cryosphere-discuss.net/"
+                                  "^https://www.web-ecol.net/"
+                                  "^https://www.wind-energ-sci.net/"
+                                  "^https://www.wind-energ-sci-discuss.net/"
+                                  )
+  "List of Copernicus URLs.")
+
+(defun doi-utils-get-copernicus-pdf-url (redirect-url)
+  "Copernicus hides the pdf url in html.  We get it out here.
+REDIRECT-URL is where the pdf url will be in."
+  (setq *doi-utils-waiting* t)
+  (url-retrieve
+   redirect-url
+   (lambda (status)
+     (goto-char (point-min))
+     (re-search-forward "citation_pdf_url\" content=\"\\([^\"]*\\)\"" nil t)
+
+     (setq *doi-utils-pdf-url* (match-string 1)
+          *doi-utils-waiting* nil)))
+  (while *doi-utils-waiting* (sleep-for 0.1))
+  *doi-utils-pdf-url*)
+
+(defun copernicus-pdf-url (*doi-utils-redirect*)
+  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
+
+  (car (cl-loop for copurl in copernicus-journal-urls
+               when (string-match copurl *doi-utils-redirect*)
+               collect
+               (progn (doi-utils-get-copernicus-pdf-url *doi-utils-redirect*)
+                      *doi-utils-pdf-url*))))
+
+
+;;** Sage
+(defun sage-pdf-url (*doi-utils-redirect*)
+  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
+  (when (string-match "^http\\(s?\\)://pss.sagepub.com" *doi-utils-redirect*)
+    (concat *doi-utils-redirect* ".full.pdf")))
+
+
+;;** Journal of Neuroscience
+(defun jneurosci-pdf-url (*doi-utils-redirect*)
+  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
+  (when (string-match "^http\\(s?\\)://www.jneurosci.org" *doi-utils-redirect*)
+    (concat *doi-utils-redirect* ".full.pdf")))
+
+;;** Generic .full.pdf
+(defun generic-full-pdf-url (*doi-utils-redirect*)
+  (let ((pdf (concat *doi-utils-redirect* ".full.pdf")))
+    (when (url-http-file-exists-p pdf)
+      pdf)))
+
+;;** IEEE
+;; 10.1109/re.2014.6912247
+;; http(s)://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=6912247
+;; http(s)://ieeexplore.ieee.org/ielx7/6903646/6912234/06912247.pdf
+;; http(s)://ieeexplore.ieee.org/iel7/6903646/6912234/06912247.pdf?arnumber=6912247
+;; <meta name="citation_pdf_url" content="http(s)://ieeexplore.ieee.org/iel7/6903646/6912234/06912247.pdf?arnumber=6912247">
+;; <frame src="http(s)://ieeexplore.ieee.org/ielx7/6903646/6912234/06912247.pdf?tp=&arnumber=6912247&isnumber=6912234" frameborder=0 />
+(defun ieee-pdf-url (*doi-utils-redirect*)
+  "Get a url to the pdf from *DOI-UTILS-REDIRECT* for IEEE urls."
+  (when (string-match "^https?://ieeexplore.ieee.org" *doi-utils-redirect*)
+    (with-current-buffer (url-retrieve-synchronously *doi-utils-redirect*)
+      (goto-char (point-min))
+      (when (re-search-forward "<meta name=\"citation_pdf_url\" content=\"\\([[:ascii:]]*?\\)\">" nil t)
+       (let ((framed-url (match-string 1)))
+          (with-current-buffer (url-retrieve-synchronously framed-url)
+            (goto-char (point-min))
+            (when (re-search-forward "<frame src=\"\\(http[[:ascii:]]*?\\)\"" nil t)
+              (match-string 1))))))))
+
+;; At least some IEEE papers need the following new pdf-link parsing
+;; Example: 10.1109/35.667413
+(defun ieee2-pdf-url (*doi-utils-redirect*)
+  "Get a url to the pdf from *DOI-UTILS-REDIRECT* for IEEE urls."
+  (when (string-match "^https?://ieeexplore.ieee.org" *doi-utils-redirect*)
+    (with-current-buffer (url-retrieve-synchronously *doi-utils-redirect*)
+      (goto-char (point-min))
+      (when (re-search-forward "\"pdfUrl\":\"\\([[:ascii:]]*?\\)\"" nil t)
+       (let ((framed-url (match-string 1)))
+          (with-current-buffer (url-retrieve-synchronously (concat "http://ieeexplore.ieee.org" framed-url))
+            (goto-char (point-min))
+            (when (re-search-forward "<frame src=\"\\(http[[:ascii:]]*?\\)\"" nil t)
+              (match-string 1))))))))
+
+;; Another try to get the ieee pdf
+;; <iframe src="http(s)://ieeexplore.ieee.org/ielx5/8/4538127/04538164.pdf?tp=&arnumber=4538164&isnumber=4538127" frameborder=0>
+(defun ieee3-pdf-url (*doi-utils-redirect*)
+  "Get a url to the pdf from *DOI-UTILS-REDIRECT* for IEEE urls."
+  (when (string-match "^https?://ieeexplore.ieee.org" *doi-utils-redirect*)
+    (with-current-buffer (url-retrieve-synchronously *doi-utils-redirect*)
+      (goto-char (point-min))
+      (when (re-search-forward "\"pdfUrl\":\"\\([[:ascii:]]*?\\)\"" nil t)
+       (let ((framed-url (match-string 1)))
+          (with-current-buffer (url-retrieve-synchronously (concat "http://ieeexplore.ieee.org" framed-url))
+            (goto-char (point-min))
+            (when (re-search-forward "<iframe src=\"\\(http[[:ascii:]]*?\\)\"" nil t)
+              (match-string 1))))))))
+
+;; ACM Digital Library
+;; https://dl.acm.org/doi/10.1145/1368088.1368132
+(defun acm-pdf-url (*doi-utils-redirect*)
+  "Get a url to the pdf from *DOI-UTILS-REDIRECT* for ACM urls."
+  (when (string-match "^https?://dl.acm.org" *doi-utils-redirect*)
+    (replace-regexp-in-string "doi" "doi/pdf" *doi-utils-redirect* )))
+
+;;** Optical Society of America (OSA)
+(defun osa-pdf-url (*doi-utils-redirect*)
+  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
+  (when (string-match "^https://www.osapublishing.org" *doi-utils-redirect*)
+    (replace-regexp-in-string "abstract.cfm" "viewmedia.cfm" *doi-utils-redirect* )))
+
+
+
+;;** Publishers using Highwire Press metatags
+;; For context and details, see:
+;; https://webmasters.stackexchange.com/questions/72746/where-are-the-complete-set-of-highwire-press-metatags-defined
+
+(defun highwire-pdf-url (*doi-utils-redirect*)
+  "Typical URL:  http://biomechanical.asmedigitalcollection.asme.org/article.aspx?articleid=1427237
+
+On this page the pdf might be here:     <meta name=\"citation_author\" content=\"Dalong Li\" /><meta name=\"citation_author_email\" content=\"dal40@pitt.enbsp;/><meta name=\"citation_journal_title\" content=\"Journal of Biomechanical Engineering\" /><meta name=\"citation_journal_abbrev\" content=\"J Biomech Eng\" /><meta name=\"citation_volume\" content=\"131\" /><meta name=\"citation_issue\" content=\"10\" /><meta name=\"citation_publication_date\" content=\"2009/10/01\" /><meta name=\"citation_issn\" content=\"0148-0731\" /><meta name=\"citation_publisher\" content=\"American Society of Mechanical Engineers\" /><meta name=\"citation_pdf_url\" content=\"http://biomechanical.asmedigitalcollection.asme.org/data/journals/jbendy/27048/101013_1.pdf\" />
+
+It is in the citation_pdf_url.
+
+It would be better to parse this, but here I just use a regexp.
+"
+
+  (when (or (string-match "^http\\(s?\\)://biomechanical.asmedigitalcollection.asme.org" *doi-utils-redirect*)
+           (string-match "^http\\(s?\\)://ojs.aaai.org" *doi-utils-redirect*)
+           (string-match "^http\\(s?\\)://aclanthology.org" *doi-utils-redirect*))
+    (setq *doi-utils-waiting* 0)
+    (url-retrieve
+     *doi-utils-redirect*
+     (lambda (status)
+       (or (progn (goto-char (point-min))
+                 (re-search-forward "citation_pdf_url\"? content=\"\\(.*\\)\"" nil t))
+          (progn (goto-char (point-min))
+                 (re-search-forward "\"\\([^\"]*\\)\" name=\"?citation_pdf_url" nil t)))
+       ;; (message-box (match-string 1))
+       (setq *doi-utils-pdf-url* (match-string 1)
+            *doi-utils-waiting* nil)))
+    (while (and *doi-utils-waiting* (< *doi-utils-waiting* 5))
+      (setq *doi-utils-waiting* (+ *doi-utils-waiting* 0.1))
+      (sleep-for 0.1))
+    *doi-utils-pdf-url*))
+
+
+;; Society for Industrial and Applied Mathematics (SIAM)
+(defun siam-pdf-url (*doi-utils-redirect*)
+  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
+  (when (string-match "^http\\(s?\\)://epubs.siam.org" *doi-utils-redirect*)
+    (replace-regexp-in-string "/doi/" "/doi/pdf/" *doi-utils-redirect* )))
+
+;; PLOS journals
+;; https://plos.org/
+(defun plos-pdf-url (*doi-utils-redirect*)
+  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
+  (when (string-match "^http\\(s*\\)://journals.plos.org" *doi-utils-redirect*)
+    (concat (replace-regexp-in-string (regexp-quote "/article?id=") "/article/file?id=" *doi-utils-redirect*) "&type=printable")))
+
+
+;; https://www.frontiersin.org/articles/10.3389/fchem.2022.1037997/full
+;; https://www.frontiersin.org/articles/10.3389/fchem.2022.1037997/pdf
+(defun frontiers-pdf-url (*doi-utils-redirect*)
+  (when (string-match "^http\\(s*\\)://www.frontiersin.org" *doi-utils-redirect*)
+    (replace-regexp-in-string "/full" "/pdf" *doi-utils-redirect*)))
+
+
+
+
+;; https://chemistry-europe.onlinelibrary.wiley.com/doi/10.1002/celc.201902035
+;; https://chemistry-europe.onlinelibrary.wiley.com/doi/epdf/10.1002/celc.201902035
+(defun chemistry-europe-pdf-url (*doi-utils-redirect*)
+  (when (string-match "^http\\(s*\\)://chemistry-europe.onlinelibrary.wiley.com" *doi-utils-redirect*)
+    (concat
+     (replace-regexp-in-string "/doi" "/doi/pdfdirect" *doi-utils-redirect*)
+     "?download=true")))
+
+
+;; ** from issue #1081
+
+(defun arxiv-pdf-url (*doi-utils-redirect*)
+  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
+  (when (string-match-p "^https?://arxiv\\.org" *doi-utils-redirect*)
+    (concat (replace-regexp-in-string "/abs/" "/pdf/" *doi-utils-redirect*)
+           ".pdf")))
+
+
+(defun rss-pdf-url (*doi-utils-redirect*)
+  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
+  (when (string-match-p "roboticsproceedings" *doi-utils-redirect*)
+    (concat (replace-regexp-in-string "\\.html" ".pdf" *doi-utils-redirect*))))
+
+
+(defun ieeestamp-pdf-url (*doi-utils-redirect*)
+  "Get url to the pdf from *DOI-UTILS-REDIRECT*."
+  (when (string-match "^https?://ieeexplore\\.ieee\\.org/document/\\([0-9]+\\)"
+                     *doi-utils-redirect*)
+    (concat "https://ieeexplore.ieee.org/stampPDF/getPDF.jsp?tp=&arnumber="
+           (match-string 1 *doi-utils-redirect*))))
+
+
+;;** Add all functions
+
+(setq doi-utils-pdf-url-functions
+      (list
+       'aps-pdf-url
+       'science-pdf-url
+       'nature-pdf-url
+       ;; 'wiley-pdf-url
+       'wiley-pdf-url-2
+       'springer-chapter-pdf-url
+       'springer-pdf-url
+       'acs-pdf-url-1
+       'acs-pdf-url-2
+       'acs-pdf-url-3
+       'iop-pdf-url
+       'jstor-pdf-url
+       'aip-pdf-url
+       'aip-pdf-url-2
+       'science-direct-pdf-url
+       'linkinghub-elsevier-pdf-url
+       'tandfonline-pdf-url
+       'ecs-pdf-url
+       'ecst-pdf-url
+       'rsc-pdf-url
+       'pnas-pdf-url
+       'copernicus-pdf-url
+       'sage-pdf-url
+       'jneurosci-pdf-url
+       'ieee-pdf-url
+       'ieee2-pdf-url
+       'ieee3-pdf-url
+       'acm-pdf-url
+       'osa-pdf-url
+       'highwire-pdf-url
+       'siam-pdf-url
+       'agu-pdf-url
+       'plos-pdf-url
+       'frontiers-pdf-url
+       'chemistry-europe-pdf-url 
+       'generic-full-pdf-url
+       'arxiv-pdf-url
+       'rss-pdf-url
+       'ieeestamp-pdf-url))
+
+;;** Get the pdf url for a doi
+
+(defun doi-utils-get-pdf-url (doi)
+  "Return a url to a pdf for the DOI if one can be calculated.
+Loops through the functions in `doi-utils-pdf-url-functions'
+until one is found."
+  (doi-utils-get-redirect doi)
+
+  (unless *doi-utils-redirect*
+    (error "No redirect found for %s" doi))
+  (catch 'pdf-url
+    (dolist (func doi-utils-pdf-url-functions)
+      (let ((this-pdf-url (funcall func *doi-utils-redirect*)))
+        (when this-pdf-url
+          (throw 'pdf-url this-pdf-url))))))
+
+;;** Finally, download the pdf
+(defvar bibtex-completion-library-path)
+(defvar bibtex-completion-bibliography)
+(declare-function async-start "async")
+
+;;;###autoload
+(defun doi-utils-async-download-pdf ()
+  "Download the PDF for bibtex entry at point asynchronously.
+It is not fully async, only the download is. Fully async is
+harder because you need to run `doi-utils-get-pdf-url' async
+too. "
+  (interactive)
+  (require 'async)
+  (save-excursion
+    (bibtex-beginning-of-entry)
+    (let (;; get doi, removing http://dx.doi.org/ if it is there.
+          (doi (replace-regexp-in-string
+                "https?://\\(dx.\\)?.doi.org/" ""
+                (bibtex-autokey-get-field "doi")))
+          (base-name (funcall doi-utils-pdf-filename-function))
+          (pdf-url)
+          (pdf-file))
+
+      (setq pdf-file
+           (concat (cond
+                    ((stringp bibtex-completion-library-path)
+                     bibtex-completion-library-path)
+                    ((= 1 (length bibtex-completion-library-path))
+                     (car bibtex-completion-library-path))
+                    (t
+                     (completing-read "Dir: " bibtex-completion-library-path)))
+                   base-name ".pdf"))
+
+      (unless doi (error "No DOI found to get a pdf for"))
+
+      (when (file-exists-p pdf-file)
+       (error "%s already exists. Delete to re-download" pdf-file))
+
+      ;; (doi-utils-get-pdf-url "10.1063/1.5019667")
+      ;; If you get here, try getting the pdf file
+      (async-start
+       `(lambda ()
+         (setq package-user-dir ,package-user-dir)
+         (require 'package)
+         (package-initialize)
+         (setq load-path (list ,@load-path))
+         (require 'doi-utils)
+
+         (setq pdf-url (doi-utils-get-pdf-url ,doi))
+         (when pdf-url
+           (url-copy-file pdf-url ,pdf-file t)
+
+           (let* ((header (with-temp-buffer
+                            (set-buffer-multibyte nil)
+                            (insert-file-contents-literally ,pdf-file nil 0 5)
+                            (buffer-string)))
+                  (valid (and (stringp header)
+                              (string-equal (encode-coding-string header 'utf-8) "%PDF-"))))
+             (if valid
+                 (format "%s downloaded" ,pdf-file)
+               (delete-file ,pdf-file)
+               (require 'browse-url)
+               (browse-url pdf-url)
+               (message "Invalid pdf (file deleted). Header = %s" header)))))
+       `(lambda (result)
+         (message "doi-utils-async-download-pdf: %s"  result))))))
+
+
+;;;###autoload
+(defun doi-utils-get-bibtex-entry-pdf (&optional arg)
+  "Download pdf for entry at point if the pdf does not already exist locally.
+The entry must have a doi. The pdf will be saved, by the name
+%s.pdf where %s is the bibtex label. Files will not be
+overwritten. The pdf will be checked to make sure it is a pdf,
+and not some html failure page. You must have permission to
+access the pdf. We open the pdf at the end if
+`doi-utils-open-pdf-after-download' is non-nil.
+
+With one prefix ARG, directly get the pdf from a file (through
+`read-file-name') instead of looking up a DOI. With a double
+prefix ARG, directly get the pdf from an open buffer (through
+`read-buffer-to-switch') instead. These two alternative methods
+work even if the entry has no DOI, and the pdf file is not
+checked."
+  (interactive "P")
+  (save-excursion
+    (bibtex-beginning-of-entry)
+    (let (;; get doi, removing http://dx.doi.org/ if it is there.
+          (doi (replace-regexp-in-string
+                "https?://\\(dx.\\)?.doi.org/" ""
+                (bibtex-autokey-get-field "doi")))
+          (base-name (funcall doi-utils-pdf-filename-function))
+          (pdf-url)
+          (pdf-file))
+
+      (setq pdf-file
+           (concat (cond
+                    ((stringp bibtex-completion-library-path)
+                     bibtex-completion-library-path)
+                    ((= 1 (length bibtex-completion-library-path))
+                     (car bibtex-completion-library-path))
+                    (t
+                     (completing-read "Dir: " bibtex-completion-library-path)))
+                   base-name ".pdf"))
+      ;; now get file if needed.
+      (unless (file-exists-p pdf-file)
+       (cond
+        ((and (not arg)
+              doi
+              (setq pdf-url (doi-utils-get-pdf-url doi)))
+         (url-copy-file pdf-url pdf-file)
+         ;; now check if we got a pdf
+          (if (org-ref-pdf-p pdf-file)
+              (message "%s saved" pdf-file)
+            (delete-file pdf-file)
+            (message "No pdf was downloaded.")
+            (browse-url pdf-url)))
+        ((equal arg '(4))
+         (copy-file (expand-file-name (read-file-name "Pdf file: " nil nil t))
+                    pdf-file))
+        ((equal arg '(16))
+         (with-current-buffer (read-buffer-to-switch "Pdf buffer: ")
+           (write-file pdf-file)))
+        (t
+         (message "We don't have a recipe for this journal.")))
+
+       (when (file-exists-p pdf-file)
+         (bibtex-set-field "file" pdf-file))
+
+       (when (and doi-utils-open-pdf-after-download (file-exists-p pdf-file))
+         (org-open-file pdf-file))))))
+
+;;* Getting bibtex entries from a DOI
+
+;; [[http://homepages.see.leeds.ac.uk/~eeaol/notes/2013/02/doi-metadata/][found]]
+;; you can download metadata about a DOI from http://dx.doi.org. You just have
+;; to construct the right http request to get it. Here is a function that gets
+;; the metadata as a plist in emacs.
+;;
+;;
+(defvar doi-utils-cache nil
+  "Cache variable for storing data we can reuse.
+A-list (doi . data) where doi is doi string, and data is what is
+retrieved from it. This is transient, and disappears when you
+restart Emacs. This mostly exists to prevent
+`doi-utils-update-field' from needing to download the data for
+every field.")
+
+
+(defun doi-utils-clear-cache ()
+  "Clear `doi-utils-cache'."
+  (interactive)
+  (setq doi-utils-cache '()))
+
+
+(defun doi-utils-get-json-metadata (doi)
+  "Try to get json metadata for DOI.  Open the DOI in a browser if we do not get it."
+  (if-let* ((data (cdr (assoc doi doi-utils-cache))))
+      ;; We have the data already, so we return it.
+      data
+    (let ((url-request-method "GET")
+          (url-mime-accept-string "application/citeproc+json")
+          (json-object-type 'plist)
+          (json-data)
+         (url (concat doi-utils-dx-doi-org-url doi)))
+      (with-temp-buffer
+       (url-insert
+        (url-retrieve-synchronously url))
+       (setq json-data (buffer-string))
+
+       (when (or (string-match "<title>Error: DOI Not Found</title>" json-data)
+                 (string-match "Resource not found" json-data)
+                 (string-match "Status *406" json-data)
+                 (string-match "400 Bad Request" json-data))
+         (browse-url (concat doi-utils-dx-doi-org-url doi))
+         (error "Something went wrong.  We got this response:
+%s
+
+Opening %s" json-data url))
+
+       (setq data (json-read-from-string json-data))
+       (cl-pushnew (cons doi data) doi-utils-cache)
+       data))))
+
+
+(defun doi-utils-get-json-metadata-curl (doi)
+  "Try to get json metadata for DOI.  Open the DOI in a browser if we do not get it."
+  (let ((json-object-type 'plist)
+        (json-data)
+       (url (concat doi-utils-dx-doi-org-url doi)))
+    (with-temp-buffer
+      (call-process "curl" nil t nil
+                    "--location"
+                    "--silent"
+                    "--header"
+                    "Accept: application/citeproc+json"
+                    url)
+      (setq json-data (buffer-string))
+      (cond
+       ((or (string-match "<title>Error: DOI Not Found</title>" json-data)
+           (string-match "Resource not found" json-data)
+           (string-match "Status *406" json-data)
+           (string-match "400 Bad Request" json-data))
+       (browse-url url)
+       (error "Something went wrong.  We got this response:
+%s
+Opening %s" json-data url))
+       ;; everything seems ok with the data
+       (t
+       (json-read-from-string json-data))))))
+
+;; We can use that data to construct a bibtex entry. We do that by defining a
+;; template, and filling it in. I wrote this template expansion code which
+;; makes it easy to substitute values like %{} in emacs lisp.
+
+
+(defun doi-utils-expand-template (s)
+  "Expand a string template S containing %{} with the eval of its contents."
+  (replace-regexp-in-string "%{\\([^}]+\\)}"
+                           (lambda (arg)
+                             (let ((sexp (substring arg 2 -1)))
+                               (format "%s" (eval (read sexp)))))
+                           s))
+
+
+;; Now we define a function that fills in that template from the metadata.
+
+;; As different bibtex types share common keys, it is advantageous to separate
+;; data extraction from json, and the formatting of the bibtex entry.
+
+;; We use eval-and-compile because we use the three following forms in the
+;; `doi-utils-def-bibtex-type' macro.  Since the macro is expanded at compile
+;; time, we need to ensure these defuns and defvars are evaluated at
+;; compile-time.
+(eval-and-compile
+  (defvar doi-utils-json-metadata-extract
+    '((type       (plist-get results :type))
+      (author     (mapconcat (lambda (x)
+                              (message "%s" x)
+                              (if (plist-get x :name)
+                                  (plist-get x :name)
+                                (concat (plist-get x :given) " " (plist-get x :family))))
+                             (plist-get results :author) " and "))
+      (title      (plist-get results :title))
+      (subtitle   (plist-get results :subtitle))
+      (journal    (plist-get results :container-title))
+      (series     (plist-get results :container-title))
+      (publisher  (plist-get results :publisher))
+      (volume     (plist-get results :volume))
+      (issue      (plist-get results :issue))
+      (number     (plist-get results :issue))
+      (year       (or (elt (elt (plist-get (plist-get results :issued) :date-parts) 0) 0)
+                      (elt (elt (plist-get (plist-get results :approved) :date-parts) 0) 0)
+                      ))
+      ;; Some dates don't have a month in them.
+      (month      (let ((date (elt
+                              (plist-get (plist-get results :issued) :date-parts) 0)))
+                   (if (>= (length date) 2)
+                       (elt date 1)
+                     "-")))
+      (pages      (or (plist-get results :page)
+                     (plist-get results :article-number)))
+      (doi        (plist-get results :DOI))
+      (url        (plist-get results :URL))
+      (booktitle  (plist-get results :container-title))
+      (school     (or (plist-get results :school)
+                      (plist-get (plist-get results :institution) :name)))
+      ;; I am not sure how general this is. This gets the first name.
+      (institution (plist-get (car (plist-get results :institution)) :name))))
+
+  ;; Next, we need to define the different bibtex types. Each type has a bibtex
+  ;; type (for output) and the type as provided in the doi record. Finally, we
+  ;; have to declare the fields we want to output.
+
+  (defvar doi-utils-bibtex-type-generators nil)
+
+  (defun doi-utils-concat-prepare (lst &optional acc)
+    "Minimize the number of args passed to `concat' from LST.
+Given a list LST of strings and other expressions, which are
+intended to be passed to `concat', concat any subsequent strings,
+minimising the number of arguments being passed to `concat'
+without changing the results.  ACC is the list of additional
+expressions."
+    (cond ((null lst) (nreverse acc))
+          ((and (stringp (car lst))
+                (stringp (car acc)))
+           (doi-utils-concat-prepare (cdr lst) (cons (concat (car acc) (car lst))
+                                                     (cdr acc))))
+          (t (doi-utils-concat-prepare (cdr lst) (cons (car lst) acc))))))
+
+(defmacro doi-utils-def-bibtex-type (name matching-types &rest fields)
+  "Define a BibTeX type identified by (symbol) NAME.
+MATCHING-TYPES is a list of strings.  FIELDS are symbols that
+match to retrieval expressions in
+`doi-utils-json-metadata-extract'.  This type will only be used
+when the `:type' parameter in the JSON metadata is contained in
+MATCHING-TYPES."
+  `(push (lambda (type results)
+           (when
+               (or ,@(mapcar
+                      (lambda (match-type)
+                        `(string= type ,match-type)) matching-types))
+             (let ,(mapcar (lambda (field)
+                             (let ((field-expr
+                                    (assoc field doi-utils-json-metadata-extract)))
+                               (if field-expr
+                                   ;; need to convert to string first
+                                   `(,(car field-expr) (format "%s" ,(cadr field-expr)))
+                                 (error "Unknown bibtex field type %s" field))))
+                           fields)
+               (concat
+                ,@(doi-utils-concat-prepare
+                   (org-ref--flatten-list
+                    (list (concat "@" (symbol-name name) "{,\n")
+                          ;; there seems to be some bug with mapcan,
+                          ;; so we fall back to flatten
+                          (mapcar (lambda (field)
+                                    `("  " ,(symbol-name field) " = {" ,field "},\n"))
+                                  fields)
+                          "}\n")))))))
+         doi-utils-bibtex-type-generators))
+
+(doi-utils-def-bibtex-type article ("journal-article" "article-journal" "article")
+                           author title journal year volume number pages doi url)
+
+(doi-utils-def-bibtex-type inproceedings ("proceedings-article" "paper-conference")
+                           author title booktitle year month pages doi url)
+
+(doi-utils-def-bibtex-type book ("book" "edited-book")
+                           author title series publisher year pages doi url)
+
+(doi-utils-def-bibtex-type inbook ("chapter" "book-chapter" "reference-entry")
+                           author title booktitle series publisher year pages doi url)
+
+(doi-utils-def-bibtex-type phdthesis ("phdthesis" "thesis" "dissertation")
+                          author title school publisher year)
+
+(doi-utils-def-bibtex-type techreport ("report")
+                          institution author title publisher year doi url)
+
+;; this is what preprints in chemrxiv look like for now
+(doi-utils-def-bibtex-type misc ("posted-content")
+                          author title year doi url)
+
+
+
+;; With the code generating the bibtex entry in place, we can glue it to the json retrieval code.
+
+(defun doi-utils-doi-to-bibtex-string (doi)
+  "Return a bibtex entry as a string for the DOI.  Not all types are supported yet."
+  (let* ((results (funcall doi-utils-metadata-function doi))
+         (type (plist-get results :type)))
+    ;; (format "%s" results) ; json-data
+    (or (cl-some (lambda (g) (funcall g type results)) doi-utils-bibtex-type-generators)
+        (message "%s not supported yet\n%S." type results))))
+
+;; That is just the string for the entry. To be useful, we need a function that
+;; inserts the string into a buffer. This function will insert the string at the
+;; cursor, clean the entry, try to get the pdf.
+
+(defun doi-utils-insert-bibtex-entry-from-doi (doi)
+  "Insert and clean bibtex entry from a DOI."
+  (insert (doi-utils-doi-to-bibtex-string doi))
+  (backward-char)
+  ;; set date added for the record
+  (let ((ts (funcall doi-utils-timestamp-format-function)))
+    (when ts
+      (bibtex-set-field doi-utils-timestamp-field
+                       ts)))
+  (org-ref-clean-bibtex-entry)
+  (when (buffer-file-name)
+      (save-buffer)))
+
+
+;;;###autoload
+(defun doi-utils-add-bibtex-entry-from-doi (doi &optional bibfile)
+  "Add DOI entry to end of a file in the current directory.
+Pick the file ending with .bib or in .  If you have an active region that
+starts like a DOI, that will be the initial prompt.  If no region
+is selected and the first entry of the ‘kill-ring’ starts like a
+DOI, then that is the initial prompt.  Otherwise, you have to type
+or paste in a DOI.
+Argument BIBFILE the bibliography to use."
+  (interactive
+   (list (read-string
+          "DOI: "
+          ;; now set initial input
+          (doi-utils-maybe-doi-from-region-or-current-kill))))
+
+  (unless bibfile
+    (setq bibfile (completing-read "Bibfile: " (org-ref-possible-bibfiles))))
+  ;; Wrap in save-window-excursion to restore your window arrangement after this
+  ;; is done.
+  (save-window-excursion
+    (with-current-buffer
+        (find-file-noselect bibfile)
+      ;; Check if the doi already exists
+      (goto-char (point-min))
+      (if (re-search-forward (concat doi "\\_>") nil t)
+          (message "%s is already in this file" doi)
+        (goto-char (point-max))
+
+       (when (not (looking-back "\n\n" (min 3 (point))))
+         (insert "\n\n"))
+
+        (doi-utils-insert-bibtex-entry-from-doi doi)
+        (save-buffer)))))
+
+(defalias 'doi-add-bibtex-entry 'doi-utils-add-bibtex-entry-from-doi
+  "Alias function for convenience.")
+
+(defun doi-utils-maybe-doi-from-region-or-current-kill ()
+  "Try to get a DOI from the active region or current kill."
+  (let* ((the-active-region (if (region-active-p) ;; nil if no active region
+                                (buffer-substring (region-beginning) (region-end))
+                              nil))
+         (the-current-kill (ignore-errors (current-kill 0 t)))  ;; nil if empty kill ring
+         ;; DOI urls
+         ;; Ex: https://doi.org/10.1109/MALWARE.2014.6999410
+         ;; Ex: https://dx.doi.org/10.1007/978-3-319-60876-1_10
+         (doi-url-prefix-regexp "^https?://\\(dx\\.\\)?doi\\.org/")
+         ;; https://www.crossref.org/blog/dois-and-matching-regular-expressions/
+         (doi-regexp "10\\.[0-9]\\{4,9\\}/[-._;()/:A-Z0-9]+$"))
+    (cond
+     ;; Check if a DOI can be found in the active region
+     ;; DOI raw
+     ;; Ex: 10.1109/MALWARE.2014.6999410
+     ((and (stringp the-active-region)
+           (org-ref--string-match (concat "^" doi-regexp) the-active-region))
+      the-active-region)
+     ;; DOI url
+     ;; Ex: https://doi.org/10.1109/MALWARE.2014.6999410
+     ((and (stringp the-active-region)
+           (org-ref--string-match (concat doi-url-prefix-regexp doi-regexp) the-active-region))
+      (replace-regexp-in-string doi-url-prefix-regexp "" the-active-region))
+     ;; DOI url as customized
+     ((and (stringp the-active-region)
+           (org-ref--string-match (regexp-quote doi-utils-dx-doi-org-url) the-active-region))
+      (replace-regexp-in-string (regexp-quote doi-utils-dx-doi-org-url) "" the-active-region))
+     ;; Check if DOI can be found in the current kill
+     ;; DOI raw
+     ;; Ex: 10.1109/MALWARE.2014.6999410
+     ((and (stringp the-current-kill)
+           (org-ref--string-match (concat "^" doi-regexp) the-current-kill))
+      the-current-kill)
+     ;; DOI url
+     ;; Ex: https://doi.org/10.1109/MALWARE.2014.6999410
+     ((and (stringp the-current-kill)
+           (org-ref--string-match (concat doi-url-prefix-regexp doi-regexp) the-current-kill))
+      (replace-regexp-in-string doi-url-prefix-regexp "" the-current-kill))
+     ;; DOI url as customized
+     ((and (stringp the-current-kill)
+           (org-ref--string-match (regexp-quote doi-utils-dx-doi-org-url) the-current-kill))
+      (replace-regexp-in-string (regexp-quote doi-utils-dx-doi-org-url) "" the-current-kill))
+     ;; otherwise, return nil
+     (t
+      nil))))
+
+;;;###autoload
+(defun doi-utils-doi-to-org-bibtex (doi)
+  "Convert a DOI to an ‘org-bibtex’ form and insert it at point."
+  (interactive "sDOI: ")
+  (with-temp-buffer
+    (insert (doi-utils-doi-to-bibtex-string doi))
+    (bibtex-clean-entry)
+    (kill-region (point-min) (point-max)))
+  (org-bibtex-yank)
+  (org-metaright)
+  (org-metaright))
+
+;;* Updating bibtex entries
+
+;; I wrote this code because it is pretty common for me to copy bibtex entries
+;; from ASAP articles that are incomplete, e.g. no page numbers because it is
+;; not in print yet. I wanted a convenient way to update an entry from its DOI.
+;; Basically, we get the metadata, and update the fields in the entry.
+
+;; There is not bibtex set field function, so I wrote this one.
+
+
+;;;###autoload
+(defun bibtex-set-field (field value &optional nodelim)
+  "Set FIELD to VALUE in bibtex file.  create field if it does not exist.
+Optional argument NODELIM see `bibtex-make-field'."
+  (interactive "sfield: \nsvalue: ")
+  (bibtex-beginning-of-entry)
+  (let ((found))
+    (if (setq found (bibtex-search-forward-field field t))
+        ;; we found a field
+        (progn
+          (goto-char (car (cdr found)))
+          (when value
+            (bibtex-kill-field)
+            (bibtex-make-field field nil nil nodelim)
+            (backward-char)
+            (insert value)))
+      ;; make a new field
+      (bibtex-beginning-of-entry)
+      (forward-line) (beginning-of-line)
+      (bibtex-next-field nil)
+      (forward-char)
+      (bibtex-make-field field nil nil nodelim)
+      (backward-char)
+      (insert value))))
+
+
+(defun plist-get-keys (plist)
+  "Return keys in a PLIST."
+  (cl-loop for (key _value) on plist by #'cddr collect key))
+
+
+;;;###autoload
+(defun doi-utils-update-bibtex-entry-from-doi (doi)
+  "Update fields in a bibtex entry from the DOI.
+Every field will be updated, so previous change will be lost."
+  (interactive (list
+                (or (replace-regexp-in-string
+                     "https?://\\(dx.\\)?doi.org/" ""
+                     (bibtex-autokey-get-field "doi"))
+                    (read-string "DOI: "))))
+  (let* ((results (funcall doi-utils-metadata-function doi))
+         (type (plist-get results :type))
+         (author (mapconcat
+                  (lambda (x)
+                   ;; There are two possible ways an author is named. The most
+                   ;; common is with :given and :family, but sometimes there is
+                   ;; :name instead.
+                   (if (plist-get x :name)
+                       (plist-get x :name)
+                     (concat (plist-get x :given)
+                             " " (plist-get x :family))))
+                  (plist-get results :author) " and "))
+         (title (plist-get results :title))
+         (journal (plist-get results :container-title))
+         (year (format "%s"
+                       (elt
+                        (elt
+                         (plist-get
+                          (plist-get results :issued) :date-parts) 0) 0)))
+         (volume (plist-get results :volume))
+         (number (or (plist-get results :issue) ""))
+         (pages (or (plist-get results :page) ""))
+         (url (or (plist-get results :URL) ""))
+         (doi (plist-get results :DOI))
+         mapping)
+
+    ;; map the json fields to bibtex fields. The code each field is mapped to is
+    ;; evaluated.
+    (setq mapping '((:author . (bibtex-set-field "author" author))
+                    (:title . (bibtex-set-field "title" title))
+                    (:container-title . (bibtex-set-field "journal" journal))
+                    (:issued . (bibtex-set-field "year" year))
+                    (:volume . (bibtex-set-field "volume" volume))
+                    (:issue . (bibtex-set-field "number" number))
+                    (:page . (bibtex-set-field "pages" pages))
+                    (:DOI . (bibtex-set-field "doi" doi))
+                    (:URL . (bibtex-set-field "url" url))))
+
+    ;; now we have code to run for each entry. we map over them and evaluate the code
+    (mapc
+     (lambda (key)
+       (eval (cdr (assoc key mapping))))
+     (plist-get-keys results)))
+
+  (org-ref-clean-bibtex-entry))
+
+
+;; A downside to updating an entry is it overwrites what you have already fixed.
+;; So, we next develop a function to update the field at point.
+
+
+;;;###autoload
+(defun doi-utils-update-field ()
+  "Update the field at point in the bibtex entry.
+Data is retrieved from the doi in the entry."
+  (interactive)
+  (let* ((doi (bibtex-autokey-get-field "doi"))
+         (results (funcall doi-utils-metadata-function doi))
+         (field (car (bibtex-find-text-internal nil nil ","))))
+    (cond
+     ((string= field "volume")
+      (bibtex-set-field field (plist-get results :volume)))
+     ((string= field "number")
+      (bibtex-set-field field (plist-get results :issue)))
+     ((string= field "pages")
+      (bibtex-set-field field (or (plist-get results :page)
+                                  (plist-get results :article-number))))
+     ((string= field "year")
+      (bibtex-set-field field (plist-get results :year)))
+     (t
+      (message "%s not supported yet." field)))))
+
+
+
+;;* DOI functions for WOS
+
+;; I came across this API http://wokinfo.com/media/pdf/OpenURL-guide.pdf to make
+;; links to the things I am interested in here. Based on that document, here are
+;; three links based on a doi:10.1021/jp047349j that take you to different Web
+;; Of Science (WOS) pages.
+
+
+;; 1. go to article in WOS: http://ws.isiknowledge.com/cps/openurl/service?url_ver=Z39.88-2004&rft_id=info:doi/10.1021/jp047349j
+;; 2. citing articles: http://ws.isiknowledge.com/cps/openurl/service?url_ver=Z39.88-2004&rft_id=info%3Adoi%2F10.1021/jp047349j&svc_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Asch_svc&svc.citing=yes
+;; 3. related articles: http://ws.isiknowledge.com/cps/openurl/service?url_ver=Z39.88-2004&rft_id=info%3Adoi%2F10.1021/jp047349j&svc_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Asch_svc&svc.related=yes
+
+;; These are pretty easy to construct, so we can write functions that will
+;; create them and open the url in our browser. There are some other options
+;; that could be considered, but since we usually have a doi, it seems like the
+;; best way to go for creating the links. Here are the functions.
+
+;;;###autoload
+(defun doi-utils-wos (doi)
+  "Open Web of Science entry for DOI."
+  (interactive "sDOI: ")
+  (browse-url
+   (format
+    "http://ws.isiknowledge.com/cps/openurl/service?url_ver=Z39.88-2004&rft_id=info:doi/%s" doi)))
+
+;;;###autoload
+(defun doi-utils-wos-citing (doi)
+  "Open Web of Science citing articles entry for DOI.
+May be empty if none are found."
+  (interactive "sDOI: ")
+  (browse-url
+   (concat
+    "http://ws.isiknowledge.com/cps/openurl/service?url_ver=Z39.88-2004&rft_id=info%3Adoi%2F"
+    doi
+    "&svc_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Asch_svc&svc.citing=yes")))
+
+;;;###autoload
+(defun doi-utils-wos-related (doi)
+  "Open Web of Science related articles page for DOI."
+  (interactive "sDOI: ")
+  (browse-url
+   (concat "http://ws.isiknowledge.com/cps/openurl/service?url_ver=Z39.88-2004&rft_id=info%3Adoi%2F"
+           doi
+           "&svc_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Asch_svc&svc.related=yes")))
+
+
+;;* DOI functions for ADS
+
+;;;###autoload
+(defun doi-utils-ads (doi)
+  "Open ADS entry for DOI"
+  (interactive "sDOI: ")
+  (browse-url
+   (concat
+    "https://ui.adsabs.harvard.edu/abs/" "%22" doi "%22")))
+
+
+;;* A new doi link for org-mode
+;; The idea is to add a menu to the doi link, so rather than just clicking to open the article, you can do other things.
+;; 1. open doi
+;; 2. open in wos
+;; 3. open citing articles
+;; 4. open related articles
+;; 5. open bibtex entry
+;; 6. get bibtex entry
+
+
+;;;###autoload
+(defun doi-utils-open (doi)
+  "Open DOI in browser."
+  (interactive "sDOI: ")
+  (browse-url (concat doi-utils-dx-doi-org-url doi)))
+
+
+;;;###autoload
+(defun doi-utils-open-bibtex (doi)
+  "Search through variable `bibtex-completion-bibliography' for DOI."
+  (interactive "sDOI: ")
+  (cl-loop for f in (org-ref-normalize-bibtex-completion-bibliography)
+          when (progn (find-file f)
+                      (when (search-forward doi (point-max) t)
+                        (bibtex-beginning-of-entry)))
+          return f))
+
+
+;;;###autoload
+(defun doi-utils-crossref (doi)
+  "Search DOI in CrossRef."
+  (interactive "sDOI: ")
+  (browse-url
+   (format
+    "http://search.crossref.org/?q=%s" doi)))
+
+
+;;;###autoload
+(defun doi-utils-google-scholar (doi)
+  "Google scholar the DOI."
+  (interactive "sDOI: ")
+  (browse-url
+   (format
+    "http://scholar.google.com/scholar?q=%s" doi)))
+
+
+;;;###autoload
+(defun doi-utils-pubmed (doi)
+  "Search Pubmed for the DOI."
+  (interactive "sDOI: ")
+  (browse-url
+   (format
+    "http://www.ncbi.nlm.nih.gov/pubmed/?term=%s"
+    (url-hexify-string doi))))
+
+(declare-function org-element-property "org-element")
+
+(defun doi-utils--context-doi ()
+  (org-element-property :path (org-element-context)))
+
+(transient-define-prefix doi-link-follow-menu ()
+  "DOI actions."
+  [["Actions"
+    ("o" "open" (lambda () (interactive)
+                  (doi-utils-open (doi-utils--context-doi))))
+    ("w" "wos" (lambda () (interactive)
+                 (doi-utils-wos (doi-utils--context-doi))))
+    ("c" "wos citing articles" (lambda () (interactive)
+                                  (doi-utils-wos-citing (doi-utils--context-doi))))
+    ("r" "wos related articles" (lambda () (interactive)
+                                   (doi-utils-wos-related (doi-utils--context-doi))))
+    ("a" "ads" (lambda () (interactive)
+                 (doi-utils-ads (doi-utils--context-doi))))
+    ("s" "Google Scholar" (lambda () (interactive)
+                            (doi-utils-google-scholar (doi-utils--context-doi))))
+    ("f" "CrossRef" (lambda () (interactive)
+                      (doi-utils-crossref (doi-utils--context-doi))))
+    ("p" "Pubmed" (lambda () (interactive)
+                    (doi-utils-pubmed (doi-utils--context-doi))))
+    ("b" "open in bibtex" (lambda () (interactive)
+                             (doi-utils-open-bibtex (doi-utils--context-doi))))
+    ("g" "get bibtex entry" (lambda () (interactive)
+                               (doi-utils-add-bibtex-entry-from-doi (doi-utils--context-doi))))
+    ("q" "quit" transient-quit-one)]])
+
+(define-obsolete-function-alias 'doi-link-follow/body
+  #'doi-link-follow-menu "3.1")
+
+
+(org-link-set-parameters "doi"
+                        :follow (lambda (_) (doi-link-follow-menu))
+                        :export (lambda (doi desc format)
+                                  (cond
+                                   ((eq format 'html)
+                                    (format "<a href=\"%s%s\">%s</a>"
+                                            doi-utils-dx-doi-org-url
+                                            doi
+                                            (or desc (concat "doi:" doi))))
+                                   ((eq format 'latex)
+                                    (format "\\href{%s%s}{%s}"
+                                            doi-utils-dx-doi-org-url
+                                            doi
+                                            (or desc (concat "doi:" doi)))))))
+
+;;* Getting a doi for a bibtex entry missing one
+
+;; Some bibtex entries do not have a DOI, maybe because they were entered by
+;; hand, or copied from a source that did not have it available. Here we develop
+;; some functions to help you find the DOI using Crossref.
+
+;; Here is our example bibtex entry.
+;; #+BEGIN_SRC bibtex
+;; @article{deml-2014-oxide,
+;;   author =   {Ann M. Deml and Vladan Stevanovi{\'c} and
+;;                   Christopher L. Muhich and Charles B. Musgrave and
+;;                   Ryan O'Hayre},
+;;   title =    {Oxide Enthalpy of Formation and Band Gap Energy As
+;;                   Accurate Descriptors of Oxygen Vacancy Formation
+;;                   Energetics},
+;;   journal =  {Energy Environ. Sci.},
+;;   volume =   7,
+;;   number =   6,
+;;   pages =    1996,
+;;   year =     2014,
+;;   doi =              {10.1039/c3ee43874k,
+;;   url =              {http://dx.doi.org/10.1039/c3ee43874k}},
+
+;; }
+
+
+;; The idea is to query Crossref in a way that is likely to give us a hit
+;; relevant to the entry.
+
+;; According to http://search.crossref.org/help/api we can send a query with a
+;; free form citation that may give us something back. We do this to get a list
+;; of candidates, which could be used to get the doi.
+
+(declare-function org-ref-bib-citation "org-ref-bibtex")
+;;;###autoload
+(defun doi-utils-crossref-citation-query ()
+  "Query Crossref with the title of the bibtex entry at point.
+Get a list of possible matches. Choose one with completion."
+  (interactive)
+  (bibtex-beginning-of-entry)
+  (let* ((entry (bibtex-parse-entry))
+        (raw-json-string)
+         (json-string)
+         (json-data)
+         (doi (bibtex-autokey-get-field "doi")))
+    (unless (string= "" doi)
+      (error "Entry already has a doi field"))
+
+    (with-current-buffer
+        (url-retrieve-synchronously
+         (concat
+          "http://search.crossref.org/dois?q="
+          (url-hexify-string (org-ref-bib-citation))))
+      (save-excursion
+       (goto-char (point-min))
+       (while (re-search-forward "<i>\\|</i>" nil t)
+         (replace-match ""))
+       (goto-char (point-min))
+       (while (re-search-forward "&amp;" nil t)
+         (replace-match "&"))
+       (goto-char (point-min))
+       (while (re-search-forward "&quot;" nil t)
+         (replace-match "\\\"" nil t)))
+      (setq raw-json-string (buffer-substring url-http-end-of-headers (point-max)))
+      ;; decode json string
+      (setq json-string (decode-coding-string (encode-coding-string raw-json-string 'utf-8) 'utf-8))
+      (setq json-data (json-read-from-string json-string)))
+
+    (let* ((name (format "Crossref hits for %s" (org-ref-bib-citation)))
+           (candidates (mapcar (lambda (x)
+                                 (cons
+                                  (concat
+                                   (cdr (assoc 'fullCitation x)))
+                                  (cdr (assoc 'doi x))))
+                               json-data))
+
+          (doi (cdr (assoc (completing-read "DOI: " candidates) candidates))))
+      (bibtex-make-field "doi" t)
+      (backward-char)
+      ;; crossref returns doi url, but I prefer only a doi for the doi field
+      (insert (replace-regexp-in-string "^https?://\\(dx.\\)?doi.org/" "" doi))
+      (when (string= "" (bibtex-autokey-get-field "url"))
+        (bibtex-make-field "url" t)
+        (backward-char)
+        (insert doi)))))
+
+
+
+;;* Debugging a DOI
+
+;; I wrote this function to help debug a DOI. This function generates an
+;; org-buffer with the doi, gets the json metadata, shows the bibtex entry, and
+;; the pdf link for it.
+(defun doi-utils-get-json (doi)
+  "Return json data as a string for DOI."
+  (let ((url-request-method "GET")
+        (url-mime-accept-string "application/citeproc+json")
+        (json-data))
+    (with-temp-buffer
+      (url-insert
+       (url-retrieve-synchronously
+       (concat doi-utils-dx-doi-org-url doi)))
+      (setq json-data (buffer-string))
+      (if (string-match "Resource not found" json-data)
+          (progn
+            (browse-url (concat doi-utils-dx-doi-org-url doi))
+            (error "Resource not found.  Opening website"))
+       json-data))))
+
+
+;;;###autoload
+(defun doi-utils-debug (doi)
+  "Generate an org-buffer showing data about DOI."
+  (interactive "sDOI: ")
+  (switch-to-buffer "*debug-doi*")
+  (erase-buffer)
+  (org-mode)
+  (insert (concat "doi:" doi) "\n\n")
+  (insert "* JSON
+"
+         (let ((url-request-method "GET")
+               (url-mime-accept-string "application/citeproc+json"))
+           (pp
+            (json-read-from-string (with-temp-buffer
+                                     (url-insert
+                                      (url-retrieve-synchronously
+                                       (concat doi-utils-dx-doi-org-url doi)))
+                                     (buffer-string)))))
+         "\n\n")
+  (goto-char (point-min)))
+
+;;* Adding a bibtex entry from a crossref query
+
+;; The idea here is to perform a query on Crossref, get a completion buffer of
+;; candidates, and select the entry(ies) you want to add to your bibtex file.
+;; You can select a region, e.g. a free form citation, or set of words, or you
+;; can type the query in by hand.
+
+;;;###autoload
+(defun doi-utils-add-entry-from-crossref-query (query bibtex-file)
+  "Search Crossref with QUERY and use completion to select an entry to add to BIBTEX-FILE."
+  (interactive (list
+                (read-string
+                 "Query: "
+                 ;; now set initial input
+                 (cond
+                  ;; If region is active assume we want it
+                  ((region-active-p)
+                   (replace-regexp-in-string
+                    "\n" " "
+                    (buffer-substring (region-beginning) (region-end))))
+                  ;; type or paste it in
+                  (t
+                   nil)))
+                (completing-read
+                 "Bibfile: "
+                 (append (org-ref--directory-files "." (lambda (f) (org-ref--file-ext-p f "bib")))
+                         bibtex-completion-bibliography))))
+  (let* ((json-data (with-temp-buffer
+                     (url-insert
+                      (url-retrieve-synchronously
+                       (concat
+                        "https://api.crossref.org/works?query="
+                        (url-hexify-string query))))
+                     
+                     (json-read-from-string (buffer-string))))
+        (name (format "Crossref hits for %s"
+                      ;; remove carriage returns. They can make completion confusing.
+                      (replace-regexp-in-string "\n" " " query)))
+        (candidates (let-alist json-data
+                      (cl-loop for item across .message.items
+                               collect (let-alist item
+                                         (cons (format "%s, %s, %s, %s."
+                                                       (string-join .title " ")
+                                                       (string-join
+                                                        (cl-loop for author across .author collect
+                                                                 (let-alist author
+                                                                   (format "%s %s"
+                                                                           .given .family)))
+                                                        ", ")
+                                                       .publisher
+                                                       .created.date-parts)                           
+                                               .DOI)))))
+        (doi (cdr (assoc (completing-read "Choice: " candidates) candidates))))
+
+    (with-current-buffer (find-file-noselect bibtex-file)
+      (doi-utils-add-bibtex-entry-from-doi
+       (replace-regexp-in-string
+       "^https?://\\(dx.\\)?doi.org/" "" doi)
+       bibtex-file)
+      (save-buffer))))
+
+
+(defalias 'crossref-add-bibtex-entry 'doi-utils-add-entry-from-crossref-query
+  "Alias function for convenience.")
+
+;; * Convenience
+
+(defun doi-utils-toggle-pdf-download ()
+  "Toggle the setting of `doi-utils-download-pdf'.
+I find this useful when downloading the pdfs slows down adding a
+lot of references; then you just toggle it off."
+  (interactive)
+  (message "Setting doi-utils-download-pdf to %s"
+          (setq doi-utils-download-pdf (not doi-utils-download-pdf))))
+
+;;* The end
+(provide 'doi-utils)
+;;; doi-utils.el ends here
diff --git a/elpa/org-ref-20251206.1422/nist-webbook.el b/elpa/org-ref-20251206.1422/nist-webbook.el
new file mode 100644 (file)
index 0000000..35b1608
--- /dev/null
@@ -0,0 +1,42 @@
+;;; nist-webbook.el --- Integration of Emacs with NIST Webbook -*- lexical-binding: t; -*-
+;; Integration of Emacs with NIST webbook
+
+;;; Commentary:
+;; nist-webbook-name :: search for a chemical name
+;; nist-webbook-formula :: search by chemical formula
+
+;;; Code:
+
+(require 'org)
+(require 'org-ref-utils)
+
+;;;###autoload
+(defun nist-webbook-formula (formula)
+  "Search NIST webbook for FORMULA."
+  (interactive "sFormula: ")
+  (browse-url
+   (concat
+    "http://webbook.nist.gov/cgi/cbook.cgi?Formula="
+    formula
+    "&NoIon=on&Units=SI")))
+
+;;;###autoload
+(defun nist-webbook-name (name)
+  "Search NIST webbook for NAME."
+  (interactive "sChemical Name: ")
+  (browse-url
+   (concat "http://webbook.nist.gov/cgi/cbook.cgi?Name="
+           (url-hexify-string name)
+           "&Units=SI")))
+
+(org-link-set-parameters "nist-wb-name"
+                        :follow (lambda (name)
+                                  (nist-webbook-name name)))
+
+(org-link-set-parameters "nist-wb-formula"
+                        :follow (lambda (formula)
+                                  (nist-webbook-formula formula)))
+
+(provide 'nist-webbook)
+
+;;; nist-webbook.el ends here
diff --git a/elpa/org-ref-20251206.1422/openalex.el b/elpa/org-ref-20251206.1422/openalex.el
new file mode 100644 (file)
index 0000000..7e7768f
--- /dev/null
@@ -0,0 +1,1176 @@
+;;; openalex.el --- Org-ref interface to OpenAlex  -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; This is an elisp interface to OpenAlex (https://docs.openalex.org/) for org-ref.
+;;
+;; This provides functionality for the OpenAlex APIs.
+;;
+;; `oa-query' provides a general interface to all the endpoints with a filter.
+;; It is not interactive though.
+;;
+;; `oa-author' provides an interactive way to search for an author and then see
+;; a Google Scholar like org buffer with information about the author.
+;;
+;; `oa-fulltext-search' provides an interactive full text search of Works in
+;; OpenAlex. You get an org-buffer of results, with links to subsequent pages of
+;; results.
+;;
+;; `oa-coa' is an interactive command to generate the NSF COA form data for
+;; coauthors.
+;;
+;; `oa-get-bibtex-entries' is an interactive command to download all bibtex
+;; entries from headings in the current buffer with a DOI property.
+;;
+;; if you have an OpenAlex API you can set `oa-api-key' to use it. The
+;; `user-mail-address' value will be added to the queries if it exists so you
+;; will get the polite pool.
+;;
+;; This library extends the `org-ref-citation-menu' and adds keys to get to
+;; cited by, references and related documents in OpenAlex.
+
+(require 'request)
+(require 'doi-utils)
+(require 'org-ref-citation-links)
+(require 'org-ref-utils)
+
+(declare-function org-ref-possible-bibfiles "org-ref-core")
+(declare-function org-ref-find-bibliography "org-ref-core")
+(declare-function org-ref-get-bibtex-key-and-file "org-ref-core")
+(declare-function bibtex-completion-show-entry "bibtex-completion")
+(declare-function bibtex-completion-apa-format-reference "bibtex-completion")
+(declare-function ivy-read "ivy")
+(declare-function ivy-more-chars "ivy")
+
+(defcustom oa-api-key
+  nil
+  "Your API key if you have one."
+  :group 'openalex
+  :type 'string)
+
+;;; Code:
+
+(defun oa--response-parser ()
+  "Parse the response from json to elisp."
+  (let ((json-array-type 'list)
+       (json-object-type 'plist)
+       (json-key-type 'keyword)
+       (json-false nil)
+       (json-encoding-pretty-print nil))
+    (json-read)))
+
+
+(defun oa--params (&rest params)
+  "Build API request parameters, excluding nil values.
+PARAMS should be an alist of (key . value) pairs.
+The mailto and api_key parameters are added automatically."
+  (let ((result (when user-mail-address
+                 `(("mailto" . ,user-mail-address)))))
+    ;; Only add api_key if it's set and non-empty
+    (when (and oa-api-key (not (string-empty-p oa-api-key)))
+      (push `("api_key" . ,oa-api-key) result))
+    ;; Add other params, filtering out nil values
+    (dolist (param params)
+      (when (cdr param)
+       (push param result)))
+    (nreverse result)))
+
+
+(defun oa-get (data query &optional iterable)
+  "Get fields from DATA with QUERY.
+QUERY is a dot notation string.
+key1.key2.key3 represents a nested item.
+key1.key2[].key3 represents key3 on all items in key1.key2.
+
+Tested with up to two [] in the query.
+
+Assumes data is in plist form."
+  (let* ((fields (and query (split-string query "\\.")))
+        (current-field (and fields (pop fields))))
+
+    (cond
+     ;; return condition
+     ((null query)
+      data)
+
+     ;; query[] means get query then turn iteration on
+     ((and (string-suffix-p "[]" current-field) (null iterable))
+      (setq current-field (substring current-field 0 -2))
+      (oa-get (plist-get data (intern-soft (concat ":" current-field)))
+             (when fields
+               (string-join fields "."))
+             t))
+
+     ;; this means another level of iteration. You already have a collection. we
+     ;; have to iterate over each one I think.
+     ((and (string-suffix-p "[]" current-field) iterable)
+      (setq current-field (substring current-field 0 -2))
+      (cl-loop for item in data collect
+              (oa-get (plist-get item (intern-soft (concat ":" current-field)))
+                      (when fields
+                        (string-join fields "."))
+                      t)))
+
+     ;; single keyword, iterate over collection
+     (iterable
+      (oa-get (cl-loop for item in data collect
+                      (plist-get item (intern-soft (concat ":" current-field))))
+             (when fields
+               (string-join fields "."))
+             t))
+
+     ;; single keyword
+     (t
+      (oa-get (plist-get data (intern-soft (concat ":" current-field)))
+             (when fields
+               (string-join fields ".")))))))
+
+
+;; * General query
+(defun oa--query-all-data (endpoint &rest filter)
+  (let* ((page 1)
+        (url (concat "https://api.openalex.org/" endpoint))
+        (filter-string (string-join
+                        (cl-loop for key in (plist-get-keys filter) collect
+                                 (concat (substring (symbol-name key) 1)
+                                         ":"
+                                         (url-hexify-string
+                                          (plist-get filter key))))
+                        ","))
+        (params (oa--params `("filter" . ,filter-string)
+                            `("page" . ,page)))
+
+        (req (request url :sync t :parser 'oa--response-parser :params params))
+        (data (request-response-data req))
+        (meta (plist-get data :meta))
+        (count (plist-get meta :count))
+        (per-page (plist-get meta :per_page))
+        (pages (ceiling (/ (float count) per-page)))
+        (results (plist-get data :results)))
+    (cl-loop for i from 2 to pages do
+            (setf (cdr (assoc "page" params)) i)
+            (setq req (request url :sync t :parser 'oa--response-parser :params params)
+                  data (request-response-data req)
+                  results (append results (plist-get data :results))))
+    results))
+
+
+(defun oa-query (endpoint &rest filter)
+  "Run a query at ENDPOINT with FILTER.
+ENDPOINT can be works, authors, sources, institutions, concepts,
+publishers, or funders.
+
+FILTER is a plist (:field value) where :field is a valid filter
+field (see
+https://docs.openalex.org/how-to-use-the-api/get-lists-of-entities/filter-entity-lists),
+and value is what you want to filter on. The following logic is supported:
+
+!value is negation
+<value is less than
+>value is greater than
+value1+value2 is and within a field
+value1|value2 is or within a field
+
+Your email address will be added if `user-mail-address' is
+non-nil, and `oa-api-key' if it is non-nil to the API url."
+  (let* ((page (if (plist-get filter :page)
+                  (prog1
+                      (string-to-number (plist-get filter :page))
+                    (setq filter (org-plist-delete filter :page)))
+                1))
+        (base-url "https://api.openalex.org")
+        (url (concat base-url "/" endpoint "?filter="))
+        (filter-string (string-join
+                        (cl-loop for key in (plist-get-keys filter) collect
+                                 (concat (substring (symbol-name key) 1)
+                                         ":"
+                                         (url-hexify-string
+                                          (plist-get filter key))))
+                        ","))
+
+        (req (request url :sync t :parser 'oa--response-parser
+               :params (oa--params `("filter" . ,filter-string)
+                                   `("page" . ,page))))
+        (data (request-response-data req))
+        (meta (plist-get data :meta))
+        (count (plist-get meta :count))
+        (per-page (plist-get meta :per_page))
+        (pages (ceiling (/ (float count) per-page)))
+        (results (plist-get data :results))
+        (next-page (format "[[elisp:(oa-query \"%s\" %s :page \"%s\")][Next page: %s]]"
+                           endpoint
+                           (string-join (cl-loop for x in filter
+                                                 collect
+                                                 (if (keywordp x)
+                                                     (format "%s" x)
+                                                   (format "%S" x)))
+                                        " ")
+                           (+ page 1)
+                           (+ page 1)))
+        (buf (generate-new-buffer "*OpenAlex - Query*")))
+
+    (with-current-buffer buf
+      (erase-buffer)
+      (org-mode)
+      (insert (concat
+              (format "#+title: %s
+** Results
+:PROPERTIES:
+:FILTER: %s
+:COUNT: %s
+:END:
+
+%s
+\n\n"
+                      filter-string
+                      filter-string
+                      count
+                      next-page)
+              (cond
+               ((string= endpoint "works")
+                (string-join
+                 (cl-loop for wrk in results collect
+                          (org-ref--format-template "*** ${title}
+:PROPERTIES:
+:HOST: ${primary_location.source.display_name}
+:YEAR: ${publication_year}
+:CITED_BY_COUNT: ${cited_by_count}
+:AUTHOR: ${authors}
+:DOI: ${doi}
+:OPENALEX: ${id}
+:CREATED_DATE: ${created_date}
+:END:
+
+
+${get-bibtex}
+
+- ${oa-refs}
+- ${oa-related}
+- ${oa-cited}
+
+${abstract}
+
+"
+                                    `(("title" . ,(oa--title wrk))
+                                      ("primary_location.source.display_name" . ,(oa-get wrk "primary_location.source.display_name"))
+                                      ("publication_year" . ,(oa-get wrk "publication_year"))
+                                      ("cited_by_count" . ,(oa-get wrk "cited_by_count"))
+                                      ("authors" . ,(oa--authors wrk))
+                                      ("doi" . ,(oa-get wrk "doi"))
+                                      ("id" . ,(oa-get wrk "id"))
+                                      ("created_date" . ,(oa-get wrk "created_date"))
+                                      ("get-bibtex" . ,(oa--elisp-get-bibtex wrk))
+                                      ("oa-refs" . ,(oa--elisp-get-oa-refs wrk))
+                                      ("oa-related" . ,(oa--elisp-get-oa-related wrk))
+                                      ("oa-cited" . ,(oa--elisp-get-oa-cited-by wrk))
+                                      ("abstract" . ,(oa--abstract wrk)))))
+                 "\n"))
+               (t
+                (format "%s" results)
+                )))))
+    (pop-to-buffer buf)
+    (goto-char (point-min))))
+
+
+;; * Work object
+
+(defun oa--work (entity-id &optional filter)
+  "Retrieve json data for a Work object for ENTITY-ID.
+ENTITY-ID is an OpenAlex ID, DOI, Pubmed id,etc.
+
+ENTITY-ID may also be a list of ids with a filter.
+
+If FILTER is non-nil it should be a string like \"filter=openalex:\"
+
+https://docs.openalex.org/api-entities/works"
+
+  (let* ((url (concat "https://api.openalex.org/works"
+                     ;; This is hackier than I prefer, but sometimes entity-id
+                     ;; is nil, or starts with ? for a filter, and I couldn't
+                     ;; see a cleaner way to solve this. this function is used
+                     ;; in a lot of places.
+                     (cond
+                      ((string-prefix-p "?" entity-id)
+                       entity-id)
+                      (t
+                       (format "/%s" entity-id)))))
+        (req (request url :sync t :parser 'oa--response-parser
+               :params (oa--params `("filter" . ,filter))))
+        (data (request-response-data req)))
+    ;; this is for convenience to inspect data in a browser, e.g. you can click
+    ;; on the url in Emacs and it opens in a browser.
+    (plist-put data :oa-url url)
+    data))
+
+
+;; * autocomplete works
+
+(defun oa--works-candidates (query)
+  "Retrieve autocomplete works from OpenAlex."
+  (or
+   (ivy-more-chars)
+   (let* ((url "https://api.openalex.org/autocomplete/works")
+         (req (request url :sync t :parser 'oa--response-parser
+                :params (let ((params `(("q" . ,query))))
+                          (when user-mail-address
+                            (push `("mailto" . ,user-mail-address) params))
+                          (nreverse params))))
+         (data (request-response-data req))
+         (results (plist-get data :results)))
+     (cl-loop for work in results collect
+             (propertize
+              (format "%s, %s"
+                      (plist-get work :display_name)
+                      (plist-get work :hint))
+              'oaid (plist-get work :id))))))
+
+
+(defun oa-works ()
+  "Autocomplete works.
+This doesn't seem as useful as it could be."
+  (interactive)
+
+  (ivy-read "Work: " #'oa--works-candidates
+           :dynamic-collection t
+           :action
+           '(1
+             ("o" (lambda (candidate)
+                    (browse-url (get-text-property 0 'oaid candidate)))
+              "Open in browser"))))
+
+;; * Viewing works
+
+
+;; ** help functions for complex data
+;;
+;; Some things like authors need to be constructed, and cannot just be looked
+;; up. In other cases, I want logic, e.g. if data is there provide something,
+;; and if not return an empty string. These functions do that work.
+(defun oa--authors (wrk)
+  "Return an author string for WRK.
+The string is a comma-separated list of links to author pages in OpenAlex."
+  (string-join (cl-loop for author in (plist-get wrk :authorships)
+                       collect
+                       (format "[[elisp:(oa--author-org \"%s\")][%s]]"
+                               (plist-get
+                                (plist-get author :author)
+                                :id)
+                               (plist-get
+                                (plist-get author :author)
+                                :display_name)))
+              ", "))
+
+
+(defun oa--title (wrk)
+  "Return a title from WRK with linebreaks removed."
+  (string-replace "\n" " " (plist-get wrk :title)))
+
+
+;; I want some links if they can be made so the buffer is interactive. It might
+;; be nice to integrate M-, navigation.
+(defun oa--elisp-get-bibtex (wrk)
+  "Return a elisp link to get a bibtex entry for WRK if there is a doi."
+  (if-let* ((doi (plist-get wrk :doi)))
+      (format "[[elisp:(doi-add-bibtex-entry \"%s\")][Get bibtex entry]]" doi)
+    ""))
+
+
+(defun oa--elisp-get-oa-related (wrk)
+  "Return a elisp link to get related works for WRK."
+  (format "[[elisp:(progn (xref--push-markers (current-buffer) (point)) (oa--related-works \"%s\"))][Get related work (%s)]]"
+         (plist-get wrk :id)
+         (length (plist-get wrk :related_works))))
+
+
+(defun oa--elisp-get-oa-refs (wrk)
+  "Return a elisp link to get references for WRK."
+  (format "[[elisp:(progn (xref--push-markers (current-buffer) (point)) (oa--referenced-works \"%s\"))][Get references (%s)]]"
+         (plist-get wrk :id)
+         (length  (plist-get wrk :referenced_works))))
+
+
+(defun oa--elisp-get-oa-cited-by (wrk)
+  "Return a elisp link to get works that cite WRK."
+  (format "[[elisp:(progn (xref--push-markers (current-buffer) (point)) (oa--cited-by-works \"%s\"))][Get cited by (%s)]]"
+         (plist-get wrk :id)
+         (plist-get wrk :cited_by_count)))
+
+
+(defun oa--works-entries (works)
+  "Return a list of org-formatted entries in WORKS.
+WORKS is a list of results from OpenAlex."
+  (cl-loop for wrk in (plist-get works :results)
+          collect
+          (org-ref--format-template "** ${title}
+:PROPERTIES:
+:HOST: ${primary_location.source.display_name}
+:YEAR: ${publication_year}
+:CITED_BY_COUNT: ${cited_by_count}
+:AUTHOR: ${authors}
+:DOI: ${doi}
+:OPENALEX: ${id}
+:END:
+
+
+${get-bibtex}
+
+- ${oa-refs}
+- ${oa-related}
+- ${oa-cited}
+
+"
+                    `(("title" . ,(oa-get wrk "title"))
+                      ("primary_location.source.display_name" . ,(oa-get wrk "primary_location.source.display_name"))
+                      ("publication_year" . ,(oa-get wrk "publication_year"))
+                      ("cited_by_count" . ,(oa-get wrk "cited_by_count"))
+                      ("authors" . ,(oa--authors wrk))
+                      ("doi" . ,(oa-get wrk "doi"))
+                      ("id" . ,(oa-get wrk "id"))
+                      ("get-bibtex" . ,(oa--elisp-get-bibtex wrk))
+                      ("oa-refs" . ,(oa--elisp-get-oa-refs wrk))
+                      ("oa-related" . ,(oa--elisp-get-oa-related wrk))
+                      ("oa-cited" . ,(oa--elisp-get-oa-cited-by wrk))))))
+
+
+(defun oa--works-buffer (bufname header entries)
+  "Create an org-buffer with BUFNAME representing the results in WORKS.
+HEADER is the first thing in the buffer
+WORKS is usually a list of results from OpenAlex.
+Argument ENTRIES A list of strings for each org entry."
+  (let ((buf (get-buffer-create bufname)))
+
+    (with-current-buffer buf
+      (erase-buffer)
+      (insert header)
+      (insert "#+COLUMNS: %25ITEM %YEAR %CITED_BY_COUNT
+elisp:org-columns    elisp:org-columns-quit
+
+
+#+caption: Sort
+| year     | [[elisp:(oa-buffer-sort-year t)][old first]] | [[elisp:(oa-buffer-sort-year)][new first]] |
+| cited by | [[elisp:(oa-buffer-sort-cited-by-count t)][low first]] | [[elisp:(oa-buffer-sort-cited-by-count)][high first]] |
+
+")
+      (insert (string-join entries "\n"))
+      (org-mode)
+      (goto-char (point-min))
+      (org-next-visible-heading 1))
+    ;; (display-buffer-in-side-window buf '((side . right)))
+    (pop-to-buffer buf)))
+
+
+(defun oa--related-works (entity-id)
+  "Show the Related works buffer for ENTITY-ID."
+  (let* ((wrk (oa--work entity-id))
+        (related-work (plist-get wrk :related_works))
+        split
+        entries)
+    (while related-work
+      (setq split (org-ref--split-at 25 related-work)
+           related-work (nth 1 split))
+
+      ;; split is what we process now
+      (setq entries (append entries
+                           (oa--works-entries
+                            (oa--work (format "?filter=openalex:%s" (string-join (nth 0 split) "|")))))))
+
+    (oa--works-buffer
+     "*OpenAlex - Related works*"
+     (format "* OpenAlex - Related works for %s ([[%s][json]])
+%s\n\n"
+            entity-id
+            (plist-get wrk :oa-url)
+            (org-ref--format-template ":PROPERTIES:
+:TITLE: ${title}
+:HOST: ${primary_location.source.display_name}
+:AUTHOR: ${authors}
+:DOI: ${doi}
+:YEAR: ${publication_year}
+:OPENALEX: ${id}
+:END:
+
+Found ${nentries} results.
+"
+                                      `(("title" . ,(oa-get wrk "title"))
+                                        ("primary_location.source.display_name" . ,(oa-get wrk "primary_location.source.display_name"))
+                                        ("authors" . ,(oa--authors wrk))
+                                        ("doi" . ,(oa-get wrk "doi"))
+                                        ("publication_year" . ,(oa-get wrk "publication_year"))
+                                        ("id" . ,(oa-get wrk "id"))
+                                        ("nentries" . ,(length entries)))))
+     entries)))
+
+
+(defun oa--referenced-works (entity-id)
+  "Show the Referenced work for ENTITY-ID."
+  (let* ((wrk (oa--work entity-id))
+        (referenced-work (plist-get wrk :referenced_works))
+        split
+        (entries '()))
+    (while referenced-work
+      (setq split (org-ref--split-at 25 referenced-work)
+           referenced-work (nth 1 split))
+      ;; split is what we process now
+      (setq entries (append entries
+                           (oa--works-entries
+                            (oa--work (format "?filter=openalex:%s"
+                                              (string-join (nth 0 split) "|")))))))
+    (oa--works-buffer
+     "*OpenAlex - References*"
+     (format "* OpenAlex - References from %s ([[%s][json]])
+%s\n\n"
+            entity-id
+            (plist-get wrk :oa-url)
+            (org-ref--format-template ":PROPERTIES:
+:TITLE: ${title}
+:HOST: ${primary_location.source.display_name}
+:AUTHOR: ${authors}
+:DOI: ${doi}
+:YEAR: ${publication_year}
+:OPENALEX: ${id}
+:END:
+
+Found ${nentries} results.
+"
+                                      `(("title" . ,(oa-get wrk "title"))
+                                        ("primary_location.source.display_name" . ,(oa-get wrk "primary_location.source.display_name"))
+                                        ("authors" . ,(oa--authors wrk))
+                                        ("doi" . ,(oa-get wrk "doi"))
+                                        ("publication_year" . ,(oa-get wrk "publication_year"))
+                                        ("id" . ,(oa-get wrk "id"))
+                                        ("nentries" . ,(length entries)))))
+     entries)))
+
+
+;; This function is different than the previous two. First we follow a URL
+;; provided by the data, and second, here we do follow pages.
+(defun oa--cited-by-works (entity-id)
+  "Show the Cited by buffer for ENTITY-ID."
+  (let* ((wrk (oa--work entity-id))
+        (url (plist-get wrk :cited_by_api_url))
+        (cited-by-works (request-response-data
+                         (request url
+                           :sync t
+                           :parser 'oa--response-parser
+                           :params (oa--params))))
+        (count (plist-get (plist-get cited-by-works :meta) :count))
+        (per-page (plist-get (plist-get cited-by-works :meta) :per_page))
+        (entries '())
+        (page 2))
+    ;; get first page
+    (setq entries (oa--works-entries cited-by-works))
+    (while (> count (* per-page (- page 1)))
+      (setq cited-by-works (request-response-data
+                           (request url
+                             :sync t
+                             :parser 'oa--response-parser
+                             :params (oa--params `("page" . ,page)))))
+      (setq entries (append entries (oa--works-entries cited-by-works)))
+      (cl-incf page))
+
+    (oa--works-buffer
+     "*OpenAlex - Cited by*"
+     (format "* OpenAlex - %s Cited by ([[%s][json]])
+%s"
+            entity-id
+            url
+            (org-ref--format-template ":PROPERTIES:
+:TITLE: ${title}
+:HOST: ${primary_location.source.display_name}
+:AUTHOR: ${authors}
+:DOI: ${doi}
+:YEAR: ${publication_year}
+:OPENALEX: ${id}
+:END:
+
+Found ${nentries} results.
+
+"
+                      `(("title" . ,(oa-get wrk "title"))
+                        ("primary_location.source.display_name" . ,(oa-get wrk "primary_location.source.display_name"))
+                        ("authors" . ,(oa--authors wrk))
+                        ("doi" . ,(oa-get wrk "doi"))
+                        ("publication_year" . ,(oa-get wrk "publication_year"))
+                        ("id" . ,(oa-get wrk "id"))
+                        ("nentries" . ,(length entries)))))
+     entries)))
+
+
+;; ** buffer utilities for sorting entries
+
+(defun oa-buffer-sort-year (&optional ascending)
+  "Sort org headings by year in descending order (new to old).
+With prefix arg ASCENDING, sort in ascending order (old to new)"
+  (interactive "P")
+  (if ascending
+      (org-sort-entries nil ?f
+                       (lambda () (string-to-number (or (org-entry-get (point) "YEAR") "0")))
+                       (lambda (y1 y2)
+                         (< y1 y2)))
+    (org-sort-entries nil ?f
+                     (lambda () (string-to-number (or (org-entry-get (point) "YEAR") "0")))
+                     (lambda (y1 y2)
+                       (> y1 y2))))
+  (org-fold-show-all))
+
+
+(defun oa-buffer-sort-cited-by-count (&optional ascending)
+  "Sort org headings by cited by count in descending order high to low.
+With prefix arg ASCENDING sort from low to high."
+  (interactive "P")
+  (if ascending
+      (org-sort-entries nil ?f
+                       (lambda ()
+                         (string-to-number
+                          (or (org-entry-get (point) "CITED_BY_COUNT")
+                              "0")))
+                       #'<)
+    (org-sort-entries nil ?f
+                     (lambda ()
+                       (string-to-number
+                        (or
+                         (org-entry-get (point) "CITED_BY_COUNT")
+                         "0")))
+                     #'>))
+  (org-fold-show-all))
+
+
+;; * Interactive versions for org-ref citations
+
+(defun oa-related-works ()
+  "Open the side window for Related works on cite at point."
+  (interactive)
+  (oa--related-works (concat "https://doi.org/" (org-ref-get-doi-at-point))))
+
+
+(defun oa-referenced-works ()
+  "Open the side window for References from the cite at point."
+  (interactive)
+  (oa--referenced-works (concat "doi:" (org-ref-get-doi-at-point))))
+
+
+(defun oa-cited-by-works ()
+  "Open the side window for Citing works for the cite at point."
+  (interactive)
+  (oa--cited-by-works (concat "doi:" (org-ref-get-doi-at-point))))
+
+
+(defun oa-open ()
+  "Open the cite at point in OpenAlex."
+  (interactive)
+  (let* ((url (concat
+              "https://api.openalex.org/works/https://doi.org/"
+              (org-ref-get-doi-at-point)))
+        (req (request url :sync t :parser 'oa--response-parser))
+        (data (request-response-data req)))
+    (browse-url (plist-get data :id))))
+
+
+(with-eval-after-load 'org-ref-citation-links
+  (transient-append-suffix 'org-ref-citation-menu "u"
+    '("xa" "Open in OpenAlex" oa-open))
+  (transient-append-suffix 'org-ref-citation-menu "xa"
+    '("xr" "Related documents" oa-related-works))
+  (transient-append-suffix 'org-ref-citation-menu "xr"
+    '("xc" "Cited by documents" oa-cited-by-works))
+  (transient-append-suffix 'org-ref-citation-menu "xc"
+    '("xf" "References from" oa-referenced-works)))
+
+
+;; * Author object
+
+(defun oa--author (entity-id &optional filter)
+  "Get an Author object for ENTITY-ID.
+FILTER is an optional string to add to the URL."
+  (let* ((url (concat  "https://api.openalex.org/authors"
+                      entity-id))
+        (req (request url :sync t :parser 'oa--response-parser
+               :params (oa--params `("filter" . ,filter))))
+        (data (request-response-data req)))
+    ;; this is for convenience to inspect data in a browser.
+    (plist-put data :oa-url url)
+    data))
+
+
+(defun oa--author-entries (works-data url)
+  "Get entries from WORKS-DATA."
+  (let* ((meta (plist-get works-data :meta))
+        (per-page (plist-get meta :per_page))
+        (count (plist-get meta :count))
+        (pages (/ count per-page))
+        (entries '()))
+    ;; if there is a remainder we need to get the rest
+    (when (> (mod count per-page) 0) (cl-incf pages))
+
+    ;; Now we have to loop through the pages
+    (cl-loop for i from 1 to pages
+            do
+            (setq works-data (request-response-data
+                              (request url
+                                :sync t
+                                :parser 'oa--response-parser
+                                :params (oa--params `("page" . ,i))))
+                  entries (append entries
+                                  (cl-loop for result in (plist-get works-data :results)
+                                           collect
+                                           (org-ref--format-template "*** ${title}
+:PROPERTIES:
+:ID: ${id}
+:DOI: ${ids.doi}
+:PDF: ${primary_location.pdf_url}
+:LANDING_PAGE: ${primary_location.landing_page_url}
+:YEAR: ${publication_year}
+:HOST_VENUE: ${primary_location.source.display_name}
+:AUTHORS: ${authors}
+:CITED_BY_COUNT: ${cited_by_count}
+:END:
+
+${get-bibtex}
+
+- ${oa-refs}
+- ${oa-related}
+- ${oa-cited}
+
+${abstract}
+
+    " `(("title" . ,(oa--title result))
+      ("id" . ,(oa-get result "id"))
+      ("ids.doi" . ,(oa-get result "ids.doi"))
+      ("publication_year" . ,(oa-get result "publication_year"))
+      ("primary_location.pdf_url" . ,(oa-get result "primary_location.pdf_url"))
+      ("primary_location.landing_page_url" . ,(oa-get result "primary_location.landing_page_url"))
+      ("primary_location.source.display_name" . ,(oa-get result "primary_location.source.display_name"))
+      ("authors" . ,(oa--authors result))
+      ("cited_by_count" . ,(oa-get result "cited_by_count"))
+      ("get-bibtex" . ,(oa--elisp-get-bibtex result))
+      ("oa-refs" . ,(oa--elisp-get-oa-refs result))
+      ("oa-related" . ,(oa--elisp-get-oa-related result))
+      ("oa-cited" . ,(oa--elisp-get-oa-cited-by result))
+      ("abstract" . ,(oa--abstract result))))))))
+    entries))
+
+
+(defun oa--abstract (wrk)
+  "Construct an abstract from a WRK."
+  (let* ((aii (plist-get wrk :abstract_inverted_index))
+        (word_index '())
+        sorted)
+
+    (cl-loop for (k v) on aii by 'cddr
+            do
+            (cl-loop for index in v
+                     do
+                     (push (list k index) word_index)))
+
+    (setq sorted (sort
+                 word_index
+                 (lambda (a b)
+                   (<
+                    (nth 1 a)
+                    (nth 1 b)))))
+
+    (string-join (mapcar
+                 (lambda (x)
+                   (substring
+                    (symbol-name (car x))
+                    1))
+                 sorted)
+                " ")))
+
+
+(defun oa--author-candidates (query)
+  "Retrieve autocomplete authors from OpenAlex."
+  (or
+   (ivy-more-chars)
+   (let* ((url "https://api.openalex.org/autocomplete/authors")
+         (req (request url :sync t :parser 'oa--response-parser
+                :params (let ((params `(("q" . ,query))))
+                          (when user-mail-address
+                            (push `("mailto" . ,user-mail-address) params))
+                          (nreverse params))))
+         (data (request-response-data req))
+         (results (plist-get data :results)))
+     (cl-loop for author in results collect
+             (propertize
+              (format "%s - %s"
+                      (plist-get author :display_name)
+                      (plist-get
+                       author :hint))
+              'oaid (plist-get author :id))))))
+
+
+(defun oa--format-institution (data)
+  "Format institution from DATA, handling nil values gracefully.
+Extracts the first institution from last_known_institutions array."
+  (let* ((institutions (plist-get data :last_known_institutions))
+        (first-inst (and institutions (listp institutions) (car institutions)))
+        (name (and first-inst (plist-get first-inst :display_name)))
+        (country (and first-inst (plist-get first-inst :country_code))))
+    (cond
+     ((and name country) (format "%s, %s" name country))
+     (name name)
+     (country country)
+     (t ""))))
+
+
+(defun oa--counts-by-year (data)
+  "Get citation counts by year and make a graph.
+DATA is an author from OpenAlex.
+Requires gnuplot. Generates a temporary file."
+  (if (executable-find "gnuplot")
+      (let* ((pngfile (make-temp-file "oa-" nil ".png"))
+            (counts (sort
+                     (cl-loop for i from 1 for item in (plist-get data :counts_by_year)
+                              collect
+                              (list
+                               (plist-get item :year)
+                               (plist-get item :cited_by_count)
+                               (plist-get item :works_count)))
+                     (lambda (a b)
+                       (< (nth 0 a)
+                          (nth 0 b)))))
+            (count-string (cl-loop for i from 1 for (year cites works) in counts
+                                   concat
+                                   (format "%s \"%s\" %s %s\n"
+                                           i year cites works)))
+            (gnuplot (format "set terminal \"png\" size 800,400
+set output \"%s\"
+$counts << EOD
+%s
+EOD
+set boxwidth 0.5
+set style fill solid noborder
+set style line 1 lc rgb \"grey\"
+set ylabel \"Citation count\"
+set y2label \"Document count\"
+set y2tics nomirror
+set key left top
+plot $counts using 1:3:xtic(2) with boxes lc rgb \"grey\" title \"Citations per year\", \"\" using 1:4 axes x1y2 with lines title \"Document count\"
+"
+                             pngfile
+                             count-string))
+            (cmdfile (make-temp-file "gnuplot-cmds-" nil ".gpl"))
+             (shellcmd (format "gnuplot --persist -c \"%s\"" cmdfile)))
+       (with-temp-file cmdfile
+         (insert gnuplot))
+       (shell-command shellcmd)
+       (delete-file cmdfile)
+       (format "[[%s]]" pngfile))
+    "Gnuplot required to see citation graph. Please install it."))
+
+
+(defun oa--author-org (entity-id)
+  "Generate an org-buffer for an author with ENTITY-ID."
+  (let* ((buf (get-buffer-create "*OpenAlex - Author*"))
+        (data (oa--author entity-id))
+        (citations-image (oa--counts-by-year data))
+        (works-count (plist-get data :works_count))
+        (works-url (plist-get data :works_api_url))
+        (works-data (request-response-data
+                     (request works-url
+                       :sync t
+                       :parser 'oa--response-parser
+                       :params (oa--params)))))
+    (with-current-buffer buf
+      (erase-buffer)
+      (insert (org-ref--format-template "* ${display_name} ([[${oa-url}][json]])
+:PROPERTIES:
+:OPENALEX: ${id}
+:ORCID: ${orcid}
+:SCOPUS: ${ids.scopus}
+:WORKS_COUNT: ${works_count}
+:CITED_BY_COUNT: ${cited_by_count}
+:INSTITUTION: ${institution}
+:END:
+
+#+COLUMNS: %25ITEM %YEAR %CITED_BY_COUNT
+elisp:org-columns    elisp:org-columns-quit
+
+${citations-image}
+
+** Articles
+
+#+caption: Sort
+| year     | [[elisp:(oa-buffer-sort-year t)][old first]] | [[elisp:(oa-buffer-sort-year)][new first]] |
+| cited by | [[elisp:(oa-buffer-sort-cited-by-count t)][low first]] | [[elisp:(oa-buffer-sort-cited-by-count)][high first]] |
+
+"
+                       `(("display_name" . ,(oa-get data "display_name"))
+                         ("oa-url" . ,(oa-get data "oa-url"))
+                         ("id" . ,(oa-get data "id"))
+                         ("orcid" . ,(oa-get data "orcid"))
+                         ("ids.scopus" . ,(oa-get data "ids.scopus"))
+                         ("works_count" . ,(oa-get data "works_count"))
+                         ("cited_by_count" . ,(oa-get data "cited_by_count"))
+                         ("institution" . ,(oa--format-institution data))
+                         ("citations-image" . ,citations-image))))
+      (insert (string-join (oa--author-entries works-data works-url) "\n"))
+
+      (org-mode)
+      (goto-char (point-min))
+      (org-next-visible-heading 1))
+    (pop-to-buffer buf)))
+
+
+(defun oa-author ()
+  "Get data and act on it for an author."
+  (interactive)
+
+  (ivy-read "Author: " #'oa--author-candidates
+           :dynamic-collection t
+           :action
+           '(1
+             ("o" (lambda (candidate)
+                    (oa--author-org (get-text-property 0 'oaid candidate)))
+              "Open org file")
+             ("l" (lambda (candidate)
+                    (insert (format "[[%s][%s]]"
+                                    (get-text-property 0 'oaid candidate)
+                                    candidate))))
+             ("u" (lambda (candidate)
+                    (browse-url (get-text-property 0 'oaid candidate)))
+              "Open in browser"))))
+
+
+;; * Full text search
+
+
+(defun oa-fulltext-search (query &optional page)
+  "Perform a fulltext search on QUERY.
+PAGE is optional, and loads that page of results. Defaults to 1."
+  (interactive (list (read-string "Query: ")
+                    nil))
+  (when (null page) (setq page 1))
+  (let* ((url "https://api.openalex.org/works")
+        (req (request url
+               :sync t
+               :parser #'oa--response-parser
+               :params (oa--params `("page" . ,page)
+                                   `("filter" . ,(format "fulltext.search:%s" query)))))
+        (data (request-response-data req))
+        (metadata (plist-get data :meta))
+        (count (plist-get metadata :count))
+        (per-page (plist-get metadata :per_page))
+        (npages (+ (/ count per-page) (if (= 0 (mod count per-page)) 0 1)))
+        (results (plist-get data :results))
+        (next-page (format "[[elisp:(oa-fulltext-search \"%s\" %s)][Next page: %s of %s]]"
+                           query
+                           (+ page 1)
+                           (+ page 1)
+                           npages))
+        (buf (get-buffer-create "*OpenAlex Full-text search*")))
+
+    (with-current-buffer buf
+      (erase-buffer)
+      (org-mode)
+      (insert (org-ref--format-template "#+title: Full-text search: ${query}
+
+[[elisp:(oa-fulltext-search \"${query}\" ${page})]]"
+                       `(("query" . ,query)
+                         ("page" . ,page))))
+      (insert (org-ref--format-template
+              "
+${meta.count} results: Page ${meta.page} of ${s1} ${s2}
+\n\n"
+              `(("meta.count" . ,count)
+                ("meta.page" . ,(oa-get data "meta.page"))
+                ("s1" . ,(format "%s" npages))
+                ("s2" . ,(format "%s" next-page)))))
+
+      (insert
+       (cl-loop for result in results concat
+               (org-ref--format-template "* ${title}
+:PROPERTIES:
+:JOURNAL: ${primary_location.source.display_name}
+:AUTHOR: ${authors}
+:YEAR: ${publication_year}
+:OPENALEX: ${id}
+:DOI: ${ids.doi}
+:END:
+
+${get-bibtex}
+
+- ${oa-refs}
+- ${oa-related}
+- ${oa-cited}
+
+" `(("title" . ,(oa--title result))
+  ("primary_location.source.display_name" . ,(oa-get result "primary_location.source.display_name"))
+  ("authors" . ,(oa--authors result))
+  ("publication_year" . ,(oa-get result "publication_year"))
+  ("id" . ,(oa-get result "id"))
+  ("ids.doi" . ,(oa-get result "ids.doi"))
+  ("get-bibtex" . ,(oa--elisp-get-bibtex result))
+  ("oa-refs" . ,(oa--elisp-get-oa-refs result))
+  ("oa-related" . ,(oa--elisp-get-oa-related result))
+  ("oa-cited" . ,(oa--elisp-get-oa-cited-by result))))))
+
+      (insert next-page)
+
+      (goto-char (point-min)))
+    (pop-to-buffer buf)))
+
+
+;; * NSF Collaborators and Other Affiliations
+(defun oa-coa (entity-id &optional COA-file)
+  "Get a list of collaborators for the past 5 years in tab-delimited form.
+This is for Table 4 in the COA_template at
+https://www.nsf.gov/bfa/dias/policy/coa/coa_template.xlsx.
+
+ENTITY-ID is an identifier that OpenAlex can use. Used
+interactively you can query and select an author.
+
+If COA-FILE is non-nil write results to that file, otherwise save
+to the clipboard. You should be able to paste the results
+directly into Excel.
+
+Results are sorted in alphaphabetical order by last name.
+
+Caveats: OpenAlex provides the name in Firstname Initial Lastname
+form. I assume this can be split on spaces, and the last word is
+the last name. That is not always correct, so some manual name
+fixing may be required.
+
+The Institutions are not always reliable. I use the most recent
+institution if an author is listed multiple times. Sometimes this
+is empty, and sometimes an author has multiple institutions
+listed.
+
+There may be duplicates for people who have different names in
+OpenAlex, e.g. missing initials, differences in spelling,
+abbreviations, including having a period or not.
+
+Your name will be included, you will need to delete this manually
+in the Excel sheet.
+
+This only gets the coauthors in publications known to OpenAlex.
+Recently published papers are probably missing.
+"
+  (interactive (list
+               (get-text-property 0 'oaid
+                                  (ivy-read "Author: " #'oa--author-candidates
+                                            :dynamic-collection t))
+               (when (y-or-n-p "Save to file?")
+                 (read-file-name "File: "))))
+
+  (let* ((data (oa--author entity-id))
+        (works-url (plist-get data :works_api_url))
+        (works-data (request-response-data
+                     (request works-url
+                       :sync t
+                       :parser 'oa--response-parser
+                       :params (oa--params))))
+        (meta (plist-get works-data :meta))
+        (count (plist-get meta :count))
+        (per-page (plist-get meta :per_page))
+        (pages (/ count per-page))
+        (results (plist-get works-data :results))
+        (current-year (string-to-number (format-time-string "%Y" (current-time))))
+        (current-authors '()))
+
+    ;; Now we need to accumulate the rest of the results from other pages
+    (when (> (mod count per-page) 0) (cl-incf pages))
+
+    (cl-loop for i from 2 to pages
+            do
+            (setq works-data (request-response-data
+                              (request works-url
+                                :sync t
+                                :parser 'oa--response-parser
+                                :params (oa--params `("page" . ,i))))
+                  results (append results (plist-get works-data :results))))
+
+    ;; Now results is a list of your publications. We need to iterate over each
+    ;; one, and accumulate author information
+    (cl-loop for result in results do
+            (let ((year (plist-get result :publication_year)))
+              (when (> year (- current-year 5))
+                (cl-loop for authorship in (plist-get result :authorships) do
+                         (let* ((author (plist-get authorship :author))
+                                (name (plist-get author :display_name))
+                                (name-parts (mapcar #'capitalize (split-string name)))
+                                (name-string (concat (car (last name-parts)) ", "
+                                                     (string-join (butlast name-parts) " ")))
+
+                                (institutions (plist-get authorship :institutions))
+                                (institution (plist-get (car institutions) :display_name)))
+                           ;; name, institution, contact info, last-active
+                           ;; we won't have contact info from openalex.
+                           (push (list name-string institution "" year
+                                       (plist-get result :publication_date))
+                                 current-authors))))))
+
+    (setq current-authors (sort current-authors
+                               (lambda (a b)
+                                 "Sort first on name, then on year in descending order"
+                                 (if (string= (nth 0 a) (nth 0 b))
+                                     (> (nth 3 a) (nth 3 b))
+                                   (string< (car a) (car b))))))
+
+    ;; now filter for unique authors
+    (setq current-authors (cl-loop for group in (seq-group-by (lambda (x)
+                                                               (car x))
+                                                             current-authors)
+                                  collect (cadr group)))
+
+    ;; Finally lets fix the year so Excel reads it correctly. I use the publication date
+    (setq current-authors (cl-loop for row in current-authors
+                                  collect
+                                  (list "A:"
+                                        (nth 0 row)
+                                        (nth 1 row)
+                                        (nth 2 row)
+                                        (nth 4 row))))
+
+    (if COA-file
+       (with-temp-file COA-file
+         (cl-loop for row in current-authors do
+                  (insert (string-join (mapcar (lambda (x)
+                                                 (format "%s" (or x "")))
+                                               row)
+                                       "\t")
+                          "\n")))
+
+
+      (kill-new (mapconcat (lambda (row)
+                            (concat (string-join (mapcar (lambda (x)
+                                                           (format "%s" (or x "")))
+                                                         row)
+                                                 "\t")
+                                    "\n"))
+                          current-authors))
+      (message "COA data on the clipboard."))))
+
+
+
+;; * utilities
+
+(defun oa-kill-buffers ()
+  "Kill OpenAlex buffers."
+  (interactive)
+  (cl-loop for buf in (buffer-list)
+          do
+          (when (string-prefix-p "*OpenAlex" (buffer-name buf))
+            (kill-buffer buf))))
+
+
+(defun oa-get-bibtex-entries ()
+  "Download all the bibtex entries in the buffer.
+Operates on headings with a DOI property."
+  (interactive)
+  (let ((bibfile (completing-read "Bibfile: " (org-ref-possible-bibfiles))))
+    (org-map-entries
+     (lambda ()
+       (kill-new (org-entry-get (point) "DOI"))
+       (doi-utils-add-bibtex-entry-from-doi
+       (doi-utils-maybe-doi-from-region-or-current-kill)
+       bibfile))
+     "DOI<>\"\"")))
+
+
+(provide 'openalex)
+
+;;; openalex.el ends here
+
+;; Local Variables:
+;; byte-compile-warnings: (not docstrings-wide)
+;; End:
diff --git a/elpa/org-ref-20251206.1422/org-ref-arxiv.el b/elpa/org-ref-20251206.1422/org-ref-arxiv.el
new file mode 100644 (file)
index 0000000..f2c26fe
--- /dev/null
@@ -0,0 +1,299 @@
+;;; org-ref-arxiv.el --- arxiv utilities for org-mode        -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2015-2024  John Kitchin
+
+;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
+;; Keywords:
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;; this library creates a new org-link for Arxiv (http://arxiv.org/) entries,
+;; and provides functions to retrieve bibtex entries from an Arxiv number.
+;;
+;; An Arxiv number might look like: cond-mat/0410285 or 1503.01742
+
+;;; Code:
+(require 'bibtex)
+(require 'org)
+(require 'org-ref-utils)
+(require 'parsebib)
+
+(require 'xml)
+
+;; This is a local variable defined in `url-http'.  We need it to avoid
+;; byte-compiler errors.
+(defvar url-http-end-of-headers)
+
+
+(declare-function parsebib-find-bibtex-dialect "parsebib")
+(declare-function org-ref-clean-bibtex-entry "org-ref-core")
+(declare-function org-ref-normalize-bibtex-completion-bibliography "org-ref-utils")
+;; this is a C function
+(declare-function libxml-parse-xml-region "xml")
+
+;;* The org-mode link
+;; this just makes a clickable link that opens the entry.
+;; example: arxiv:cond-mat/0410285
+(org-link-set-parameters "arxiv"
+                        :follow (lambda (link-string)
+                                  (browse-url (format "http://arxiv.org/abs/%s" link-string)))
+                        :export (lambda (keyword desc format)
+                                  (cond
+                                   ((eq format 'html)
+                                    (format  "<a href=\"http://arxiv.org/abs/%s\">arxiv:%s</a>"
+                                             keyword  (or desc keyword)))
+                                   ((eq format 'latex)
+                                    ;; write out the latex command
+                                    (format "\\url{http://arxiv.org/abs/%s}{%s}" keyword (or desc keyword))))))
+
+;;* Getting a bibtex entry for an arXiv article using remote service:
+;; For an arxiv article, there is a link to a NASA ADS page like this:
+;; http://adsabs.harvard.edu/cgi-bin/bib_query?arXiv:1503.01742
+;; On that page, there is a link to a bibtex entry:
+;; http://adsabs.harvard.edu/cgi-bin/nph-bib_query?bibcode=2015arXiv150301742H&data_type=BIBTEX&db_key=PRE&nocookieset=1
+;;
+;; It looks like you need to get a Bibliographic code from the arxiv number to
+;; then get the bibtex entry.
+
+(defun arxiv-get-bibliographic-code (arxiv-number)
+  "Get Bibliographic code for ARXIV-NUMBER."
+  (with-current-buffer
+      (url-retrieve-synchronously
+       (concat
+        "http://adsabs.harvard.edu/cgi-bin/bib_query?arXiv:"
+        arxiv-number))
+    (search-forward-regexp "<link rel=\"canonical\" href=\"http://ui.adsabs.harvard.edu/abs/\\(.*\\)/abstract\"/>")
+    (match-string 1)))
+
+
+(defun arxiv-get-bibtex-entry (arxiv-bibliographic-code)
+  "Get bibtex entry for ARXIV-BIBLIOGRAPHIC-CODE."
+  (with-current-buffer
+      (url-retrieve-synchronously (format "https://ui.adsabs.harvard.edu/abs/%s/exportcitation" arxiv-bibliographic-code))
+    (when (re-search-forward
+          "<textarea.*>\\(.*\\(?:\n.*\\)*?\\)\\(?:\n\\s-*\n\\)</textarea>"
+          nil t)
+      (xml-substitute-special (match-string 1)))))
+
+;;* Getting a bibtex entry for an arXiv article using arXiv API:
+;; Retrieves the meta data of an article view arXiv's http API,
+;; extracts the necessary information, and formats a new BibTeX entry.
+
+(defvar arxiv-entry-format-string "@article{%s,
+  journal = {CoRR},
+  title = {%s},
+  author = {%s},
+  archivePrefix = {arXiv},
+  year = {%s},
+  eprint = {%s},
+  primaryClass = {%s},
+  abstract = {%s},
+  url = {%s},
+}"
+  "Template for BibTeX entries of arXiv articles.")
+
+
+(declare-function doi-utils-doi-to-bibtex-string "doi-utils")
+(declare-function org-ref-replace-nonascii "org-ref-bibtex")
+
+(defun arxiv-get-bibtex-entry-via-arxiv-api (arxiv-number)
+  "Retrieve meta data for ARXIV-NUMBER.
+Returns a formatted BibTeX entry."
+  (with-current-buffer
+      (url-retrieve-synchronously (format "http://export.arxiv.org/api/query?id_list=%s" arxiv-number) t)
+    (let* ((parse-tree (libxml-parse-xml-region
+                        (progn (goto-char 0)
+                               (search-forward "<?xml ")
+                               (match-beginning 0))
+                        (point-max)))
+           (entry (assq 'entry parse-tree))
+           (authors (mapcar (lambda (it) (nth 2 (nth 2 it)))
+                           (seq-filter (lambda (it) (and (listp it) (eq (car it) 'author))) entry)))
+           (year (format-time-string "%Y" (date-to-time (nth 2 (assq 'published entry)))))
+           (title (nth 2 (assq 'title entry)))
+           (names (arxiv-bibtexify-authors authors))
+           (category (cdar (nth 1 (assq 'primary_category entry))))
+           (abstract (string-trim (nth 2 (assq 'summary entry))))
+           (url (nth 2 (assq 'id entry)))
+           (temp-bibtex (format arxiv-entry-format-string "" title names year arxiv-number category abstract url))
+           (key (with-temp-buffer
+                  (insert temp-bibtex)
+                 (bibtex-mode)
+                 (bibtex-set-dialect (parsebib-find-bibtex-dialect) t)
+                 (org-ref-replace-nonascii)
+                  (bibtex-generate-autokey)))
+          (doi (assq 'doi entry)))
+      (unless (and doi
+                  (ignore-errors (doi-utils-doi-to-bibtex-string (nth 2 doi))))
+       ;; no doi or inactive doi, so we fall back to the simple template
+       (format arxiv-entry-format-string key title names year arxiv-number category abstract url)))))
+
+
+(defun arxiv-bibtexify-authors (authors)
+  "Return names in 'SURNAME, FIRST NAME' format from AUTHORS list."
+  (string-join
+          (mapcar (lambda (it)
+                    (concat (car (last it)) ", "
+                            (string-join (butlast it) " ")))
+                  (mapcar (lambda (it) (split-string it " +")) authors))
+          " and "))
+
+
+(defun arxiv-maybe-arxiv-id-from-current-kill ()
+  "Try to get an arxiv ID from the current kill."
+  (let* ((the-current-kill (ignore-errors (current-kill 0 t)))  ;; nil if empty kill ring
+         (arxiv-url-prefix-regexp "^https?://arxiv\\.org/\\(pdf\\|abs\\|format\\)/")
+         (arxiv-cite-prefix-regexp "^\\(arXiv\\|arxiv\\):")
+         (arxiv-id-old-regexp "[a-z-]+\\(\\.[A-Z]\\{2\\}\\)?/[0-9]\\{5,7\\}") ; Ex: math.GT/0309136
+         (arxiv-id-new-regexp "[0-9]\\{4\\}[.][0-9]\\{4,5\\}\\(v[0-9]+\\)?") ; Ex: 1304.4404v2
+         (arxiv-id-regexp (concat "\\(" arxiv-id-old-regexp "\\|" arxiv-id-new-regexp "\\)")))
+    (cond
+     (;; make sure current-kill has something in it
+      ;; if current-kill is not a string, return nil
+      (not (stringp the-current-kill))
+      nil)
+     (;; check if current-kill looks like an arxiv ID
+      ;; if so, return it
+      ;; Ex: 1304.4404v2
+      (org-ref--string-match (concat "^" arxiv-id-regexp) the-current-kill)
+      the-current-kill)
+     (;; check if current-kill looks like an arxiv cite
+      ;; if so, remove the prefix and return
+      ;; Ex: arXiv:1304.4404v2 --> 1304.4404v2
+      (org-ref--string-match (concat arxiv-cite-prefix-regexp arxiv-id-regexp "$") the-current-kill)
+      (replace-regexp-in-string arxiv-cite-prefix-regexp "" the-current-kill))
+     (;; check if current-kill looks like an arxiv url
+      ;; if so, remove the url prefix and return
+      ;; Ex: https://arxiv.org/abs/1304.4404 --> 1304.4404
+      (org-ref--string-match (concat arxiv-url-prefix-regexp arxiv-id-regexp "$") the-current-kill)
+      (replace-regexp-in-string arxiv-url-prefix-regexp "" the-current-kill))
+     (;; check if current-kill looks like an arxiv PDF url
+      ;; if so, remove the url prefix, the .pdf suffix, and return
+      ;; Ex: https://arxiv.org/pdf/1304.4404.pdf --> 1304.4404
+      (org-ref--string-match (concat arxiv-url-prefix-regexp arxiv-id-regexp "\\.pdf$") the-current-kill)
+      (replace-regexp-in-string arxiv-url-prefix-regexp "" (substring the-current-kill 0 (- (length the-current-kill) 4))))
+     ;; otherwise, return nil
+     (t
+      nil))))
+
+(defvar bibtex-completion-bibliography)
+
+;;;###autoload
+(defun arxiv-add-bibtex-entry (arxiv-number bibfile)
+  "Add bibtex entry for ARXIV-NUMBER to BIBFILE."
+  (interactive
+   (list (read-string
+          "arxiv: "
+          (arxiv-maybe-arxiv-id-from-current-kill))
+         ;;  now get the bibfile to add it to
+         (completing-read
+          "Bibfile: "
+          (append (org-ref--directory-files "." (lambda (f) (org-ref--file-ext-p f "bib")))
+                 (org-ref-normalize-bibtex-completion-bibliography)))))
+  (save-window-excursion
+    (find-file bibfile)
+    (goto-char (point-max))
+    (when (not (looking-at "^")) (insert "\n"))
+    (insert (arxiv-get-bibtex-entry-via-arxiv-api arxiv-number))
+    (org-ref-clean-bibtex-entry)
+    (goto-char (point-max))
+    (when (not (looking-at "^")) (insert "\n"))
+    (save-buffer)))
+
+
+;;;###autoload
+(defun arxiv-get-pdf (arxiv-number pdf)
+  "Retrieve a pdf for ARXIV-NUMBER and save it to PDF."
+  (interactive
+   (list (read-string
+          "arxiv: "
+          (arxiv-maybe-arxiv-id-from-current-kill))
+         (read-string
+          "PDF: ")))
+  (let ((pdf-url (format "https://arxiv.org/pdf/%s" arxiv-number)))
+    (url-copy-file pdf-url pdf)
+    ;; now check if we got a pdf
+    (unless (org-ref-pdf-p pdf)
+      (delete-file pdf)
+      (message "Error downloading arxiv pdf %s" pdf-url))))
+
+(defvar bibtex-completion-library-path)
+
+;;;###autoload
+(defun arxiv-get-pdf-add-bibtex-entry (arxiv-number bibfile pdfdir)
+  "Add bibtex entry for ARXIV-NUMBER to BIBFILE.
+Remove troublesome chars from the bibtex key, retrieve a pdf
+for ARXIV-NUMBER and save it to PDFDIR with the same name of the
+key."
+  (interactive
+   (list (read-string
+          "arxiv: "
+          (arxiv-maybe-arxiv-id-from-current-kill))
+         ;;  now get the bibfile to add it to
+         (completing-read
+          "Bibfile: "
+          (append (org-ref--directory-files "." (lambda (f) (org-ref--file-ext-p f "bib")))
+                  (org-ref-normalize-bibtex-completion-bibliography)))
+        (cond
+         ((stringp bibtex-completion-library-path)
+          bibtex-completion-library-path)
+         ((= 1 (length bibtex-completion-library-path))
+          (car bibtex-completion-library-path))
+         (t
+          (completing-read "PDF dir: " bibtex-completion-library-path)))))
+
+  (arxiv-add-bibtex-entry arxiv-number bibfile)
+
+  (save-window-excursion
+    (let ((key ""))
+      (find-file bibfile)
+      (goto-char (point-max))
+      (bibtex-beginning-of-entry)
+      (re-search-forward bibtex-entry-maybe-empty-head)
+      (if (match-beginning bibtex-key-in-head)
+          (progn
+            (setq key (delete-and-extract-region
+                       (match-beginning bibtex-key-in-head)
+                       (match-end bibtex-key-in-head)))
+            ;; remove potentially troublesome characters from key
+            ;; as it will be used as  a filename
+            (setq key (replace-regexp-in-string   "\"\\|\\*\\|/\\|:\\|<\\|>\\|\\?\\|\\\\\\||\\|\\+\\|,\\|\\.\\|;\\|=\\|\\[\\|]\\|!\\|@"
+                                                  "" key))
+            ;; check if the key is in the buffer
+            (when (save-excursion
+                    (bibtex-search-entry key))
+              (save-excursion
+                (bibtex-search-entry key)
+                (bibtex-copy-entry-as-kill)
+                (switch-to-buffer-other-window "*duplicate entry*")
+                (bibtex-yank))
+              (setq key (bibtex-read-key "Duplicate Key found, edit: " key))))
+        (setq key (bibtex-read-key "Key not found, insert: ")))
+      (insert key)
+      (arxiv-get-pdf arxiv-number (concat pdfdir key ".pdf"))
+      ;; Check that it worked, and insert a field for it.
+      (when (file-exists-p (concat pdfdir key ".pdf"))
+       (bibtex-end-of-entry)
+       (backward-char)
+       (insert (format "  file = {%s}\n  " (concat pdfdir key ".pdf")))))
+    (save-buffer)))
+
+
+(provide 'org-ref-arxiv)
+;;; org-ref-arxiv.el ends here
+
+;; Local Variables:
+;; byte-compile-warnings: (not docstrings)
+;; End:
diff --git a/elpa/org-ref-20251206.1422/org-ref-autoloads.el b/elpa/org-ref-20251206.1422/org-ref-autoloads.el
new file mode 100644 (file)
index 0000000..d6f72b4
--- /dev/null
@@ -0,0 +1,661 @@
+;;; org-ref-autoloads.el --- automatically extracted autoloads (do not edit)   -*- lexical-binding: t -*-
+;; Generated by the `loaddefs-generate' function.
+
+;; This file is part of GNU Emacs.
+
+;;; Code:
+
+(add-to-list 'load-path (or (and load-file-name (directory-file-name (file-name-directory load-file-name))) (car load-path)))
+
+
+\f
+;;; Generated autoloads from contrib.el
+
+(register-definition-prefixes "contrib" '("org-ref-"))
+
+\f
+;;; Generated autoloads from doi-utils.el
+
+(autoload 'doi-utils-async-download-pdf "doi-utils" "\
+Download the PDF for bibtex entry at point asynchronously.
+It is not fully async, only the download is. Fully async is
+harder because you need to run `doi-utils-get-pdf-url' async
+too. " t)
+(autoload 'doi-utils-get-bibtex-entry-pdf "doi-utils" "\
+Download pdf for entry at point if the pdf does not already exist locally.
+The entry must have a doi. The pdf will be saved, by the name
+%s.pdf where %s is the bibtex label. Files will not be
+overwritten. The pdf will be checked to make sure it is a pdf,
+and not some html failure page. You must have permission to
+access the pdf. We open the pdf at the end if
+`doi-utils-open-pdf-after-download' is non-nil.
+
+With one prefix ARG, directly get the pdf from a file (through
+`read-file-name') instead of looking up a DOI. With a double
+prefix ARG, directly get the pdf from an open buffer (through
+`read-buffer-to-switch') instead. These two alternative methods
+work even if the entry has no DOI, and the pdf file is not
+checked.
+
+(fn &optional ARG)" t)
+(autoload 'doi-utils-add-bibtex-entry-from-doi "doi-utils" "\
+Add DOI entry to end of a file in the current directory.
+Pick the file ending with .bib or in .  If you have an active region that
+starts like a DOI, that will be the initial prompt.  If no region
+is selected and the first entry of the ‘kill-ring’ starts like a
+DOI, then that is the initial prompt.  Otherwise, you have to type
+or paste in a DOI.
+Argument BIBFILE the bibliography to use.
+
+(fn DOI &optional BIBFILE)" t)
+(autoload 'doi-utils-doi-to-org-bibtex "doi-utils" "\
+Convert a DOI to an ‘org-bibtex’ form and insert it at point.
+
+(fn DOI)" t)
+(autoload 'bibtex-set-field "doi-utils" "\
+Set FIELD to VALUE in bibtex file.  create field if it does not exist.
+Optional argument NODELIM see `bibtex-make-field'.
+
+(fn FIELD VALUE &optional NODELIM)" t)
+(autoload 'doi-utils-update-bibtex-entry-from-doi "doi-utils" "\
+Update fields in a bibtex entry from the DOI.
+Every field will be updated, so previous change will be lost.
+
+(fn DOI)" t)
+(autoload 'doi-utils-update-field "doi-utils" "\
+Update the field at point in the bibtex entry.
+Data is retrieved from the doi in the entry." t)
+(autoload 'doi-utils-wos "doi-utils" "\
+Open Web of Science entry for DOI.
+
+(fn DOI)" t)
+(autoload 'doi-utils-wos-citing "doi-utils" "\
+Open Web of Science citing articles entry for DOI.
+May be empty if none are found.
+
+(fn DOI)" t)
+(autoload 'doi-utils-wos-related "doi-utils" "\
+Open Web of Science related articles page for DOI.
+
+(fn DOI)" t)
+(autoload 'doi-utils-ads "doi-utils" "\
+Open ADS entry for DOI
+
+(fn DOI)" t)
+(autoload 'doi-utils-open "doi-utils" "\
+Open DOI in browser.
+
+(fn DOI)" t)
+(autoload 'doi-utils-open-bibtex "doi-utils" "\
+Search through variable `bibtex-completion-bibliography' for DOI.
+
+(fn DOI)" t)
+(autoload 'doi-utils-crossref "doi-utils" "\
+Search DOI in CrossRef.
+
+(fn DOI)" t)
+(autoload 'doi-utils-google-scholar "doi-utils" "\
+Google scholar the DOI.
+
+(fn DOI)" t)
+(autoload 'doi-utils-pubmed "doi-utils" "\
+Search Pubmed for the DOI.
+
+(fn DOI)" t)
+(autoload 'doi-utils-crossref-citation-query "doi-utils" "\
+Query Crossref with the title of the bibtex entry at point.
+Get a list of possible matches. Choose one with completion." t)
+(autoload 'doi-utils-debug "doi-utils" "\
+Generate an org-buffer showing data about DOI.
+
+(fn DOI)" t)
+(autoload 'doi-utils-add-entry-from-crossref-query "doi-utils" "\
+Search Crossref with QUERY and use completion to select an entry to add to BIBTEX-FILE.
+
+(fn QUERY BIBTEX-FILE)" t)
+(register-definition-prefixes "doi-utils" '("*doi-utils-" "agu-pdf-url" "aip-pdf-url" "aps-pdf-url" "arxiv-pdf-url" "chemistry-europe-pdf-url" "copernicus-" "crossref-add-bibtex-entry" "doi-" "ecs" "frontiers-pdf-url" "generic-full-pdf-url" "highwire-pdf-url" "ieee" "iop-pdf-url" "jneurosci-pdf-url" "jstor-pdf-url" "linkinghub-elsevier-pdf-url" "nature-pdf-url" "osa-pdf-url" "pnas-pdf-url" "rsc-pdf-url" "rss-pdf-url" "sage-pdf-url" "science-" "siam-pdf-url" "springer-" "tandfonline-pdf-url" "wiley-pdf-url-2"))
+
+\f
+;;; Generated autoloads from nist-webbook.el
+
+(autoload 'nist-webbook-formula "nist-webbook" "\
+Search NIST webbook for FORMULA.
+
+(fn FORMULA)" t)
+(autoload 'nist-webbook-name "nist-webbook" "\
+Search NIST webbook for NAME.
+
+(fn NAME)" t)
+
+\f
+;;; Generated autoloads from openalex.el
+
+(register-definition-prefixes "openalex" '("oa-"))
+
+\f
+;;; Generated autoloads from org-ref-arxiv.el
+
+(autoload 'arxiv-add-bibtex-entry "org-ref-arxiv" "\
+Add bibtex entry for ARXIV-NUMBER to BIBFILE.
+
+(fn ARXIV-NUMBER BIBFILE)" t)
+(autoload 'arxiv-get-pdf "org-ref-arxiv" "\
+Retrieve a pdf for ARXIV-NUMBER and save it to PDF.
+
+(fn ARXIV-NUMBER PDF)" t)
+(autoload 'arxiv-get-pdf-add-bibtex-entry "org-ref-arxiv" "\
+Add bibtex entry for ARXIV-NUMBER to BIBFILE.
+Remove troublesome chars from the bibtex key, retrieve a pdf
+for ARXIV-NUMBER and save it to PDFDIR with the same name of the
+key.
+
+(fn ARXIV-NUMBER BIBFILE PDFDIR)" t)
+(register-definition-prefixes "org-ref-arxiv" '("arxiv-"))
+
+\f
+;;; Generated autoloads from org-ref-bibliography-links.el
+
+(register-definition-prefixes "org-ref-bibliography-links" '("org-ref-"))
+
+\f
+;;; Generated autoloads from org-ref-bibtex.el
+
+(autoload 'org-ref-bibtex-generate-longtitles "org-ref-bibtex" "\
+Generate longtitles.bib which are @string definitions.
+The full journal names are in `org-ref-bibtex-journal-abbreviations'." t)
+(autoload 'org-ref-bibtex-generate-shorttitles "org-ref-bibtex" "\
+Generate shorttitles.bib which are @string definitions.
+The abbreviated journal names in `org-ref-bibtex-journal-abbreviations'." t)
+(autoload 'org-ref-stringify-journal-name "org-ref-bibtex" "\
+Replace journal name in a bibtex entry with a string.
+The strings are defined in
+`org-ref-bibtex-journal-abbreviations'.  The optional arguments KEY,
+START and END allow you to use this with `bibtex-map-entries'
+
+(fn &optional KEY START END)" t)
+(autoload 'org-ref-set-journal-string "org-ref-bibtex" "\
+Set a bibtex journal name to the string that represents FULL-JOURNAL-NAME.
+This is defined in `org-ref-bibtex-journal-abbreviations'.
+
+(fn FULL-JOURNAL-NAME)" t)
+(autoload 'org-ref-replace-nonascii "org-ref-bibtex" "\
+Replace non-ascii characters with LaTeX representations in a
+bibtex entry." t)
+(autoload 'org-ref-title-case "org-ref-bibtex" "\
+Convert a bibtex entry title and booktitle to title-case.
+Convert only if the entry type is a member of the list
+`org-ref-title-case-types'. The arguments KEY, START and END are
+optional, and are only there so you can use this function with
+`bibtex-map-entries' to change all the title entries in articles and
+books.
+
+(fn &optional KEY START END)" t)
+(autoload 'org-ref-title-case-article "org-ref-bibtex" "\
+Convert a bibtex entry article or book title to title-case.
+The arguments KEY, START and END are optional, and are only there
+so you can use this function with `bibtex-map-entries' to change
+all the title entries in articles and books.
+
+(fn &optional KEY START END)" t)
+(autoload 'org-ref-sentence-case-article "org-ref-bibtex" "\
+Convert a bibtex entry article title to sentence-case.
+The arguments KEY, START and END are optional, and are only there
+so you can use this function with `bibtex-map-entries' to change
+all the title entries in articles.
+
+(fn &optional KEY START END)" t)
+(autoload 'org-ref-bibtex-next-entry "org-ref-bibtex" "\
+Jump to the beginning of the next bibtex entry.
+N is a prefix argument.  If it is numeric, jump that many entries
+forward.  Negative numbers do nothing.
+
+(fn &optional N)" t)
+(autoload 'org-ref-bibtex-previous-entry "org-ref-bibtex" "\
+Jump to beginning of the previous bibtex entry.
+N is a prefix argument.  If it is numeric, jump that many entries back.
+
+(fn &optional N)" t)
+(autoload 'org-ref-bibtex-visible-entry "org-ref-bibtex" "\
+Jump to visible entry." t)
+(autoload 'org-ref-bibtex-visible-field "org-ref-bibtex" "\
+Jump to visible field." t)
+(autoload 'org-ref-bibtex-format-url-if-doi "org-ref-bibtex" "\
+Hook function to format url to follow the current DOI conventions." t)
+(autoload 'org-ref-bibtex-wos "org-ref-bibtex" "\
+Open bibtex entry in Web Of Science if there is a DOI." t)
+(autoload 'org-ref-bibtex-wos-citing "org-ref-bibtex" "\
+Open citing articles for bibtex entry in Web Of Science if
+there is a DOI." t)
+(autoload 'org-ref-bibtex-wos-related "org-ref-bibtex" "\
+Open related articles for bibtex entry in Web Of Science if
+there is a DOI." t)
+(autoload 'org-ref-bibtex-crossref "org-ref-bibtex" "\
+Open the bibtex entry in Crossref by its doi." t)
+(autoload 'org-ref-bibtex-google-scholar "org-ref-bibtex" "\
+Open the bibtex entry at point in google-scholar by its doi." t)
+(autoload 'org-ref-bibtex-pubmed "org-ref-bibtex" "\
+Open the bibtex entry at point in Pubmed by its doi." t)
+(autoload 'org-ref-bibtex-pdf "org-ref-bibtex" "\
+Open the pdf for the bibtex entry at point.
+Thin wrapper to get `org-ref-bibtex' to open pdf, because it
+calls functions with a DOI argument.
+
+(fn &optional _)" t)
+(autoload 'org-ref-bibtex-assoc-pdf-with-entry "org-ref-bibtex" "\
+Prompt for pdf associated with entry at point and rename it.
+Check whether a pdf already exists in `bibtex-completion-library' with the
+name '[bibtexkey].pdf'. If the file does not exist, rename it to
+'[bibtexkey].pdf' using
+`org-ref-bibtex-assoc-pdf-with-entry-move-function' and place it in
+a directory. Optional PREFIX argument toggles between
+`rename-file' and `copy-file'.
+
+(fn &optional PREFIX)" t)
+(autoload 'org-ref-email-bibtex-entry "org-ref-bibtex" "\
+Email current bibtex entry at point and pdf if it exists." t)
+(autoload 'org-ref-set-bibtex-keywords "org-ref-bibtex" "\
+Add KEYWORDS to a bibtex entry.
+If KEYWORDS is a list, it is converted to a comma-separated
+string.  The KEYWORDS are added to the beginning of the
+field.  Otherwise KEYWORDS should be a string of comma-separate
+keywords.  Optional argument ARG prefix arg to replace keywords.
+
+(fn KEYWORDS &optional ARG)" t)
+(autoload 'org-ref-extract-bibtex-blocks "org-ref-bibtex" "\
+Extract all bibtex blocks in buffer to BIBFILE.
+If BIBFILE exists, append, unless you use a prefix arg (C-u), which
+will clobber the file.
+
+(fn BIBFILE)" t)
+(autoload 'org-ref-open-bibtex-pdf "org-ref-bibtex" "\
+Open pdf for a bibtex entry, if it exists." t)
+(autoload 'org-ref-open-bibtex-notes "org-ref-bibtex" "\
+From a bibtex entry, open the notes if they exist." t)
+(autoload 'org-ref-open-in-browser "org-ref-bibtex" "\
+Open the bibtex entry at point in a browser using the url field or doi field." t)
+(autoload 'org-ref-build-full-bibliography "org-ref-bibtex" "\
+Build pdf of all bibtex entries, and open it." t)
+(autoload 'org-ref-sort-bibtex-entry "org-ref-bibtex" "\
+Sort fields of entry in standard order." t)
+(autoload 'org-ref-downcase-bibtex-entry "org-ref-bibtex" "\
+Downcase the entry type and fields." t)
+(autoload 'org-ref-clean-bibtex-entry "org-ref-bibtex" "\
+Clean and replace the key in a bibtex entry.
+See functions in `org-ref-clean-bibtex-entry-hook'." t)
+(register-definition-prefixes "org-ref-bibtex" '("orcb-" "org-ref-"))
+
+\f
+;;; Generated autoloads from org-ref-citation-links.el
+
+(autoload 'org-ref-delete-citation-at-point "org-ref-citation-links" "\
+Delete the citation or reference at point." t)
+(autoload 'org-ref-replace-citation-at-point "org-ref-citation-links" "\
+Replace the citation at point." t)
+(autoload 'org-ref-edit-pre-post-notes "org-ref-citation-links" "\
+Edit the pre/post notes at point.
+
+if you are not on a key, or with optional prefix
+arg COMMON, edit the common prefixes instead.
+
+(fn &optional COMMON)" t)
+(autoload 'org-ref-change-cite-type "org-ref-citation-links" "\
+Change the cite type of citation link at point." t)
+(autoload 'org-ref-sort-citation-link "org-ref-citation-links" "\
+Replace link at point with sorted link by year." t)
+(autoload 'org-ref-next-key "org-ref-citation-links" "\
+Move cursor to the next cite key when on a cite link.
+Otherwise run `right-word'. If the cursor moves off the link,
+move to the beginning of the next cite link after this one." t)
+(autoload 'org-ref-previous-key "org-ref-citation-links" "\
+Move cursor to the previous cite key when on a cite link.
+Otherwise run `left-word'. If the cursor moves off the link,
+move to the beginning of the previous cite link after this one." t)
+(autoload 'org-ref-jump-to-visible-key "org-ref-citation-links" "\
+Jump to a visible key with avy." t)
+(autoload 'org-ref-insert-cite-link "org-ref-citation-links" "\
+Insert a cite link with completion.
+Optional prefix arg SET-TYPE to choose the cite type.
+
+(fn &optional SET-TYPE)" t)
+(register-definition-prefixes "org-ref-citation-links" '("org-ref-"))
+
+\f
+;;; Generated autoloads from org-ref-compat.el
+
+(register-definition-prefixes "org-ref-compat" '("org-ref-to-org-cite"))
+
+\f
+;;; Generated autoloads from org-ref-core.el
+
+(autoload 'org-ref-insert-link "org-ref-core" "\
+Insert an org-ref link.
+If no prefix ARG insert a cite.
+If one prefix ARG insert a ref.
+If two prefix ARGs insert a label.
+
+This is a generic function. Specific backends might
+provide their own version.
+
+(fn ARG)" t)
+(autoload 'org-ref-help "org-ref-core" "\
+Open the `org-ref' manual." t)
+(register-definition-prefixes "org-ref-core" '("org-ref-"))
+
+\f
+;;; Generated autoloads from org-ref-export.el
+
+(register-definition-prefixes "org-ref-export" '("org-ref"))
+
+\f
+;;; Generated autoloads from org-ref-extract.el
+
+(register-definition-prefixes "org-ref-extract" '("org-ref-"))
+
+\f
+;;; Generated autoloads from org-ref-glossary.el
+
+(register-definition-prefixes "org-ref-glossary" '("or-" "org-ref-"))
+
+\f
+;;; Generated autoloads from org-ref-helm.el
+
+(autoload 'org-ref-cite-insert-helm "org-ref-helm" "\
+Search BibTeX entries.
+
+With a prefix ARG, the cache is invalidated and the bibliography
+reread.
+
+If LOCAL-BIB is non-nil, display that the BibTeX entries are read
+from the local bibliography.  This is set internally by
+`helm-bibtex-with-local-bibliography'.
+
+If INPUT is non-nil and a string, that value is going to be used
+as a predefined search term.  Can be used to define functions for
+frequent searches (e.g. your own publications).
+
+(fn &optional ARG LOCAL-BIB INPUT)" t)
+(register-definition-prefixes "org-ref-helm" '("org-ref-helm-source-"))
+
+\f
+;;; Generated autoloads from org-ref-isbn.el
+
+(autoload 'org-ref-isbn-clean-bibtex-entry "org-ref-isbn" "\
+Clean a bibtex entry inserted via `isbn-to-bibtex'.
+See functions in `org-ref-isbn-clean-bibtex-entry-hook'." t)
+(autoload 'isbn-to-bibtex-lead "org-ref-isbn" "\
+Search lead.to for ISBN bibtex entry.
+You have to copy the entry if it is on the page to your bibtex
+file.
+
+(fn ISBN)" t)
+(autoload 'isbn-to-bibtex "org-ref-isbn" "\
+Get bibtex entry for ISBN and insert it into BIBFILE.
+Nothing happens if an entry with the generated key already exists
+in the file. Data comes from www.ebook.de.
+
+(fn ISBN BIBFILE)" t)
+(register-definition-prefixes "org-ref-isbn" '("isbn-to-bibtex-open-library" "org-ref-isbn-" "oricb-"))
+
+\f
+;;; Generated autoloads from org-ref-ivy.el
+
+(register-definition-prefixes "org-ref-ivy" '("org-ref-"))
+
+\f
+;;; Generated autoloads from org-ref-label-link.el
+
+(autoload 'org-ref-insert-label-link "org-ref-label-link" "\
+Insert a new label with completion.
+The completion helps ensure you use a unique label." t)
+
+\f
+;;; Generated autoloads from org-ref-latex.el
+
+(register-definition-prefixes "org-ref-latex" '("org-ref-" "orl-"))
+
+\f
+;;; Generated autoloads from org-ref-misc-links.el
+
+(autoload 'org-ref-list-of-figures "org-ref-misc-links" "\
+Generate buffer with list of figures in them.
+ARG does nothing.
+Ignore figures in COMMENTED sections.
+
+(fn &optional ARG)" t)
+(autoload 'org-ref-list-of-tables "org-ref-misc-links" "\
+Generate a buffer with a list of tables.
+ARG does nothing.
+
+(fn &optional ARG)" t)
+(autoload 'org-ref-index "org-ref-misc-links" "\
+Open an *index* buffer with links to index entries.
+PATH is required for the org-link, but it does nothing here.
+
+(fn &optional PATH)" t)
+(register-definition-prefixes "org-ref-misc-links" '("org-ref-idxproc"))
+
+\f
+;;; Generated autoloads from org-ref-natbib-bbl-citeproc.el
+
+(register-definition-prefixes "org-ref-natbib-bbl-citeproc" '("org-"))
+
+\f
+;;; Generated autoloads from org-ref-pdf.el
+
+(autoload 'org-ref-pdf-to-bibtex "org-ref-pdf" "\
+Add pdf of current buffer to bib file and save pdf. The pdf
+should be open in Emacs using the `pdf-tools' package." t)
+(autoload 'org-ref-pdf-debug-pdf "org-ref-pdf" "\
+Try to debug getting a doi from a pdf.
+Opens a buffer with the pdf converted to text, and `occur' on the
+variable `org-ref-pdf-doi-regex'.
+
+(fn PDF-FILE)" t)
+(autoload 'org-ref-pdf-crossref-lookup "org-ref-pdf" "\
+Lookup highlighted text in PDFView in CrossRef." t)
+(register-definition-prefixes "org-ref-pdf" '("org-ref-" "pdftotext-executable"))
+
+\f
+;;; Generated autoloads from org-ref-publish.el
+
+(register-definition-prefixes "org-ref-publish" '("org-ref-publish-"))
+
+\f
+;;; Generated autoloads from org-ref-pubmed.el
+
+(autoload 'pubmed-insert-bibtex-from-pmid "org-ref-pubmed" "\
+Insert a bibtex entry at point derived from PMID.
+You must clean the entry after insertion.
+
+(fn PMID)" t)
+(autoload 'pubmed "org-ref-pubmed" "\
+Open http://www.ncbi.nlm.nih.gov/pubmed in a browser." t)
+(autoload 'pubmed-advanced "org-ref-pubmed" "\
+Open http://www.ncbi.nlm.nih.gov/pubmed/advanced in a browser." t)
+(autoload 'pubmed-simple-search "org-ref-pubmed" "\
+Open QUERY in Pubmed in a browser.
+
+(fn QUERY)" t)
+(autoload 'pubmed-clinical "org-ref-pubmed" "\
+Open http://www.ncbi.nlm.nih.gov/pubmed/clinical in a browser." t)
+(autoload 'pubmed-clinical-search "org-ref-pubmed" "\
+Open QUERY in pubmed-clinical.
+
+(fn QUERY)" t)
+(register-definition-prefixes "org-ref-pubmed" '("pubmed-"))
+
+\f
+;;; Generated autoloads from org-ref-ref-links.el
+
+(register-definition-prefixes "org-ref-ref-links" '("org-ref-"))
+
+\f
+;;; Generated autoloads from org-ref-refproc.el
+
+(register-definition-prefixes "org-ref-refproc" '("org-ref-"))
+
+\f
+;;; Generated autoloads from org-ref-scifinder.el
+
+(autoload 'scifinder "org-ref-scifinder" "\
+Open https://scifinder.cas.org/scifinder/view/scifinder/scifinderExplore.jsf in a browser." t)
+
+\f
+;;; Generated autoloads from org-ref-scopus.el
+
+(autoload 'scopus-related-by-keyword-url "org-ref-scopus" "\
+Return a Scopus url to articles related by keyword for DOI.
+
+(fn DOI)" t)
+(autoload 'scopus-related-by-author-url "org-ref-scopus" "\
+Return a Scopus url to articles related by author for DOI.
+
+(fn DOI)" t)
+(autoload 'scopus-related-by-references-url "org-ref-scopus" "\
+Return a Scopus url to articles related by references for DOI.
+
+(fn DOI)" t)
+(autoload 'scopus-open-eid "org-ref-scopus" "\
+Open article with EID in browser.
+
+(fn EID)" t)
+(autoload 'scopus-basic-search "org-ref-scopus" "\
+Open QUERY as a basic title-abstract-keyword search at scopus.com.
+
+(fn QUERY)" t)
+(autoload 'scopus-advanced-search "org-ref-scopus" "\
+Open QUERY as an advanced search at scopus.com.
+
+(fn QUERY)" t)
+(register-definition-prefixes "org-ref-scopus" '("*scopus-api-key*" "org-ref-scopus--current-eid" "scopus"))
+
+\f
+;;; Generated autoloads from org-ref-url-utils.el
+
+(autoload 'org-ref-url-debug-url "org-ref-url-utils" "\
+Open a buffer to URL with all doi patterns highlighted.
+
+(fn URL)" t)
+(autoload 'org-ref-url-html-to-bibtex "org-ref-url-utils" "\
+Convert URL to a bibtex or biblatex entry in BIBFILE.
+If URL is the first in the kill ring, use it. Otherwise, prompt for
+one in the minibuffer.
+
+(fn BIBFILE &optional URL)" t)
+(register-definition-prefixes "org-ref-url-utils" '("org-ref-"))
+
+\f
+;;; Generated autoloads from org-ref-utils.el
+
+(autoload 'org-ref-version "org-ref-utils" "\
+Provide a version string for org-ref.
+Copies the string to the clipboard." t)
+(autoload 'org-ref-debug "org-ref-utils" "\
+Print some debug information to a buffer." t)
+(autoload 'org-ref-open-pdf-at-point "org-ref-utils" "\
+Open the pdf for bibtex key under point if it exists." t)
+(autoload 'org-ref-add-pdf-at-point "org-ref-utils" "\
+Add the pdf for bibtex key under point if it exists.
+
+Similar to org-ref-bibtex-assoc-pdf-with-entry prompt for pdf
+associated with bibtex key at point and rename it.  Check whether a
+pdf already exists in `bibtex-completion-library' with the name
+'[bibtexkey].pdf'. If the file does not exist, rename it to
+'[bibtexkey].pdf' using
+`org-ref-bibtex-assoc-pdf-with-entry-move-function' and place it
+in a directory. Optional PREFIX argument toggles between
+`rename-file' and `copy-file'.
+
+(fn &optional PREFIX)" t)
+(autoload 'org-ref-open-url-at-point "org-ref-utils" "\
+Open the url for bibtex key under point." t)
+(autoload 'org-ref-open-notes-at-point "org-ref-utils" "\
+Open the notes for bibtex key under point in a cite link in a buffer.
+Can also be called with THEKEY in a program.
+
+(fn &optional THEKEY)" t)
+(autoload 'org-ref-open-citation-at-point "org-ref-utils" "\
+Open bibtex file to key at point." t)
+(autoload 'org-ref-copy-entry-as-summary "org-ref-utils" "\
+Copy the bibtex entry for the citation at point as a summary." t)
+(autoload 'org-ref-ads-at-point "org-ref-utils" "\
+Open the doi in ADS for bibtex key under point." t)
+(autoload 'org-ref-wos-at-point "org-ref-utils" "\
+Open the doi in wos for bibtex key under point." t)
+(autoload 'org-ref-wos-citing-at-point "org-ref-utils" "\
+Open the doi in wos citing articles for bibtex key under point." t)
+(autoload 'org-ref-wos-related-at-point "org-ref-utils" "\
+Open the doi in wos related articles for bibtex key under point." t)
+(autoload 'org-ref-google-scholar-at-point "org-ref-utils" "\
+Search google scholar for bibtex key under point using the title." t)
+(autoload 'org-ref-biblio-at-point "org-ref-utils" "\
+Do a biblio search for bibtex key under point using the title." t)
+(autoload 'org-ref-pubmed-at-point "org-ref-utils" "\
+Open the doi in pubmed for bibtex key under point." t)
+(autoload 'org-ref-crossref-at-point "org-ref-utils" "\
+Open the doi in crossref for bibtex key under point." t)
+(autoload 'org-ref-email-at-point "org-ref-utils" "\
+Email the citation(s) at point." t)
+(autoload 'org-ref-find-non-ascii-characters "org-ref-utils" "\
+Find non-ascii characters in the buffer.  Useful for cleaning up bibtex files." t)
+(autoload 'org-ref-extract-bibtex-to-file "org-ref-utils" "\
+Extract all bibtex entries for citations buffer to BIBFILE.
+If BIBFILE exists, append, unless you use a prefix arg (C-u),
+which will CLOBBER the file.
+
+(fn BIBFILE &optional CLOBBER)" t)
+(autoload 'org-ref-extract-bibtex-entries "org-ref-utils" "\
+Extract the bibtex entries in the current buffer into a bibtex src block." t)
+(autoload 'org-ref-extract-cited-pdfs "org-ref-utils" "\
+Copy PDFs in citations in current buffer to NEWDIR.
+
+(fn NEWDIR)" t)
+(register-definition-prefixes "org-ref-utils" '("ords" "org-ref"))
+
+\f
+;;; Generated autoloads from org-ref-worldcat.el
+
+(register-definition-prefixes "org-ref-worldcat" '("worldcat-query-all"))
+
+\f
+;;; Generated autoloads from org-ref-wos.el
+
+(autoload 'wos-search "org-ref-wos" "\
+Open the word at point or selection in Web of Science as a topic query." t)
+(autoload 'wos "org-ref-wos" "\
+Open Web of Science search page in a browser." t)
+(register-definition-prefixes "org-ref-wos" '("*wos-" "wos-"))
+
+\f
+;;; Generated autoloads from x2bib.el
+
+(autoload 'ris2bib "x2bib" "\
+Convert RISFILE to bibtex and insert at point.
+Without a prefix arg, stderr is diverted.
+If VERBOSE is non-nil show command output.
+If the region is active, assume it is a ris entry
+and convert it to bib format in place.
+
+(fn RISFILE &optional VERBOSE)" t)
+(autoload 'medxml2bib "x2bib" "\
+Convert MEDFILE (in Pubmed xml) to bibtex and insert at point.
+Without a prefix arg, stderr is diverted.
+Display output if VERBOSE is non-nil.
+
+(fn MEDFILE &optional VERBOSE)" t)
+(autoload 'clean-entries "x2bib" "\
+Map over bibtex entries and clean them." t)
+\f
+;;; End of scraped data
+
+(provide 'org-ref-autoloads)
+
+;; Local Variables:
+;; version-control: never
+;; no-byte-compile: t
+;; no-update-autoloads: t
+;; no-native-compile: t
+;; coding: utf-8-emacs-unix
+;; End:
+
+;;; org-ref-autoloads.el ends here
diff --git a/elpa/org-ref-20251206.1422/org-ref-bibliography-links.el b/elpa/org-ref-20251206.1422/org-ref-bibliography-links.el
new file mode 100644 (file)
index 0000000..f5c996b
--- /dev/null
@@ -0,0 +1,316 @@
+;;; org-ref-bibliography-links.el --- Bibliography and bibliographystyle links -*- lexical-binding: t; -*-
+;;
+;; Copyright (C) 2024  John Kitchin
+
+;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
+;; Keywords: convenience
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+;;
+;;; Commentary:
+;;
+
+;;; Code:
+
+(defcustom org-ref-latex-bib-resolve-func #'file-relative-name
+  "Function to expand paths to the bibliography file on latex export.
+Use this to convert a path to what you want, e.g. relative to
+some directory, absolute, etc."
+  :type 'function
+  :group 'org-ref)
+
+
+(defcustom org-ref-validate-bibliography nil
+  "If non-nil, validate bibliography files in fontification.
+This can be slow, so we don't do it by default."
+  :type 'boolean
+  :group 'org-ref)
+
+
+;;* bibliography* links
+
+(defun org-ref-get-bibfile-path (bibfile)
+  "Get a path to BIBFILE as local file, or using kpsewhich.
+This should allow you to use a bib file that is setup with TeX
+variables like BIBINPUTS."
+  (or (when (file-exists-p bibfile) bibfile)
+      (let ((f (replace-regexp-in-string
+               "\n$" ""
+               (shell-command-to-string (format "kpsewhich %s" bibfile)))))
+       (unless (string= "" f)
+         f))))
+
+
+(defun org-ref-bibliography*-export (cmd bibfiles _desc backend)
+  "Exporting function for bibliography links.
+To be used as a partial function e.g.
+ (apply-partially \"bibliography\" 'org-ref-bibliography*-export)
+Argument CMD is the command it should export to.
+Argument BIBFILES is a comma-separated list of strings.
+Argument BACKEND is the export backend."
+  (cond
+   ((eq backend 'latex)
+    (format "%s{%s}"
+           cmd
+           (if (not (string= "" bibfiles)) 
+               (replace-regexp-in-string
+                "\\.bib" ""
+                (mapconcat
+                 'identity
+                 (mapcar
+                  (lambda (f)
+                    (funcall org-ref-latex-bib-resolve-func (org-ref-get-bibfile-path f)))
+                  (split-string bibfiles ","))
+                 ","))
+             "")))))
+
+
+(defun org-ref-bibliography-activate (start end path _bracketp)
+  "Activate a bibliography link.
+Adds a warning face to non-existent or invalid bib-files.
+START and END are the bounds of the link.
+PATH is a comma-separated list of bibfiles."
+  (goto-char start)
+  (cl-loop for p in (split-string path ",") do
+          (setq p (string-trim p))
+          (search-forward p)
+          (setq p (org-ref-get-bibfile-path p))
+          (put-text-property (match-beginning 0) (match-end 0) 'org-ref-bibfile p)
+          (put-text-property (match-beginning 0) (match-end 0) 'help-echo (format "File exists at %s" p))
+
+          ;; activate files that don't exist
+          (when (or (null p) (not (file-exists-p p)))
+            (put-text-property (match-beginning 0) (match-end 0)
+                               'face 'font-lock-warning-face)
+            (put-text-property (match-beginning 0) (match-end 0)
+                               'help-echo "This file was not found."))
+
+          (when (and p (file-exists-p p))
+            (when org-ref-validate-bibliography
+              ;; Let's do a validation, but only if it has changed since the last time we checked.
+              (let* ((mod-time-last-check (or (get-text-property (match-beginning 0)
+                                                                 'mod-time-last-check)
+                                              '(0 0 0 0)))
+                     (last-modified (file-attribute-modification-time (file-attributes p)))
+                     (bibtex-valid))
+                (if (time-equal-p mod-time-last-check last-modified)
+                    (setq bibtex-valid (get-text-property (match-beginning 0) 'bibtex-valid))
+
+                  ;; the times were not equal, so we check and store the state.
+                  (setq bibtex-valid (save-match-data
+                                       (with-current-buffer (find-file-noselect p)
+                                         (bibtex-validate))))
+                  (put-text-property (match-beginning 0)
+                                     (match-end 0)
+                                     'mod-time-last-check
+                                     last-modified)
+                  (put-text-property (match-beginning 0)
+                                     (match-end 0)
+                                     'bibtex-valid
+                                     bibtex-valid))
+
+                (unless bibtex-valid
+                  (put-text-property (match-beginning 0) (match-end 0)
+                                     'face 'font-lock-warning-face)
+                  (put-text-property (match-beginning 0) (match-end 0)
+                                     'help-echo "This file did not pass `bibtex-validate'.")))))))
+
+
+(defun org-ref-bibliography*-follow (_path)
+  "Function to follow bibliography links."
+  (interactive)
+  (save-excursion
+    (unless (get-text-property (point) 'org-ref-bibfile)
+      (re-search-forward ":"))
+    (find-file (org-ref-get-bibfile-path (get-text-property (point) 'org-ref-bibfile)))))
+
+
+(defun org-ref-printbibliography-export (options _desc backend)
+  "Export function for printbibliography links.
+Argument OPTIONS are the options used for the command.
+Optional argument BACKEND is the export backend."
+  (cond
+   ((eq backend 'latex)
+    ;; write out the biblatex bibliography command
+    (format "\\printbibliography%s"
+           (if (not (string= "" options))
+               (format "[%s]" options)
+             "")))))
+
+(defvar org-ref-cite-types)
+(declare-function org-element-map "org-element")
+(declare-function org-element-property "org-element")
+(declare-function org-element-parse-buffer "org-element")
+(declare-function bibtex-completion-show-entry "bibtex-completion")
+(declare-function org-ref-possible-bibfiles "org-ref-core")
+(declare-function org-ref-parse-cite-path "org-ref-citation-links")
+
+(defun org-ref-insert-bibliography-link ()
+  "Insert a bibliography link for the files used in this buffer."
+  (interactive)
+  (let* ((cite-links (org-element-map (org-element-parse-buffer) 'link
+                      (lambda (lnk)
+                        (when (assoc (org-element-property :type lnk) org-ref-cite-types)
+                          lnk))))
+        (keys (delete-dups (cl-loop for cl in cite-links append
+                                    (cl-loop for ref in (plist-get (org-ref-parse-cite-path
+                                                                    (org-element-property :path cl))
+                                                                   :references)
+                                             collect (plist-get ref :key)))))
+        (files (delete-dups (cl-loop for key in keys collect
+                                     (save-window-excursion
+                                       (bibtex-completion-show-entry (list key))
+                                       (buffer-file-name))))))
+    (insert (format "[[bibliography:%s]]" (string-join files ",")))))
+
+
+(defun org-ref-bibliography-complete (&optional arg)
+  "Completion function for bibliography links."
+  (concat "bibliography:"
+         (completing-read "Bibliography file: " (org-ref-possible-bibfiles))))
+
+(defun org-ref-nobibliography-complete (&optional arg)
+  "Completion function for bibliography links."
+  (concat "nobibliography:"
+         (completing-read "Bibliography file: " (org-ref-possible-bibfiles))))
+
+
+(defvar org-ref-default-citation-link)
+
+(defun org-ref-bibtex-store-link ()
+  "Store a link from a bibtex file. Only supports the cite link.
+This essentially the same as the store link in org-bibtex, but it
+creates a cite link."
+  (when (eq major-mode 'bibtex-mode)
+    (let ((link (concat org-ref-default-citation-link
+                       ":&"
+                       (save-excursion
+                          (bibtex-beginning-of-entry)
+                         (cdr (assoc "=key=" (bibtex-parse-entry)))))))
+      (push (list link) org-stored-links)
+      (car org-stored-links))))
+
+
+;; ** bibliography* links
+
+(org-link-set-parameters "bibliography"
+                        :follow #'org-ref-bibliography*-follow
+                        :store #'org-ref-bibtex-store-link
+                        :complete #'org-ref-bibliography-complete
+                        :help-echo "Bibliography link"
+                        :export (apply-partially 'org-ref-bibliography*-export "\\bibliography")
+                        :activate-func #'org-ref-bibliography-activate
+                        :face 'org-link)
+
+
+(org-link-set-parameters "nobibliography"
+                        :complete #'org-ref-nobibliography-complete
+                        :store #'org-ref-bibtex-store-link
+                        :help-echo "No bibliography link"
+                        :activate-func #'org-ref-bibliography-activate
+                        :follow #'org-ref-bibliography*-follow
+                        :export (apply-partially 'org-ref-bibliography*-export "\\nobibliography")
+                        :face 'org-link)
+
+
+(org-link-set-parameters "nobibliography*"
+                        :complete #'org-ref-nobibliography-complete
+                        :store #'org-ref-bibtex-store-link
+                        :help-echo "No bibliography link"
+                        :activate-func #'org-ref-bibliography-activate
+                        :follow #'org-ref-bibliography*-follow
+                        :export (apply-partially 'org-ref-bibliography*-export "\\nobibliography*")
+                        :face 'org-link)
+
+
+(org-link-set-parameters "printbibliography"
+                        :export #'org-ref-printbibliography-export)
+
+;; Note I removed the addbibresource link, it goes in the header, not the document.
+
+;; *** bibliographystyle
+(defvar-local org-ref-bst-styles nil
+  "A list of known bibliography styles. Used to cache results.")
+
+
+(defun org-ref-clear-bst-cache ()
+  "Clear `org-ref-bst-styles' to reload it."
+  (interactive)
+  (setq org-ref-bst-styles nil))
+
+
+(defun org-ref-bibliography-styles ()
+  "Return a list of known bibliography styles.
+Returns `org-ref-bst-styles' or sets it and returns it."
+  (or org-ref-bst-styles
+      (setq org-ref-bst-styles
+           (mapcar 'file-name-nondirectory
+                   (mapcar 'file-name-sans-extension
+                           (org-ref--flatten-list
+                            (mapcar (lambda (path)
+                                      (setq path (replace-regexp-in-string "!" "" path))
+                                      (when (file-directory-p path)
+                                        (org-ref--directory-files path (lambda (f) (org-ref--file-ext-p f "bst")))))
+                                    (split-string
+                                     ;; https://tex.stackexchange.com/questions/431948/get-a-list-of-installed-bibliography-styles-with-kpsewhich?noredirect=1#comment1082436_431948
+                                     (shell-command-to-string "kpsewhich -expand-path '$BSTINPUTS'")
+                                     ":"))))))))
+
+
+(defun org-ref-bibliographystyle-complete-link (&optional arg)
+  "Completion function for bibliography style links.
+ARG is a not used."
+  (when (executable-find "kpsewhich")
+    (concat "bibliographystyle:"
+           (completing-read "Style: " (org-ref-bibliography-styles)))))
+
+
+(defun org-ref-bibliographystyle-activate (start _end path _bracketp)
+  "Activation function for bibliography styles.
+START is the beginning position of the link.
+Optional argument PATH contains the selected style."
+  (unless (member path (org-ref-bibliography-styles))
+    (goto-char start)
+    (search-forward path)
+    (put-text-property (match-beginning 0) (match-end 0) 'face 'font-lock-warning-face)
+    (put-text-property (match-beginning 0) (match-end 0) 'help-echo "Unrecognized style")))
+
+
+(defun org-ref-bibliographystyle-export (style _desc backend)
+  "Export function for bibliographystyle links.
+Argument STYLE is the desired style.
+Optional argument BACKEND is the export backend."
+  (cond
+   ((or (eq backend 'latex)
+       (eq backend 'beamer))
+    ;; write out the latex bibliography command
+    (format "\\bibliographystyle{%s}" style))
+   ;; No other backend needs this I think
+   (t
+    "")))
+
+
+(org-link-set-parameters "bibliographystyle"
+                        :complete #'org-ref-bibliographystyle-complete-link
+                        :activate-func #'org-ref-bibliographystyle-activate
+                        :export #'org-ref-bibliographystyle-export)
+
+
+(provide 'org-ref-bibliography-links)
+
+;;; org-ref-bibliography-links.el ends here
+
+;; Local Variables:
+;; byte-compile-warnings: (not docstrings)
+;; End:
diff --git a/elpa/org-ref-20251206.1422/org-ref-bibtex.el b/elpa/org-ref-20251206.1422/org-ref-bibtex.el
new file mode 100644 (file)
index 0000000..b45399c
--- /dev/null
@@ -0,0 +1,1469 @@
+;;; org-ref-bibtex.el -- org-ref-bibtex utilities -*- lexical-binding: t; -*-
+
+;; Copyright(C) 2014-2024 John Kitchin
+
+;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
+;; URL: https://github.com/jkitchin/org-ref
+;; Keywords: org-mode, bibtex
+
+;; This file is not currently part of GNU Emacs.
+
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation; either version 2, or (at
+;; your option) any later version.
+
+;; This program is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program ; see the file COPYING.  If not, write to
+;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+
+;; Functions to act on a bibtex entry or file
+;;
+;; ** Modifying bibtex entries
+;; - `org-ref-sort-bibtex-entry' :: sort the fields in an entry
+;; - `org-ref-downcase-bibtex-entry' :: downcase the fields in an entry
+;; - `org-ref-clean-bibtex-entry' :: run hooks in `org-ref-clean-bibtex-entry-hook' on an entry
+;; - `org-ref-title-case-article' :: title case the title in an article or book
+;; - `org-ref-sentence-case-article' :: sentence case the title in an article.
+;; org-ref-bibtex-generate-longtitles
+;; org-ref-bibtex-generate-shorttitles
+;; org-ref-stringify-journal-name :: replace a journal name with a string in
+;; `org-ref-bibtex-journal-abbreviations'
+;; org-ref-set-journal-string :: in a bibtex entry run this to replace the
+;; journal with a string
+;;
+
+;; * Navigating bibtex entries
+;; `org-ref-bibtex-next-entry' :: bound to M-n
+;; `org-ref-bibtex-previous-entry' :: bound to M-p
+
+;;
+;; ** Operate on whole bibtex file
+;; - `org-ref-build-full-bibliography'
+;; org-ref-replace-nonascii :: replace nonascii characters in a bibtex
+;; entry.  Replacements are in `org-ref-nonascii-latex-replacements'.
+;;
+;; ** Transient menu for bibtex files
+;; `org-ref-bibtex-entry-menu' gives access to many useful functions.
+;; `org-ref-bibtex-new-entry-menu' presents commands to add new bibtex entries.
+;; `org-ref-bibtex-file-menu' collects actions for entire bibtex files.
+;;
+;;; Code
+
+(require 'bibtex)
+(require 'transient)
+(require 'message)
+(require 'doi-utils)
+(require 'avy)
+(require 'sgml-mode)
+
+(defvar bibtex-completion-bibliography)
+(defvar bibtex-completion-library-path)
+(declare-function bibtex-completion-show-entry "bibtex-completion")
+(declare-function org-ref-find-bibliography "org-ref-core")
+(declare-function org-element-property "org-element")
+
+;;* Custom variables
+(defgroup org-ref-bibtex nil
+  "Customization group for org-ref-bibtex."
+  :group 'org-ref-bibtex)
+
+
+(defcustom org-ref-shorten-authors nil
+  "If non-nil show only last names in the completion selection buffer."
+  :type 'boolean
+  :group 'org-ref-bibtex)
+
+
+(defcustom org-ref-bibtex-sort-order
+  '(("article"  . ("author" "title" "journal" "volume" "number" "pages" "year" "doi" "url"))
+    ("inproceedings" . ("author" "title" "booktitle" "year" "volume" "number" "pages" "doi" "url"))
+    ("book" . ("author" "title" "year" "publisher" "url")))
+  "A-list of bibtex entry fields and the order to sort an entry with.
+\(entry-type . (list of fields). This is used in
+`org-ref-sort-bibtex-entry'. Entry types not listed here will
+have fields sorted alphabetically."
+  :type '(alist :key-type (string) :value-type (repeat string))
+  :group 'org-ref)
+
+
+(defcustom orcb-%-replacement-string " \\\\%"
+  "Replacement for a naked % sign in cleaning a BibTeX entry.
+The replacement string should be escaped for use with
+`replace-match'. Compare to the default value. Common choices
+would be to omit the space or to replace the space with a ~ for a
+non-breaking space."
+  :type 'regexp
+  :group 'org-ref)
+
+
+(defcustom org-ref-clean-bibtex-key-function
+  (lambda (key)
+    (replace-regexp-in-string ":" "" key))
+  "Function to modify a bibtex key.
+The default behavior is to remove : from the key."
+  :type 'function
+  :group 'org-ref)
+
+
+(defcustom org-ref-clean-bibtex-entry-hook
+  '(org-ref-bibtex-format-url-if-doi
+    orcb-key-comma
+    org-ref-replace-nonascii
+    orcb-&
+    orcb-%
+    org-ref-title-case-article
+    orcb-clean-year
+    orcb-key
+    orcb-clean-doi
+    orcb-clean-pages
+    orcb-check-journal
+    org-ref-sort-bibtex-entry
+    orcb-fix-spacing
+    orcb-download-pdf)
+  "Hook that is run in `org-ref-clean-bibtex-entry'.
+The functions should have no arguments, and
+operate on the bibtex entry at point. You can assume point starts
+at the beginning of the entry. These functions are wrapped in
+`save-restriction' and `save-excursion' so you do not need to
+save the point position.
+
+Org ref contains some functions that are not included by default
+such as `orcb-clean-nil' or `orcb-clean-nil-opinionated' that
+users may be interested in adding themselves."
+  :group 'org-ref
+  :type 'hook)
+
+;; see https://github.com/fxcoudert/tools/blob/master/doi2bib for more replacements
+(defcustom org-ref-nonascii-latex-replacements
+  '(("í" . "{\\\\'i}")
+    ("æ" . "{\\\\ae}")
+    ("ć" . "{\\\\'c}")
+    ("é" . "{\\\\'e}")
+    ("ä" . "{\\\\\"a}")
+    ("è" . "{\\\\`e}")
+    ("à" . "{\\\\`a}")
+    ("á" . "{\\\\'a}")
+    ("ø" . "{\\\\o}")
+    ("ë" . "{\\\\\"e}")
+    ("ü" . "{\\\\\"u}")
+    ("ñ" . "{\\\\~n}")
+    ("ņ" . "{\\\\c{n}}")
+    ("ñ" . "{\\\\~n}")
+    ("å" . "{\\\\aa}")
+    ("ö" . "{\\\\\"o}")
+    ("Á" . "{\\\\'A}")
+    ("í" . "{\\\\'i}")
+    ("ó" . "{\\\\'o}")
+    ("ó" . "{\\\\'o}")
+    ("ú" . "{\\\\'u}")
+    ("ú" . "{\\\\'u}")
+    ("ý" . "{\\\\'y}")
+    ("š" . "{\\\\v{s}}")
+    ("č" . "{\\\\v{c}}")
+    ("ř" . "{\\\\v{r}}")
+    ("š" . "{\\\\v{s}}")
+    ("İ" . "{\\\\.I}")
+    ("ğ" . "{\\\\u{g}}")
+    ("δ" . "$\\\\delta$")
+    ("ç" . "{\\\\c{c}}")
+    ("ß" . "{\\\\ss}")
+    ("≤" . "$\\\\le$")
+    ("≥" . "$\\\\ge$")
+    ("θ" . "$\\\\theta$")
+    ("μ" . "$\\\\mu$")
+    ("→" . "$\\\\rightarrow$")
+    ("⇌" . "$\\\\leftrightharpoons$")
+    ("×" . "$\\\\times$")
+    ("°" . "$\\\\deg$")
+    ("ş" . "{\\\\c{s}}")
+    ("γ" . "$\\\\gamma$")
+    ("ɣ" . "$\\\\gamma$")
+    ("º" . "degC")
+    ("η" . "$\\\\eta$")
+    ("µ" . "$\\\\mu$")
+    ("α" . "$\\\\alpha$")
+    ("β" . "$\\\\beta$")
+    ("ɛ" . "$\\\\epsilon$")
+    ("Ⅵ" . "\\textrm{VI}")
+    ("Ⅲ" . "\\textrm{III}")
+    ("Ⅴ" . "\\textrm{V}")
+    ("λ" . "$\\\\lambda$")
+    ("π" . "$\\\\pi$")
+    ("∞" . "$\\\\infty$")
+    ("χ" . "$\\\\chi$")
+    ("∼" . "\\\\textasciitilde{}")
+    ("‑" . "\\\\textemdash{}")
+    (" " . " ")
+    ("…" . "...")
+    ("•" . "\\\\textbullet ")
+    ;; I think these are non-ascii spaces. there seems to be more than one.
+    (" " . " ")
+    (" " . " ")
+    (" " . " ")
+    ("–" . "-")
+    ("−" . "-")
+    ("–" . "-")
+    ("—" . "-")
+    ("‒" . "\\\\textemdash{}")
+    ("‘" . "'")
+    ("’" . "'")
+    ("’" . "'")
+    ("“" . "\"")
+    ("’" . "'")
+    ("”" . "\""))
+  "Cons list of non-ascii characters and their LaTeX representations.
+This may be deprecated. When `org-ref' started, non-ascii
+characters were often problematic with bibtex, but in 2021, it is
+not obvious that is still try."
+  :type '(alist :key-type (string) :value-type (string))
+  :group 'org-ref-bibtex)
+
+(defcustom org-ref-bibtex-assoc-pdf-with-entry-move-function 'rename-file
+  "Function to use when associating pdf files with bibtex entries.
+The value should be either `rename-file' or `copy-file'. The former
+will move and rename the original file. The latter will leave the
+original file in place while creating a renamed copy in some directory."
+  :type 'function
+  :group 'org-ref-bibtex)
+
+;;* Journal abbreviations
+(defcustom org-ref-bibtex-journal-abbreviations
+  '(("ACR" "Accounts of Chemical Research" "Acc. Chem. Res.")
+    ("ACAT" "ACS Catalysis" "ACS Catal.")
+    ("AM" "Acta Materialia" "Acta Mater.")
+    ("AMM" "Acta Metallurgica et Materialia" "Acta Metall. Mater.")
+    ("AEM" "Advanced Energy Materials" "Adv. Energy Mater.")
+    ("AAMI" "ACS Applied Materials \\& Interfaces"
+     "ACS Appl. Mater. Interfaces")
+    ("AMiner" "American Mineralogist" "Am. Mineral.")
+    ("AngC" "Angewandte Chemie-International Edition"
+     "Angew. Chem. Int. Edit.")
+    ("APLM" "APL Materials" "APL Mat.")
+    ("ACBE" "Applied Catalysis B: Environmental" "Appl. Catal. B-Environ.")
+    ("APL" "Applied Physics Letters" "Appl. Phys. Lett.")
+    ("ASS" "Applied Surface Science" "Appl. Surf. Sci.")
+    ("CL" "Catalysis Letters" "Catal. Lett.")
+    ("CC" "Catalysis Communications" "Catal. Commun.")
+    ("CST" "Catalysis Science & Technology" "Catal. Sci. Technol.")
+    ("CT" "Catalysis Today" "Catal. Today")
+    ("ChC" "Chemical Communications" "Chem. Commun.")
+    ("CPL" "Chemical Physics Letters" "Chem. Phys. Lett")
+    ("CR" "Chemical Reviews" "Chem. Rev.")
+    ("CSR" "Chemical Society Reviews" "Chem. Soc. Rev.")
+    ("CSR" "Chemical Society Reviews" "Chem. Soc. Rev.")
+    ("CM" "Chemistry of Materials" "Chem. Mater.")
+    ("CSA" "Colloids and Surfaces, A: Physicochemical and Engineering Aspects"
+     "Colloids Surf., A")
+    ("CF" "Combustion and Flame" "Combust. Flame")
+    ("CPMS" "Computational Materials Science" "Comp. Mater. Sci.")
+    ("CPC" "Computer Physics Communications" "Comput. Phys. Commun.")
+    ("CSE" "Computing in Science \\& Engineering" "Comput. Sci. Eng.")
+    ("CGD" "Crystal Growth \\& Design" "Cryst. Growth Des.")
+    ("CEC" "CrystEngComm" "CrystEngComm")
+    ("EA" "Electrochimica Acta" "Electrochim. Acta")
+    ("ECST" "ECS Transactions" "ECS Trans.")
+    ("EES" "Energy \\& Environmental Science" "Energy Environ. Sci.")
+    ("HPR" "High Pressure Research" "High Pressure Res.")
+    ("IC" "Inorganic Chemistry" "Inorg. Chem.")
+    ("IECR" "Industrial \\& Engineering Chemistry Research"
+     "Ind. Eng. Chem. Res.")
+    ("JJAP" "Japanese Journal of Applied Physics" "Jpn. J. Appl. Phys.")
+    ("JMatR" "Journal of  Materials Research" "J. Mater. Res.")
+    ("JALC" "Journal of Alloys and Compounds" "J. Alloy Compd.")
+    ("JAC" "Journal of Applied Crystallography" "J. Appl. Crystallogr.")
+    ("JAE" "Journal of Applied Electrochemistry" "J. Appl. Electrochem.")
+    ("JAP" "Journal of Applied Physics" "J. Appl. Phys.")
+    ("JC" "Journal of Catalysis" "J. Catal.")
+    ("JCP" "Journal of Chemical Physics" "J. Chem. Phys.")
+    ("JCC" "Journal of Computational Chemistry" "J. Comput. Chem.")
+    ("JCG" "Journal of Crystal Growth" "J. Crys. Growth")
+    ("JMC" "Journal of Materials Chemistry" "J. Mater. Chem.")
+    ("JMC" "Journal of Materials Chemistry" "J. Mater. Chem.")
+    ("JMSL" "Journal of Materials Science Letters" "J. Mater. Sci. Lett.")
+    ("JMS" "Journal of Membrane Science" "J. Memb. Sci.")
+    ("JPE" "Journal of Phase Equilibria" "J. Phase Equilib.")
+    ("JPCS" "Journal of Physics and Chemistry of Solids"
+     "J. Phys. Chem. Solids")
+    ("JPCM" "Journal of Physics: Condensed Matter"
+     "J. Phys.: Condens. Matter")
+    ("JPS" "Journal of Power Sources" "J. Power Sources")
+    ("JSSC" "Journal of Solid State Chemistry" "J. Solid State Chem.")
+    ("JACerS" "Journal of the American Ceramic Society" "J. Am. Ceram. Soc.")
+    ("JACS" "Journal of the American Chemical Society" "J. Am. Chem. Soc.")
+    ("JASIST" "Journal of the American Society for Information Science and Technology"
+     "J. Am. Soc. Inf. Sci. Technol.")
+    ("JES" "Journal of The Electrochemical Society" "J. Electrochem. Soc.")
+    ("JEaC" "Journal of Electroanalytical Chemistry" "J. Electroanal. Chem.")
+    ("JMS" "Journal of Membrane Science" "J. Memb. Sci.")
+    ("JRS" "Journal of Raman Spectroscopy" "J. Raman Spectrosc.")
+    ("JVST" "Journal of Vacuum Science \\& Technology A"
+     "J. Vac. Sci. Technol. A")
+    ("ML" "Materials Letters" "Mater. Lett.")
+    ("MSE-BS" "Materials Science and Engineering B" "Mat. Sci. Eng. B-Solid")
+    ("MOLSIM" "Molecular Simulation" "Mol. Sim.")
+    ("Nature" "Nature" "Nature")
+    ("NM" "Nature Materials" "Nat. Mater.")
+    ("NC" "Nature Chemistry" "Nat. Chem.")
+    ("PML" "Philosophical Magazine Letters" "Phil. Mag. Lett.")
+    ("PMA" "Philosophical Magazine A" "Phil. Mag. A")
+    ("PA" "Physica A: Statistical Mechanics and its Applications" "Physica A")
+    ("PB" "Physica B-Condensed Matter" "Physica B")
+    ("PCCP" "Physical Chemistry Chemical Physics" "Phys. Chem. Chem. Phys.")
+    ("PSSB" "physica status solidi (b)" "Phys. Status Solidi B")
+    ("PRA" "Physical Review A" "Phys. Rev. A")
+    ("PRB" "Physical Review B" "Phys. Rev. B")
+    ("PRL" "Physical Review Letters" "Phys. Rev. Lett.")
+    ("PCM" "Physics and Chemistry of Minerals" "Phys. Chem. Miner.")
+    ("PNAS" "Proceedings of the National Academy of Sciences of the United States of America"
+     "Proc. Natl. Acad. Sci. U. S. A.")
+    ("PSurfSci" "Progress in Surface Science" "Prog. Surf. Sci.")
+    ("Science" "Science" "Science")
+    ("SM" "Scripta Materialia" "Scr. Mater.")
+    ("SABC" "Sensors and Actuators B: Chemical" "Sensor. Actuat. B-Chem.")
+    ("SS" "Surface Science" "Surf. Sci.")
+    ("EPJB" "The European Physical Journal B" "Eur. Phys. J. B")
+    ("JPC" "The Journal of Physical Chemistry" "J. Phys. Chem.")
+    ("JPCB" "The Journal of Physical Chemistry B" "J. Phys. Chem. B")
+    ("JPCC" "The Journal of Physical Chemistry C" "J. Phys. Chem. C")
+    ("JPCL" "The Journal of Physical Chemistry Letters"
+     "J. Phys. Chem. Lett.")
+    ("JCP" "The Journal of Chemical Physics" "J. Chem. Phys.")
+    ("MSMSE" "Modelling and Simulation in Materials Science and Engineering"
+     "Modell. Simul. Mater. Sci. Eng.")
+    ("TSF" "Thin Solid Films" "Thin Solid Films")
+    ("TC" "Topics in Catalysis" "Top. Catal.")
+    ("WR" "Water Research" "Water Res."))
+  "List of (string journal-full-name journal-abbreviation). Find
+  new abbreviations at http://cassi.cas.org/search.jsp."
+  :type '(list (repeat (list string string)))
+  :group 'org-ref-bibtex)
+
+
+(defcustom org-ref-title-case-types '(("article" . ("title"))
+                                     ("book" . ("booktitle")))
+
+  "An a-list of bibtex entry types and fields that will be converted to
+title-case by org-ref-title-case."
+  :type '(repeat string)
+  :group 'org-ref-bibtex)
+
+
+(defcustom org-ref-bibtex-pdf-download-dir
+  (cond
+   ((stringp bibtex-completion-library-path)
+    bibtex-completion-library-path)
+   (t
+    (car bibtex-completion-library-path)))
+  "Default directory to look for downloaded pdfs.
+Used in `org-ref-bibtex-assoc-pdf-with-entry' when looking for a
+PDF to associate with an entry. Defaults to the first entry in
+`bibtex-completion-library-path'."
+  :group 'org-ref-bibtex
+  :type 'directory)
+
+
+;; * Modifying journal titles
+;;;###autoload
+(defun org-ref-bibtex-generate-longtitles ()
+  "Generate longtitles.bib which are @string definitions.
+The full journal names are in `org-ref-bibtex-journal-abbreviations'."
+  (interactive)
+  (with-temp-file "longtitles.bib"
+    (dolist (row org-ref-bibtex-journal-abbreviations)
+      (insert (format "@string{%s=\"%s\"}\n"
+                      (nth 0 row)
+                      (nth 1 row))))))
+
+
+;;;###autoload
+(defun org-ref-bibtex-generate-shorttitles ()
+  "Generate shorttitles.bib which are @string definitions.
+The abbreviated journal names in `org-ref-bibtex-journal-abbreviations'."
+  (interactive)
+  (with-temp-file "shorttitles.bib"
+    (dolist (row org-ref-bibtex-journal-abbreviations)
+      (insert (format "@string{%s=\"%s\"}\n"
+                      (nth 0 row)
+                      (nth 2 row))))))
+
+
+;;;###autoload
+(defun org-ref-stringify-journal-name (&optional key start end)
+  "Replace journal name in a bibtex entry with a string.
+The strings are defined in
+`org-ref-bibtex-journal-abbreviations'.  The optional arguments KEY,
+START and END allow you to use this with `bibtex-map-entries'"
+  (interactive)
+  (bibtex-beginning-of-entry)
+  (when
+      (string= "article"
+               (downcase
+                (cdr (assoc "=type=" (bibtex-parse-entry)))))
+    (let* ((full-names (mapcar
+                        (lambda (row)
+                          (cons  (nth 1 row) (nth 0 row)))
+                        org-ref-bibtex-journal-abbreviations))
+           (abbrev-names (mapcar
+                          (lambda (row)
+                            (cons  (nth 2 row) (nth 0 row)))
+                          org-ref-bibtex-journal-abbreviations))
+           (journal (string-trim (bibtex-autokey-get-field "journal")))
+           (bstring (or
+                     (cdr (assoc journal full-names))
+                     (cdr (assoc journal abbrev-names)))))
+      (when bstring
+        (bibtex-set-field "journal" bstring t)
+        (bibtex-fill-entry)))))
+
+
+;;;###autoload
+(defun org-ref-set-journal-string (full-journal-name)
+  "Set a bibtex journal name to the string that represents FULL-JOURNAL-NAME.
+This is defined in `org-ref-bibtex-journal-abbreviations'."
+  (interactive (list
+                (completing-read
+                 "Journal: "
+                 (mapcar
+                  (lambda (x)
+                    (nth 1 x))
+                  org-ref-bibtex-journal-abbreviations))))
+  ;; construct data alist for the string lookup.
+  (let ((alist (mapcar
+                (lambda (x)
+                  (cons (nth 1 x) (nth 0 x)))
+                org-ref-bibtex-journal-abbreviations)))
+    (bibtex-set-field "journal" (cdr (assoc full-journal-name alist)) t)
+    (bibtex-fill-entry)
+    (bibtex-clean-entry)))
+
+;;* Non-ascii character replacement
+
+;;;###autoload
+(defun org-ref-replace-nonascii ()
+  "Replace non-ascii characters with LaTeX representations in a
+bibtex entry."
+  (interactive)
+  (save-restriction
+    (bibtex-narrow-to-entry)
+    (goto-char (point-min))
+    (dolist (char (mapcar (lambda (x)
+                           (car x))
+                         org-ref-nonascii-latex-replacements))
+      (while (re-search-forward char nil t)
+        (replace-match (cdr (assoc char org-ref-nonascii-latex-replacements))))
+      (goto-char (point-min)))))
+
+
+;;* Title case transformations
+(defvar org-ref-lower-case-words
+  '("a" "an" "on" "and" "for"
+    "the" "of" "in")
+  "List of words to keep lowercase when changing case in a title.")
+
+
+;;;###autoload
+(defun org-ref-title-case (&optional key start end)
+  "Convert a bibtex entry title and booktitle to title-case.
+Convert only if the entry type is a member of the list
+`org-ref-title-case-types'. The arguments KEY, START and END are
+optional, and are only there so you can use this function with
+`bibtex-map-entries' to change all the title entries in articles and
+books."
+  (interactive)
+  (save-restriction
+    (bibtex-narrow-to-entry)
+    (bibtex-beginning-of-entry)
+    (let* ((entry-type (downcase (cdr (assoc "=type=" (bibtex-parse-entry)))))
+          (fields (cdr (assoc entry-type org-ref-title-case-types)))
+          ;; temporary variables
+          title words)
+      (when fields
+       (cl-loop for field in fields
+                when (bibtex-autokey-get-field field)
+                do
+                (setq title (bibtex-autokey-get-field field)
+                      words (split-string title)
+                      start 0)
+                (setq words (mapcar
+                             (lambda (word)
+                               (cond
+                                ;; words containing more than one . are probably
+                                ;; abbreviations. We do not change those.
+                                ((with-temp-buffer
+                                   (insert word)
+                                   (goto-char (point-min))
+                                   (> (count-matches "\\.") 1))
+                                 word)
+                                ;; match words containing {} or \ which are probably
+                                ;; LaTeX or protected words, ignore
+                                ((string-match "\\$\\|{\\|}\\|(\\|)\\|\\\\" word)
+                                 word)
+                                ;; these words should not be capitalized, unless they
+                                ;; are the first word
+                                ((member (downcase word) org-ref-lower-case-words)
+                                 (downcase word))
+                                ;; Words that are quoted
+                                ((string-prefix-p "\"" word)
+                                 (concat "\"" (capitalize (substring word 1))))
+                                (t
+                                 (capitalize word))))
+                             words))
+
+                ;; Check if first word should be capitalized
+                (when (member (car words) org-ref-lower-case-words)
+                  (setf (car words) (capitalize (car words))))
+
+                (setq title (mapconcat 'identity words " "))
+
+                ;; Capitalize letters after a dash
+                (while
+                    (string-match "[a-zA-Z]-\\([a-z]\\)" title start)
+                  (let ((char (substring title (match-beginning 1) (match-end 1))))
+                    (setf (substring title (match-beginning 1) (match-end 1))
+                          (format "%s" (upcase char)))
+                    (setq start (match-end 1))))
+
+                ;; this is defined in doi-utils
+                (bibtex-set-field
+                 field
+                 title)
+                (bibtex-fill-entry))))))
+
+
+;;;###autoload
+(defun org-ref-title-case-article (&optional key start end)
+  "Convert a bibtex entry article or book title to title-case.
+The arguments KEY, START and END are optional, and are only there
+so you can use this function with `bibtex-map-entries' to change
+all the title entries in articles and books."
+  (interactive)
+  (let ((org-ref-title-case-types '(("article" . ("title")))))
+    (org-ref-title-case)))
+
+
+;;;###autoload
+(defun org-ref-sentence-case-article (&optional key start end)
+  "Convert a bibtex entry article title to sentence-case.
+The arguments KEY, START and END are optional, and are only there
+so you can use this function with `bibtex-map-entries' to change
+all the title entries in articles."
+  (interactive)
+  (bibtex-beginning-of-entry)
+
+  (let* ((title (bibtex-autokey-get-field "title"))
+         (words (split-string title))
+         (start 0))
+    (when
+        (string= "article"
+                (downcase
+                 (cdr (assoc "=type="
+                             (bibtex-parse-entry)))))
+      (setq words (mapcar
+                   (lambda (word)
+                     (if
+                         ;; match words containing {} or \ which are probably
+                         ;; LaTeX or protected words
+                         (string-match "\\$\\|{\\|}\\|\\\\" word)
+                         word
+                       (downcase word)))
+                   words))
+
+      ;; capitalize first word
+      (setf (car words) (capitalize (car words)))
+
+      ;; join the words
+      (setq title (mapconcat 'identity words " "))
+
+      ;; capitalize a word after a :, eg. a subtitle, and protect it
+      (while
+          (string-match "[a-z]:\\s-+\\([A-Z]\\)" title start)
+        (let ((char (substring title (match-beginning 1) (match-end 1))))
+          (setf (substring title (match-beginning 1) (match-end 1))
+                (format "%s" (upcase char)))
+          (setq start (match-end 1))))
+
+      ;; this is defined in doi-utils
+      (bibtex-set-field "title" title)
+
+      ;; clean and refill entry so it looks nice
+      (bibtex-clean-entry)
+      (bibtex-fill-entry))))
+
+
+;;* Navigation in bibtex file
+;;;###autoload
+(defun org-ref-bibtex-next-entry (&optional n)
+  "Jump to the beginning of the next bibtex entry.
+N is a prefix argument.  If it is numeric, jump that many entries
+forward.  Negative numbers do nothing."
+  (interactive "P")
+  ;; Note if we start at the beginning of an entry, nothing
+  ;; happens. We need to move forward a char, and call again.
+  (when (= (point) (save-excursion
+                     (bibtex-beginning-of-entry)))
+    (forward-char)
+    (org-ref-bibtex-next-entry))
+
+  ;; search forward for an entry
+  (when
+      (re-search-forward bibtex-entry-head nil t (and (numberp n) n))
+    ;; go to beginning of the entry
+    (bibtex-beginning-of-entry)))
+
+
+;;;###autoload
+(defun org-ref-bibtex-previous-entry (&optional n)
+  "Jump to beginning of the previous bibtex entry.
+N is a prefix argument.  If it is numeric, jump that many entries back."
+  (interactive "P")
+  (bibtex-beginning-of-entry)
+  (when
+      (re-search-backward bibtex-entry-head nil t (and (numberp n) n))
+    (bibtex-beginning-of-entry)))
+
+
+;;;###autoload
+(defun org-ref-bibtex-visible-entry ()
+  "Jump to visible entry."
+  (interactive)
+  (avy-with avy-ve
+    (avy-process
+     (save-excursion
+       (goto-char (window-start))
+       (let ((positions ()))
+        (while (re-search-forward "^@.*{" (window-end) t)
+          (push (match-beginning 0) positions))
+        (reverse positions))))
+    (avy--style-fn avy-style)))
+
+
+;;;###autoload
+(defun org-ref-bibtex-visible-field ()
+  "Jump to visible field."
+  (interactive)
+  (avy-with avy-vf
+    (avy-process
+     (save-excursion
+       (goto-char (window-start))
+       (let ((positions ()))
+        (while (re-search-forward ".*=\\s-*." (window-end) t)
+          (push (match-end 0) positions))
+        (reverse positions))))
+    (avy--style-fn avy-style)))
+
+
+(defun org-ref-bibtex-mode-keys ()
+  "Modify keymaps used by `bibtex-mode'."
+  (local-set-key (kbd "M-n") 'org-ref-bibtex-next-entry)
+  (local-set-key (kbd "M-p") 'org-ref-bibtex-previous-entry))
+
+;; add to bibtex-mode-hook
+(add-hook 'bibtex-mode-hook 'org-ref-bibtex-mode-keys)
+
+;;* Functions to act on an entry with a doi
+
+(defun org-ref-bibtex-entry-doi ()
+  "Get doi from entry at point."
+  (save-excursion
+    (bibtex-beginning-of-entry)
+    (when (not (looking-at bibtex-any-valid-entry-type))
+      (error "This entry does not appear to be a valid type."))
+    (let ((entry (bibtex-parse-entry t)))
+      (when (null entry)
+       (error "Unable to parse this bibtex entry."))
+      (cdr (assoc "doi" entry)))))
+
+;; function that ensures that the url field of a bibtex entry is the
+;; properly-formatted hyperlink of the DOI. See
+;; http://blog.crossref.org/2016/09/new-crossref-doi-display-guidelines.html
+;; for more information.
+;;;###autoload
+(defun org-ref-bibtex-format-url-if-doi ()
+  "Hook function to format url to follow the current DOI conventions."
+  (interactive)
+  ;; Don't overwrite an existing url field though.
+  (unless (bibtex-autokey-get-field "url")
+    (if (eq (org-ref-bibtex-entry-doi) "") nil
+      (let ((front-url "https://doi.org/")
+            (doi (org-ref-bibtex-entry-doi)))
+       (bibtex-set-field "url"
+                          (concat front-url doi))))))
+
+
+;;;###autoload
+(defun org-ref-bibtex-wos ()
+  "Open bibtex entry in Web Of Science if there is a DOI."
+  (interactive)
+  (doi-utils-wos (org-ref-bibtex-entry-doi)))
+
+
+;;;###autoload
+(defun org-ref-bibtex-wos-citing ()
+  "Open citing articles for bibtex entry in Web Of Science if
+there is a DOI."
+  (interactive)
+  (doi-utils-wos-citing (org-ref-bibtex-entry-doi)))
+
+
+;;;###autoload
+(defun org-ref-bibtex-wos-related ()
+  "Open related articles for bibtex entry in Web Of Science if
+there is a DOI."
+  (interactive)
+  (doi-utils-wos-related (org-ref-bibtex-entry-doi)))
+
+
+;;;###autoload
+(defun org-ref-bibtex-crossref ()
+  "Open the bibtex entry in Crossref by its doi."
+  (interactive)
+  (doi-utils-crossref (org-ref-bibtex-entry-doi)))
+
+
+;;;###autoload
+(defun org-ref-bibtex-google-scholar ()
+  "Open the bibtex entry at point in google-scholar by its doi."
+  (interactive)
+  (let ((doi (org-ref-bibtex-entry-doi)))
+    (doi-utils-google-scholar
+     (if (string= "" doi)
+        (save-excursion
+          (bibtex-beginning-of-entry)
+          (cdr (assoc "title" (bibtex-parse-entry t))))
+       doi))))
+
+
+;;;###autoload
+(defun org-ref-bibtex-pubmed ()
+  "Open the bibtex entry at point in Pubmed by its doi."
+  (interactive)
+  (doi-utils-pubmed (org-ref-bibtex-entry-doi)))
+
+
+;;;###autoload
+(defun org-ref-bibtex-pdf (&optional _)
+  "Open the pdf for the bibtex entry at point.
+Thin wrapper to get `org-ref-bibtex' to open pdf, because it
+calls functions with a DOI argument."
+  (interactive)
+  (org-ref-open-bibtex-pdf))
+
+
+(defun org-ref-bibtex-get-file-move-func (prefix)
+  "Determine whether to use `rename-file' or `copy-file' for `org-ref-bibtex-assoc-pdf-with-entry'.
+When called with a PREFIX argument,
+`org-ref-bibtex-assoc-pdf-with-entry-move-function' switches to the
+opposite function from that which is defined in
+`org-ref-assoc-pdf-with-entry-move-function'."
+  (message (format "%s" prefix))
+  (if (eq prefix nil)
+      org-ref-bibtex-assoc-pdf-with-entry-move-function
+    (if (eq org-ref-bibtex-assoc-pdf-with-entry-move-function 'rename-file)
+       'copy-file
+      'rename-file)))
+
+
+(defvar bibtex-completion-library-path)
+(declare-function bibtex-completion-find-pdf-in-library "bibtex-completion")
+
+
+;;;###autoload
+(defun org-ref-bibtex-assoc-pdf-with-entry (&optional prefix)
+  "Prompt for pdf associated with entry at point and rename it.
+Check whether a pdf already exists in `bibtex-completion-library' with the
+name '[bibtexkey].pdf'. If the file does not exist, rename it to
+'[bibtexkey].pdf' using
+`org-ref-bibtex-assoc-pdf-with-entry-move-function' and place it in
+a directory. Optional PREFIX argument toggles between
+`rename-file' and `copy-file'."
+  (interactive "P")
+  (save-excursion
+    (bibtex-beginning-of-entry)
+    (let* ((file (read-file-name
+                 "Select file associated with entry: "
+                 org-ref-bibtex-pdf-download-dir))
+          (bibtex-expand-strings t)
+           (entry (bibtex-parse-entry t))
+           (key (cdr (assoc "=key=" entry)))
+          (file-move-func (org-ref-bibtex-get-file-move-func prefix))
+          pdf)
+      (if (bibtex-completion-find-pdf-in-library key)
+         (message (format "A file named %s already exists" (bibtex-completion-find-pdf-in-library key)))
+       (setq pdf (expand-file-name (concat key ".pdf") (cond
+                                                        ((stringp bibtex-completion-library-path)
+                                                         bibtex-completion-library-path)
+                                                        ((and (listp bibtex-completion-library-path)
+                                                              (= 1 (length bibtex-completion-library-path)))
+                                                         (car bibtex-completion-library-path))
+                                                        (t
+                                                         (completing-read "Dir: " bibtex-completion-library-path)))))
+       (funcall file-move-func file pdf)
+       (message (format "Created file %s" pdf))))))
+
+
+;;* Hydra menus
+;;** Hydra menu for bibtex entries
+;; transient menu for actions on bibtex entries
+(transient-define-prefix org-ref-bibtex-entry-menu ()
+  "Bibtex actions."
+  [["Open"
+    ("p" "PDF" org-ref-open-bibtex-pdf)
+    ("n" "Notes" org-ref-open-bibtex-notes)
+    ("b" "URL" org-ref-open-in-browser)]
+   ["Edit"
+    ("K" "Keywords" (lambda ()
+                      (interactive)
+                      (org-ref-set-bibtex-keywords
+                       (read-string "Keywords: "
+                                    (bibtex-autokey-get-field "keywords"))
+                       t)))
+    ("a" "Replace nonascii" org-ref-replace-nonascii)
+    ("s" "Sort fields" org-ref-sort-bibtex-entry)
+    ("T" "Title case" org-ref-title-case-article)
+    ("S" "Sentence case" org-ref-sentence-case-article)
+    ("U" "Update entry" (lambda ()
+                          (interactive)
+                          (doi-utils-update-bibtex-entry-from-doi (org-ref-bibtex-entry-doi))))
+    ("u" "Update field" doi-utils-update-field :transient t)
+    ("<backspace>" "Delete line" (lambda ()
+                                    (interactive)
+                                    (cl--set-buffer-substring
+                                     (line-beginning-position)
+                                     (1+ (line-end-position))
+                                     "")) :transient t)
+    ("d" "Kill entry" bibtex-kill-entry)
+    ("L" "Clean entry" org-ref-clean-bibtex-entry)
+    ("A" "Add pdf" org-ref-bibtex-assoc-pdf-with-entry)
+    ("r" "Refile entry" (lambda ()
+                          (interactive)
+                          (bibtex-beginning-of-entry)
+                          (bibtex-kill-entry)
+                          (find-file (completing-read
+                                     "Bibtex file: "
+                                     (append bibtex-completion-bibliography
+                                             (org-ref--directory-files "." (lambda (f) (org-ref--file-ext-p f "bib"))))))
+                          (goto-char (point-max))
+                          (bibtex-yank)
+                          (save-buffer)
+                          (kill-buffer)))]
+   ["WWW"
+    ("P" "Pubmed" org-ref-bibtex-pubmed)
+    ("w" "WOS" org-ref-bibtex-wos)
+    ("c" "WOS citing" org-ref-bibtex-wos-citing)
+    ("a" "WOS related" org-ref-bibtex-wos-related)
+    ("R" "Crossref" org-ref-bibtex-crossref)
+    ("g" "Google Scholar" org-ref-bibtex-google-scholar)
+    ("e" "Email" org-ref-email-bibtex-entry)]
+   ["Copy"
+    ("o" "Copy entry" (lambda ()
+                        (interactive)
+                        (bibtex-copy-entry-as-kill)
+                        (message "Use %s to paste the entry"
+                                (substitute-command-keys (format "\\[bibtex-yank]")))))
+    ("y" "Copy key" (lambda ()
+                      (interactive)
+                      (save-excursion
+                        (bibtex-beginning-of-entry)
+                        (when (looking-at bibtex-entry-maybe-empty-head)
+                          (kill-new (bibtex-key-in-head))))))
+    ("f" "Formatted entry" (lambda ()
+                             (interactive)
+                             (save-excursion
+                               (bibtex-beginning-of-entry)
+                               (kill-new (bibtex-completion-apa-format-reference
+                                         (cdr (assoc "=key=" (bibtex-parse-entry t))))))))]
+   ["Navigation"
+    ("[" "Next entry" org-ref-bibtex-next-entry :transient t)
+    ("]" "Previous entry" org-ref-bibtex-previous-entry :transient t)
+    ("<down>" "Next line" next-line :transient t)
+    ("<up>" "Previous line" previous-line :transient t)
+    ("<next>" "Scroll up" scroll-up-command :transient t)
+    ("<prior>" "Scroll down" scroll-down-command :transient t)
+    ("v" "Visible entry" org-ref-bibtex-visible-entry :transient t)
+    ("V" "Visible field" org-ref-bibtex-visible-field :transient t)]
+   ["Misc"
+    ("F" "File menu" org-ref-bibtex-file-menu)
+    ("N" "New entry" org-ref-bibtex-new-entry-menu)
+    ("q" "Quit" transient-quit-one)]])
+
+
+(declare-function biblio-lookup "biblio")
+(declare-function arxiv-add-bibtex-entry "org-ref-arxiv")
+(declare-function doi-insert-bibtex "doi-utils")
+
+;;** Transient menu for new bibtex entries
+;; A transient for adding new bibtex entries.
+(transient-define-prefix org-ref-bibtex-new-entry-menu ()
+  "New Bibtex entry."
+  [["Automatic"
+    ("d" "from DOI" doi-insert-bibtex)
+    ("c" "from Crossref" crossref-add-bibtex-entry)
+    ("a" "From Arxiv" arxiv-add-bibtex-entry)
+    ("b" "From biblio" biblio-lookup)]
+   ["Manual"
+    ("ma" "Article" bibtex-Article)
+    ("mb" "Book" bibtex-Book)
+    ("mi" "In book" bibtex-InBook)
+    ("ml" "Booklet" bibtex-Booklet)
+    ("mP" "Proceedings" bibtex-Proceedings)
+    ("mp" "In proceedings" bibtex-InProceedings)
+    ("mm" "Misc." bibtex-Misc)
+    ("mM" "Manual" bibtex-Manual)
+    ("mT" "PhD Thesis" bibtex-PhdThesis)
+    ("mt" "MS Thesis" bibtex-MastersThesis)
+    ("mR" "Report" bibtex-TechReport)
+    ("mu" "unpublished" bibtex-Unpublished)
+    ("mc" "Article in collection" bibtex-InCollection)
+    ("q" "Quit" transient-quit-one)]])
+
+
+;;** Transient menu of functions to act on a bibtex file.
+(transient-define-prefix org-ref-bibtex-file-menu ()
+  "Bibtex file functions."
+  [["Commands"
+    ("v" "Validate entries" bibtex-validate)
+    ("s" "Sort entries" bibtex-sort-buffer)
+    ("r" "Reformat entries" bibtex-reformat)
+    ("c" "Count entries" bibtex-count-entries)
+    ("p" "PDF bibliography" org-ref-build-full-bibliography)
+    ("q" "Quit" transient-quit-one)]])
+
+(define-obsolete-function-alias 'org-ref-bibtex-hydra/body
+  #'org-ref-bibtex-entry-menu "3.1")
+(define-obsolete-function-alias 'org-ref-bibtex-new-entry/body
+  #'org-ref-bibtex-new-entry-menu "3.1")
+(define-obsolete-function-alias 'org-ref-bibtex-file/body
+  #'org-ref-bibtex-file-menu "3.1")
+
+
+;;* Email a bibtex entry
+(declare-function bibtex-completion-find-pdf "bibtex-completion")
+
+;;;###autoload
+(defun org-ref-email-bibtex-entry ()
+  "Email current bibtex entry at point and pdf if it exists."
+  (interactive)
+  (bibtex-beginning-of-entry)
+  (let* ((key (cdr (assoc "=key=" (bibtex-parse-entry t))))
+        (pdfs (bibtex-completion-find-pdf key)))
+
+    (bibtex-copy-entry-as-kill)
+    (compose-mail)
+    (message-goto-body)
+    (insert (pop bibtex-entry-kill-ring))
+    (message-goto-subject)
+    (insert key)
+    (cl-loop for pdf in pdfs do (mml-attach-file pdf))
+    (message-goto-to)
+    ;; I am not sure why I have to put an empty string here, but it prevents a
+    ;; bell error.
+    ""))
+
+;;* org-ref bibtex keywords
+;; adapted from bibtex-utils.el
+;; these are candidates for selecting keywords/tags
+(defun org-ref-bibtex-keywords ()
+  "Get keywords defined in current bibtex file.
+These are in the keywords field, and are comma or semicolon separated."
+  (save-excursion
+    (goto-char (point-min))
+    (let (keywords kstring)
+      (while (re-search-forward "^\\s-*keywords.*{\\([^}]+\\)}" nil t)
+        ;; TWS - remove newlines/multiple spaces:
+        (setq kstring (replace-regexp-in-string
+                      "[ \t\n]+" " "
+                      (match-string 1)))
+        (mapc
+         (lambda (v)
+           (add-to-list 'keywords v t))
+         (split-string kstring "\\(,\\|;\\)[ \n]*\\|{\\|}" t)))
+      keywords)))
+
+
+;;;###autoload
+(defun org-ref-set-bibtex-keywords (keywords &optional arg)
+  "Add KEYWORDS to a bibtex entry.
+If KEYWORDS is a list, it is converted to a comma-separated
+string.  The KEYWORDS are added to the beginning of the
+field.  Otherwise KEYWORDS should be a string of comma-separate
+keywords.  Optional argument ARG prefix arg to replace keywords."
+  (interactive
+   (list
+    (completing-read "Keyword: " (org-ref-bibtex-keywords))
+    current-prefix-arg))
+  (bibtex-set-field
+   "keywords"
+   (if arg
+       ;; replace with arg
+       (if (listp keywords)
+           (mapconcat 'identity keywords ", ")
+         keywords)
+     ;; else concatenate
+     (concat
+      (if (listp keywords)
+          (mapconcat 'identity keywords ", ")
+        keywords)
+      (when (not (string= "" (bibtex-autokey-get-field "keywords")))
+        (concat ", "  (bibtex-autokey-get-field "keywords"))))))
+  (when (buffer-file-name)
+    (save-buffer)))
+
+
+(defun org-ref-save-all-bibtex-buffers ()
+  "Save all bibtex-buffers."
+  (cl-loop for buffer in (buffer-list)
+          do
+          (with-current-buffer buffer
+            (when (and (buffer-file-name) (org-ref--file-ext-p (buffer-file-name) "bib"))
+              (save-buffer)))))
+
+
+;; * Extract bibtex blocks from an org-file
+
+;;;###autoload
+(defun org-ref-extract-bibtex-blocks (bibfile)
+  "Extract all bibtex blocks in buffer to BIBFILE.
+If BIBFILE exists, append, unless you use a prefix arg (C-u), which
+will clobber the file."
+  (interactive
+   (list (read-file-name "Bibfile: " nil nil nil
+                        (file-name-nondirectory
+                         (concat (file-name-sans-extension
+                                  (buffer-file-name))
+                                 ".bib")))))
+
+  (let ((contents ""))
+    (when (and (file-exists-p bibfile)
+              (not current-prefix-arg))
+      (setq contents (with-temp-buffer
+                      (insert-file-contents bibfile)
+                      (buffer-string))))
+
+    (save-excursion
+      (goto-char (point-min))
+      (while (re-search-forward "#\\+BEGIN_SRC bibtex" nil t)
+       (setq contents
+             (concat
+              contents
+              (org-element-property :value (org-element-at-point))))))
+
+    (with-temp-file bibfile
+      (insert contents))))
+
+
+;;** create text citations from a bibtex entry
+(declare-function bibtex-completion-apa-format-reference "bibtex-completion")
+(declare-function bibtex-completion-get-key-bibtex "bibtex-completion")
+
+(defun org-ref-bib-citation ()
+  "From a bibtex entry, create and return a lightly formatted citation string."
+  (bibtex-completion-apa-format-reference (list (bibtex-completion-get-key-bibtex))))
+
+
+;;** Open pdf in bibtex entry
+(declare-function bibtex-completion-open-pdf "bibtex-completion")
+;;;###autoload
+(defun org-ref-open-bibtex-pdf ()
+  "Open pdf for a bibtex entry, if it exists."
+  (interactive)
+  (bibtex-completion-open-pdf (list (bibtex-completion-get-key-bibtex))))
+
+
+;;** Open notes from bibtex entry
+(declare-function bibtex-completion-edit-notes "bibtex-completion")
+
+;;;###autoload
+(defun org-ref-open-bibtex-notes ()
+  "From a bibtex entry, open the notes if they exist."
+  (interactive)
+  (bibtex-completion-edit-notes (list (bibtex-completion-get-key-bibtex))))
+
+
+;;** Open bibtex entry in browser
+(declare-function bibtex-completion-open-url-or-doi "bibtex-completion")
+
+;;;###autoload
+(defun org-ref-open-in-browser ()
+  "Open the bibtex entry at point in a browser using the url field or doi field."
+  (interactive)
+  (bibtex-completion-open-url-or-doi (list (bibtex-completion-get-key-bibtex))))
+
+
+;;** Build a pdf of the bibtex file
+;;;###autoload
+(defun org-ref-build-full-bibliography ()
+  "Build pdf of all bibtex entries, and open it."
+  (interactive)
+  (let* ((bibfile (file-name-nondirectory (buffer-file-name)))
+         (bib-base (file-name-sans-extension bibfile))
+         (texfile (concat bib-base ".tex"))
+         (pdffile (concat bib-base ".pdf")))
+    (find-file texfile)
+    (erase-buffer)
+    (insert (format "\\documentclass[12pt]{article}
+\\usepackage[version=3]{mhchem}
+\\usepackage{url}
+\\usepackage[numbers]{natbib}
+\\usepackage[colorlinks=true, linkcolor=blue, urlcolor=blue, pdfstartview=FitH]{hyperref}
+\\usepackage{doi}
+\\begin{document}
+\\nocite{*}
+\\bibliographystyle{unsrtnat}
+\\bibliography{%s}
+\\end{document}" bib-base))
+    (save-buffer)
+    (shell-command (concat "pdflatex " bib-base))
+    (shell-command (concat "bibtex " bib-base))
+    (shell-command (concat "pdflatex " bib-base))
+    (shell-command (concat "pdflatex " bib-base))
+    (kill-buffer texfile)
+    (org-open-file pdffile)))
+
+
+;;** Sort fields in a bibtex entry
+;;;###autoload
+(defun org-ref-sort-bibtex-entry ()
+  "Sort fields of entry in standard order."
+  (interactive)
+  (bibtex-beginning-of-entry)
+  (let* ((entry (bibtex-parse-entry))
+         (entry-fields)
+         (other-fields)
+         (type (cdr (assoc "=type=" entry)))
+         (key (cdr (assoc "=key=" entry)))
+        (field-order (cdr (assoc (if type (downcase type))
+                                 org-ref-bibtex-sort-order))))
+
+    ;; these are the fields we want to order that are in this entry
+    (setq entry-fields (mapcar (lambda (x) (car x)) entry))
+    ;; we do not want to reenter these fields
+    (setq entry-fields (remove "=key=" entry-fields))
+    (setq entry-fields (remove "=type=" entry-fields))
+
+    ;;these are the other fields in the entry, and we sort them alphabetically.
+    (setq other-fields
+         (sort (cl-remove-if (lambda(x) (member x field-order)) entry-fields)
+               'string<))
+
+    (save-restriction
+      (bibtex-kill-entry)
+      (insert
+       (concat "@" type "{" key ",\n"
+              (mapconcat
+               (lambda (field)
+                 (when (member field entry-fields)
+                   (format "%s = %s,"
+                           field
+                           (cdr (assoc field entry)))))
+               field-order "\n")
+              ;; now add the other fields
+              (mapconcat
+               (lambda (field)
+                 (cl-loop for (f . v) in entry concat
+                          (when (string= f field)
+                            (format "%s = %s,\n" f v))))
+               (delete-dups other-fields) "\n")
+              "\n}"))
+      (bibtex-search-entry key)
+      (bibtex-fill-entry)
+      (bibtex-clean-entry))))
+
+;; downcase entries
+;;;###autoload
+(defun org-ref-downcase-bibtex-entry ()
+  "Downcase the entry type and fields."
+  (interactive)
+  (bibtex-beginning-of-entry)
+  (let* ((entry (bibtex-parse-entry))
+         (entry-fields)
+         (type (downcase (cdr (assoc "=type=" entry))))
+         (key (cdr (assoc "=key=" entry))))
+
+    (setq entry-fields (mapcar (lambda (x) (car x)) entry))
+    ;; we do not want to reenter these fields
+    (setq entry-fields (remove "=key=" entry-fields))
+    (setq entry-fields (remove "=type=" entry-fields))
+
+    (bibtex-kill-entry)
+    (insert
+     (concat "@" (downcase type) "{" key ",\n"
+            (mapconcat
+             (lambda (field)
+               (format "%s = %s,"
+                       (downcase field)
+                       (cdr (assoc field entry))))
+             entry-fields "\n")
+            "\n}\n\n"))
+    (bibtex-search-entry key)
+    (bibtex-fill-entry)
+    (bibtex-clean-entry)))
+
+
+;;** Clean a bibtex entry
+;; These functions operate on a bibtex entry and "clean" it in some way.
+
+(defun orcb-clean-nil (&optional arg)
+  "Remove nil from some article fields.
+The removal is conditional. Sometimes it is useful to have nil
+around, e.g. for ASAP articles where the fields are not defined
+yet but will be in the future.
+
+With \\[universal-argument], run `bibtex-clean-entry' after."
+  (interactive "P")
+  (bibtex-beginning-of-entry)
+  (let* ((entry (bibtex-parse-entry))
+         (type (downcase (cdr (assoc "=type=" entry)))))
+    (when (string= type "article")
+      (cond
+       ;; we have volume and pages but number is nil.
+       ;; remove the number field.
+       ((and (string= type "article")
+            (not (string= (cdr (assoc "volume" entry)) "{nil}"))
+            (not (string= (cdr (assoc "pages" entry)) "{nil}"))
+            (string= (cdr (assoc "number" entry)) "{nil}"))
+       (bibtex-set-field "number" "")
+       (if arg
+            (bibtex-clean-entry)))))))
+
+
+(defun orcb-clean-nil-opinionated ()
+  "Remove nil from all article fields.
+
+Note that by default, this will leave the entry empty, which may
+then get deleted by `bibtex-clean-entry.' To disable this
+behavior, remove opts-or-alts from `bibtex-entry-format'. This
+will leave the empty entries so that you may fill them in later."
+  (interactive)
+  (bibtex-beginning-of-entry)
+  (let* ((entry (bibtex-parse-entry))
+         (type (downcase (cdr (assoc "=type=" entry)))))
+    (when (string= type "article")
+      (cl-loop for (field . text) in entry do
+               (if (string= text "{nil}")
+                   (bibtex-set-field field ""))))))
+
+
+(defun orcb-clean-doi ()
+  "Remove http://dx.doi.org/ or https://doi.org in the doi field."
+  (let ((doi (bibtex-autokey-get-field "doi")))
+    (when (or (string-match "^http://dx.doi.org/" doi)
+             (string-match "^https://doi.org/" doi))
+      (setq doi (replace-match "" nil nil doi))
+      (bibtex-beginning-of-entry)
+      (goto-char (car (cdr (bibtex-search-forward-field "doi" t))))
+      (bibtex-kill-field)
+      (bibtex-make-field "doi")
+      (backward-char)
+      (insert doi))))
+
+
+(defun orcb-clean-year (&optional new-year)
+  "Fix years set to 0.
+If optional NEW-YEAR set it to that, otherwise prompt for it."
+  ;; asap articles often set year to 0, which messes up key
+  ;; generation. fix that.
+  (let ((year (bibtex-autokey-get-field "year")))
+    (when (string= "0" year)
+      (bibtex-beginning-of-entry)
+      (goto-char (car (cdr (bibtex-search-forward-field "year" t))))
+      (bibtex-kill-field)
+      (bibtex-make-field "year")
+      (backward-char)
+      (insert (or new-year (read-string "Enter year: "))))))
+
+
+(defun orcb-clean-pages ()
+  "Check for empty pages, and put eid in its place if it exists."
+  (let ((pages (bibtex-autokey-get-field "pages"))
+       (eid (bibtex-autokey-get-field "eid")))
+    (when (and (not (string= "" eid))
+              (or (string= "" pages)))
+      (bibtex-set-field "pages" eid))))
+
+
+(defun orcb-& ()
+  "Replace naked & with \\& in a bibtex entry."
+  (save-restriction
+    (bibtex-narrow-to-entry)
+    (bibtex-beginning-of-entry)
+    (while (re-search-forward " & " nil t)
+      (replace-match " \\\\& "))))
+
+
+(defun orcb-% ()
+  "Replace naked % with % in a bibtex entry.
+Except when it is already escaped or in a URL. The replacement
+for the % is defined by `orcb-%-replacement-string'."
+  (save-restriction
+    (bibtex-narrow-to-entry)
+    (bibtex-beginning-of-entry)
+    (while (re-search-forward "\\([^\\]\\)%\\([^[:xdigit:]]\\)" nil t)
+      (replace-match (concat "\\1"
+                             orcb-%-replacement-string
+                             "\\2")))))
+
+
+(defun orcb-key-comma ()
+  "Make sure there is a comma at the end of the first line."
+  (bibtex-beginning-of-entry)
+  (end-of-line)
+  ;; some entries do not have a key or comma in first line. We check and add it,
+  ;; if needed.
+  (unless (string-match ", *$" (thing-at-point 'line))
+    (end-of-line)
+    (insert ",")))
+
+
+(defun orcb-key (&optional allow-duplicate-keys)
+  "Replace the key in the entry.
+Prompts for replacement if the new key duplicates one already in
+the file, unless ALLOW-DUPLICATE-KEYS is non-nil."
+  (let ((key (funcall org-ref-clean-bibtex-key-function
+                     (bibtex-generate-autokey))))
+    ;; remove any \\ in the key
+    (setq key (replace-regexp-in-string "\\\\" "" key))
+    ;; first we delete the existing key
+    (bibtex-beginning-of-entry)
+    (re-search-forward bibtex-entry-maybe-empty-head)
+    (if (match-beginning bibtex-key-in-head)
+       (delete-region (match-beginning bibtex-key-in-head)
+                      (match-end bibtex-key-in-head)))
+    ;; check if the key is in the buffer
+    (when (and (not allow-duplicate-keys)
+               (save-excursion
+                 (bibtex-search-entry key)))
+      (save-excursion
+       (bibtex-search-entry key)
+       (bibtex-copy-entry-as-kill)
+       (switch-to-buffer-other-window "*duplicate entry*")
+       (bibtex-yank))
+      (setq key (bibtex-read-key "Duplicate Key found, edit: " key)))
+
+    (insert key)
+    (kill-new key)))
+
+
+(defun orcb-check-journal ()
+  "Check entry at point to see if journal exists in `org-ref-bibtex-journal-abbreviations'.
+If not, issue a warning."
+  (interactive)
+  (when
+      (string= "article"
+               (downcase
+                (cdr (assoc "=type=" (bibtex-parse-entry)))))
+    (save-excursion
+      (bibtex-beginning-of-entry)
+      (let* ((entry (bibtex-parse-entry t))
+             (journal (cdr (assoc "journal" entry))))
+        (when (null journal)
+          (warn "Unable to get journal for this entry."))
+        (unless (member journal (org-ref--flatten-list org-ref-bibtex-journal-abbreviations))
+          (message "Journal \"%s\" not found in org-ref-bibtex-journal-abbreviations." journal))))))
+
+
+(defun orcb-fix-spacing ()
+  "Delete whitespace and fix spacing between entries."
+  (let (beg end)
+    (save-excursion
+      (save-restriction
+       (widen)
+       (bibtex-beginning-of-entry)
+       (setq beg (point))
+       (bibtex-end-of-entry)
+       (setq end (if (re-search-forward bibtex-any-entry-maybe-empty-head nil t)
+                     (progn (beginning-of-line)
+                            (point))
+                   (point-max)))
+       ;; 1. delete whitespace
+       (narrow-to-region beg end)
+       (delete-trailing-whitespace)
+       ;; 2. delete consecutive empty lines
+       (goto-char end)
+       (while (re-search-backward "\n\n\n+" nil 'move)
+         (replace-match "\n\n"))
+       ;; 3. add one line between entries
+       (goto-char end)
+       (forward-line -1)
+       (when (looking-at "[}][ \t]*\\|@Comment.+\\|%.+")
+         (end-of-line)
+         (newline))))))
+
+
+(defun orcb-download-pdf ()
+  "Try to get the pdf in an entry."
+  ;; try to get pdf
+  (when doi-utils-download-pdf
+    (if doi-utils-async-download
+       (doi-utils-async-download-pdf)
+      (doi-utils-get-bibtex-entry-pdf))))
+
+
+(defun orcb-clean-<>-tags ()
+  "Try removing <tags> from the entry."
+  (sgml-mode)
+  (ignore-errors
+    (while (sgml-skip-tag-forward 1)
+      (sgml-skip-tag-backward 1)
+      (sgml-delete-tag 1)))
+  (bibtex-mode))
+
+
+;;;###autoload
+(defun org-ref-clean-bibtex-entry ()
+  "Clean and replace the key in a bibtex entry.
+See functions in `org-ref-clean-bibtex-entry-hook'."
+  (interactive)
+  (save-excursion
+    (save-restriction
+      (bibtex-narrow-to-entry)
+      (bibtex-beginning-of-entry)
+      ;; run hooks. each of these operates on the entry with no arguments.
+      ;; this did not work like  i thought, it gives a symbolp error.
+      ;; (run-hooks org-ref-clean-bibtex-entry-hook)
+      (mapc (lambda (x)
+             (save-restriction
+               (save-excursion
+                 (funcall x))))
+           org-ref-clean-bibtex-entry-hook))))
+
+
+;; * Missing functions in bibtex-completion
+;; I couldn't find these, and they seem useful.
+
+(defun org-ref-bibtex-get-entry (key)
+  "Return a parsed bibtex entry."
+  (save-window-excursion
+    (let ((bibtex-completion-bibliography (org-ref-find-bibliography)))
+      (bibtex-completion-show-entry (list key))
+      (bibtex-beginning-of-entry)
+      (bibtex-parse-entry))))
+
+
+(defun org-ref-bibtex-get-entry-value (key field)
+  "For the entry associated with KEY get the FIELD value."
+  (cdr (assoc field (org-ref-bibtex-get-entry key))))
+
+
+(defun org-ref-get-citation-year (key)
+  "Get the year of an entry with KEY.  Return year as a string."
+  (org-ref-bibtex-get-entry-value key "year"))
+
+
+;;* The end
+(provide 'org-ref-bibtex)
+
+;;; org-ref-bibtex.el ends here
+
+;; Local Variables:
+;; byte-compile-warnings: (not docstrings-wide)
+;; End:
diff --git a/elpa/org-ref-20251206.1422/org-ref-citation-links.el b/elpa/org-ref-20251206.1422/org-ref-citation-links.el
new file mode 100644 (file)
index 0000000..8c308e0
--- /dev/null
@@ -0,0 +1,1427 @@
+;;; org-ref-citation-links.el --- citation links for org-ref -*- lexical-binding: t; -*-
+;;
+;; Copyright (C) 2024  John Kitchin
+
+;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
+;; Keywords: convenience
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+;;
+;;; Commentary:
+;;
+;; This library provides hyper-functional citation links. These links can
+;; contain common pre/post notes, and multiple citation keys that each have
+;; their own pre/postnotes.
+;;
+;; These links are fontified to indicate if the citation keys are valid, and to
+;; indicate the pre/post-note structure. They also have tooltips that show
+;; information from the bibtex entry.
+;;
+;; Each link is functional, and clicking on one will open a transient menu
+;; `org-ref-citation-menu' of actions that range from opening the bibtex
+;; entry, notes, pdf or associated URL, to searching the internet for related
+;; articles.
+;;
+;; Each citation link also has a local keymap on it, which provides keyboard
+;; shortcuts for some actions like sorting, rearranging and navigating citation
+;; links. See `org-ref-cite-keymap' for the key bindings.
+;;
+;; Each link exports to a corresponding LaTeX citation command, or can be
+;; rendered with CSL for other kinds of exports like HTML, markdown, or ODT.
+;;
+;; This library also provides a minimal set of insertion functions that use
+;; completion. You can also use the org link completion mechanism to insert a
+;; citation.
+;;
+;; natmove like preprocessing is provided with `org-ref-cite-natmove'.
+;;
+;;; Code:
+(require 'org-keys)
+(require 'transient)
+(require 'xref)
+(eval-when-compile (require 'subr-x))
+
+(defvar bibtex-completion-cache)
+(declare-function bibtex-completion-format-citation-cite "bibtex-completion")
+(declare-function bibtex-completion-show-entry "bibtex-completion")
+
+(defgroup org-ref-faces nil
+  "A group for faces in `org-ref'."
+  :group 'org-ref-faces)
+
+
+(defface org-ref-cite-face
+  `((t (:inherit org-link
+                 :foreground "forest green")))
+  "Color for cite-like links in org-ref."
+  :group 'org-ref-faces)
+
+
+(defface org-ref-bad-cite-key-face
+  `((t (:inherit org-ref-cite-face
+                :foreground "red")))
+  "Color for bad cite keys in org-ref."
+  :group 'org-ref-faces)
+
+
+(defface org-ref-cite-global-prefix/suffix-face
+  `((t (:inherit org-ref-cite-face :weight bold)))
+  "Face for global prefix/suffix in a cite link."
+  :group 'org-ref-faces)
+
+
+(defface org-ref-cite-&-face
+  `((t (:inherit org-ref-cite-face :weight bold)))
+  "Face for the starting & in a cite key."
+  :group 'org-ref-faces)
+
+
+(defface org-ref-cite-local-prefix/suffix-face
+  `((t (:inherit org-ref-cite-face :slant italic)))
+  "Face for local prefix/suffix in a cite link."
+  :group 'org-ref-faces)
+
+
+(defface org-ref-cite-invalid-local-prefix/suffix-face
+  `((t (:inherit org-ref-cite-face :foreground "red")))
+  "Face for invalid local prefix/suffix in a cite link.
+This is mostly for multicites and natbib."
+  :group 'org-ref-faces)
+
+
+(defcustom org-ref-activate-cite-links t
+  "If non-nil use font-lock to activate citations.
+In large documents with many citations activation can be slow.
+Set this to nil to turn that off, which increase performance."
+  :type 'boolean
+  :group 'org-ref)
+
+
+(defcustom org-ref-default-citation-link
+  "cite"
+  "The default type of citation link to use."
+  :type 'string
+  :group 'org-ref)
+
+
+(defcustom org-ref-natbib-types
+  '(("cite" "basic citation")
+    ("nocite" "add key to bibliography, but do not cite it in the text")
+    ("citet" "textual, Jones et al. (1990)")
+    ("citet*" "textual, full author list Jones, Baker, and Williams (1990)")
+    ("citep" "parenthetical citation (Jones et al. (1990))")
+    ("citep*" "parenthetical, full author list, (Jones, Baker, and Williams, 1990)")
+    ("citealt" "same as citet, but without parentheses")
+    ("citealt*" "same as citet, with full author list but without parentheses")
+    ("citealp" "same as citep, but without parentheses")
+    ("citealp*" "same as citep, with full author list, but without parentheses")
+    ("citenum" "The number of the citation in the bibliography, e.g. 11")
+    ("citetext" "text inserted in citation in the document")
+    ("citeauthor" "Only the author, Jones et al.")
+    ("citeauthor*" "The full author list, Jones, Baker, and Williams")
+    ("citeyear" "The year of the citation, 2021")
+    ("citeyearpar" "The year in parentheses (2021)")
+    ("Citet" "like citet, but with forced capitalization for starting sentences")
+    ("Citep" "like citep, but with forced capitalization for starting sentences")
+    ("Citealt" "like citet, but with forced capitalization and no parentheses")
+    ("Citealp" "like citep, but with forced capitalization and no parentheses")
+    ("Citeauthor" "like citeauthor with forced capitalization")
+    ("Citet*" "like citet, with full author list and forced capitalization")
+    ("Citep*" "like citep, with full author list and forced capitalization")
+    ("Citealt*" "like citet, with full author list, forced capitalization and no parentheses")
+    ("Citealp*" "like citep, with full author list, forced capitalization and no parentheses")
+    ("Citeauthor*" "like citeauthor with forced capitalization"))
+  "Natbib commands can have many references, and global prefix/suffix text.
+  For natbib cite commands see
+  http://tug.ctan.org/macros/latex/contrib/natbib/natnotes.pdf"
+  :type '(repeat :tag "List of citation types" (list string string))
+  :group 'org-ref)
+
+
+(defcustom org-ref-biblatex-types
+  '(("Cite" "basic citation with capitalization")
+    ("parencite" "similar to cite with parentheses")
+    ("Parencite" "similar to cite with parentheses and capitalization")
+    ("footcite" "Put the citation in a footnote")
+    ("footcitetext" "Put the citation in a footnote using \footnotetext")
+
+    ("textcite" "print the authors or editors as a subject of the sentence")
+    ("Textcite" "print the authors or editors as a subject of the sentence with capitalization")
+    ("smartcite" "like parencite in a footnote, and footcite in the body")
+    ("Smartcite" "like parencite in a footnote, and footcite in the body with capitalization")
+    ("cite*" "similar to cite, but prints the year or title")
+    ("parencite*" "similar to parencite, but prints the year or title")
+    ("supercite" "superscripted numeric citation (only in numeric styles)")
+
+    ("autocite" "handles some punctuation nuances")
+    ("Autocite" "handles some punctuation nuances with punctuation")
+    ("autocite*" "same as autocite but * is passed to the backend")
+    ("Autocite*" "same as Autocite but * is passed to the backend")
+
+    ("citetitle" "the shorttitle or title field")
+    ("citetitle*" "the full title")
+
+    ("citeyear" "the year field")
+    ("citeyear*" "the year field and extradate information if available")
+
+    ("citedate" "the full date or year")
+    ("citedate*" "the full date or year, including extradate information if available")
+
+    ("citeurl" "the url field")
+
+    ("fullcite" "create a full citation similar to what is in the bibliography")
+    ("footfullcite" "create a full citation as a footnote")
+    ;; "volcite" "Volcite" cannot support the syntax
+    ("notecite" "print prenote and postnote, but no citation")
+    ("Notecite" "print prenote and postnote, but no citation with capitalization")
+
+    ("pnotecite" "similar to notecite with parentheses")
+    ("Pnotecite" "similar to Notecite with parentheses")
+    ("fnotecite" "similar to notecite in a footnote"))
+  "biblatex commands.
+  Biblatex commands
+  https://mirrors.ibiblio.org/CTAN/macros/latex/contrib/biblatex/doc/biblatex.pdf"
+  :type '(repeat :tag "List of citation types" string)
+  :group 'org-ref)
+
+
+(defcustom org-ref-biblatex-multitypes
+  '(("cites" "multicite version of cite")
+    ("Cites" "multicite version of Cite")
+    ("parencites" "multicite version of parencite")
+    ("Parencites" "multicite version of Parencite")
+    ("footcites" "multicite version of footcite")
+    ("footcitetexts" "multicite version of footcitetext")
+    ("smartcites" "multicite version of smartcite")
+    ("Smartcites" "multicite version of Smartcite")
+    ("textcites" "multicite version of textcite")
+    ("Textcites" "multicite version of Textcite")
+    ("supercites" "multicite version of supercite")
+    ("autocites" "multicite version of autocite")
+    ("Autocites" "multicite version of Autocite"))
+  "Multicite link types"
+  :type '(repeat :tag "List of citation types" string)
+  :group 'org-ref)
+
+
+(defcustom org-ref-cite-types
+  (append
+   org-ref-natbib-types
+   org-ref-biblatex-types
+   org-ref-biblatex-multitypes
+   ;; for the bibentry package
+   '(("bibentry" "Insert the bibtex entry")))
+  "List of citation types known in `org-ref'."
+  :type '(repeat :tag "List of citation types (type description)" (list string string))
+  :group 'org-ref)
+
+
+(defvar org-ref-insert-cite-function)
+
+(defcustom org-ref-cite-keymap
+  (let ((map (copy-keymap org-mouse-map)))
+    ;; Navigation keys
+    (define-key map (kbd "C-<left>") 'org-ref-previous-key)
+    (define-key map (kbd "C-<right>") 'org-ref-next-key)
+
+    ;; rearrangement keys
+    (define-key map (kbd "S-<left>") (lambda () (interactive) (org-ref-swap-citation-link -1)))
+    (define-key map (kbd "S-<right>") (lambda () (interactive) (org-ref-swap-citation-link 1)))
+    (define-key map (kbd "S-<up>") 'org-ref-sort-citation-link)
+    (define-key map (kbd "<tab>") (lambda ()
+                                   (interactive)
+                                   (funcall org-ref-insert-cite-function)))
+
+    ;; xref navigation
+    (define-key map (kbd "M-.") (lambda ()
+                                 (interactive)
+                                 (xref-push-marker-stack)
+                                 (org-ref-open-citation-at-point)))
+    map)
+  "Keymap for cite links."
+  :type 'symbol
+  :group 'org-ref)
+
+
+(defcustom org-ref-cite-insert-version 3
+  "Default version to insert citations with.
+  The default is 3. In legacy documents you might prefer 2 though,
+  so this variable can be buffer- or directory local if you want.
+
+  version 2 means the links are not bracketed, and comma-separated keys.
+
+  version 3 means the links are bracketed, with semicolon-separated
+  &keys."
+  :type 'number
+  :group 'org-ref)
+
+
+(defvar org-ref-citation-key-re
+  (rx-to-string
+   '(seq "&" (group-n 1 (one-or-more (any word "-.:?!`'/*@+|(){}<>&_^$#%~")))))
+  "Numbered regular expression for a version 3 cite key.
+  Key is in group 1.
+  Adapted from the expression in org-cite.")
+
+
+(defun org-ref-cite-version (path)
+  "Return the version for PATH.
+  PATH is from a cite link.
+  Version 2 is separated by commas and uses plain keys.
+  Version 3 is separated by semicolons and uses &keys.
+  I think that if there is a & in path, it must be version 3."
+  (if (string-match "&" path)
+      3
+    2))
+
+
+;; * Parsing/interpreting a citation path
+
+(defun org-ref-parse-cite-path (path)
+  "Return a data structure representing the PATH.
+  the data structure is a plist with (:version :prefix :suffix :references).
+  Each reference is a plist with (:key :prefix :suffix)."
+  (pcase (org-ref-cite-version path)
+    (2
+     ;; This will not have any prefix or suffix, since that was previously done in the desc.
+     (list :version 2 :references (cl-loop for key in (split-string path ",") collect
+                                          (list :key (string-trim key)))))
+    (3 (let ((citation-references (split-string path ";"))
+            (these-results '(:version 3)))
+        ;; if the first ref doesn't match a key, it must be a global prefix
+        ;; this pops the reference off.
+        (when (null (string-match org-ref-citation-key-re (cl-first citation-references)))
+          (setq these-results (append these-results (list :prefix (cl-first citation-references)))
+                citation-references (cdr citation-references)))
+
+        ;; if the last ref doesn't match a key, then it is a global suffix
+        ;; we remove the last one if this is true after getting the suffix.
+        (when (null (string-match org-ref-citation-key-re (car (last citation-references))))
+          (setq these-results (append these-results (list :suffix (car (last citation-references))))
+                citation-references (butlast citation-references)))
+
+        (setq these-results
+              (append these-results
+                      (list
+                       :references
+                       (cl-loop for s in citation-references collect
+                                (if (null (string-match org-ref-citation-key-re s))
+                                    (error "No matching key found in %s" s)
+                                  (let* ((key (match-string-no-properties 1 s))
+                                         (key-start (match-beginning 0))
+                                         (key-end (match-end 0))
+                                         (prefix (let ((p (substring s 0 key-start)))
+                                                   (if (string= "" (string-trim p))
+                                                       nil
+                                                     p)))
+                                         (suffix (let ((s (substring s key-end)))
+                                                   (if (string= "" (string-trim s))
+                                                       nil
+                                                     s))))
+                                    (list :key key :prefix prefix :suffix suffix)))))))))))
+
+
+(defun org-ref-interpret-cite-data (data)
+  "Interpret the DATA structure from `org-ref-parse-cite-path' back
+to a path string."
+  (pcase (plist-get data :version)
+    (2
+     (string-join (cl-loop for ref in (plist-get data :references) collect (plist-get ref :key)) ","))
+    (3
+     (concat
+      (when-let* ((prefix (plist-get data :prefix))) (concat prefix ";"))
+      (string-join (cl-loop for ref in (plist-get data :references) collect
+                           (concat
+                            (plist-get ref :prefix)
+                            "&" (plist-get ref :key)
+                            (plist-get ref :suffix)))
+                  ";")
+      (when-let* ((suffix (plist-get data :suffix))) (concat ";" suffix))))))
+
+
+;; * Activating citation links
+;;
+;; We use the activate-func for fontification of pieces of each link.
+
+
+(declare-function bibtex-completion-candidates "bibtex-completion")
+(declare-function bibtex-completion-init "bibtex-completion")
+(defvar bibtex-completion-bibliography)
+(defvar bibtex-completion-display-formats-internal)
+
+
+(defun org-ref-valid-keys ()
+  "Return a list of valid bibtex keys for this buffer.
+This is used a lot in `org-ref-cite-activate' so it needs to be
+fast, but also up to date."
+
+  ;; this seems to be needed, but we don't want to do this every time
+  ;; I found when bibtex-completion-display-formats-internal is nil
+  ;;  we have to run this init function
+  (unless bibtex-completion-display-formats-internal
+    (bibtex-completion-init))
+
+  (let* ((files (org-ref-find-bibliography)))
+    (if (seq-every-p 'identity
+                    (cl-loop for file in files
+                             collect (assoc file bibtex-completion-cache)))
+       ;; We have a cache for each file
+       ;; bibtex-completion-cache contains (filename md5hash entries)
+       (cl-loop for entry in
+                (cl-loop
+                 for file in files
+                 append (cddr (assoc file bibtex-completion-cache)))
+                collect (cdr (assoc "=key=" (cdr entry))))
+      ;; you need to get a cache because one or more of the files was not in the
+      ;; cache. The cache should be automatically made by
+      ;; bibtex-completion-candidates
+      (let ((bibtex-completion-bibliography files))
+       (cl-loop for entry in (bibtex-completion-candidates)
+                collect
+                (cdr (assoc "=key=" (cdr entry))))))))
+
+
+(defvar-local org-ref-valid-keys-hashes nil)
+(defvar-local org-ref-valid-keys-cache  nil)
+
+(defun org-ref-valid-keys-cached ()
+  "Update `org-ref-valid-keys-cache` only when files changed or it is empty.
+Returns a hash-table you can use to test key validity.
+
+(gethash key (org-ref-valid-keys-cached)"
+
+  (let ((local-hashes (cons bibtex-completion-bibliography
+                            (mapcar 'cadr bibtex-completion-cache))))
+    (when (or (null org-ref-valid-keys-cache)
+             (not (equal local-hashes org-ref-valid-keys-hashes)))
+      (setq-local org-ref-valid-keys-hashes local-hashes)
+      (setq-local org-ref-valid-keys-cache (make-hash-table :test 'equal))
+      (cl-loop for entry in (org-ref-valid-keys)
+               do
+               (puthash entry t org-ref-valid-keys-cache))))
+  org-ref-valid-keys-cache)
+
+
+(defun org-ref-cite-activate (start end path _bracketp)
+  "Activation function for a cite link.
+START and END are the bounds of the link.
+PATH has the citations in it."
+  (when (and org-ref-activate-cite-links
+            ;; Try avoid fontifying org-cite elements. this is based on the
+            ;; path containing @ which makes it likely to be an org-cite. Maybe
+            ;; a text property is better, in case this is an issue in the
+            ;; future.
+            (not (string-match-p (regexp-quote "@") path)))
+    (let* ((valid-keys (org-ref-valid-keys))
+          valid-key
+          substrings)
+      (goto-char start)
+      (pcase (org-ref-cite-version path)
+       (2
+        ;; This makes the brackets visible, but we only need it when there is a
+        ;; description.
+        (when (looking-at "\\[\\[\\(.*\\)\\]\\[\\(.*\\)\\]\\]")
+          (remove-text-properties start end '(invisible nil)))
+        (setq substrings (split-string path ","))
+        (cl-loop for key in substrings
+                 do
+                 ;; get to the substring
+                 (search-forward key end)
+                 (put-text-property (match-beginning 0)
+                                    (match-end 0)
+                                    'keymap
+                                    org-ref-cite-keymap)
+                 (put-text-property (match-beginning 0)
+                                    (match-end 0)
+                                    'cite-key
+                                    key)
+                 (unless (member (string-trim key) valid-keys)
+                   (put-text-property (match-beginning 0)
+                                      (match-end 0)
+                                      'face 'org-ref-bad-cite-key-face)
+                   (put-text-property (match-beginning 0)
+                                      (match-end 0)
+                                      'help-echo "Key not found"))))
+       (3
+        (setq substrings (split-string path ";"))
+        (cl-loop for i from 0 for s in substrings
+                 do
+                 ;; get to the substring
+                 (search-forward s end)
+                 (put-text-property (match-beginning 0)
+                                    (match-end 0)
+                                    'keymap
+                                    org-ref-cite-keymap)
+                 (let* (key-begin
+                        key-end
+                        key)
+
+                   ;; Look for a key. common pre/post notes do not have keys in them.
+                   (save-match-data
+                     (when (string-match org-ref-citation-key-re s)
+                       (setq key (match-string-no-properties 1 s)
+                             valid-key (member key valid-keys))))
+
+                   ;; these are global prefix/suffixes
+                   (when (and (or (= i 0)
+                                  (= i (- (length substrings) 1)))
+                              (null key))
+                     (put-text-property (match-beginning 0) (match-end 0)
+                                        'face 'org-ref-cite-global-prefix/suffix-face)
+                     (put-text-property (match-beginning 0) (match-end 0)
+                                        'help-echo "Global prefix/suffix"))
+
+                   ;; we have a key. we have to re-search to get its position
+                   (when key
+                     (save-excursion
+                       (save-match-data
+                         (search-backward (concat "&" key))
+                         (setq key-begin (match-beginning 0)
+                               key-end (match-end 0))))
+                     ;; mark the &
+                     (put-text-property key-begin (+ 1 key-begin)
+                                        'face 'org-ref-cite-&-face)
+                     ;; store key on the whole thing
+                     (put-text-property (match-beginning 0)
+                                        (match-end 0)
+                                        'cite-key
+                                        key)
+
+                     ;; fontify any prefix /suffix text
+                     (put-text-property (match-beginning 0) key-begin
+                                        'face 'org-ref-cite-local-prefix/suffix-face)
+
+                     (put-text-property key-end (match-end 0)
+                                        'face 'org-ref-cite-local-prefix/suffix-face)
+
+                     ;; bad key activation
+                     (unless valid-key
+                       (put-text-property key-begin key-end
+                                          'face 'font-lock-warning-face)
+                       (put-text-property key-begin key-end
+                                          'help-echo "Key not found"))))))))))
+
+
+;; * Following citation links
+
+(declare-function org-ref-get-bibtex-key-and-file "org-ref-core")
+
+(transient-define-prefix org-ref-citation-menu ()
+  "Citation actions."
+  [["Open"
+    ("o" "Bibtex" org-ref-open-citation-at-point)
+    ("p" "PDF" org-ref-open-pdf-at-point)
+    ("n" "Notes" org-ref-open-notes-at-point)
+    ("u" "URL" org-ref-open-url-at-point)]
+   ["WWW"
+    ("ww" "WOS" org-ref-wos-at-point)
+    ("wr" "WOS related" org-ref-wos-related-at-point)
+    ("wc" "WOS citing" org-ref-wos-citing-at-point)
+    ("wg" "Google Scholar" org-ref-google-scholar-at-point)
+    ("wp" "Pubmed" org-ref-pubmed-at-point)
+    ("wf" "Crossref" org-ref-crossref-at-point)
+    ("wb" "Biblio" org-ref-biblio-at-point)
+    ("e" "Email" org-ref-email-at-point)]
+   ["Copy"
+    ("K" "Copy bibtex" (lambda ()
+                         (interactive)
+                         (save-window-excursion
+                           (let ((bibtex-completion-bibliography (org-ref-find-bibliography)))
+                             (bibtex-completion-show-entry (list (org-ref-get-bibtex-key-under-cursor)))
+                             (bibtex-copy-entry-as-kill)
+                             (kill-new (pop bibtex-entry-kill-ring))))))
+    ("a" "Add pdf to library" org-ref-add-pdf-at-point)
+    ("k" "Copy key" (lambda ()
+                      (interactive)
+                      (kill-new (car (org-ref-get-bibtex-key-and-file)))))
+    ("f" "Copy formatted" (lambda ()
+                            (interactive)
+                            (kill-new (bibtex-completion-apa-format-reference
+                                      (org-ref-get-bibtex-key-under-cursor)))))
+    ("h" "Copy org heading" (lambda ()
+                              (interactive)
+                              (kill-new
+                               (format "* %s\n\n cite:&%s"
+                                       (bibtex-completion-apa-format-reference
+                                        (org-ref-get-bibtex-key-under-cursor))
+                                       (car (org-ref-get-bibtex-key-and-file))))))]
+   ["Edit"
+    ("<left>" "Shift left" org-ref-cite-shift-left :transient t)
+    ("<right>" "Shift right" org-ref-cite-shift-right :transient t)
+    ("<up>" "Sort by year" org-ref-sort-citation-link)
+    ("i" "Insert cite" (lambda () (interactive) (funcall org-ref-insert-cite-function)))
+    ("t" "Change cite type" org-ref-change-cite-type)
+    ("d" "Delete at point" org-ref-delete-citation-at-point)
+    ("r" "Replace cite" org-ref-replace-citation-at-point)
+    ("P" "Edit pre/suffix" org-ref-edit-pre-post-notes)]
+   ["Navigation"
+    ("[" "Previous key" org-ref-previous-key :transient t)
+    ("]" "Next key" org-ref-next-key :transient t)
+    ("v" "Visible key" org-ref-jump-to-visible-key :transient t)
+    ("q" "Quit" transient-quit-one)]])
+
+
+(defun org-ref-cite-follow (_path)
+  "Follow a cite link."
+  (org-ref-citation-menu))
+
+(define-obsolete-function-alias 'org-ref-citation-hydra/body
+  #'org-ref-citation-menu "3.1")
+
+
+;; * Citation links tooltips
+(defvar bibtex-completion-bibliography)
+(defvar bibtex-completion-pdf-symbol)
+(defvar bibtex-completion-notes-symbol)
+(defvar bibtex-completion-find-note-functions)
+
+(declare-function org-ref-find-bibliography "org-ref-core")
+(declare-function bibtex-completion-find-pdf "bibtex-completion")
+(declare-function bibtex-completion-apa-format-reference "bibtex-completion")
+
+(defun org-ref-cite-tooltip (_win _obj position)
+  "Get a tooltip for the cite at POSITION."
+  (let ((key (get-text-property position 'cite-key)))
+    (when key
+      (let* ((bibtex-completion-bibliography (org-ref-find-bibliography))
+            (has-pdf (when (bibtex-completion-find-pdf key) bibtex-completion-pdf-symbol))
+            (has-notes (when (cl-some #'identity
+                                      (mapcar (lambda (fn)
+                                                (funcall fn key))
+                                              bibtex-completion-find-note-functions))
+                         bibtex-completion-notes-symbol)))
+       (format "%s%s %s" (or has-pdf "") (or has-notes "")
+               (bibtex-completion-apa-format-reference key))))))
+
+
+;; * Exporting citation links
+
+(defun org-ref-cite-export (cmd path desc backend)
+  "Export a cite link.
+This supports the syntax:  \\cmd[optional prefix][optional suffix]{keys}
+The prefix and suffix must be the global version. Local prefix/suffixes are ignored.
+PATH contains the link path.
+BACKEND is the export backend.
+Use with apply-partially."
+  (pcase backend
+    ('latex
+     (let* ((cite (org-ref-parse-cite-path path))
+           (references (plist-get cite :references))
+           (keys (cl-loop for ref in references collect
+                          (plist-get ref :key))))
+       (pcase (org-ref-cite-version path)
+        (2
+         (let* ((prefix-suffix (split-string (or desc "") "::"))
+                (prefix (cond
+                         ((and (cl-first prefix-suffix) (not (string= "" (cl-first prefix-suffix))))
+                          (format "[%s]" (cl-first prefix-suffix)))
+                         ((cl-second prefix-suffix)
+                          "[]")
+                         (t
+                          "")))
+                (suffix (cond
+                         ((cl-second prefix-suffix)
+                          (format "[%s]" (cl-second prefix-suffix)))
+                         (t
+                          ""))))
+           (org-ref--format-template "\\${cmd}${prefix}${suffix}{${keys}}"
+                     `(("cmd" . ,cmd)
+                       ("prefix" . ,(string-trim prefix))
+                       ("suffix" . ,(string-trim suffix))
+                       ("keys" . ,(string-join keys ","))))))
+        (3
+         (org-ref--format-template "\\${cmd}${prefix}${suffix}{${keys}}"
+                   `(("cmd" . ,cmd)
+                     ;; if there is more than one key, we only do global
+                     ;; prefix/suffix But for one key, we should allow local
+                     ;; prefix and suffix or the global one.
+                     ("prefix" . ,(if (= 1 (length references))
+                                      ;; single reference
+                                      (cond
+                                       ;; global and common prefixes exist, combine them
+                                       ((and (plist-get cite :prefix)
+                                             (plist-get (car references) :prefix))
+
+                                        (concat "["
+                                                (plist-get cite :prefix)
+                                                ";" ;; add this back as a separator
+                                                (plist-get (car references) :prefix)
+                                                "]"))
+                                       ;; local prefix is not empty, we use it.
+                                       ((plist-get (car references) :prefix)
+                                        (concat "["
+                                                (string-trim (plist-get (car references) :prefix))
+                                                "]"))
+                                       ;; local prefix is empty, but global one
+                                       ;; is not, so we use it
+                                       ((plist-get cite :prefix)
+                                        (concat "["
+                                                (string-trim (plist-get cite :prefix))
+                                                "]"))
+                                       ;; if you have a suffix, you need an empty prefix
+                                       ((plist-get cite :suffix)
+                                        "[]")
+                                       (t
+                                        ""))
+                                    ;; Multiple references
+                                    (cond
+                                     ;; Check the common prefix
+                                     ((plist-get cite :prefix)
+                                      (concat "["
+                                              (string-trim (plist-get cite :prefix))
+                                              "]"))
+                                     ;; Check the prefix in the first cite
+                                     ((plist-get (car references) :prefix)
+                                      (concat "["
+                                              (string-trim (plist-get (car references) :prefix))
+                                              "]"))
+                                     ;; if you get here, the prefix is empty.
+                                     ;; if you have a suffix, you need an empty prefix placeholder
+                                     ((plist-get cite :suffix)
+                                      "[]")
+                                     (t
+                                      ""))))
+                     ("suffix" . ,(if (= 1 (length references))
+                                      ;; Single reference
+                                      (cond
+                                       ;; local suffix is not empty, so use it
+                                       ((plist-get (car references) :suffix)
+                                        (format "[%s]"
+                                                (string-trim (plist-get (car references) :suffix))))
+                                       ;; global suffix is not empty
+                                       ((plist-get cite :suffix)
+                                        (format "[%s]" (string-trim (plist-get cite :suffix))))
+                                       (t
+                                        ;; If there is a prefix, then this should
+                                        ;; be an empty bracket, and if not it
+                                        ;; should am empty string. You need an
+                                        ;; empty bracket, at least for biblatex
+                                        ;; commands. With just one set of
+                                        ;; brackets it is interpreted as a
+                                        ;; suffix.
+                                        (if (or (plist-get cite :prefix)
+                                                (plist-get (car references) :prefix))
+                                            "[]"
+                                          "")))
+                                    ;; Multiple references
+                                    (cond
+                                     ;; this is a common suffix
+                                     ((plist-get cite :suffix)
+                                      (format "[%s]" (string-trim (plist-get cite :suffix))))
+                                     ;; last reference has a suffix
+                                     ((plist-get (car (last references)) :suffix)
+                                      (format "[%s]" (string-trim (plist-get (car (last references)) :suffix))))
+                                     (t
+                                      ;; If there is a prefix, then this should
+                                      ;; be an empty bracket, and if not it
+                                      ;; should am empty string. You need an
+                                      ;; empty bracket, at least for biblatex
+                                      ;; commands. With just one set of
+                                      ;; brackets it is interpreted as a
+                                      ;; suffix.
+                                      (if (or (plist-get cite :prefix)
+                                              (plist-get (car references) :prefix))
+                                          "[]"
+                                        "")))))
+                     ("keys" . ,(string-join keys ","))))))))))
+
+
+(defun org-ref-multicite-export (cmd path _desc backend)
+  "Export a multicite link.
+This supports the syntax:  \\cmd(multiprenote)(multipostnote)[prenote][postnote]{key1}...[prenote][postnote]{key}
+PATH contains the link path.
+BACKEND is the export backend.
+Use with apply-partially."
+  (pcase backend
+    ('latex
+     (let ((cite (org-ref-parse-cite-path path)))
+       (org-ref--format-template "\\${cmd}${global-prefix}${global-suffix}${keys}"
+                `(("cmd" . ,cmd)
+                  ("global-prefix" . ,(cond
+                                       ((plist-get cite :prefix)
+                                        (concat "(" (plist-get cite :prefix) ")"))
+                                       ;; if you have a suffix, you need an empty prefix
+                                       ((plist-get cite :suffix)
+                                        "()")
+                                       (t
+                                        "")))
+                  ("global-suffix" . ,(if (not (string= "" (or (plist-get cite :suffix) "")))
+                                          (format "(%s)" (plist-get cite :suffix))
+                                        ""))
+                  ("keys" . ,(string-join
+                              (cl-loop for ref in (plist-get cite :references)
+                                       collect
+                                       (format "%s%s{%s}"
+                                               (cond
+                                                ;; we have a prefix, stick it in
+                                                ((not (string= ""
+                                                               (or (plist-get ref :prefix) "")))
+                                                 (concat "[" (plist-get ref :prefix) "]"))
+                                                ;; no prefix, but a suffix, so
+                                                ;; empty prefix for placeholder
+                                                ((not (string= ""
+                                                               (or (plist-get ref :suffix) "")))
+                                                 "[]")
+                                                (t
+                                                 ""))
+                                               (cond
+                                                ((not (string= ""
+                                                               (or (plist-get ref :suffix) "")))
+                                                 (concat "[" (plist-get ref :suffix) "]"))
+                                                (t
+                                                 ""))
+                                               (plist-get ref :key)))))))))))
+
+;; * Completion for citation links
+;;
+;; This allows you to type C-c l, choose a cite link type, and then insert a key.
+
+(defun org-ref-cite-link-complete (cmd &optional _arg)
+  "Cite link completion for CMD."
+  (concat
+   cmd ":"
+   "&" (org-ref-read-key)))
+
+;; * Generate all the links
+;;
+;; We loop on the three categories because there are some differences between
+;; them, mostly in the multitypes.
+
+(cl-loop for (cmd _desc) in (append org-ref-natbib-types
+                                   org-ref-biblatex-types)
+        do
+        (org-link-set-parameters
+         cmd
+         :complete (apply-partially #'org-ref-cite-link-complete cmd)
+         :follow #'org-ref-cite-follow
+         :face 'org-ref-cite-face
+         :help-echo #'org-ref-cite-tooltip
+         :export (apply-partially 'org-ref-cite-export  cmd)
+         :activate-func #'org-ref-cite-activate))
+
+
+(cl-loop for (cmd _desc) in org-ref-biblatex-multitypes do
+        (org-link-set-parameters
+         cmd
+         :complete (apply-partially #'org-ref-cite-link-complete cmd)
+         :follow #'org-ref-cite-follow
+         :face 'org-ref-cite-face
+         :help-echo #'org-ref-cite-tooltip
+         :export (apply-partially 'org-ref-multicite-export cmd)
+         :activate-func #'org-ref-cite-activate))
+
+
+(org-link-set-parameters
+ "bibentry"
+ :complete (apply-partially #'org-ref-cite-link-complete "bibentry")
+ :follow #'org-ref-cite-follow
+ :face 'org-ref-cite-face
+ :help-echo #'org-ref-cite-tooltip
+ :export (apply-partially 'org-ref-cite-export  "bibentry")
+ :activate-func #'org-ref-cite-activate)
+
+
+;; * Cite link utilities
+
+;;;###autoload
+(defun org-ref-delete-citation-at-point ()
+  "Delete the citation or reference at point."
+  (interactive)
+  (let* ((object (org-element-context))
+         (type (org-element-property :type object))
+         (begin (org-element-property :begin object))
+         (end (org-element-property :end object))
+         (link-string (org-element-property :path object))
+        (data (org-ref-parse-cite-path link-string))
+        (references (plist-get data :references))
+        (cp (point))
+         key i)
+    ;;   We only want this to work on citation links
+    (when (assoc type org-ref-cite-types)
+      (setq key (org-ref-get-bibtex-key-under-cursor))
+      (if (null key)
+         ;; delete the whole cite
+         (cl--set-buffer-substring begin end "")
+       (setq i (seq-position references key (lambda (el key)
+                                              (string= key (plist-get el :key)))))
+       ;; delete i'th reference
+       (setq references (org-ref--remove-at i references))
+       (setq data (plist-put data :references references))
+       (save-excursion
+         (goto-char begin)
+         (re-search-forward link-string)
+         (replace-match (org-ref-interpret-cite-data data)))
+       (goto-char cp)))))
+
+
+;;;###autoload
+(defun org-ref-replace-citation-at-point ()
+  "Replace the citation at point."
+  (interactive)
+  (let* ((object (org-element-context))
+         (type (org-element-property :type object))
+         (begin (org-element-property :begin object))
+         (end (org-element-property :end object))
+         (link-string (org-element-property :path object))
+        (data (org-ref-parse-cite-path link-string))
+        (references (plist-get data :references))
+        (cp (point))
+         key i)
+    ;;   We only want this to work on citation links
+    (when (assoc type org-ref-cite-types)
+      (setq key (org-ref-get-bibtex-key-under-cursor))
+
+      (if (null key)
+         ;; delete the whole cite
+         (cl--set-buffer-substring begin end "")
+       (setq i (seq-position references key (lambda (el key) (string= key (plist-get el :key))))) ;; defined in org-ref
+       (setf (plist-get (nth i references) :key)  (org-ref-read-key))
+
+       (setq data (plist-put data :references references))
+       (save-excursion
+         (goto-char begin)
+         (re-search-forward link-string)
+         (replace-match (org-ref-interpret-cite-data data)))
+       (goto-char cp)))))
+
+
+;;;###autoload
+(defun org-ref-edit-pre-post-notes (&optional common)
+  "Edit the pre/post notes at point.
+
+if you are not on a key, or with optional prefix
+arg COMMON, edit the common prefixes instead."
+  (interactive "P")
+  ;; find out what the point is on.
+  (let* ((key (get-text-property (point) 'cite-key))
+        (cp (point))
+        (cite (org-element-context))
+        (type (org-element-property :type cite))
+        (data (org-ref-parse-cite-path (org-element-property :path cite)))
+        prefix suffix
+        (delta 0))
+
+    (if (or (null key) common)
+       (progn
+         (setq prefix (read-string "prenote: " (plist-get data :prefix))
+               suffix (read-string "postnote: " (plist-get data :suffix))
+               delta (- (length (plist-get data :prefix)) (length prefix)))
+
+         (plist-put data :prefix (if (string= "" prefix)
+                                     nil prefix))
+
+         (plist-put data :suffix (if (string= "" suffix)
+                                     nil suffix)))
+
+      ;; On a key
+      (let ((index (seq-position (plist-get data :references)
+                                key
+                                (lambda (el1 key-at-point)
+                                  (string= key-at-point (plist-get el1 :key))))))
+       ;; Pad with spaces after prefix and before suffix
+       (setq prefix (concat
+                     (read-string "prenote: "
+                                  (string-trim
+                                   (or
+                                    (plist-get
+                                     (nth index (plist-get data :references))
+                                     :prefix)
+                                    "")))
+                     " ")
+             suffix (concat " "
+                            (read-string "postnote: "
+                                         (string-trim
+                                          (or
+                                           (plist-get
+                                            (nth index (plist-get data :references))
+                                            :suffix)
+                                           ""))))
+             delta (- (length (plist-get
+                               (nth index (plist-get data :references))
+                               :prefix))
+                      (length prefix)))
+       (plist-put
+        (nth index (plist-get data :references))
+        :prefix (if (string= "" prefix)
+                    nil prefix))
+
+       (plist-put
+        (nth index (plist-get data :references))
+        :suffix (if (string= "" suffix)
+                    nil suffix))))
+
+
+    (cl--set-buffer-substring (org-element-property :begin cite) (org-element-property :end cite)
+                             (format "[[%s:%s]]" type (org-ref-interpret-cite-data data)))
+
+    ;; This doesn't exactly save the point. I need a fancier calculation for
+    ;; that I think that accounts for the change due to the prefix change. e.g.
+    ;; you might add or subtract from the prefix.
+    (goto-char (- cp delta))))
+
+
+(declare-function org-element-create "org-element")
+
+;;;###autoload
+(defun org-ref-change-cite-type ()
+  "Change the cite type of citation link at point."
+  (interactive)
+  (let* ((type-annotation (lambda (s)
+                           (let ((item (assoc s minibuffer-completion-table)))
+                             (when item (concat
+                                         (make-string (- 12 (length s)) ? )
+                                         "-- "
+                                         (cl-second item))))))
+        (completion-extra-properties `(:annotation-function ,type-annotation))
+        (new-type (completing-read "Type: " org-ref-cite-types))
+        (cite-link (org-element-context))
+        (cp (point)))
+    (cl--set-buffer-substring
+     (org-element-property :begin cite-link)
+     (org-element-property :end cite-link)
+     (org-element-interpret-data
+      (org-element-create 'link
+                         `(:type ,new-type
+                                 :path ,(org-element-property :path cite-link)
+                                 :contents-begin ,(org-element-property :contents-begin cite-link)
+                                 :contents-end ,(org-element-property :contents-end  cite-link)))))
+    (goto-char cp)))
+
+
+(defun org-ref-get-bibtex-key-under-cursor ()
+  "Return key under the cursor in org-mode.
+If not on a key, but on a cite, prompt for key."
+  (cond
+   (org-ref-activate-cite-links
+    (if-let* ((key (get-text-property (point) 'cite-key)))
+       ;; Point is on a key, so we get it directly
+       key
+      ;; point is not on a key, but may still be on a cite link
+      (let ((el (org-element-context))
+           (cp (point))
+           data
+           keys)
+       (cond
+        ;; on a cite-link type
+        ((and
+          (eq (org-element-type el) 'link)
+          (assoc (org-element-property :type el) org-ref-cite-types))
+
+         (goto-char (org-element-property :begin el))
+         (setq data (org-ref-parse-cite-path (org-element-property :path el))
+               keys (cl-loop for ref in (plist-get data :references)
+                             collect (plist-get ref :key)))
+         (cond
+          ((= 1 (length keys))
+           (search-forward (car keys))
+           (goto-char (match-beginning 0)))
+          ;; multiple keys
+          (t
+           (setq key (completing-read "Key: " keys))
+           (search-forward key)
+           (goto-char (match-beginning 0))))
+         (prog1
+             (get-text-property (point) 'cite-key)
+           (goto-char cp)))
+
+        ;; somewhere else, but looking at a cite-type see issue #908. links in
+        ;; places like keywords are not parsed as links, but they seem to get
+        ;; activated, so we can just get onto the key, and then open it.
+        ((assoc (thing-at-point 'word) org-ref-cite-types)
+         (save-excursion
+           (when (re-search-forward ":" (line-end-position) t)
+             (prog1
+                 (get-text-property (point) 'cite-key)
+               (goto-char cp)))))))))
+
+   ;; org-ref-activate-cite-links is nil so font-lock does not put
+   ;; text-properties on keys. We temporarily activate this
+
+   (t
+    (let ((el (org-element-context))
+         (org-ref-activate-cite-links t)) ;; temporary
+      (when (and
+            (eq (org-element-type el) 'link)
+            (assoc (org-element-property :type el) org-ref-cite-types))
+       (save-excursion
+         ;; We activate just this one link
+         (org-ref-cite-activate
+          (org-element-property :begin el)
+          (org-element-property :end el)
+          (org-element-property :path el)
+          nil)))
+      ;; Now we have to handle some cases.
+      (cond
+       ;; on a key, return a key
+       ((get-text-property (point) 'cite-key)
+       (get-text-property (point) 'cite-key))
+       ;; not on a key, but on a cite. this is lazy, but we just search forward
+       ;; to the first key
+       (t
+       (search-forward ":")
+       (get-text-property (point) 'cite-key)))))))
+
+
+;; ** Shift-arrow sorting of keys in a cite link
+
+(defun org-ref-swap-list-elements (i j lst)
+  "Swap index I and J in the list LST."
+  (let ((tempi (nth i lst)))
+    (setf (nth i lst) (nth j lst))
+    (setf (nth j lst) tempi))
+  lst)
+
+
+(defun org-ref-swap-citation-link (direction)
+  "Move citation at point in DIRECTION +1 is to the right, -1 to the left."
+  (let* ((object (org-element-context))
+         (type (org-element-property :type object))
+         (begin (org-element-property :begin object))
+         ;; (end (org-element-property :end object))
+         (link-string (org-element-property :path object))
+        (data (org-ref-parse-cite-path link-string))
+        (references (plist-get data :references))
+         key i)
+    ;;   We only want this to work on citation links
+    (when (assoc type org-ref-cite-types)
+      (setq key (org-ref-get-bibtex-key-under-cursor))
+      (setq i (seq-position references key (lambda (el key) (string= key (plist-get el :key))))) ;; defined in org-ref
+      (if (> direction 0) ;; shift right
+          (org-ref-swap-list-elements i (min (+ i 1) (- (length references) 1)) references)
+        (org-ref-swap-list-elements i (max (- i 1) 0) references))
+      (setq data (plist-put data :references references))
+
+      ;; and replace the link with the sorted keys
+      (save-excursion
+       (goto-char begin)
+       (re-search-forward link-string)
+       (replace-match (org-ref-interpret-cite-data data)))
+      ;; now go forward to key so we can move with the key
+      (goto-char begin)
+      (re-search-forward key)
+      (goto-char (match-beginning 0)))))
+
+
+(defun org-ref-cite-shift-left ()
+  "Shift reference at point to the left."
+  (interactive)
+  (org-ref-swap-citation-link -1))
+
+
+(defun org-ref-cite-shift-right ()
+  "Shift citation at point to the right."
+  (interactive)
+  (org-ref-swap-citation-link +1))
+
+
+;;** Sort cite in cite link
+
+;;;###autoload
+(defun org-ref-sort-citation-link ()
+  "Replace link at point with sorted link by year."
+  (interactive)
+  (let* ((object (org-element-context))
+         ;; (type (org-element-property :type object))
+         (begin (org-element-property :begin object))
+         ;; (end (org-element-property :end object))
+         (link-string (org-element-property :path object))
+        (data (org-ref-parse-cite-path link-string))
+        (references (plist-get data :references))
+        (bibtex-completion-bibliography (org-ref-find-bibliography))
+        current-point)
+
+    (setq references (cl-sort (cl-loop for ref in references collect
+                                      (append ref (list :year (bibtex-completion-get-value
+                                                               "year"
+                                                               (bibtex-completion-get-entry
+                                                                (plist-get ref :key))))))
+                             (lambda (x y)
+                               (< (string-to-number (plist-get x :year))
+                                  (string-to-number (plist-get y :year))))))
+    (setq data (plist-put data :references references)
+         current-point (point))
+    (goto-char begin)
+    (re-search-forward link-string)
+    (replace-match (org-ref-interpret-cite-data data))
+    (goto-char current-point)))
+
+
+;;** C-arrow navigation of cite keys
+;;
+;; These are a little tricky to understand to me. There are two calls because
+;; when you are on a cite, and move, the first change is the boundary of the
+;; current cite, and the second is the boundary of next cite.
+
+;;;###autoload
+(defun org-ref-next-key ()
+  "Move cursor to the next cite key when on a cite link.
+Otherwise run `right-word'. If the cursor moves off the link,
+move to the beginning of the next cite link after this one."
+  (interactive)
+  (when-let* ((next (next-single-property-change (point) 'cite-key)))
+    (goto-char next))
+  (unless (get-text-property (point) 'cite-key)
+    (when-let* ((next (next-single-property-change (point) 'cite-key)))
+      (goto-char next))))
+
+
+;;;###autoload
+(defun org-ref-previous-key ()
+  "Move cursor to the previous cite key when on a cite link.
+Otherwise run `left-word'. If the cursor moves off the link,
+move to the beginning of the previous cite link after this one."
+  (interactive)
+  (when-let* ((prev (previous-single-property-change (point) 'cite-key)))
+    (goto-char prev))
+  (unless (get-text-property (point) 'cite-key)
+    (when-let* ((prev (previous-single-property-change (point) 'cite-key)))
+      (goto-char prev))))
+
+(defvar avy-goto-key)
+(defvar avy-style)
+(declare-function avy--style-fn "avy")
+(declare-function avy-process "avy")
+(declare-function avy-with "avy")
+(declare-function org-element-parse-buffer "org-element")
+(declare-function org-element-property "org-element")
+(declare-function org-element-type "org-element")
+(declare-function org-element-map "org-element")
+(declare-function bibtex-completion-get-value "bibtex-completion")
+(declare-function bibtex-completion-get-entry "bibtex-completion")
+
+;;;###autoload
+(defun org-ref-jump-to-visible-key ()
+  "Jump to a visible key with avy."
+  (interactive)
+  (avy-with avy-goto-key
+    (avy-process
+     (apply #'append
+           (save-excursion
+             (org-element-map (org-element-parse-buffer) 'link
+               (lambda (c)
+                 (when (assoc (org-element-property :type c) org-ref-cite-types)
+                   (goto-char (org-element-property :begin c))
+                   (let* ((path (org-element-property :path c))
+                          (data (org-ref-parse-cite-path path))
+                          (references (plist-get data :references)))
+                     (append (list (org-element-property :begin c))
+                             (cl-loop for ref in references collect
+                                      (progn
+                                        (search-forward (plist-get ref :key))
+                                        (match-beginning 0)))))))))))
+    (avy--style-fn avy-style)))
+
+
+;; * Insert links
+(declare-function bibtex-completion-format-entry "bibtex-completion")
+
+;; The formatting is adapted from ivy-bibtex-transformer. I feel like it is
+;; slower than ivy-bibtex though. It is completion agnostic though...
+(defun org-ref-read-key ()
+  "Read a key with completion."
+  (unless bibtex-completion-display-formats-internal
+    (bibtex-completion-init))
+  (let* ((bibtex-completion-bibliography (org-ref-find-bibliography))
+        (candidates (mapcar (lambda (entry)
+                              (cons (bibtex-completion-format-entry entry (1- (frame-width)))
+                                    (cdr entry)))
+                            (bibtex-completion-candidates)))
+        (choice (completing-read "org-ref BibTeX entries: " candidates)))
+    (cdr (assoc "=key=" (assoc choice candidates)))))
+
+
+(defun org-ref-insert-cite-key (key &optional set-type)
+  "Insert KEY at point as a cite link.
+With optional prefix SET-TYPE choose the link type (only on initial insert).
+Rules:
+1. at beginning of key, insert before it.
+2. at middle or end of key, insert after it."
+  (let* ((object (org-element-context))
+        (type (org-element-property :type object))
+        ;; (cp (point))
+        link-string version data references key-at-point index
+        (type-annotation (lambda (s)
+                           (let ((item (assoc s minibuffer-completion-table)))
+                             (when item (concat
+                                         (make-string (- 12 (length s)) ? )
+                                         "-- "
+                                         (cl-second item))))))
+        (completion-extra-properties `(:annotation-function ,type-annotation)))
+
+    (cond
+     ((derived-mode-p 'latex-mode)
+      (insert (bibtex-completion-format-citation-cite (list key))))
+     (t
+    (cond
+     ;; Not on a link, so we just insert a cite
+     ((null (assoc type org-ref-cite-types))
+      (insert (format "[[%s:%s%s]]"
+                     (if set-type
+                         (completing-read "cite type: " org-ref-cite-types)
+                       org-ref-default-citation-link)
+                     (pcase org-ref-cite-insert-version
+                       (2 "")
+                       (3 "&"))
+                     key)))
+     ;; On a link with no path
+     ;; See https://github.com/jkitchin/org-ref/issues/951#issuecomment-985998821
+     ;; This is an unusual corner case most often triggered by a snippet, although
+     ;; perhaps there is some scenario like [[cite:]]
+     ((string= "" (org-element-property :path object))
+      (unless (looking-back ":" 1)
+       (goto-char (org-element-property :end object))
+       (skip-chars-backward "]"))
+      (insert (concat
+              (pcase org-ref-cite-insert-version
+                (2 "")
+                (3 "&"))
+              key)))
+
+     ;; On a link somewhere, and we need to figure out what to do.
+     (t
+      (setq link-string (org-element-property :path object)
+           version (org-ref-cite-version link-string)
+           data (org-ref-parse-cite-path link-string)
+           references (plist-get data :references)
+           key-at-point (get-text-property (point) 'cite-key))
+
+      ;; There are two scenarios where key-at-point is null
+      ;; 1. on the link-type before the :
+      ;; 2. at the end of the link
+      ;; Either way we just go to the end.
+      (when (null key-at-point)
+       ;; that failed, so move to the last one This seems weird, but when you
+       ;; insert several marked candidates the point does weird things.
+       (goto-char (org-element-property :end object))
+       (skip-chars-backward " ")
+       (setq key-at-point (plist-get (car (last references)) :key)))
+
+
+      ;; this is index of selected key
+      (setq index (seq-position references key-at-point
+                               (lambda (el1 key-at-point)
+                                 (string= key-at-point (plist-get el1 :key)))))
+
+      (setq data (plist-put data :references
+                           (org-ref--insert-at
+                            (+ index (if (and (= 3 version) (looking-at "&"))
+                                         0
+                                       1))
+                            (list :key key) references)))
+
+      (pcase org-ref-cite-insert-version
+       (2
+        (cl--set-buffer-substring
+         (org-element-property :begin object)
+         (org-element-property :end object)
+         (concat type ":" (string-join (cl-loop for ref in (plist-get data :references)
+                                                collect (plist-get ref :key))
+                                       ","))))
+       (3 (cl--set-buffer-substring
+           (org-element-property :begin object)
+           (org-element-property :end object)
+           (concat "[["
+                   type ":"
+                   (org-ref-interpret-cite-data data)
+                   "]]"
+                   (make-string (org-element-property :post-blank object) ? )))))))
+
+    ;; Now get to the end of the key you just put in.
+    (setq object (org-element-context))
+    (goto-char (org-element-property :end object))
+    (skip-chars-backward " ")))))
+
+
+(defun org-ref-insert-cite-keys (keys &optional set-type)
+  "Insert KEYS as citation links.
+Optional SET-TYPE to choose the cite type."
+  (cl-loop for key in keys
+          do
+          (org-ref-insert-cite-key key set-type)))
+
+
+;;;###autoload
+(defun org-ref-insert-cite-link (&optional set-type)
+  "Insert a cite link with completion.
+Optional prefix arg SET-TYPE to choose the cite type."
+  (interactive "P")
+  (org-ref-insert-cite-key (org-ref-read-key) set-type))
+
+
+;; * natmove like pre-processing
+;;
+;; I think that citations belong in the sentence where they are used, which
+;; means on the left side of punctuation. However, for some citation styles,
+;; especially superscripts, it is nicer if they appear on the right hand side of
+;; punctuation. achemso in LaTeX provides natmove
+;; (https://ctan.org/pkg/natmove?lang=en) for this. It doesn't seem to work for
+;; all LaTeX styles though, and in particular only works on the cite command
+;; itself. So, Here is a preprocessor function you can use to move all the
+;; cites.
+
+(declare-function org-ref-get-cite-links "org-ref-export")
+
+(defun org-ref-cite-natmove (_backend)
+  "Move citations to the right side of punctuation.
+Intended for use in `org-export-before-parsing-hook'.
+
+Here is an example use:
+
+  (let ((org-export-before-parsing-hook '(org-ref-cite-natmove)))
+    (org-open-file (org-latex-export-to-pdf)))"
+  (let ((cites (org-ref-get-cite-links))
+       punct)
+    (cl-loop for cite in (reverse cites) do
+            (goto-char (org-element-property :end cite))
+            (skip-chars-backward " ")
+            (when (string-match-p "[[:punct:]]" (buffer-substring (point) (+ (point) 1)))
+              (setq punct (buffer-substring (point) (+ (point) 1)))
+              ;; delete the punctuation
+              (cl--set-buffer-substring (point) (+ (point) 1) "")
+              ;; and insert it at the beginning of the link.
+              (goto-char (org-element-property :begin cite))
+              ;; delete spaces backward
+              (skip-chars-backward " ")
+              (cl--set-buffer-substring (point) (org-element-property :begin cite) "")
+              (insert punct)))))
+
+;; * Convert version 2 to version 3
+
+(defun org-ref-v2-cites-to-v3 ()
+  "Replace version 2 citation syntax with version 3 citation syntax"
+  (interactive)
+  (cl-loop for cite in (reverse (org-ref-get-cite-links))
+          collect
+          (let ((data (org-ref-parse-cite-path (org-element-property :path cite)))
+                prefix-suffix)
+            (when (org-element-property :contents-begin cite)
+              (setq prefix-suffix (split-string (buffer-substring (org-element-property :contents-begin cite)
+                                                                  (org-element-property :contents-end cite))
+                                                "::"))
+              (plist-put data :prefix (cl-first prefix-suffix))
+              (plist-put data :suffix (cl-second prefix-suffix)))
+            (plist-put data :version  3)
+            (cl--set-buffer-substring (org-element-property :begin cite)
+                                      (org-element-property :end cite)
+                                      (format "[[%s:%s]]" (org-element-property :type cite)
+                                              (org-ref-interpret-cite-data data))))))
+
+
+(provide 'org-ref-citation-links)
+
+;;; org-ref-citation-links.el ends here
+
+;; Local Variables:
+;; byte-compile-warnings: (not docstrings docstrings-wide)
+;; End:
diff --git a/elpa/org-ref-20251206.1422/org-ref-compat.el b/elpa/org-ref-20251206.1422/org-ref-compat.el
new file mode 100644 (file)
index 0000000..da287aa
--- /dev/null
@@ -0,0 +1,94 @@
+;;; org-ref-compat.el --- Compatibility functions for org-cite -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;;
+;; The main function of this library is to provide compatibility functions for
+;; converting between org-ref and org-cite.
+
+(require 'org-ref-export)
+
+
+(defcustom org-ref-to-org-cite-mapping
+  '(("cite" . "")
+    ("citep" . "")
+    ("Citep" . "//caps-full")
+    ("citealp" . "//bare")
+    ("Citealp" . "//bare-caps")
+    ("Citealp*" . "//bare-caps-full")
+    ("citep*" . "//full")
+
+    ("citet" . "/text")
+
+    ("citeyear" . "/noauthor/bare")
+    ("citeyearpar" . "/noauthor")
+    
+    ("nocite" . "/nocite")
+
+    ("citeauthor" . "/author")
+    ("citeauthor*" . "/author/full")
+    ("Citeauthor" . "/author/caps"))
+  
+  "A-list of (org-ref-type . org-cite-style).
+This builds from
+https://blog.tecosaur.com/tmio/2021-07-31-citations.html#cite-syntax.
+There is no way to get them all though, there are conflicting
+translations with some biblatex and some natbib commands. This
+list maps the natbib commands. I have also opted to use the full
+names rather than the short names."
+  :group 'org-ref
+  :type '(list (cons string string)))
+
+
+(defun org-ref-to-org-cite ()
+  (interactive)
+  (let ((ref-cites (reverse (org-ref-get-cite-links)))
+       type path
+       beg end)
+    ;; This takes care of the cite links
+    (cl-loop for rc in ref-cites do
+            (setq
+             type (org-element-property :type rc)
+             path (org-element-property :path rc)
+             beg (org-element-property :begin rc)
+             end (org-element-property :end rc))
+            (cl--set-buffer-substring
+             beg end
+             (format "[cite%s:%s]"
+                     (or (cdr (assoc type org-ref-to-org-cite-mapping)) "")
+                     ;; This is not 100% correct, if someone has put an extra &
+                     ;; anywhere in a note, this will be a little wrong. It
+                     ;; would be a little more correct if I also look for a
+                     ;; word next to it. The most correct would probably be to
+                     ;; build the data and then use org-element interpret I
+                     ;; think
+                     (replace-regexp-in-string "&" "@" path))))
+
+    ;; Next replace bibliography links. I assume the paths are ok, and we just
+    ;; need to convert them to keywords.
+    (cl-loop for bib-link in
+            (reverse (org-element-map (org-element-parse-buffer) 'link
+                       (lambda (bl)
+                         (when (member (org-element-property :type bl)
+                                       '("bibliography" "nobibliography"))
+                           bl))))
+            do
+            (cl--set-buffer-substring
+             (org-element-property :begin bib-link)
+             (org-element-property :end bib-link)
+             (format "#+bibliography: %s%s"
+                     (org-element-property :path bib-link)
+                     (if (string= "bibliography"
+                                  (org-element-property :type bib-link))
+                         "\n#+print_bibliography:"
+                       ""))))
+    ;; Note it is a bit ambiguous what do do about where the bibliography is to
+    ;; be printed. This should be done via #+print_bibliography:. In org-ref the
+    ;; bibliography normally goes where the bibliography link was, and I sue
+    ;; that convention.
+    
+    ))
+
+
+(provide 'org-ref-compat)
+
+;;; org-ref-compat.el ends here
diff --git a/elpa/org-ref-20251206.1422/org-ref-core.el b/elpa/org-ref-20251206.1422/org-ref-core.el
new file mode 100644 (file)
index 0000000..e190745
--- /dev/null
@@ -0,0 +1,379 @@
+;;; org-ref-core.el --- citations, cross-references and bibliographies in org-mode -*- lexical-binding: t; -*-
+
+;; Copyright(C) 2014-2024 John Kitchin
+
+;; This file is not currently part of GNU Emacs.
+
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation; either version 2, or (at
+;; your option) any later version.
+
+;; This program is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program ; see the file COPYING.  If not, write to
+;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+;;
+;; This is the core library.
+;;
+
+;;; Code:
+
+(eval-when-compile
+  (require 'cl-lib))
+
+(require 'org)
+;; the eval and compile seems especially necessary for native compilation on the newest Emacs.
+(eval-and-compile (require 'org-macs))
+
+(require 'org-element)
+
+(require 'org-ref-utils)
+
+(require 'parsebib)
+(require 'bibtex-completion)
+(require 'transient)
+
+(require 'org-ref-bibliography-links)
+(require 'org-ref-citation-links)
+(require 'org-ref-ref-links)
+(require 'org-ref-label-link)
+(require 'org-ref-misc-links)
+(require 'org-ref-export)
+
+(require 'org-ref-utils)
+(require 'org-ref-bibtex)
+(require 'org-ref-glossary)
+(require 'openalex)
+
+
+;;* Custom variables
+
+(defgroup org-ref nil
+  "Customization group for org-ref."
+  :tag "Org Ref"
+  :group 'org)
+
+
+(defcustom org-ref-insert-link-function
+  nil
+  "Generic function for inserting org-ref links.
+The function should take a prefix arg.
+No arg means insert a cite link
+1 arg means insert a ref link
+2 args means insert a label."
+  :type 'function
+  :group 'org-ref)
+
+
+(defcustom org-ref-insert-cite-function
+  nil
+  "Function to call to insert citation links.
+This function should prompt for keys with completion, and insert
+the citation link into the buffer."
+  :type 'function
+  :group 'org-ref)
+
+
+(defcustom org-ref-cite-completion-function
+  nil
+  "Function to prompt for keys with completion."
+  :type '(choice (const nil)
+                 (function))
+  :group 'org-ref)
+
+
+(defcustom org-ref-insert-label-function
+  nil
+  "Function to call to insert label links.
+This function should prompt for a label, and insert the label
+link."
+  :type 'function
+  :group 'org-ref)
+
+
+(defcustom org-ref-insert-ref-function
+  nil
+  "Function to call to insert ref links.
+This function should prompt for a label with completion, and
+insert the ref link."
+  :type 'function
+  :group 'org-ref)
+
+
+(defcustom org-ref-cite-onclick-function
+  nil
+  "Function that runs when you click on a cite link.
+The function must take one argument which is the path of the link
+that was clicked on."
+  :type 'function
+  :group 'org-ref)
+
+
+(defvar org-ref-prefix-arg nil
+  "Variable to store a prefix arg during completion.")
+
+
+(defun org-ref-minibuffer-prefix ()
+  "Hook function for `minibuffer-setup-hook'.
+The idea is to locally bind C-u to a function that captures
+prefix args in `org-ref-prefix-arg' so you can use them later."
+  (setq org-ref-prefix-arg nil)
+  (local-set-key (kbd "C-u") (lambda ()
+                              (interactive)
+                              (setq org-ref-prefix-arg
+                                    (if (null org-ref-prefix-arg)
+                                        '(4)
+                                      (list (* 4 (car org-ref-prefix-arg))))))))
+
+
+;; * Bibliography related functions
+
+(defun org-ref-find-bibliography ()
+  "Find the bibliography in the buffer.
+This function sets and returns a list of files either from internal bibliographies, from files in the
+BIBINPUTS env var, and finally falling back to what the user has
+set in `bibtex-completion-bibliography'"
+  (let ((org-ref-bibliography-files ()))
+    (catch 'result
+      (save-excursion
+       (when (eq major-mode 'org-mode)
+         (org-with-wide-buffer
+           (goto-char (point-min))
+          ;; This just searches for these strings, and then checks if it
+          ;; is on a link. This is faster than parsing the org-file when
+          ;; it gets large.
+           ;; look for org-ref bibliography
+           (while (re-search-forward "\\(no\\)?bibliography:" nil t)
+            (let ((link (org-element-context)))
+              (when (and (eq (car link) 'link)
+                         (member (org-element-property :type link) '("bibliography" "nobibliography")))
+                (setq org-ref-bibliography-files
+                      (mapcar 'org-ref-get-bibfile-path
+                              (mapcar 'string-trim (split-string
+                                                    (org-element-property :path link)
+                                                    ","))))
+                (throw 'result (nreverse (delete-dups org-ref-bibliography-files))))))
+
+           (goto-char (point-min))
+           (while (re-search-forward "\\\\addbibresource{\\(.*\\)}" nil t)
+             (push (match-string 1) org-ref-bibliography-files))
+
+           (when org-ref-bibliography-files
+             (throw 'result (nreverse (delete-dups (mapcar 'org-ref-get-bibfile-path org-ref-bibliography-files)))))))
+       ;; we did not find anything. use defaults. Make sure we have a list in
+        ;; case it is a single string. 
+       (throw 'result (org-ref-normalize-bibtex-completion-bibliography))))))
+
+
+(defun org-ref-key-in-file-p (key filename)
+  "Determine if the KEY is in the FILENAME."
+  (with-temp-buffer
+    (insert-file-contents filename)
+    (hack-local-variables)
+    (bibtex-set-dialect (parsebib-find-bibtex-dialect) t)
+    (bibtex-search-entry key)))
+
+
+(defun org-ref-possible-bibfiles ()
+  "Make a unique list of possible bibliography files for completing-read"
+  (delete-dups
+   (append
+    ;; see if we should add it to a bib-file defined in the file
+    (org-ref-find-bibliography)
+    ;; or any bib-files that exist in the current directory
+    (org-ref--directory-files "." (lambda (f)
+                    (and (not (string-match "#" f))
+                         (org-ref--file-ext-p f "bib"))))
+    ;; and last in the default bibliography
+    (org-ref-normalize-bibtex-completion-bibliography))))
+
+
+(defun org-ref-get-bibtex-key-and-file (&optional key)
+  "Return a  a cons cell of (KEY . file) that KEY is in.
+If no key is provided, get one under point."
+  (unless key
+    (setq key (org-ref-get-bibtex-key-under-cursor)))
+
+  (cons key (save-window-excursion
+             (let ((bibtex-completion-bibliography (org-ref-find-bibliography)))
+               (bibtex-completion-show-entry (list key))
+               (buffer-file-name)))))
+
+
+;; * Insert link functions
+
+;;;###autoload
+(defun org-ref-insert-link (arg)
+  "Insert an org-ref link.
+If no prefix ARG insert a cite.
+If one prefix ARG insert a ref.
+If two prefix ARGs insert a label.
+
+This is a generic function. Specific backends might
+provide their own version."
+  (interactive "P")
+  (cond
+   ((eq arg nil)
+    (funcall org-ref-insert-cite-function))
+   ((equal arg '(4))
+    (funcall org-ref-insert-ref-function))
+   ((equal arg '(16))
+    (funcall org-ref-insert-label-function))))
+
+
+;; This is an alternative that doesn't rely on prefix args.
+(defun org-ref-insert-link-menu--insert-citation ()
+  (interactive)
+  (funcall org-ref-insert-cite-function))
+
+(defun org-ref-insert-link-menu--insert-reference ()
+  (interactive)
+  (funcall org-ref-insert-ref-function))
+
+(defun org-ref-insert-link-menu--insert-label ()
+  (interactive)
+  (funcall org-ref-insert-label-function))
+
+(defun org-ref-insert-link-menu--open-bibliography ()
+  (interactive)
+  (find-file (completing-read "Bibliography: " (org-ref-find-bibliography))))
+
+(defun org-ref-insert-link-menu--ensure-table (name template)
+  (org-mark-ring-push)
+  (goto-char (point-min))
+  (if (re-search-forward (format "#\\+name: %s" name) nil t)
+      (progn
+        (goto-char (org-element-property :contents-end (org-element-context)))
+        (backward-char)
+        (org-table-insert-row '(4)))
+    (goto-char (point-max))
+    (insert template)
+    (beginning-of-line)
+    (forward-char)))
+
+(defun org-ref-insert-link-menu--new-glossary-term ()
+  (interactive)
+  (org-ref-insert-link-menu--ensure-table
+   "glossary"
+   "\n\n#+name: glossary
+| label | term    | definition                    |
+|-------+---------+-------------------------------|
+|       |         |                               |"))
+
+(defun org-ref-insert-link-menu--new-acronym-term ()
+  (interactive)
+  (org-ref-insert-link-menu--ensure-table
+   "acronym"
+   "\n\n#+name: acronyms
+| label | abbreviation | full form                  |
+|-------+--------------+----------------------------|
+|       |              |                            |"))
+
+(defun org-ref-insert-link-menu--insert-string (string)
+  (insert string))
+
+(defun org-ref-insert-link-menu--insert-index (prompt template)
+  (org-ref-insert-link-menu--insert-string
+   (format template (string-trim (read-string prompt)))))
+
+(transient-define-prefix org-ref-insert-link-menu ()
+  "Insert an org-ref link."
+  [["org-ref"
+    ("]" "Citation" org-ref-insert-link-menu--insert-citation :transient t)
+    ("r" "Cross-reference" org-ref-insert-link-menu--insert-reference :transient t)
+    ("\\" "Label" org-ref-insert-link-menu--insert-label :transient t)]
+   ["Bibliography"
+    ("bs" "Bibliographystyle" (lambda () (interactive)
+            (org-ref-insert-link-menu--insert-string
+             (org-ref-bibliographystyle-complete-link))))
+    ("bf" "Bibliography" (lambda () (interactive)
+            (org-ref-insert-link-menu--insert-string
+             (org-ref-bibliography-complete))))
+    ("nb" "Nobibliography" (lambda () (interactive)
+            (org-ref-insert-link-menu--insert-string
+             (org-ref-nobibliography-complete))))]
+   ["Glossary"
+    ("g" "Glossary link" org-ref-insert-glossary-link)
+    ("a" "Acronym link" org-ref-insert-acronym-link)
+    ("ng" "New glossary term" org-ref-insert-link-menu--new-glossary-term :transient t)
+    ("na" "New acronym term" org-ref-insert-link-menu--new-acronym-term :transient t)]
+   ["Bibtex"
+    ("bd" "Add bibtex entry from a DOI" doi-add-bibtex-entry :transient t)
+    ("bc" "Add bibtex entry from Crossref" crossref-add-bibtex-entry :transient t)
+    ("bo" "Open bibtex file" org-ref-insert-link-menu--open-bibliography :transient t)]
+   ["Misc"
+    ("t" "List of tables" (lambda () (interactive)
+           (org-ref-insert-link-menu--insert-string "[[list-of-tables:]]\n"))
+     :transient t)
+    ("f" "List of figures" (lambda () (interactive)
+           (org-ref-insert-link-menu--insert-string "[[list-of-figures:]]\n"))
+     :transient t)
+    ("i" "Index entry" (lambda () (interactive)
+           (org-ref-insert-link-menu--insert-index
+            "Index entry: " "[[index:%s]]"))
+     :transient t)
+    ("pi" "Print index" (lambda () (interactive)
+            (org-ref-insert-link-menu--insert-string "[[printindex:]]"))
+     :transient t)
+    ("pg" "Print glossary" (lambda () (interactive)
+            (org-ref-insert-link-menu--insert-string "[[printglossaries:]]"))
+     :transient t)
+    ("q" "Quit" transient-quit-one)]])
+
+(define-obsolete-function-alias 'org-ref-insert-link-hydra/body
+  #'org-ref-insert-link-menu "3.1")
+
+
+;;* org-ref-help
+;;;###autoload
+(defun org-ref-help ()
+  "Open the `org-ref' manual."
+  (interactive)
+  (find-file (expand-file-name
+              "org-ref.org"
+              (file-name-directory
+               (find-library-name "org-ref")))))
+
+
+;;* org-ref menu
+
+(defun org-ref-org-menu ()
+  "Add `org-ref' menu to the Org menu."
+
+  (easy-menu-change
+   '("Org") "org-ref"
+   `(["Insert citation" ,org-ref-insert-cite-function]
+     ["Insert ref" ,org-ref-insert-ref-function]
+     ["Insert label" ,org-ref-insert-label-function]
+     "--"
+     ["List of figures" org-ref-list-of-figures]
+     ["List of tables" org-ref-list-of-tables]
+     ["Extract bibtex entries" org-ref-extract-bibtex-entries]
+     ["Check org-file" org-ref]
+     "--"
+     ["Help" org-ref-help]
+     ["Customize org-ref" (customize-group 'org-ref)])
+   "Show/Hide")
+
+  (easy-menu-change '("Org") "--" nil "Show/Hide"))
+
+(add-hook 'org-mode-hook 'org-ref-org-menu)
+
+
+
+;;* The end
+(provide 'org-ref-core)
+
+;;; org-ref-core.el ends here
+
+;; Local Variables:
+;; byte-compile-warnings: (not docstrings docstrings-wide)
+;; End:
diff --git a/elpa/org-ref-20251206.1422/org-ref-export.el b/elpa/org-ref-20251206.1422/org-ref-export.el
new file mode 100644 (file)
index 0000000..f2ed26e
--- /dev/null
@@ -0,0 +1,980 @@
+;;; org-ref-export.el --- org-ref-export library -*- lexical-binding: t; -*-
+;;
+;; Copyright (C) 2024  John Kitchin
+
+;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
+;; Keywords: convenience
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+;;
+;;; Commentary:
+;; This is an export library that uses CSL to process the citations and bibliography.
+;;
+;; It is intended for non-LaTeX exports, but you can also use it with LaTeX if
+;; you want to avoid using bibtex/biblatex for some reason.
+;;
+;; The default style is set by a CSL-STYLE keyword or
+;; `org-ref-csl-default-style'. If this is an absolute or relative path that
+;; exists, it is used. Otherwise, it looks in `org-cite-csl-styles-dir' from
+;; `org-cite' if it is defined, and in the citeproc/csl-styles directory in
+;; `org-ref' otherwise.
+;;
+;; The default locale is set by a CSL-LOCALE keyword or
+;; `org-ref-csl-default-locale'. This is looked for in
+;; `org-cite-csl-locales-dir' if it is defined, and otherwise in the csl-locales
+;; directory of `org-ref'.
+;;
+;; Note that citeproc does not do anything for cross-references, so if non-LaTeX
+;; export is your goal, you may want to use org-ref-refproc.el to handle
+;; cross-references.
+;;
+;;; Formatting Limitations:
+;;
+;; Different export backends have different formatting capabilities. HTML and
+;; LaTeX support full CSL formatting including small caps, italics, bold, etc.
+;;
+;; The org-mode backend has limitations because org-mode syntax does not support
+;; small caps. Many CSL citation styles use small caps for author names, so these
+;; will not render correctly when exporting to formats that use the org backend
+;; (like DOCX by default).
+;;
+;; For DOCX export with better formatting support, set
+;; `org-ref-docx-use-html-backend' to t. This causes citations to be rendered
+;; as HTML which pandoc can convert to DOCX while preserving formatting.
+;;
+;; See `org-ref-backend-csl-formats' to customize backend mappings for different
+;; export formats.
+;;
+
+;;; Code:
+(require 'transient)
+(require 'org-ref-utils)
+(require 'org-ref-citation-links)
+
+(defvar hfy-user-sheet-assoc)                  ; to quiet compiler
+
+(require 'ox-org)
+(when (executable-find "pandoc")
+  (ignore-errors (require 'ox-pandoc)))
+
+(ignore-errors (require 'citeproc))
+
+(defvar org-cite-csl-styles-dir)
+
+(defcustom org-ref-backend-csl-formats
+  '((html . html)
+    (latex . latex)
+    (md . plain)
+    (org . org)
+    (ascii . plain)
+    (odt . org-odt)
+    (docx . org))
+  "Mapping of export backend to csl-backends.
+
+Each entry maps an org export backend symbol to a citeproc-el backend
+format used for rendering citations and bibliographies.
+
+Note: The 'org backend has formatting limitations because org-mode
+syntax does not support small caps. CSL styles that use small caps
+(common for author names) will not render correctly when using the
+'org backend. For DOCX export, consider setting
+`org-ref-docx-use-html-backend' to t to use HTML formatting which
+pandoc can convert while preserving small caps and other formatting.
+
+Available citeproc backends:
+- html: Full HTML formatting with CSS styles
+- latex: Full LaTeX formatting with commands like \\textsc{}
+- org: Org-mode markup (limited, no small caps support)
+- org-odt: ODT-specific XML formatting
+- plain: Plain text with no formatting"
+  :type '(alist :key-type (symbol) :value-type (symbol))
+  :group 'org-ref)
+
+
+(defcustom org-ref-cite-internal-links 'auto
+  "Should be one of these symbols (quoted)
+- bib-links :: link cites to bibliography entries
+- no-links :: do not link cites to bibliography entries
+- nil or auto :: add links based on the style."
+  :type '(choice symbol (sexp :tag bib-links)
+                symbol (sexp :tag no-links)
+                symbol (sexp :tag auto-links)
+                symbol (sexp :tag nil))
+  :group 'org-ref)
+
+
+(defcustom org-ref-csl-default-style "chicago-author-date-16th-edition.csl"
+  "Default csl style to use.
+Should be a csl filename, or an absolute path to a csl filename."
+  :type 'string
+  :group 'org-ref)
+
+
+(defcustom org-ref-csl-default-locale "en-US"
+  "Default csl locale to use."
+  :type 'string
+  :group 'org-ref)
+
+
+(defcustom org-ref-docx-use-html-backend nil
+  "Use HTML backend for DOCX export to preserve CSL formatting.
+
+When non-nil, citations exported to DOCX will be rendered using the
+HTML backend, which preserves formatting like small caps and italics
+that pandoc can convert to DOCX.
+
+When nil (default), uses the org backend which has limited formatting
+support due to org-mode syntax limitations. Specifically, org-mode has
+no native syntax for small caps, so CSL styles that use small caps
+(common for author names in many citation styles) will not render
+correctly in DOCX output.
+
+Note: This option only affects DOCX export via pandoc. Other export
+formats (HTML, LaTeX, ODT) are not affected.
+
+See also `org-ref-backend-csl-formats' to customize backend mappings
+for other export formats.
+
+Related to issue #981: https://github.com/jkitchin/org-ref/issues/981"
+  :type 'boolean
+  :group 'org-ref)
+
+
+(defcustom org-ref-csl-label-aliases
+  '((("app" "apps") . "appendix")
+    (("art" "arts") . "article-locator")
+    (("bk" "bks") . "book")
+    (("can") . "canon")
+    (("ch" "chap" "chaps" "chapt") . "chapter")
+    (("col" "cols") . "column")
+    (("el") . "elocation")
+    (("eq" "eqs") . "equation")
+    (("fig" "figs") . "figure")
+    (("fol" "fols") . "folio")
+    (("iss") . "issue")
+    (("l" "ll") . "line")
+    (("n" "nn") . "note")
+    ;; number is not listed in the url in the docstring
+    (("no" "nos" "#") . "number")
+    (("op" "opp") . "opus")
+    (("p" "pp" "pg" "pgs") . "page")
+    (("para" "paras" "¶" "¶¶" "§" "§§") . "paragraph")
+    (("pt" "pts") . "part")
+    (("sec" "secs") . "section")
+    (("s.v" "s.vv") . "sub verbo")
+    (("sup" "supp") . "supplement")
+    (("tab" "tabs") . "table")
+    (("ts") . "timestamp")
+    (("ti" "tit") . "title")
+    (("v" "vv") . "verse")
+    (("vol" "vols") . "volume"))
+  "A-list of aliases for a csl label.
+The car is a list of possible aliases (including if they end in a .
+This list was adapted from `org-cite-csl--label-alist'.
+See https://github.com/citation-style-language/documentation/blob/master/specification.rst#locators"
+  :type '(alist :key-type (list (repeat string)) :value-type string)
+  :group 'org-ref)
+
+
+(defcustom org-ref-export-suppress-affix-types
+  '("citet"
+    "citet*"
+    "citetitle"
+    "citeyear"
+    "citeauthor"
+    "citenum"
+    "textcite")
+  "List of cite types to suppress affixes (usually parentheses) on."
+  :type '(list (repeat string))
+  :group 'org-ref)
+
+
+;;; Footnote citation support (issue #993)
+
+(defvar org-ref-footnote-counter 0
+  "Counter for footnote citations during export.
+Reset to 0 at the start of each export process.")
+
+(defcustom org-ref-footnote-cite-types
+  '("footcite"
+    "footfullcite"
+    "footcitetext"
+    "footcites"
+    "footcitetexts"
+    "smartcite"
+    "Smartcite")
+  "List of citation types that should be rendered as footnotes.
+These citation types will be given a :note-index parameter when
+passed to citeproc-el, which causes them to be rendered as notes/footnotes
+when using CSL styles that support note formatting."
+  :type '(repeat string)
+  :group 'org-ref)
+
+
+(defun org-ref-footnote-cite-type-p (cite-type)
+  "Return non-nil if CITE-TYPE should be rendered as a footnote.
+CITE-TYPE is a string like \"footcite\" or \"cite\"."
+  (member cite-type org-ref-footnote-cite-types))
+
+
+(defun org-ref-get-next-footnote-number ()
+  "Get the next footnote number and increment the counter.
+Returns the next sequential footnote number (1, 2, 3, ...)."
+  (setq org-ref-footnote-counter (1+ org-ref-footnote-counter)))
+
+
+(defun org-ref-csl-style-supports-notes-p (csl-style-file)
+  "Return non-nil if CSL-STYLE-FILE supports note/footnote formatting.
+CSL-STYLE-FILE is a filename like \"chicago-fullnote-bibliography.csl\".
+
+This function checks if the CSL style file contains note-related
+class attributes, which indicate it supports footnote formatting."
+  (or
+   ;; Check filename for common note-style indicators
+   ;; Match: -note-, -note.csl, fullnote, footnote
+   (string-match-p "\\(\\bnote\\b\\|fullnote\\|footnote\\)" csl-style-file)
+   ;; If we have the actual file, check its contents
+   (when (file-exists-p csl-style-file)
+     (with-temp-buffer
+       (insert-file-contents csl-style-file)
+       (goto-char (point-min))
+       ;; Look for class="note" in the CSL XML
+       (re-search-forward "class=\"note\"" nil t)))))
+
+
+(defun org-ref-get-citation-note-index (citation-link)
+  "Get the note-index for CITATION-LINK if it's a footnote citation type.
+CITATION-LINK is an org-element link object.
+Returns a footnote number if this is a footnote citation, nil otherwise."
+  (when (org-ref-footnote-cite-type-p
+         (org-element-property :type citation-link))
+    (org-ref-get-next-footnote-number)))
+
+
+(defun org-ref-dealias-label (alias)
+  "Return the full, de-aliased label for ALIAS.
+Looked up from `org-ref-csl-label-aliases'.
+
+I added this because I think it is reasonable to expect if you
+write pg. 2 that it will show that way when rendered. At the
+moment that is not the case, and only page is accepted. This is
+actually done in oc-csl too, although it uses a flat a-list."
+  (or (cdr (assoc "page" org-ref-csl-label-aliases
+                 (lambda (x1 _x2)
+                   (or (member alias x1)
+                       (member (concat (downcase alias) ".") x1)))))
+      alias))
+
+
+(defun org-ref-get-cite-links ()
+  "Return list of cite links in the order they appear in the buffer."
+  (org-element-map (org-element-parse-buffer) 'link
+    (lambda (lnk)
+      (when (assoc (org-element-property :type lnk) org-ref-cite-types)
+       lnk))))
+
+
+(defun org-ref-ref-csl-data (ref type)
+  "Return the CSL alist for a REF of TYPE.
+REF is a plist data structure returned from `org-ref-parse-cite-path'."
+  ;; I believe the suffix contains "label locator suffix"
+  ;; where locator is a number, or maybe a range of numbers like 5-6.
+  ;; label is something like page or chapter
+  ;; and the rest is the suffix text.
+  ;; For example: ch. 5, for example
+  ;; would be label = ch., locator=5, ",for example" as suffix.
+  (let* ((full-suffix (string-trim (or (plist-get ref :suffix) "")))
+        locator
+        label locator suffix)
+
+    ;; org-cite is more sophisticated than this and would allow things like 5, 6
+    ;; and 12. I am not sure about what all should be supported yet. I guess the
+    ;; idea there is you use everything from the first to last number as the
+    ;; locator, but that seems tricky, what about something like: 5, 6 and 12,
+    ;; because he had 3 books. One solution might be some kind of delimiter,
+    ;; e.g. {5, 6 and 12}, because he had 3 books.
+
+    (if (and (string-match
+             (rx-to-string
+              `(seq
+                ;; optional label
+                (group-n 1 (optional
+                            (regexp ,(regexp-opt (cl-loop for (abbrvs . full)
+                                                          in org-ref-csl-label-aliases
+                                                          append (append abbrvs (list full)))))))
+                (optional (one-or-more space))
+                ;; number or numeric ranges
+                (group-n 2 (one-or-more digit) (optional "-" (one-or-more digit)))
+                ;; everything else
+                (group-n 3 (* "."))))
+             full-suffix)
+            (match-string 2 full-suffix)
+            (not (string= "" (match-string 2 full-suffix))))
+       ;; We found a locator
+       (setq label (match-string 1 full-suffix)
+             locator (match-string 2 full-suffix)
+             suffix (match-string 3 full-suffix))
+      (setq label nil
+           locator nil
+           suffix full-suffix))
+
+    ;; Let's assume if you have a locator but not a label that you mean page.
+    (when (and locator (string= "" (string-trim label)))
+      (setq label "page"))
+
+    `((id . ,(plist-get ref :key))
+      (prefix . ,(plist-get ref :prefix))
+      (suffix . ,suffix)
+      (locator . ,locator)
+      (label . ,(when label (org-ref-dealias-label (string-trim label))))
+      ;; [2024-01-29 Mon] see
+      ;; https://github.com/jkitchin/org-ref/issues/1103#issuecomment-1915028374
+      ;; and related comments at
+      ;; https://github.com/andras-simonyi/citeproc-el/issues/151. It seems I
+      ;; should not be adding this. TODO: proof of concept and not complete. I
+      ;; did not go through all the types to see what else should be in here.
+      ;; (suppress-author . ,(not (null (member type '("citenum" "citeyear"
+      ;; "citeyear*" "citedate" "citedate*" "citetitle" "citetitle*"
+      ;; "citeurl")))))
+      )))
+
+(declare-function org-ref-find-bibliography "org-ref-core")
+
+(defun org-ref-process-buffer (backend &optional subtreep)
+  "Process the citations and bibliography in the org-buffer.
+Usually run on a copy of the buffer during export.
+BACKEND is the org export backend."
+  ;; Reset footnote counter for this export
+  (setq org-ref-footnote-counter 0)
+
+  (save-restriction
+    (when subtreep
+      (org-narrow-to-subtree))
+    (let* ((csl-backend (or (cdr (assoc backend org-ref-backend-csl-formats)) 'plain))
+          ;; Use HTML backend for DOCX if requested for better formatting
+          (csl-backend (if (and (eq backend 'docx) org-ref-docx-use-html-backend)
+                           'html
+                         csl-backend))
+
+          (style (or (cadr (assoc "CSL-STYLE"
+                                  (org-collect-keywords
+                                   '("CSL-STYLE"))))
+                     org-ref-csl-default-style))
+          (locale (or (cadr (assoc "CSL-LOCALE"
+                                   (org-collect-keywords
+                                    '("CSL-LOCALE"))))
+                      org-ref-csl-default-locale))
+
+          ;; Determine the actual style file path for checking note support
+          (style-file (cond
+                       ((file-exists-p style)
+                        style)
+                       ((and (bound-and-true-p org-cite-csl-styles-dir)
+                             (file-exists-p (org-ref--file-join org-cite-csl-styles-dir style)))
+                        (org-ref--file-join org-cite-csl-styles-dir style))
+                       ((file-exists-p (expand-file-name style
+                                                         (org-ref--file-join (file-name-directory
+                                                                              (locate-library "org-ref"))
+                                                                             "citeproc/csl-styles")))
+                        (expand-file-name style (org-ref--file-join
+                                                 (file-name-directory
+                                                  (locate-library "org-ref"))
+                                                 "citeproc/csl-styles")))
+                       (t
+                        style)))  ; Fallback to style name itself
+
+          (proc (citeproc-create
+                 ;; The style
+                 (cond
+                  ((file-exists-p style)
+                   style)
+                  ;; In a user-dir
+                  ((and (bound-and-true-p org-cite-csl-styles-dir)
+                        (file-exists-p (org-ref--file-join org-cite-csl-styles-dir style)))
+                   (org-ref--file-join org-cite-csl-styles-dir style))
+                  ;; provided by org-ref
+                  ((file-exists-p (expand-file-name style
+                                                    (org-ref--file-join (file-name-directory
+                                                             (locate-library "org-ref"))
+                                                            "citeproc/csl-styles")))
+                   (expand-file-name style (org-ref--file-join
+                                            (file-name-directory
+                                             (locate-library "org-ref"))
+                                            "citeproc/csl-styles")))
+                  (t
+                   (error "%s not found" style)))
+                 ;; item-getter
+                 ;; (citeproc-itemgetter-from-bibtex (org-ref-find-bibliography))
+                 (citeproc-hash-itemgetter-from-any (org-ref-find-bibliography) t)
+                 ;; locale getter
+                 (citeproc-locale-getter-from-dir (if (bound-and-true-p org-cite-csl-locales-dir)
+                                                      org-cite-csl-locales-dir
+                                                    (org-ref--file-join (file-name-directory
+                                                             (locate-library "org-ref"))
+                                                            "citeproc/csl-locales")))
+                 ;; the actual locale
+                 locale))
+
+          ;; list of links in the buffer
+          (cite-links (org-element-map (org-element-parse-buffer) 'link
+                        (lambda (lnk)
+                          (when (assoc (org-element-property :type lnk) org-ref-cite-types)
+                            lnk))))
+
+          (cites (cl-loop for cl in cite-links collect
+                          (let* ((cite-data (org-ref-parse-cite-path (org-element-property :path cl)))
+                                 (common-prefix (or (plist-get cite-data :prefix) ""))
+                                 (common-suffix (or (plist-get cite-data :suffix) ""))
+                                 (refs (plist-get cite-data :references))
+                                 (type (org-element-property :type cl))
+
+                                 (cites (cl-loop for ref in refs collect
+                                                 (org-ref-ref-csl-data ref type))))
+                            ;; TODO: update eventually
+                            ;; https://github.com/andras-simonyi/citeproc-el/issues/46
+                            ;; To handle common prefixes, suffixes, I just concat
+                            ;; them with the first/last entries. That is all that
+                            ;; is supported for now. Combine common/local prefix
+                            (setf (cdr (assoc 'prefix (cl-first cites)))
+                                  (concat common-prefix
+                                          (cdr (assoc 'prefix (cl-first cites)))))
+                            ;; Combine local/common suffix
+                            (setf (cdr (assoc 'suffix (car (last cites))))
+                                  (concat (cdr (assoc 'suffix (car (last cites))))
+                                          common-suffix))
+
+                            ;; https://github.com/andras-simonyi/citeproc-el#creating-citation-structures
+                            (citeproc-citation-create
+                             :cites cites
+                             :suppress-affixes (let ((type (org-element-property :type cl)))
+                                                 (when (member type
+                                                               org-ref-export-suppress-affix-types)
+                                                   t))
+
+                             ;; TODO: this is proof of concept, and not complete.
+                             ;; mode is one of suppress-author, textual,
+                             ;; author-only, year-only, or nil for default. These
+                             ;; are not all clear to me.
+                             :mode (let ((type (org-element-property :type cl)))
+                                     (cond
+                                      ((member type '("citet" "citet*"))
+                                       'textual)
+                                      ((member type '("citeauthor" "citeauthor*"))
+                                       'author-only)
+                                      ((member type '("citeyear" "citeyear*"))
+                                       'year-only)
+                                      ((member type '("citedate" "citedate*"))
+                                       'suppress-author)
+                                      (t
+                                       nil)))
+
+                             ;; I think the capitalized styles are what this is for
+                             :capitalize-first (string-match
+                                                "[A-Z]"
+                                                (substring
+                                                 (org-element-property :type cl) 0 1))
+                             ;; Set note-index for footnote citation types (issue #993)
+                             :note-index (when (org-ref-footnote-cite-type-p
+                                                (org-element-property :type cl))
+                                           ;; Warn if using footnote citations with non-note style
+                                           (unless (org-ref-csl-style-supports-notes-p style-file)
+                                             (warn "Citation type '%s' is a footnote citation but CSL style '%s' may not support notes. Consider using a note-based style like chicago-fullnote-bibliography.csl"
+                                                   (org-element-property :type cl)
+                                                   style))
+                                           (org-ref-get-next-footnote-number))
+                             :ignore-et-al nil
+                             :grouped nil))))
+
+          (rendered-citations (progn (citeproc-append-citations cites proc)
+                                     (citeproc-render-citations proc csl-backend org-ref-cite-internal-links)))
+          ;; I only use the returned bibliography string. citeproc returns a
+          ;; bunch of other things related to offsets and linespacing, but I
+          ;; don't know what you do with these, so just ignore them here.
+          (bibdata (citeproc-render-bib proc csl-backend))
+          (rendered-bib (car bibdata))
+          (bib-parameters (cdr bibdata))
+          ;; The idea is we will wrap each citation and the bibliography in
+          ;; org-code so it exports appropriately.
+          (cite-formatters '((html . "@@html:%s@@")
+                             (latex . "@@latex:%s@@")
+                             (odt . "@@odt:%s@@")))
+          (bib-formatters '((html .  "\n#+BEGIN_EXPORT html\n%s\n#+END_EXPORT\n")
+                            (latex .  "\n#+BEGIN_EXPORT latex\n%s\n#+END_EXPORT\n")
+                            (odt . "\n#+BEGIN_EXPORT ODT\n%s\n#+END_EXPORT\n"))))
+
+      ;; replace the cite links
+      (cl-loop for cl in (reverse cite-links) for rc in (reverse rendered-citations) do
+              (cl--set-buffer-substring (org-element-property :begin cl)
+                                        (org-element-property :end cl)
+                                        (format (or
+                                                 (cdr (assoc backend cite-formatters))
+                                                 "%s")
+                                                (concat
+                                                 rc
+                                                 ;; Add on extra spaces that were
+                                                 ;; following it.
+                                                 (make-string
+                                                  (or
+                                                   (org-element-property :post-blank cl) 0)
+                                                  ? )))))
+
+      ;; Decorate the bibliography for different outputs adapted from
+      ;;  `org-cite-csl-render-bibliography' in oc-csl I don't know what all
+      ;;  these do or how to use them in the CSS for html, or LaTeX. This is to
+      ;;  fix an annoying HTML feature that has an extra line in the numbering.
+      ;;  This seems to do the right thing. I don't support hanging-indent like
+      ;;  oc-csl does, and I don't currently support LaTeX here. It already does
+      ;;  a good job there.
+      ;;
+      ;; (find-library "oc-csl")
+      ;;
+      ;; Here are some examples of what is in the bib-parameters.
+      ;;  (max-offset . 2) (hanging-indent) (second-field-align . flush)
+      ;; (entry-spacing . 0)
+      ;; (line-spacing . 2)
+      ;;
+      ;; Here we add style css for html output.
+      (cond
+       ((or (eq 'html backend) (eq 'html csl-backend))
+       (let ((s1 "")
+             (s2 ""))
+         (when (cdr (assq 'second-field-align bib-parameters))
+           (setq s1 (format
+                     "<style>.csl-left-margin{float: left; padding-right: 0em;}
+ .csl-right-inline{margin: 0 0 0 %dem;}</style>"
+                     ;; I hard coded this factor of 0.6 from the oc-csl code.
+                     (* 0.6  (or (cdr (assq 'max-offset bib-parameters)) 0)))))
+
+         ;; hard-coded the hanging indent. oc-csl uses a variable for this. I
+         ;; guess we could too, but this seems simpler.
+         (when (cdr (assq 'hanging-indent bib-parameters))
+           (setq s2 "<style>.csl-entry{text-indent: -1.5em; margin-left: 1.5em;}</style>"))
+
+         (setq rendered-bib (concat
+                             s1 s2
+                             rendered-bib)))))
+
+      ;; replace the bibliography
+      (org-element-map (org-element-parse-buffer) 'link
+       (lambda (lnk)
+         (cond
+          ((string= (org-element-property :type lnk) "bibliography")
+           (cl--set-buffer-substring (org-element-property :begin lnk)
+                                     (org-element-property :end lnk)
+                                     (format (or
+                                              (cdr (assoc backend bib-formatters))
+                                              "%s")
+                                             rendered-bib)))
+          ;; We just get rid of nobibliography links.
+          ((string= (org-element-property :type lnk) "nobibliography")
+           (cl--set-buffer-substring (org-element-property :begin lnk)
+                                     (org-element-property :end lnk)
+                                     "")))))
+      ;; For LaTeX we need to define the citeprocitem commands
+      ;; see https://www.mail-archive.com/emacs-orgmodeNOSPAMgnu.org/msg138546.html
+      (when (eq backend 'latex)
+       (goto-char (point-min))
+       (insert "#+latex_header: \\makeatletter
+#+latex_header: \\newcommand{\\citeprocitem}[2]{\\hyper@linkstart{cite}{citeproc_bib_item_#1}#2\\hyper@linkend}
+#+latex_header: \\makeatother\n")))))
+
+
+(defun org-ref-export-to (backend &optional async subtreep visible-only
+                                 body-only info)
+  "Export buffer to BACKEND.
+See `org-export-as' for the meaning of ASYNC SUBTREEP
+VISIBLE-ONLY BODY-ONLY and INFO."
+  (let* ((fname (buffer-file-name))
+        (extensions '((html . ".html")
+                      (latex . ".tex")
+                      (ascii . ".txt")
+                      (md . ".md")
+                      (odt . ".odf")))
+        (cp (point))
+        (mm)                           ;marker to save place
+        (export-name (concat (file-name-sans-extension fname)
+                             (or (cdr (assoc backend extensions)) ""))))
+
+    (org-export-with-buffer-copy
+     ;; Note I use a marker here to make sure we stay in the same place we were.
+     ;; This is more robust than save-excursion I think, since processing moves
+     ;; points around. In theory the marker should move too.
+     (setq mm (make-marker))
+     (move-marker mm cp)
+     ;; make sure we expand includes
+     (org-export-expand-include-keyword)
+     (goto-char (marker-position mm))
+     (org-ref-process-buffer backend subtreep)
+     (set-marker mm nil)
+
+     (pcase backend
+       ;; odt is a little bit special, and is missing one argument
+       ('odt (org-open-file (org-odt-export-to-odt async subtreep visible-only
+                                                  info)
+                           'system))
+       ;; for pandoc, we mean make a docx via pandoc
+       ('docx (org-open-file (plist-get (org-pandoc-export-to-docx async subtreep visible-only
+                                                                  body-only info)
+                                       'output-file)
+                            'system))
+       (_
+       (org-open-file (org-export-to-file backend export-name
+                        async subtreep visible-only
+                        body-only info)
+                      'system))))))
+
+
+;; I guess I tried to use apply-partially here, and it did not work, so these
+;; are each defined manually
+
+(defun org-ref-export-to-html (&optional async subtreep visible-only
+                                        body-only info)
+  "Export the buffer to HTML and open.
+See `org-export-as' for the meaning of ASYNC SUBTREEP
+VISIBLE-ONLY BODY-ONLY and INFO."
+  (org-ref-export-to 'html async subtreep visible-only
+                    body-only info))
+
+
+(defun org-ref-export-to-ascii (&optional async subtreep visible-only
+                                         body-only info)
+  "Export the buffer to ascii and open.
+See `org-export-as' for the meaning of ASYNC SUBTREEP
+VISIBLE-ONLY BODY-ONLY and INFO."
+  (org-ref-export-to 'ascii async subtreep visible-only
+                    body-only info))
+
+
+(defun org-ref-export-to-md (&optional async subtreep visible-only
+                                      body-only info)
+  "Export the buffer to md and open.
+See `org-export-as' for the meaning of ASYNC SUBTREEP
+VISIBLE-ONLY BODY-ONLY and INFO."
+  (org-ref-export-to 'md async subtreep visible-only
+                    body-only info))
+
+
+(defun org-ref-export-to-pdf (&optional async subtreep visible-only
+                                       body-only info)
+  "Export the buffer to PDF via LaTeX and open.
+See `org-export-as' for the meaning of ASYNC SUBTREEP
+VISIBLE-ONLY BODY-ONLY and INFO."
+  (let ((org-export-before-parsing-functions (append
+                                             org-export-before-parsing-functions
+                                             '(org-ref-csl-preprocess-buffer))))
+    (org-open-file (org-latex-export-to-pdf async subtreep visible-only
+                                           body-only info))))
+
+
+(defun org-ref-export-to-latex (&optional async subtreep visible-only
+                                         body-only info)
+  "Export the buffer to LaTeX and open.
+See `org-export-as' for the meaning of ASYNC SUBTREEP
+VISIBLE-ONLY BODY-ONLY and INFO."
+  (org-ref-export-to 'latex async subtreep visible-only
+                    body-only info))
+
+
+(defun org-ref-export-to-odt (&optional async subtreep visible-only
+                                       body-only info)
+  "Export the buffer to ODT and open.
+See `org-export-as' for the meaning of ASYNC SUBTREEP
+VISIBLE-ONLY BODY-ONLY and INFO."
+  (require 'htmlfontify)
+  (unless (boundp 'hfy-user-sheet-assoc) (setq  hfy-user-sheet-assoc nil))
+  (org-ref-export-to 'odt async subtreep visible-only
+                    body-only info))
+
+
+(defun org-ref-export-to-docx (&optional async subtreep visible-only
+                                        body-only info)
+  "Export the buffer to docx via pandoc and open.
+
+Note: By default, DOCX export uses the org backend for citations which
+has formatting limitations (no small caps support). Set
+`org-ref-docx-use-html-backend' to t for better formatting preservation.
+
+See `org-export-as' for the meaning of ASYNC SUBTREEP
+VISIBLE-ONLY BODY-ONLY and INFO."
+  (org-ref-export-to 'docx async subtreep visible-only
+                    body-only info))
+
+
+(defun org-ref-export-as-org (&optional _async subtreep visible-only
+                                       body-only info)
+  "Export the buffer to an ORG buffer and open.
+We only make a buffer here to avoid overwriting the original file.
+See `org-export-as' for the meaning of ASYNC SUBTREEP
+VISIBLE-ONLY BODY-ONLY and INFO."
+  (let* ((export-buf "*org-ref ORG Export*")
+        export)
+
+    (org-export-with-buffer-copy
+     (org-ref-process-buffer 'org subtreep)
+     (setq export (org-export-as 'org subtreep visible-only body-only info))
+     (with-current-buffer (get-buffer-create export-buf)
+       (erase-buffer)
+       (org-mode)
+       (insert export)))
+    (pop-to-buffer export-buf)))
+
+
+(defun org-ref-export-to-message (&optional _async subtreep visible-only
+                                           body-only info)
+  "Export to ascii and insert in an email message."
+  (let* ((backend 'ascii)
+        (content (org-export-with-buffer-copy
+                  (org-ref-process-buffer backend subtreep)
+                  (org-export-as backend subtreep visible-only
+                                 body-only info))))
+    (compose-mail)
+    (message-goto-body)
+    (insert content)
+    (message-goto-to)))
+
+
+(org-export-define-derived-backend 'org-ref 'org
+  :menu-entry
+  '(?r "Org-ref export"
+       ((?a "to Ascii" org-ref-export-to-ascii)
+       (?m "to markdown" org-ref-export-to-md)
+       (?h "to html" org-ref-export-to-html)
+       (?l "to LaTeX" org-ref-export-to-latex)
+       (?p "to PDF" org-ref-export-to-pdf)
+       (?o "to ODT" org-ref-export-to-odt)
+       (?O "to Org buffer" org-ref-export-as-org)
+       (?e "to email" org-ref-export-to-message)
+       (?w "to docx" org-ref-export-to-docx))))
+
+;; An alternative to this exporter is to use an  `org-export-before-parsing-functions'
+;; (add-hook 'org-export-before-parsing-functions 'org-ref-csl-preprocess-buffer)
+
+(defun org-ref-csl-preprocess-buffer (backend)
+  "Preprocess the buffer in BACKEND export.
+Note this may not work as expected, what about subtreep? The hook
+function just takes one argument. For now we rely on
+`buffer-narrowed-p' and an org-heading at the beginning.
+I am not positive on this though."
+  (org-ref-process-buffer backend (and (buffer-narrowed-p)
+                                      (save-excursion
+                                        (goto-char (point-min))
+                                        (org-at-heading-p)))))
+
+
+;; A transient exporter with preprocessors
+(defvar org-ref/natmove nil
+  "Toggle for moving natbib citations before export.")
+
+(defvar org-ref/citeproc nil
+  "Toggle for running citeproc before export.")
+
+(defvar org-ref/refproc nil
+  "Toggle for running refproc before export.")
+
+(defvar org-ref/acrossproc nil
+  "Toggle for running acrossproc before export.")
+
+(defvar org-ref/idxproc nil
+  "Toggle for running idxproc before export.")
+
+(defvar org-ref/bblproc nil
+  "Toggle for running bblproc before export.")
+
+(defun org-ref-export--toggle (var)
+  (set var (not (symbol-value var)))
+  (message "%s %s"
+           (capitalize (replace-regexp-in-string "/" " " (symbol-name var)))
+           (if (symbol-value var) "enabled" "disabled"))
+  (symbol-value var))
+
+(defun org-ref-export-toggle-natmove ()
+  (interactive)
+  (org-ref-export--toggle 'org-ref/natmove))
+
+(defun org-ref-export-toggle-citeproc ()
+  (interactive)
+  (org-ref-export--toggle 'org-ref/citeproc))
+
+(defun org-ref-export-toggle-refproc ()
+  (interactive)
+  (org-ref-export--toggle 'org-ref/refproc))
+
+(defun org-ref-export-toggle-acrossproc ()
+  (interactive)
+  (org-ref-export--toggle 'org-ref/acrossproc))
+
+(defun org-ref-export-toggle-idxproc ()
+  (interactive)
+  (org-ref-export--toggle 'org-ref/idxproc))
+
+(defun org-ref-export-toggle-bblproc ()
+  (interactive)
+  (org-ref-export--toggle 'org-ref/bblproc))
+
+(defun org-ref-export--toggle-description (label var)
+  (format "%s %s" label (if (symbol-value var) "[on]" "[off]")))
+
+
+(defun org-ref-export-dispatch (&optional arg)
+  "Run the export dispatcher with the desired hooks selected in the export menu."
+  (interactive "P")
+
+  (when (and org-ref/citeproc org-ref/bblproc)
+    (error "You cannot use CSL and BBL at the same time."))
+
+  (let ((org-export-before-parsing-functions org-export-before-parsing-functions))
+    (when org-ref/citeproc
+      (cl-pushnew 'org-ref-csl-preprocess-buffer org-export-before-parsing-functions))
+
+    (when org-ref/refproc
+      (cl-pushnew 'org-ref-refproc org-export-before-parsing-functions))
+
+    (when org-ref/acrossproc
+      (cl-pushnew 'org-ref-acrossproc org-export-before-parsing-functions))
+
+    (when org-ref/idxproc
+      (cl-pushnew 'org-ref-idxproc org-export-before-parsing-functions))
+
+    (when org-ref/bblproc
+      (unless (featurep 'org-ref-natbib-bbl-citeproc)
+       (require 'org-ref-natbib-bbl-citeproc))
+      (cl-pushnew 'org-ref-bbl-preprocess org-export-before-parsing-functions))
+
+    ;; this goes last since it moves cites before they might get replaced.
+    (when org-ref/natmove
+      (cl-pushnew 'org-ref-cite-natmove org-export-before-parsing-functions))
+
+    (org-export-dispatch arg)))
+
+(transient-define-prefix org-ref-export-menu ()
+  "Select export preprocessors and dispatch export."
+  [["Preprocessors"
+    ("n" org-ref-export-toggle-natmove :transient t
+     :description (lambda () (org-ref-export--toggle-description "natmove" 'org-ref/natmove)))
+    ("c" org-ref-export-toggle-citeproc :transient t
+     :description (lambda () (org-ref-export--toggle-description "citeproc" 'org-ref/citeproc)))
+    ("r" org-ref-export-toggle-refproc :transient t
+     :description (lambda () (org-ref-export--toggle-description "refproc" 'org-ref/refproc)))
+    ("a" org-ref-export-toggle-acrossproc :transient t
+     :description (lambda () (org-ref-export--toggle-description "acrossproc" 'org-ref/acrossproc)))
+    ("i" org-ref-export-toggle-idxproc :transient t
+     :description (lambda () (org-ref-export--toggle-description "idxproc" 'org-ref/idxproc)))
+    ("b" org-ref-export-toggle-bblproc :transient t
+     :description (lambda () (org-ref-export--toggle-description "bblproc" 'org-ref/bblproc)))]
+   ["Actions"
+    ("e" "Export" org-ref-export-dispatch)
+    ("q" "Quit" transient-quit-one)]])
+
+(define-obsolete-function-alias 'org-ref-export/body
+  #'org-ref-export-menu "3.1")
+
+(define-obsolete-function-alias 'org-ref-export-from-hydra
+  #'org-ref-export-dispatch "3.1")
+
+;; * exporting formatted citations
+;; ** with user defined templates
+(defcustom org-ref-format-templates
+  '(("article" . "${author} (${year}). /${title}/. ${journal}, *${volume}(${number})*, ${pages}.${doi}")
+    ("inproceedings" . "${author} (${year}). ${title}. In ${editor}, ${booktitle} (pp. ${pages}). ${address}: ${publisher}.")
+    ("book" . "${author} (${year}). ${title}. ${address}: ${publisher}.")
+    ("phdthesis" .  "${author} (${year}). ${title} (Doctoral dissertation). ${school}, ${address}.")
+    ("inbook" . "${author} (${year}). ${chapter}. In ${editor} (Eds.), ${title} (pp. ${pages}). ${address}: ${publisher}.")
+    ("incollection" . "${author} (${year}). ${title}. In ${editor} (Eds.), ${booktitle} (pp. ${pages}). ${address}: ${publisher}.")
+    ("proceedings" . "${editor} (Eds.). (${year}). ${booktitle}. ${address}: ${publisher}.")
+    ("unpublished" . "${author} (${year}). ${title}. Unpublished manuscript.")
+    ("misc" . "${author} (${year}). ${title}."))
+  "a-list of templates for formatting references.
+The car is the BibTeX entry type, and the cdr is a template for `org-ref--format-template'.")
+
+
+(defun org-ref-format-reference (key)
+  "Insert a formatted reference at point using `org-ref-format-templates'."
+  (let* ((entry (org-ref-bibtex-get-entry key))
+        (type (cdr (assoc "=type=" entry)))
+        (fmt (cdr (assoc (downcase type) org-ref-format-templates)))
+        (result (org-ref--format-template fmt entry)))
+
+    (setq
+     ;; remove ${...} patterns that were not filled in
+     result (replace-regexp-in-string "\\${[^}]*}" "" result)
+     ;; clean up multiple spaces/newlines/tabs
+     result (replace-regexp-in-string "[ \t\r\n]+" " " result))
+    result))
+
+
+(defun org-ref-insert-formatted-reference ()
+  "Insert a formatted reference at point."
+  (interactive)
+  (let* ((bibtex-completion-bibliography (org-ref-find-bibliography))
+        (candidates (bibtex-completion-candidates))
+        (key (completing-read "Key: " candidates
+                              nil t))
+        (entry (assoc key candidates))
+        (actual-key (cdr (assoc "=key=" entry))))
+    (insert (org-ref-format-reference actual-key))))
+
+
+;; ** with csl styles
+
+(defun org-ref-format-reference-csl (key &optional style-file)
+  "Return a formatted reference for KEY using CSL style.
+  STYLE-FILE is a path to a CSL style file. If nil, uses apa.csl
+  from the standard csl-styles location."
+  (let* ((bibfiles (org-ref-find-bibliography))
+         (style (or style-file (expand-file-name
+                               org-ref-csl-default-style
+                               (org-ref--file-join (file-name-directory
+                                                    (locate-library "org-ref"))
+                                                   "citeproc/csl-styles"))))
+         ;; Create item getter from your bib files
+         (item-getter (citeproc-hash-itemgetter-from-any bibfiles))
+         ;; Get the item data for this key
+         (item-data (cdr (car (funcall item-getter (list key)))))
+         ;; Create a minimal style object
+         (proc-style (citeproc-create-style
+                      style
+                      (citeproc-locale-getter-from-dir
+                      (org-ref--file-join (file-name-directory
+                                           (locate-library "org-ref"))
+                                          "citeproc/csl-locales")))))
+    (when item-data
+      ;; Render as org format with 'bib mode for bibliography-style output
+      (citeproc-render-item item-data proc-style 'bib 'org))))
+
+
+(defun org-ref-insert-formatted-reference-csl (&optional arg)
+  "Insert a formatted reference at point using citeproc."
+  (interactive "P")
+  (let* ((bibtex-completion-bibliography (org-ref-find-bibliography))
+        (candidates (bibtex-completion-candidates))
+        (ref (completing-read "Reference: " candidates
+                              nil t))
+        (entry (assoc ref candidates))
+         (key (cdr (assoc "=key=" entry)))
+        (style (if arg
+                   (read-file-name "CSL style file: "
+                                   (org-ref--file-join (file-name-directory
+                                                        (locate-library "org-ref"))
+                                                       "citeproc/csl-styles"))
+                 nil))
+        (actual-key (or key ref))
+        (result (org-ref-format-reference-csl key style)))
+    (insert (or result
+               (format "Could not format reference for %s"
+                       actual-key)))))
+
+
+(provide 'org-ref-export)
+
+;;; org-ref-export.el ends here
diff --git a/elpa/org-ref-20251206.1422/org-ref-extract.el b/elpa/org-ref-20251206.1422/org-ref-extract.el
new file mode 100644 (file)
index 0000000..50ac206
--- /dev/null
@@ -0,0 +1,198 @@
+;;; org-ref-extract.el --- Extract BibTeX from HTML  -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2023  Justus Piater
+
+;; Author: Justus Piater <Justus-devNOSPAMPiater.name>
+;; Keywords:
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+
+(declare-function org-ref-clean-bibtex-entry "org-ref-bibtex" ())
+(declare-function xml-substitute-special "xml" ())
+
+
+(defun org-ref--extract (html-buffer rx num)
+  "Return content matched within HTML-BUFFER by RX at parenthesized
+sub-expression NUM."
+  (with-current-buffer html-buffer
+    (goto-char (point-min))
+    (if (re-search-forward rx nil t)
+       (match-string num)
+      nil)))
+
+
+(defun org-ref--get-pdf (pdf-url)
+  "For BibTeX entry at point, if not already present, get PDF, place
+it in`bibtex-completion-library-path', and add a corresponding
+FILE field to the entry."
+  (bibtex-beginning-of-entry)
+  (let* ((key (cdr (assoc "=key=" (bibtex-parse-entry))))
+         (pdf-file (concat (car bibtex-completion-library-path) key ".pdf")))
+    (unless (file-exists-p pdf-file)
+      (url-copy-file pdf-url pdf-file)
+      (if (org-ref-pdf-p pdf-file)
+          (message "%s saved" pdf-file)
+        (delete-file pdf-file)
+        (message "No pdf was downloaded.")
+        (browse-url pdf-url)))
+    (when (file-exists-p pdf-file)
+      (bibtex-set-field "file" pdf-file)
+      (when doi-utils-open-pdf-after-download
+       (org-open-file pdf-file)))))
+
+
+(defun org-ref--extract-entry-from-html
+    (html-buffer bibtex pdf-url &rest more-fields)
+  "At point, create a BibTeX entry using information extracted
+  from the HTML-BUFFER, and kill HTML-BUFFER."
+  (bibtex-mode)
+  (let ((bibtex (if (consp bibtex)
+                   (org-ref--extract html-buffer (car bibtex) (cdr bibtex))
+                 bibtex))
+       (pdf-url (if (consp pdf-url)
+                    (org-ref--extract html-buffer (car pdf-url) (cdr pdf-url))
+                  pdf-url))
+       (more-fields
+        (mapcar
+         (lambda (field)
+           (cons (car field)
+                 (if (consp (cdr field))
+                     (org-ref--extract html-buffer (cadr field) (cddr field))
+                   (cdr field))))
+         more-fields)))
+    (insert bibtex)
+    (goto-char (point-min))
+    (while (search-forward "{\\n" nil t)
+      (replace-match "{"))
+    (goto-char (point-min))
+    (while (search-forward "\\n" nil t)
+      (replace-match "\n"))
+    (org-ref-clean-bibtex-entry)
+    (dolist (pair more-fields)
+      (when (cdr pair)
+       (bibtex-set-field (car pair) (cdr pair))))
+    (org-ref--get-pdf pdf-url))
+  (kill-buffer html-buffer))
+
+
+(defun org-ref--html-buffer (url)
+  "Retrieve resource from URL, decode it, substitute XML entities,
+and return the buffer."
+  (with-current-buffer (generate-new-buffer "org-ref--html")
+    (let ((url-request-method "GET"))
+      (url-insert (url-retrieve-synchronously url)))
+    (goto-char (point-min))
+    (insert (xml-substitute-special (buffer-string)))
+    (delete-region (point) (point-max))
+    (current-buffer)))
+
+
+(defun org-ref-extract-from-openreview (id)
+  "At point, create a BibTeX entry for the given OpenReview ID."
+  (interactive "MOpenReview ID: ")
+  (let* ((url (concat "https://openreview.net/forum?id=" id))
+        (html-buffer (org-ref--html-buffer url)))
+    (with-current-buffer html-buffer
+      (replace-string-in-region "\\\\n" "\\n" (point-min) (point-max)))
+    (org-ref--extract-entry-from-html
+     html-buffer
+     '("\\\\\"_bibtex\\\\\":\\({\\\\\"value\\\\\":\\)?\\\\\"\\(@.+?}\\)\\\\\""
+       . 2)
+     (replace-regexp-in-string "forum" "pdf" url)
+     '("abstract" .
+       ("<meta name=\"citation_abstract\" content=\"\\(.+?\\(\n.*?\\)*?\\)\"/>" . 1))
+     '("area" .
+       ("\"Please_choose_the_closest_area_that_your_submission_falls_into\":\"\\(.+?\\)\"" . 1))
+     '("keywords" . ("Keywords.*?\"note-content-value\">\\(.+?\\)</span>" . 1))
+     '("summary" .
+       ("\\(Summary\\|TL;DR\\).*?\"note-content-value\">\\(.+?\\)</span>" . 2))
+     ;; Should we proactively download supplementary materials too?
+     (cons "supp"
+          (if-let* ((supp (org-ref--extract
+                          html-buffer
+                          ">Supplementary Material<.*?href=\"\\([^\"]+\\)" 1)))
+              (concat "https://openreview.net" supp))))))
+
+
+(defun org-ref-extract-from-pmlr (url)
+  "At point, create a BibTeX entry for the given PMLR URL."
+  (interactive "MPMLR URL: ")
+  (org-ref--extract-entry-from-html
+   (org-ref--html-buffer url)
+   '("id=\"bibtex\">\n\\(@.+\\(\n.*?\\)+?\\)\n</" . 1)
+   '("{\\(http.+\\.pdf\\)}" . 1)
+   ;; Should we proactively download supplementary materials too?
+   '("supp" . ("href=\"\\(https?://proceedings\\.mlr\\.press/[^\"]+?-supp[^\"]*?\\)\".*?>Supplementary PDF</" . 1))))
+
+
+(defun org-ref-extract-from-neurips (url)
+  "At point, create a BibTeX entry for the given NeurIPS Abstract URL."
+  (interactive "MNeurIPS Abstract URL: ")
+  (let ((hash (progn (string-match "/\\([0-9a-f]+\\)-" url)
+                    (match-string 1 url)))
+       (neurips-url "https://proceedings.neurips.cc")
+       (html-buffer (org-ref--html-buffer url))
+       (bibtex))
+    (with-current-buffer html-buffer
+      (goto-char (point-min))
+      (re-search-forward "href=[\"']\\([^\"']+bibtex[^\"']*\\)[\"']")
+      (let ((bibtex-url (match-string 1)))
+       (with-temp-buffer
+         (url-insert
+          (url-retrieve-synchronously (concat neurips-url bibtex-url)))
+         (setq bibtex (buffer-string)))))
+    (org-ref--extract-entry-from-html
+     html-buffer
+     bibtex
+     (concat neurips-url
+            (org-ref--extract html-buffer
+                              "href=[\"']\\([^\"']+-Paper[^\"']*\\)[\"']" 1))
+     (cons "url" url)
+     '("abstract" . ("<h4>Abstract</h4>[ \n]*?\\(<p>\\)+\\(.+?\\)</p>" . 2))
+     ;; Should we proactively download supplementary materials too?
+     (cons "supp"
+          (if-let*
+              ((supp (org-ref--extract
+                      html-buffer
+                      "href=[\"']\\([^\"']+-Supplemental[^\"']*\\)[\"']" 1)))
+              (concat neurips-url supp))))))
+
+
+(defun org-ref-extract-from-cvf (url)
+  "At point, create a BibTeX entry for the given CVF HTML URL."
+  (interactive "MCVF HTML URL: ")
+  (let ((cvf-url "https://openaccess.thecvf.com")
+       (html-buffer (org-ref--html-buffer url)))
+    (org-ref--extract-entry-from-html
+     html-buffer
+     '("class=\"bibref[^\"]*\">[ \n]*\\(@.+?\\(\n.*?\\)+?\\)[ \n]*</" . 1)
+     (concat cvf-url (org-ref--extract
+                     html-buffer "<a href=[\"']\\([^\"']+\\)[\"']>pdf</a>" 1))
+     (cons "url" url)
+     '("abstract" . ("id=\"abstract\">[ \n]*\\([^<]+\\)[ \n]*</" . 1))
+     ;; Should we proactively download supplementary materials too?
+     (cons "supp" (concat cvf-url
+                         (org-ref--extract html-buffer
+                                           "href=[\"']\\([^\"']+\\)[\"']>supp</"
+                                           1))))))
+
+
+(provide 'org-ref-extract)
+;;; org-ref-extract.el ends here
diff --git a/elpa/org-ref-20251206.1422/org-ref-glossary.el b/elpa/org-ref-20251206.1422/org-ref-glossary.el
new file mode 100644 (file)
index 0000000..7bcc499
--- /dev/null
@@ -0,0 +1,1187 @@
+;;; org-ref-glossary.el --- glossary support in org-ref  -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2016-2024  John Kitchin
+
+;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
+;; Keywords:
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Provides Some acronym and glossary support for org-mode. Only export to LaTeX
+;; is currently supported. The functionality is based on the LaTeX glossaries
+;; package. See https://en.wikibooks.org/wiki/LaTeX/Glossary and
+;; http://ctan.math.washington.edu/tex-archive/macros/latex/contrib/glossaries/glossaries-user.pdf
+
+;; Put something like this in your org-file.
+;; #+latex_header: \usepackage{glossaries}
+;; #+latex_header: \makeglossaries
+
+;; Put this where you want the glossaries to appear in your org-file.
+;; [[printglossaries:]]
+
+;; This is the preferred way to add glossary entries to an org-file. The table
+;; must be named glossary.
+;; 
+;; #+name: glossary
+;; | label | name  | description   |
+;; |-------+-------+---------------|
+;; | tree  | Tree  | A woody plant |
+;; | shrub | Shrub | A woody bush  |
+;;
+;; This is the preferred way to add acronyms
+;; #+name: acronyms
+;; | key  | abbreviation | full form                      |
+;; |------+--------------+--------------------------------|
+;; | mimo | mimo         | multiple-input multiple output |
+;; | qos  | QoS          | quality-of-service             |
+;; | bb   | BB           | branch and bound               |
+;;
+;; Then add `org-ref-glossary-before-parsing' and
+;; `org-ref-acronyms-before-parsing' to the `org-export-before-parsing-hook'.
+
+;; See `org-ref-acronym-types' and `org-ref-glossary-gls-commands' for the types defined.
+
+;; Use `org-ref-insert-glossary-link' and `org-ref-insert-acronym-link' to
+;; insert a link with completion.
+
+;; * Known limitations
+;; 
+;; This only works well in a single file (i.e. you cannot include the tables
+;; from another file). I tried implementing that once, and it was too slow.
+
+
+
+;; * DEPRECATED way of adding entries
+;; This is still supported but using the tables is preferred.
+;; Add new glossary entries to your org-file like this. Enclose strings
+;; containing a comma in {}. Multiline entries are supported.
+
+;; #+latex_header_extra: \newglossaryentry{computer}{name=computer,description={A machine, that computes}}
+;; #+latex_header_extra: \newglossaryentry{tree}{name=tree,description=a big plant}
+
+;; #+latex_header_extra: \newglossaryentry{naiive}
+;; #+latex_header_extra: {
+;; #+latex_header_extra:   name=na\"{\i}ve,
+;; #+latex_header_extra:   description={is a French loanword (adjective, form of naïf)
+;; #+latex_header_extra:                indicating having or showing a lack of experience,
+;; #+latex_header_extra:                understanding or sophistication}
+;; #+latex_header_extra: }
+
+;; Here is an example acronym definition
+;; #+latex_header_extra: \newacronym{lvm}{LVM}{Logical Volume Manager}
+
+(require 'org-element)
+(require 'org-ref-utils)
+(require 'ox)
+(require 'org-ref-ref-links) ; For multi-file support utilities
+
+;;; Code:
+(defgroup org-ref-glossary nil
+  "Customization group for org-ref-glossary."
+  :tag "Org Ref glossary"
+  :group 'org)
+
+
+(defcustom org-ref-activate-glossary-links t
+  "If non-nil activate acronym and glossary links.
+Checks in `org-ref-glossary-face-fn' and `org-ref-acronym-face-fn'.
+This is not always fast, so we provide a way to disable it."
+  :type 'boolean
+  :group 'org-ref-glossary)
+
+
+(defcustom org-ref-glossary-show-tooltips t
+  "If non-nil, show tooltips when hovering over glossary and acronym links.
+When nil, tooltips are disabled entirely for glossary links, which can
+improve responsiveness if you find the tooltips distracting or slow.
+
+This is separate from `org-ref-activate-glossary-links' which controls
+whether links are fontified and clickable."
+  :type 'boolean
+  :group 'org-ref-glossary)
+
+
+(defcustom org-ref-glossary-enable-multi-file t
+  "Enable scanning #+INCLUDE'd files for glossary/acronym definitions.
+When non-nil, glossary and acronym lookups will search in files included
+via #+INCLUDE directives, enabling multi-file document support.
+
+Uses timestamp-based caching to maintain performance. Only files that have
+changed since the last scan are re-parsed."
+  :type 'boolean
+  :group 'org-ref-glossary)
+
+
+(defcustom org-ref-glsentries '()
+  "Variable to hold locations of glsentries load files.")
+
+
+(defvar-local org-ref-glossary-cache nil
+  "Buffer-local variable for glossary entry cache.")
+
+
+(defvar-local org-ref-acronym-cache nil
+  "Buffer-local variable for acronym entry cache.")
+
+
+(defvar org-ref-glossary-file-cache (make-hash-table :test 'equal)
+  "Global cache of glossary entries per file.
+Maps file paths to lists of glossary entry plists.
+Used when `org-ref-glossary-enable-multi-file' is non-nil.")
+
+
+(defvar org-ref-acronym-file-cache (make-hash-table :test 'equal)
+  "Global cache of acronym entries per file.
+Maps file paths to lists of acronym entry plists.
+Used when `org-ref-glossary-enable-multi-file' is non-nil.")
+
+
+(defun or-find-closing-curly-bracket (&optional limit)
+  "Find closing bracket for the bracket at point and move point to it.
+Go up to LIMIT or `point-max'. This is a parsing function. I
+wrote this because using `forward-list' does not always work if
+there is an escaped \" for example. This seems pretty robust."
+  (unless (looking-at "{") (error "Not at a curley bracket"))
+
+  (let ((level 1))
+    (while (and (not (= 0 level))
+               (not (eobp))
+               (< (point) (or limit (point-max))))
+      (forward-char)
+      (when (and (looking-at "{")
+                (not (looking-back "\\\\" (- (point) 2))))
+       (cl-incf level))
+      (when (and (looking-at "}")
+                (not (looking-back "\\\\" (- (point) 2))))
+       (cl-decf level)))
+    (point)))
+
+
+;;* Glossary
+(defun or-parse-glossary-entry (entry)
+  "Parse a LaTeX glossary ENTRY definition to a p-list of key=value.
+ENTRY is the label we are looking for.
+Typically returns  (:name name :description description)
+but there could be other :key value pairs.
+
+This is a source of performance loss, because this is search
+based and it is done on each fontification. It is easy to cache
+the results, but not easy to invalidate them, e.g. to reflect
+changes."
+  (if (and org-ref-glossary-cache (gethash entry org-ref-glossary-cache))
+      ;; We have the cache, and an entry and use it
+      (gethash entry org-ref-glossary-cache)
+    ;; We don't have a cache, or an entry in it, so we find it.
+    ;; No cache? we make one
+    (unless org-ref-glossary-cache
+      (setq-local org-ref-glossary-cache (make-hash-table :test 'equal)))
+
+    ;; Now we search to get the data
+    (save-excursion
+      (goto-char (point-min))
+      (let* (end-of-entry
+            data
+            (external (when (re-search-forward
+                             "\\\\loadglsentries\\(\\[.*\\]\\)?{\\(?1:.*\\)}" nil t)
+                        (match-string 1)))
+            (glsentries (and external
+                             (or (cdr (assoc external org-ref-glsentries))
+                                 (progn
+                                   (cl-pushnew (cons external (string-trim
+                                                               (shell-command-to-string
+                                                                (format "kpsewhich tex %s"
+                                                                        external))))
+                                               org-ref-glsentries)
+                                   (cdr (assoc external org-ref-glsentries))))))
+            key value p1 p2 position)
+       (setq data
+             (catch 'data
+               ;; look inside first for latex-headers
+               (goto-char (point-min))
+               (when (re-search-forward
+                      (format "\\newglossaryentry{%s}" entry) nil t)
+                 (setq position (match-beginning 0))
+                 (re-search-forward "{")
+                 (save-excursion
+                   (backward-char)
+                   (or-find-closing-curly-bracket)
+                   (setq end-of-entry (point)))
+
+                 (while (re-search-forward "\\(\\w+?\\)=" end-of-entry t)
+                   (setq key (match-string 1))
+                   ;; get value
+                   (goto-char (+ 1 (match-end 1)))
+                   (setq p1 (point))
+                   (if (looking-at "{")
+                       ;; value is wrapped in {}
+                       (progn
+                         (or-find-closing-curly-bracket)
+                         (setq p2 (point)
+                               value (buffer-substring (+ 1 p1) p2)))
+                     ;; value is up to the next comma
+                     (re-search-forward "," end-of-entry 'mv)
+                     (setq value (buffer-substring p1 (- (point) 1))))
+                   ;; remove #+latex_header_extra:
+                   (setq value (replace-regexp-in-string
+                                "#\\+latex_header_extra: " "" value))
+                   (setq value (replace-regexp-in-string
+                                "\n +" " " value))
+                   (setq data (append data
+                                      (list :label entry)
+                                      (list (intern (format ":%s" key)))
+                                      (list value)
+                                      (list :position position))))
+                 (throw 'data data))
+
+               ;; check for a glossary table
+               (let* ((entries (save-excursion
+                                 (catch 'found
+                                   (org-element-map
+                                       (org-element-parse-buffer)
+                                       'table
+                                     (lambda (el)
+                                       (when (string= "glossary" (org-element-property :name el))
+                                         (goto-char (org-element-property :contents-begin el))
+                                         (setq position (point))
+                                         (throw 'found
+                                                (nthcdr 2 (org-babel-read-table)))))))))
+                      (result (assoc entry entries)))
+                 (when result
+                   (throw 'data (list :label entry
+                                      :name (cl-second result)
+                                      :description (cl-third result)
+                                      :position position))))
+
+               ;; then external
+               (when (and glsentries
+                          (file-exists-p glsentries))
+
+                 (with-current-buffer (find-file-noselect glsentries)
+                   (goto-char (point-min))
+                   (when (re-search-forward
+                          (format "\\newglossaryentry{%s}" entry) nil t) 
+                     (re-search-forward "{")
+                     (save-excursion
+                       (backward-char)
+                       (or-find-closing-curly-bracket)
+                       (setq end-of-entry (point)))
+
+                     (while (re-search-forward "\\(\\w+?\\)=" end-of-entry t)
+                       (setq key (match-string 1))
+                       ;; get value
+                       (goto-char (+ 1 (match-end 1)))
+                       (setq p1 (point))
+                       (if (looking-at "{")
+                           ;; value is wrapped in {}
+                           (progn
+                             (or-find-closing-curly-bracket)
+                             (setq p2 (point)
+                                   value (buffer-substring (+ 1 p1) p2)))
+                         ;; value is up to the next comma
+                         (re-search-forward "," end-of-entry 'mv)
+                         (setq value (buffer-substring p1 (- (point) 1))))
+                       (setq data (append data
+                                          (list :label entry)
+                                          (list (intern (format ":%s" key)))
+                                          (list value)
+                                          (list :position nil))))
+                     (throw 'data data))))))
+       (puthash entry data org-ref-glossary-cache)
+       data))))
+
+
+;;** Multi-file glossary support
+
+(defun or-scan-file-for-glossary-table (file)
+  "Scan FILE and return list of glossary entries from #+name: glossary table.
+Returns list of plists with :label, :name, :description, :file.
+Returns nil if no glossary table is found in FILE."
+  (when (file-exists-p file)
+    (with-temp-buffer
+      (insert-file-contents file)
+      (org-mode)
+      (let ((entries '()))
+        (or (catch 'found
+              (org-element-map
+                  (org-element-parse-buffer)
+                  'table
+                (lambda (el)
+                  (when (string= "glossary" (org-element-property :name el))
+                    (goto-char (org-element-property :contents-begin el))
+                    (let ((table-data (nthcdr 2 (org-babel-read-table))))
+                      ;; Convert table rows to plists
+                      (dolist (row table-data)
+                        (when (and (listp row) (= 3 (length row)))
+                          (push (list :label (nth 0 row)
+                                      :name (nth 1 row)
+                                      :description (nth 2 row)
+                                      :file file)
+                                entries)))
+                      (throw 'found (nreverse entries)))))))
+            entries)))))
+
+
+(defun or-scan-file-for-acronym-table (file)
+  "Scan FILE and return list of acronym entries from #+name: acronyms table.
+Returns list of plists with :label, :abbrv, :full, :file.
+Returns nil if no acronym table is found in FILE."
+  (when (file-exists-p file)
+    (with-temp-buffer
+      (insert-file-contents file)
+      (org-mode)
+      (let ((entries '()))
+        (or (catch 'found
+              (org-element-map
+                  (org-element-parse-buffer)
+                  'table
+                (lambda (el)
+                  (when (string= "acronyms" (org-element-property :name el))
+                    (goto-char (org-element-property :contents-begin el))
+                    (let ((table-data (nthcdr 2 (org-babel-read-table))))
+                      ;; Convert table rows to plists
+                      (dolist (row table-data)
+                        (when (and (listp row) (= 3 (length row)))
+                          (push (list :label (nth 0 row)
+                                      :abbrv (nth 1 row)
+                                      :full (nth 2 row)
+                                      :file file)
+                                entries)))
+                      (throw 'found (nreverse entries)))))))
+            entries)))))
+
+
+(defun or-parse-glossary-entry-multi-file (label)
+  "Find glossary LABEL in current file or included files.
+Uses timestamp-based caching to avoid re-scanning unchanged files.
+Returns plist with :label, :name, :description, :file."
+  (when (and (boundp 'org-ref-glossary-enable-multi-file)
+             org-ref-glossary-enable-multi-file
+             (boundp 'org-ref-glossary-file-cache)
+             (buffer-file-name))
+    (cl-block or-parse-glossary-entry-multi-file
+      (let* ((current-file (buffer-file-name))
+             (included-files (org-ref-get-included-files))
+             (all-files (cons current-file included-files)))
+
+        ;; Scan each file (with caching)
+        (dolist (file all-files)
+          ;; Scan if file changed OR if not in cache yet
+          (when (or (org-ref-file-changed-p file)
+                    (not (gethash file org-ref-glossary-file-cache)))
+            ;; File changed or not cached, scan it
+            (let ((file-entries (or-scan-file-for-glossary-table file)))
+              (puthash file file-entries org-ref-glossary-file-cache)
+              (org-ref-mark-file-scanned file)))
+
+          ;; Look for label in this file's cache
+          (let ((entries (gethash file org-ref-glossary-file-cache)))
+            (when entries
+              (let ((entry (cl-find label entries
+                                    :key (lambda (e) (plist-get e :label))
+                                    :test 'string=)))
+                (when entry
+                  (cl-return-from or-parse-glossary-entry-multi-file entry))))))))))
+
+
+(defun or-parse-acronym-entry-multi-file (label)
+  "Find acronym LABEL in current file or included files.
+Uses timestamp-based caching to avoid re-scanning unchanged files.
+Returns plist with :label, :abbrv, :full, :file."
+  (when (and (boundp 'org-ref-glossary-enable-multi-file)
+             org-ref-glossary-enable-multi-file
+             (boundp 'org-ref-acronym-file-cache)
+             (buffer-file-name))
+    (cl-block or-parse-acronym-entry-multi-file
+      (let* ((current-file (buffer-file-name))
+             (included-files (org-ref-get-included-files))
+             (all-files (cons current-file included-files)))
+
+        ;; Scan each file (with caching)
+        (dolist (file all-files)
+          ;; Scan if file changed OR if not in cache yet
+          (when (or (org-ref-file-changed-p file)
+                    (not (gethash file org-ref-acronym-file-cache)))
+            ;; File changed or not cached, scan it
+            (let ((file-entries (or-scan-file-for-acronym-table file)))
+              (puthash file file-entries org-ref-acronym-file-cache)
+              (org-ref-mark-file-scanned file)))
+
+          ;; Look for label in this file's cache
+          (let ((entries (gethash file org-ref-acronym-file-cache)))
+            (when entries
+              (let ((entry (cl-find label entries
+                                    :key (lambda (e) (plist-get e :label))
+                                    :test 'string=)))
+                (when entry
+                  (cl-return-from or-parse-acronym-entry-multi-file entry))))))))))
+
+
+;;** Glossary links
+
+(defun or-activate-glossary (start end path bracketp)
+  "Activate function for a glossary link.
+set data on text with properties
+Set face property, and help-echo."
+  (let ((data (or (or-parse-glossary-entry path)
+                 (or-parse-acronym-entry path)
+                  ;; Try multi-file lookup if enabled and not found in current buffer
+                  (or-parse-glossary-entry-multi-file path)
+                  (or-parse-acronym-entry-multi-file path))))
+    (add-text-properties
+     start end
+     (list 'or-glossary data
+          'face (if data
+                    'org-ref-glossary-face
+                  'font-lock-warning-face)
+           ;; Suppress spell-checking with nospell property.
+           ;; For jinx users: add 'nospell to jinx-exclude-properties:
+           ;;   (setq jinx-exclude-properties '((org-mode read-only nospell)))
+           ;; Or exclude by face using jinx-exclude-faces:
+           ;;   (add-to-list 'jinx-exclude-faces 'org-ref-glossary-face)
+           'nospell t))))
+
+(defface org-ref-glossary-face
+  `((t (:inherit org-link :foreground "Mediumpurple3")))
+  "Face for glossary links.")
+
+
+(defun or-follow-glossary (entry)
+  "Goto beginning of the glossary ENTRY.
+If entry is in an included file, opens that file and navigates to the glossary table."
+  (org-mark-ring-push)
+  (let* ((data (get-text-property (point) 'or-glossary))
+         (file (plist-get data :file))
+         (label (plist-get data :label))
+         (position (plist-get data :position)))
+    (cond
+     ;; Entry in current buffer (has position)
+     (position
+      (goto-char position))
+     ;; Entry in external file
+     (file
+      (find-file file)
+      (goto-char (point-min))
+      (when (re-search-forward "^[ \t]*#\\+name:[ \t]+\\(glossary\\|acronyms\\)" nil t)
+        (when (re-search-forward (regexp-quote label) nil t)
+          (goto-char (line-beginning-position)))))
+     ;; Fallback: search in current buffer
+     (t
+      (goto-char (point-min))
+      (when (re-search-forward "^[ \t]*#\\+name:[ \t]+\\(glossary\\|acronyms\\)" nil t)
+        (when (re-search-forward (regexp-quote label) nil t)
+          (goto-char (line-beginning-position))))))))
+
+
+(defun or-glossary-tooltip (_window buffer position)
+  "Return tooltip for the glossary entry.
+The entry is in WINDOW and OBJECT at POSITION.
+Used in fontification."
+  (when org-ref-glossary-show-tooltips
+    (with-current-buffer buffer
+      (let ((data (get-text-property position 'or-glossary)))
+        (if data
+            (let ((name (or (plist-get data :name)
+                            (plist-get data :abbrv)))
+                  (description (or (plist-get data :description)
+                                   (plist-get data :full))))
+              (when (and name description)
+                (format "%s: %s"
+                        name
+                        (with-temp-buffer
+                          (insert (concat description "."))
+                          (fill-paragraph)
+                          (buffer-string)))))
+          ;; No data found - return helpful message or nil
+          "This is not defined in this file.")))))
+
+
+(defvar org-ref-glossary-gls-commands
+  '(("gls" "The term associated with the label")
+    ("glspl" "The plural term")
+    ("Gls" "The capitalized term")
+    ("Glspl" "The plural capitalized term")
+    ("glssymbol" "The symbol defined (only with latex definition)")
+    ("Glssymbol" "The capitalized symbol defined (only with latex definition)")
+    ("glsdesc" "The description associated with the label")
+    ("Glsdesc" "The capitalized description associated with the label"))
+  "An alist of (cmd description).")
+
+(dolist (command org-ref-glossary-gls-commands)
+  (org-link-set-parameters (cl-first command)
+                          :follow #'or-follow-glossary
+                          :activate-func #'or-activate-glossary 
+                          :help-echo 'or-glossary-tooltip
+                          :export (lambda (path _ format)
+                                    (cond
+                                     ((memq format '(latex beamer))
+                                      (format "\\%s{%s}" (cl-first command) path))
+                                     (t
+                                      (format "%s" path))))))
+
+
+(org-link-set-parameters "glslink"
+                        :follow #'or-follow-glossary
+                        :activate-func #'or-activate-glossary
+                        :face 'org-ref-glossary-face-fn
+                        :help-echo 'or-glossary-tooltip
+                        :export (lambda (path desc format)
+                                  (cond
+                                   ((memq format '(latex beamer))
+                                    (format "\\glslink{%s}{%s}" path desc))
+                                   (t
+                                    (format "%s" path)))))
+
+
+
+
+;; **  printglossaries links
+;; There is a printglossary command in LaTeX, but I am not supporting it for now.
+(org-link-set-parameters "printglossaries"
+                        :export (lambda (path _desc format)
+                                  (cond
+                                   ((memq format '(latex beamer))
+                                    "\\printglossaries")
+                                   (t
+                                    (format "%s" path)))))
+
+
+
+;; ** exporting with a glossary table
+(defun org-ref-glossary-before-parsing (_backend)
+  "Function to preprocess a glossary table on export.
+This assumes a table like
+
+#+name: glossary
+| label | name  | description   |
+|-------+-------+---------------|
+| tree  | Tree  | A woody plant |
+| shrub | Shrub | A woody bush  |
+
+is in the org-buffer, and will add the relevant latex_header
+items if there is. The table is deleted in a copy of the buffer
+before the export, so you can put it where you want. The column
+names are arbitrary, but three columns are expected, and the
+hline is expected.
+
+This is intended to be run in `org-export-before-parsing-hook'."
+  (save-restriction
+    (widen)
+    (let* (begin
+          end
+          (entries (save-excursion
+                     (catch 'found
+                       (org-element-map
+                           (org-element-parse-buffer)
+                           'table
+                         (lambda (el)
+                           (when (and (org-element-property :name el)
+                                      (stringp (org-element-property :name el))
+                                      (string= "glossary" (org-element-property :name el)))
+                             (setq begin (org-element-property :begin el)
+                                   end (org-element-property :end el))
+                             (goto-char (org-element-property :contents-begin el))
+                             (throw 'found
+                                    (nthcdr 2 (org-babel-read-table))))))))))
+      ;; Delete the table
+      (when entries
+       (cl--set-buffer-substring begin end ""))
+
+      (goto-char (point-min))
+      (cl-loop for (label name description) in entries
+              do
+              (insert (format "#+latex_header_extra: \\newglossaryentry{%s}{name=%s,description={{%s}}}\n"
+                              label name description))))))
+
+
+;;* Acronyms
+
+(defun or-parse-acronym-entry (label)
+  "Parse an acronym entry LABEL to a plist.
+Returns (:abbrv abbrv :full full :label label)
+The plist maps to \newacronym{<label>}{<abbrv>}{<full>}"
+  (if (and org-ref-acronym-cache (gethash label org-ref-acronym-cache))
+      ;; We have the cache, and an entry and use it
+      (gethash label org-ref-acronym-cache)
+    ;; We don't have a cache, or an label in it, so we find it.
+    ;; No cache? we make one
+    (unless org-ref-acronym-cache
+      (setq-local org-ref-acronym-cache (make-hash-table :test 'equal )))
+
+    ;; Now search for the data
+    (save-excursion
+      (goto-char (point-min))
+      (let* (abbrv
+            full p1
+            (external (when (re-search-forward "\\\\loadglsentries\\(\\[.*\\]\\)?{\\(?1:.*\\)}" nil t)
+                        (match-string 1)))
+            (glsentries (and external
+                             (or (cdr (assoc external org-ref-glsentries))
+                                 (progn
+                                   (cl-pushnew (cons external
+                                                     (string-trim (shell-command-to-string
+                                                              (format "kpsewhich tex %s" external))))
+                                               org-ref-glsentries)
+                                   (cdr (assoc external org-ref-glsentries))))))
+            data)
+       (setq data
+             (catch 'data
+               (goto-char (point-min))
+               ;; check in the definitions of newacronym
+               (when (re-search-forward (format "\\newacronym{%s}" label) nil t)
+                 (setq p1 (+ 1 (point)))
+                 (forward-list)
+                 (setq abbrv (buffer-substring p1 (- (point) 1)))
+                 (setq p1 (+ 1 (point)))
+                 (forward-list)
+                 (setq full (buffer-substring p1 (- (point) 1)))
+                 (throw 'data
+                        (list :label label :abbrv abbrv :full full)))
+
+               ;; look for acronyms table
+               (let* ((entries (save-excursion
+                                 (catch 'found
+                                   (org-element-map
+                                       (org-element-parse-buffer)
+                                       'table
+                                     (lambda (el)
+                                       (when (string= "acronyms" (org-element-property :name el))
+                                         (goto-char (org-element-property :contents-begin el))
+                                         (throw 'found
+                                                (nthcdr 2 (org-babel-read-table)))))))))
+                      (result (assoc label entries)))
+                 (when result
+                   (throw 'data (list :label label
+                                      :abbrv (cl-second result) :full (cl-third result)))))
+
+               ;; look external
+               (when (and glsentries
+                          (file-exists-p glsentries))
+                 (with-current-buffer (find-file-noselect glsentries)
+                   (goto-char (point-min))
+                   (when (re-search-forward (format "\\newacronym{%s}" label) nil t)
+                     (setq p1 (+ 1 (point)))
+                     (forward-list)
+                     (setq abbrv (buffer-substring p1 (- (point) 1)))
+                     (setq p1 (+ 1 (point)))
+                     (forward-list)
+                     (setq full (buffer-substring p1 (- (point) 1)))
+                     (throw 'data
+                            (list :label label :abbrv abbrv :full full )))))))
+       (puthash label data org-ref-acronym-cache)
+       data))))
+
+
+(defun org-ref-glossary-invalidate-caches ()
+  "Function to invalidate the caches."
+  (interactive)
+  (setq-local org-ref-acronym-cache (make-hash-table :test 'equal))
+  (setq-local org-ref-glossary-cache (make-hash-table :test 'equal)))
+
+;;** Acronym links
+
+(defun or-activate-acronym (start end path bracketp)
+  "Activate function for an acronym link.
+set data on text with properties
+Set face property, and help-echo."
+  (let ((data (or (or-parse-acronym-entry path)
+                  ;; Try multi-file lookup if enabled and not found in current buffer
+                  (or-parse-acronym-entry-multi-file path))))
+    (add-text-properties
+     start end
+     (list 'or-glossary data
+          'face (if data
+                    'org-ref-acronym-face
+                  'font-lock-warning-face)
+           ;; Suppress spell-checking with nospell property.
+           ;; For jinx users: add 'nospell to jinx-exclude-properties:
+           ;;   (setq jinx-exclude-properties '((org-mode read-only nospell)))
+           ;; Or exclude by face using jinx-exclude-faces:
+           ;;   (add-to-list 'jinx-exclude-faces 'org-ref-acronym-face)
+           'nospell t))))
+
+
+(defun or-follow-acronym (label)
+  "Go to the definition of the acronym LABEL.
+If entry is in an included file, opens that file and navigates to the acronym table."
+  (org-mark-ring-push)
+  (let* ((data (get-text-property (point) 'or-glossary))
+         (file (plist-get data :file))
+         (entry-label (plist-get data :label)))
+    (cond
+     ;; Entry in external file
+     (file
+      (find-file file)
+      (goto-char (point-min))
+      (if (and (re-search-forward "^[ \t]*#\\+name:[ \t]+acronyms" nil t)
+               (re-search-forward (regexp-quote entry-label) nil t))
+          (goto-char (line-beginning-position))
+        (message "Entry %s not found in %s" entry-label file)))
+     ;; Entry in current buffer - try table first
+     ((progn (goto-char (point-min))
+             (and (re-search-forward "#\\+name: acronyms" nil t)
+                  (re-search-forward label nil t)))
+      nil)
+     ;; Try LaTeX format
+     ((progn (goto-char (point-min))
+             (re-search-forward (format "\\newacronym{%s}" label) nil t))
+      (goto-char (match-beginning 0)))
+     (t
+      (message "no entry found for %s" label)))))
+
+
+;;** Tooltips on acronyms
+(defface org-ref-acronym-face
+  `((t (:inherit org-link :foreground "Darkorange2")))
+  "Face for acronym links.")
+
+
+(defun or-acronym-tooltip (_window buffer position)
+  "Return tooltip for the acronym entry.
+The entry is in WINDOW and OBJECT at POSITION.
+Used in fontification.
+WINDOW and OBJECT are ignored."
+  (when org-ref-glossary-show-tooltips
+    (with-current-buffer buffer
+      (save-excursion
+        (goto-char position)
+        (let ((acronym-data (get-text-property position 'or-glossary)))
+          (if acronym-data
+              (let ((abbrv (plist-get acronym-data :abbrv))
+                    (full (plist-get acronym-data :full)))
+                (when (and abbrv full)
+                  (format "%s: %s" abbrv full)))
+            "This is not defined in this file."))))))
+
+
+(defvar org-ref-acronym-types
+  '(("acrshort" "The acronym for label")
+    ("acrshortpl" "The acronym for label in plural")
+    ("Acrshort" "Capitalized acronym")
+    ("Acrshortpl" "Plural capitalized acronym")
+    ("ACRshort" "ALL-CAPS acronym")
+    ("ACRshortpl" "ALL-CAPS plural acronym")
+    
+    ("acrlong" "The label definition")
+    ("acrlongpl" "The plural definition")
+    ("Acrlong" "Capitalized definition")
+    ("Acrlongpl" "Plural capitalized definition")
+    ("ACRlong" "ALL-CAPS definition")
+    ("ACRlongpl" "plural ALL-CAPS definition")
+    
+    ("acrfull" "Both the acronym and its definition")
+    ("acrfullpl" "Both the acronym and its definition in plural")
+    ("Acrfull" "Capitalized both the acronym and its definition")
+    ("Acrfullpl" "Capitalized both the acronym and its definition in plural")
+    ("ACRfull" "Both the acronym and its definition in ALL-CAPS")
+    ("ACRfullpl" "Both the acronym and its definition in plural ALL-CAPS"))
+  "list of acronym types (type description)")
+
+
+(cl-dolist (mapping org-ref-acronym-types)
+  (org-link-set-parameters (cl-first mapping)
+                          :follow #'or-follow-acronym
+                          :activate-func #'or-activate-acronym 
+                          :help-echo #'or-acronym-tooltip
+                          :export (lambda (path _ format)
+                                    (cond
+                                     ((memq format '(latex beamer))
+                                      (format "\\%s{%s}" (cl-first mapping) path))
+                                     (t
+                                      (format "%s" (upcase path)))))))
+
+
+
+
+;; ** Exporting with an acronym table
+(defun org-ref-acronyms-before-parsing (_backend)
+  "Function to preprocess a glossary table on export.
+This assumes a table like
+
+#+name: acronyms
+| Key  | Short | Long                           |
+|------+-------+--------------------------------|
+| mimo |       | multiple-input multiple output |
+| qos  | QoS   | quality-of-service             |
+| bb   | BB    | branch and bound               |
+
+is in the org-buffer, and will add the relevant latex_header items if there is. The table is deleted in a copy of the buffer before the export.
+
+This will run in `org-export-before-parsing-hook'."
+  (save-restriction
+    (widen)
+    (let* (begin
+          end
+          (entries (save-excursion
+                     (catch 'found
+                       (org-element-map
+                           (org-element-parse-buffer)
+                           'table
+                         (lambda (el)
+                           (when (and (org-element-property :name el)
+                                      (stringp (org-element-property :name el))
+                                      (string= "acronyms" (org-element-property :name el)))
+                             (setq begin (org-element-property :begin el)
+                                   end (org-element-property :end el))
+                             (goto-char (org-element-property :contents-begin el))
+                             (throw 'found
+                                    (nthcdr 2 (org-babel-read-table))))))))))
+      (when entries
+       ;; Delete the table
+       (cl--set-buffer-substring begin end ""))
+
+      (goto-char (point-min))
+      (cl-loop for (label name description) in entries
+              do
+              (insert (format "#+latex_header_extra: \\newacronym{%s}{%s}{%s}\n"
+                              label name description))))))
+
+
+;; * Interactive command to insert acroynm/glossary links
+
+(defun org-ref-insert-glossary-link ()
+  "Insert glossary entry as links."
+  (interactive)
+  ;; gather entries
+  (let* ((glossary-candidates '()) 
+        key entry type
+        type-annotation
+        completion-extra-properties
+        choice)
+
+    ;; glossary terms
+    (save-excursion
+      (goto-char (point-min))
+      (while (re-search-forward
+             "\\\\newglossaryentry{\\([[:ascii:]]+?\\)}" nil t)
+
+       (setq key (match-string 1)
+             entry (or-parse-glossary-entry key))
+
+       (cl-pushnew (cons
+                    (propertize (format "%s: %s - glossary."
+                                        (plist-get entry :name)
+                                        (plist-get entry :description))
+                                'face 'org-ref-glossary-face)
+                    entry)
+                   glossary-candidates)))
+
+    ;; get entries from the table
+    (let ((entries (save-excursion
+                    (catch 'found
+                      (org-element-map
+                          (org-element-parse-buffer)
+                          'table
+                        (lambda (el)
+                          (when (and (org-element-property :name el)
+                                     (stringp (org-element-property :name el))
+                                     (string= "glossary"
+                                              (org-element-property :name el)))
+                            (goto-char (org-element-property :contents-begin el))
+                            (throw 'found
+                                   ;; skip header and hline
+                                   (nthcdr 2 (org-babel-read-table))))))))))
+      (cl-loop for (label name description) in entries do
+              (cl-pushnew (cons
+                           (propertize (format "%s: %s - glossary."
+                                               label
+                                               description)
+                                       'face 'org-ref-glossary-face)
+                           (list :label label :name name :description description))
+                          glossary-candidates)))
+
+
+    (setq choice (completing-read "Choose: " glossary-candidates)
+         entry (cdr (assoc choice glossary-candidates))
+         type-annotation (lambda (s)
+                           (let ((item (assoc s minibuffer-completion-table)))
+                             (when item (concat
+                                         (make-string (- 12 (length s)) ? )
+                                         "-- "
+                                         (cl-second item)))))
+         completion-extra-properties `(:annotation-function ,type-annotation)
+         type (completing-read "Type: "
+                               org-ref-glossary-gls-commands
+                               nil t))
+
+    (insert (format
+            "[[%s:%s][%s]]"
+            type
+            (plist-get entry :label)
+            (pcase type
+              ("gls" (plist-get entry :name))
+              ("glspl" (concat (plist-get entry :name) "s"))
+              ("Gls" (concat (capitalize (substring (plist-get entry :name) 0 1))
+                             (substring (plist-get entry :name) 1)))
+              ("Glspl" (concat (capitalize (substring (plist-get entry :name) 0 1))
+                               (substring (plist-get entry :name) 1)
+                               "s"))
+              ("glssymbol" (plist-get entry :name))
+              ("Glssymbol" (concat (capitalize (substring (plist-get entry :name) 0 1))
+                                   (substring (plist-get entry :name) 1)))
+              ("glsdesc" (plist-get entry :description))
+              ("Glsdesc" (concat (capitalize (substring (plist-get entry :description) 0 1))
+                                 (substring (plist-get entry :description) 1)))
+              ;; fall-through for everything else
+              (_ (plist-get entry :name)))))))
+
+
+(defun org-ref-insert-acronym-link ()
+  "Insert acronym entry as links."
+  (interactive)
+  ;; gather entries
+  (let* ((acronym-candidates '())
+        key entry
+        type
+        type-annotation
+        completion-extra-properties
+        choice
+        (cap1 (lambda (s)
+                "capitalize first letter only"
+                (concat
+                 (capitalize (substring s 0 1))
+                 (substring s 1)))))
+
+    (save-excursion
+      (goto-char (point-min))
+      (while (re-search-forward
+             "\\\\newacronym{\\([[:ascii:]]+?\\)}" nil t)
+       (setq key (match-string 1)
+             entry (or-parse-acronym-entry key))
+       (cl-pushnew (cons (propertize
+                          (format "%s (%s) - acronym."
+                                  (plist-get entry :full)
+                                  (plist-get entry :abbrv))
+                          'face 'org-ref-acronym-face)
+                         entry)
+                   acronym-candidates)))
+
+    (let ((entries (save-excursion
+                    (catch 'found
+                      (org-element-map
+                          (org-element-parse-buffer)
+                          'table
+                        (lambda (el)
+                          (when (and (org-element-property :name el)
+                                     (stringp (org-element-property :name el))
+                                     (string= "acronyms"
+                                              (org-element-property :name el)))
+                            (goto-char (org-element-property :contents-begin el))
+                            (throw 'found
+                                   ;; skip header and hline
+                                   (nthcdr 2 (org-babel-read-table))))))))))
+      (cl-loop for (key abbrv full) in entries do
+              (cl-pushnew (cons (propertize
+                                 (format "%s (%s) - acronym."
+                                         full
+                                         abbrv)
+                                 'face 'org-ref-acronym-face)
+                                (list :label key :abbrv abbrv :full full))
+                          acronym-candidates)))
+
+    (setq choice (completing-read "Choose: " acronym-candidates)
+         entry (cdr (assoc choice acronym-candidates))
+         type-annotation (lambda (s)
+                           (let ((item (assoc s minibuffer-completion-table)))
+                             (when item (concat
+                                         (make-string (- 12 (length s)) ? )
+                                         "-- "
+                                         (cl-second item)))))
+         
+         completion-extra-properties `(:annotation-function ,type-annotation)
+         type (completing-read "Type: "
+                               org-ref-acronym-types
+                               nil t))
+
+    (insert (format
+            "[[%s:%s][%s]]"
+            type
+            (plist-get entry :label)
+            (pcase type
+              ("acrshort" (plist-get entry :abbrv))
+              ;; this is a cheap way to pluralize. I don't know what the rules
+              ;; are in LaTeX. this is only for display, so it isn't critical.
+              ("acrshortpl" (concat (plist-get entry :abbrv) "s"))
+              
+              ("Acrshort" (funcall cap1 (plist-get entry :abbrv)))
+              ("Acrshortpl" (concat (capitalize (plist-get entry :abbrv)) "s"))
+
+              ("ACRshort" (upcase (plist-get entry :abbrv)))
+              ("ACRshortpl" (concat (upcase (plist-get entry :abbrv)) "s"))
+
+              ("acrlong" (plist-get entry :full))
+              ("acrlongpl" (concat (plist-get entry :full) "s"))
+              
+              ("Acrlong" (funcall cap1 (plist-get entry :full)))
+              ("Acrlongpl" (concat (funcall cap1 (plist-get entry :full)) "s"))
+              
+              ("acrfull" (format "%s (%s)"
+                                 (plist-get entry :full)
+                                 (plist-get entry :abbrv)))
+              ("acrfullpl" (format "%ss (%ss)"
+                                   (plist-get entry :full)
+                                   (plist-get entry :abbrv)))
+              
+              ("Acrfull" (funcall cap1 (format "%s (%s)"
+                                               (plist-get entry :full)
+                                               (plist-get entry :abbrv))))
+              ("Acrfullpl" (funcall cap1 (format "%ss (%ss)"
+                                                 (plist-get entry :full)
+                                                 (plist-get entry :abbrv))))
+              ("ACRfull" (upcase (format "%s (%s)"
+                                         (plist-get entry :full)
+                                         (plist-get entry :abbrv))))
+              ("ACRfullpl" (upcase (format "%ss (%ss)"
+                                           (plist-get entry :full)
+                                           (plist-get entry :abbrv))))
+              ;; fall-through in case anything is added later.
+              (_ (plist-get entry :abbrv)))))))
+
+
+;; * acrossproc - acronym and glossary preprocessor
+;;
+;; Replace printglossary with the acronym and glossary entries
+;;
+;; Replace the links with links
+;;
+;; TODO: support only one or the other? via printglossary:acronyms for example?
+
+(defun org-ref-acrossproc (_backend)
+  "Preprocessing function for acronyms and glossary entries.
+Meant for non-LaTeX exports."
+  (save-excursion
+    (let* ((glossary)
+          (acronyms)
+          (printglossary-link)
+          (links))
+
+      (setq glossary (org-element-map
+                        (org-element-parse-buffer)
+                        'table 
+                      (lambda (el)
+                        (when (and (org-element-property :name el)
+                                   (stringp (org-element-property :name el))
+                                   (string= "glossary" (org-element-property :name el))) 
+                          (goto-char (org-element-property :contents-begin el))
+                          (prog1
+                              ;; skip header and hline
+                              (nthcdr 2 (org-babel-read-table))
+                            ;; delete the table
+                            (cl--set-buffer-substring (org-element-property :begin el)
+                                                      (org-element-property :end el)
+                                                      ""))))
+                      nil t))
+      (setq acronyms (org-element-map
+                        (org-element-parse-buffer)
+                        'table 
+                      (lambda (el)
+                        (when (and (org-element-property :name el)
+                                   (stringp (org-element-property :name el))
+                                   (string= "acronyms" (org-element-property :name el))) 
+                          (goto-char (org-element-property :contents-begin el))
+                          (prog1
+                              (nthcdr 2 (org-babel-read-table))
+                            ;; delete the table
+                            (cl--set-buffer-substring (org-element-property :begin el)
+                                                      (org-element-property :end el)
+                                                      ""))))
+                      nil t))
+      
+      ;; Replace printglossary link
+      ;; For each entry, use - name :: description <<label>>
+      (setq printglossary-link (org-element-map
+                                  ;; reparse in case the replacement above changed places
+                                  (org-element-parse-buffer)
+                                  'link
+                                (lambda (lnk)
+                                  (when (string= "printglossaries"
+                                                 (org-element-property :type lnk))
+                                    lnk))
+                                nil t))
+      (when printglossary-link
+       (cl--set-buffer-substring (org-element-property :begin printglossary-link)
+                                 (org-element-property :end printglossary-link)
+                                 
+                                 (concat "*Glossary*\n"
+                                         (string-join
+                                          (cl-loop for (label name description) in glossary collect
+                                                   (format "<<%s>>\n- %s :: %s" label name description))
+                                          "\n")
+
+                                         "\n*Acronyms*\n"
+                                         (string-join
+                                          (cl-loop for (label name description) in acronyms collect
+                                                   (format "<<%s>>\n- %s :: %s " label name description))
+                                          "\n"))))
+
+
+      ;; Replace links
+      (setq links (org-element-map
+                     ;; reparse in case the replacement above changed places
+                     (org-element-parse-buffer)
+                     'link
+                   (lambda (lnk)
+                     (when (assoc (org-element-property :type lnk)
+                                  (append org-ref-glossary-gls-commands
+                                          org-ref-acronym-types))
+                       lnk))))
+      ;; For each link, replace with [[label][link description]]
+      (cl-loop for lnk in (reverse links) do
+              (cl--set-buffer-substring (org-element-property :begin lnk)
+                                        (org-element-property :end lnk)
+                                        (format "[[%s][%s]]%s"
+                                                (org-element-property :path lnk)
+                                                (buffer-substring (org-element-property :contents-begin lnk)
+                                                                  (org-element-property :contents-end lnk))
+                                                (make-string (org-element-property :post-blank lnk) ? )))))))
+
+
+;;** Jinx spell-checker integration
+
+;; Automatically configure jinx to exclude glossary and acronym links from
+;; spell-checking if jinx is loaded. This prevents jinx from marking these
+;; links as typos.
+;;
+;; This configuration applies immediately if jinx is already loaded, or will
+;; take effect when jinx is loaded in the future.
+(defun org-ref-glossary--configure-jinx ()
+  "Add glossary and acronym faces to jinx-exclude-faces for org-mode."
+  (when (boundp 'jinx-exclude-faces)
+    ;; jinx-exclude-faces is an alist: ((mode face1 face2 ...) ...)
+    ;; We need to add our faces to the org-mode entry
+    (let ((org-entry (assq 'org-mode jinx-exclude-faces)))
+      (if org-entry
+          ;; org-mode entry exists, add our faces to it
+          (progn
+            (unless (memq 'org-ref-glossary-face org-entry)
+              (setcdr org-entry (cons 'org-ref-glossary-face (cdr org-entry))))
+            (unless (memq 'org-ref-acronym-face org-entry)
+              (setcdr org-entry (cons 'org-ref-acronym-face (cdr org-entry)))))
+        ;; org-mode entry doesn't exist, create it
+        (push '(org-mode org-ref-glossary-face org-ref-acronym-face)
+              jinx-exclude-faces)))
+    (message "org-ref-glossary: Configured jinx to exclude glossary/acronym faces in org-mode")))
+
+;; Configure immediately if jinx is already loaded
+(when (featurep 'jinx)
+  (org-ref-glossary--configure-jinx))
+
+;; Also configure when jinx loads in the future
+(with-eval-after-load 'jinx
+  (org-ref-glossary--configure-jinx))
+
+
+(provide 'org-ref-glossary)
+;;; org-ref-glossary.el ends here
diff --git a/elpa/org-ref-20251206.1422/org-ref-helm.el b/elpa/org-ref-20251206.1422/org-ref-helm.el
new file mode 100644 (file)
index 0000000..162baa7
--- /dev/null
@@ -0,0 +1,113 @@
+;;; org-ref-helm.el --- org-ref interface to helm-bibtex -*- lexical-binding: t; -*-
+
+;; Copyright(C) 2014-2024 John Kitchin
+
+;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
+;; URL: https://github.com/jkitchin/org-ref
+;; Keywords: org-mode, cite, ref, label
+;; Package-Requires: ((helm-bibtex "0") (org-ref "0"))
+
+;; This file is not currently part of GNU Emacs.
+
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation; either version 2, or (at
+;; your option) any later version.
+
+;; This program is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program ; see the file COPYING.  If not, write to
+;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+;;
+;; Adapted from helm-bibtex, mostly so you get the default action to insert a citation
+
+(require 'org-ref-core)
+(require 'helm-bibtex)
+
+(defvar helm-bibtex-local-bib)  ; to quiet compiler. 
+
+;;; Code:
+
+(helm-bibtex-helmify-action org-ref-insert-cite-keys org-ref-helm-bibtex-insert-citation)
+
+(defvar org-ref-helm-source-bibtex
+  (helm-build-sync-source "BibTeX entries"
+    :header-name (lambda (name)
+                   (format "%s%s: " name (if helm-bibtex-local-bib " (local)" "")))
+    :candidates 'helm-bibtex-candidates
+    :filtered-candidate-transformer 'helm-bibtex-candidates-formatter
+    :action (helm-make-actions
+            "Insert citation"            'org-ref-helm-bibtex-insert-citation
+            "Insert reference"           'helm-bibtex-insert-reference
+             "Open PDF, URL or DOI"       'helm-bibtex-open-any
+             "Open URL or DOI in browser" 'helm-bibtex-open-url-or-doi
+             "Insert BibTeX key"          'helm-bibtex-insert-key
+             "Insert BibTeX entry"        'helm-bibtex-insert-bibtex
+             "Attach PDF to email"        'helm-bibtex-add-PDF-attachment
+             "Edit notes"                 'helm-bibtex-edit-notes
+             "Show entry"                 'helm-bibtex-show-entry
+             "Add PDF to library"         'helm-bibtex-add-pdf-to-library))
+  "Source for searching in BibTeX files.")
+
+(defvar org-ref-helm-source-fallback-options
+  '((name            . "Fallback options")
+    (match             (lambda (_candidate) t))
+    (candidates      . bibtex-completion-fallback-candidates)
+    (no-matchplugin)
+    (nohighlight)
+    (action          . (lambda (candidate) (bibtex-completion-fallback-action candidate helm-pattern))))
+  "Source for online look-up.")
+
+;; Helm-bibtex command:
+
+;;;###autoload
+(defun org-ref-cite-insert-helm (&optional arg local-bib input)
+  "Search BibTeX entries.
+
+With a prefix ARG, the cache is invalidated and the bibliography
+reread.
+
+If LOCAL-BIB is non-nil, display that the BibTeX entries are read
+from the local bibliography.  This is set internally by
+`helm-bibtex-with-local-bibliography'.
+
+If INPUT is non-nil and a string, that value is going to be used
+as a predefined search term.  Can be used to define functions for
+frequent searches (e.g. your own publications)."
+  (interactive "P")
+  (when arg
+    (bibtex-completion-clear-cache))
+  (bibtex-completion-init)
+  (let* ((candidates (bibtex-completion-candidates))
+         (key (bibtex-completion-key-at-point))
+         (preselect (and key
+                         (cl-position-if (lambda (cand)
+                                          (member (cons "=key=" key)
+                                                  (cdr cand)))
+                                         candidates))))
+    (helm :sources (list org-ref-helm-source-bibtex org-ref-helm-source-fallback-options)
+          :full-frame helm-bibtex-full-frame
+          :buffer "*helm bibtex*"
+          :input input
+          :preselect (lambda ()
+                      (and preselect
+                           (> preselect 0)
+                           (helm-next-line preselect)))
+          :candidate-number-limit (max 500 (1+ (or preselect 0)))
+          :bibtex-candidates candidates
+          :bibtex-local-bib local-bib)))
+
+
+(setq org-ref-insert-cite-function 'org-ref-cite-insert-helm)
+
+
+(provide 'org-ref-helm)
+
+;;; org-ref-helm.el ends here
diff --git a/elpa/org-ref-20251206.1422/org-ref-isbn.el b/elpa/org-ref-20251206.1422/org-ref-isbn.el
new file mode 100644 (file)
index 0000000..4d0c086
--- /dev/null
@@ -0,0 +1,262 @@
+;;; org-ref-isbn.el --- utilities for generating bibtex entries from an ISBN  -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2015-2024  John Kitchin
+
+;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
+;; Keywords: convenience
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Provides functions to download bibtex entries from isbn numbers.
+
+;;; Code:
+(require 'org-ref-utils)
+(require 'org)
+
+(declare-function org-ref-possible-bibfiles "org-ref-core" ())
+(declare-function org-ref-clean-bibtex-entry "org-ref-bibtex" ())
+
+(defvar url-http-end-of-headers)
+
+;;* ISBN utility
+
+(defcustom org-ref-isbn-clean-bibtex-entry-hook
+  '(oricb-remove-enclosing-brackets
+    oricb-clean-author-field
+    oricb-remove-period
+    oricb-kill-fields
+    oricb-replace-field-names)
+  "Hook that is run in `org-ref-isbn-clean-bibtex-entry'.
+The functions should have no arguments, and operate on the bibtex
+entry at point. You can assume point starts at the beginning of the
+entry. These functions are wrapped in `save-restriction' and
+`save-excursion' so you do not need to save the point position."
+  :group 'org-ref-isbn
+  :type 'hook)
+
+
+(defcustom org-ref-isbn-exclude-fields nil
+  "List of bibtex fields to kill when new entry is inserted."
+  :group 'org-ref-isbn
+  :type '(repeat :tag "List of bibtex fields to kill" string))
+
+
+(defcustom org-ref-isbn-field-name-replacements nil
+  "List of bitex field name/replacement pairs.
+The entries in this list are cons cells where the car is the field name
+and cdr is the replacement name."
+  :group 'org-ref-isbn
+  :type '(repeat (cons (string :tag "Field name")
+                      (string :tag "Field name replacement"))))
+
+
+(defun oricb-replace-field-names ()
+  "Replace bibtex field names defined in
+`org-ref-isbn-field-name-replacements'."
+  (when org-ref-isbn-field-name-replacements
+    (mapcar (lambda (field)
+             (bibtex-beginning-of-entry)
+             (let ((f (bibtex-autokey-get-field (car field))))
+               (unless (string= "" f)
+                 (goto-char (cadr (bibtex-search-forward-field (car field) t)))
+                 (bibtex-kill-field)
+                 (bibtex-make-field (cdr field))
+                 (backward-char)
+                 (insert f))))
+           org-ref-isbn-field-name-replacements)))
+
+
+(defun oricb-kill-fields ()
+  "Kill all bibtex fields defined in `org-ref-isbn-exclude-fields'."
+  (when org-ref-isbn-exclude-fields
+    (mapcar (lambda (field)
+             (bibtex-beginning-of-entry)
+             (let ((f (bibtex-autokey-get-field field)))
+               (unless (string= "" f)
+                 (goto-char (cadr (bibtex-search-forward-field field t)))
+                 (bibtex-kill-field))))
+           org-ref-isbn-exclude-fields)))
+
+
+(defun oricb-remove-enclosing-brackets ()
+  "Remove enclosing brackets from fields."
+  (save-restriction
+    (bibtex-narrow-to-entry)
+    (while (re-search-forward "\\({\\)\\(\\[\\)\\(.+\\)\\(]\\)\\(}\\)" nil t)
+      (replace-match "\\1\\3\\5"))))
+
+
+(defun oricb-clean-author-field ()
+  "Remove extra information from author's field."
+  (goto-char (cadr (bibtex-search-forward-field "author" t)))
+  (let ((case-fold-search nil))
+    (when (re-search-forward "\\({\\)\\(by \\|ed. by \\|edited by \\)" nil t)
+      (replace-match "\\1"))))
+
+
+(defun oricb-remove-period ()
+  "Remove period from author's field."
+  (goto-char (cadr (bibtex-search-forward-field "author" t)))
+  (when (re-search-forward "\\(\\.\\)\\(}\\)" nil t)
+    (replace-match "\\2")))
+
+
+;;;###autoload
+(defun org-ref-isbn-clean-bibtex-entry ()
+  "Clean a bibtex entry inserted via `isbn-to-bibtex'.
+See functions in `org-ref-isbn-clean-bibtex-entry-hook'."
+  (interactive)
+  (bibtex-beginning-of-entry)
+  (mapc (lambda (x)
+         (save-restriction
+           (save-excursion
+             (funcall x))))
+       org-ref-isbn-clean-bibtex-entry-hook))
+
+
+;; I found this on the web. It can be handy, but the bibtex entry has a lot of stuff in it.
+
+;;;###autoload
+(defun isbn-to-bibtex-lead (isbn)
+  "Search lead.to for ISBN bibtex entry.
+You have to copy the entry if it is on the page to your bibtex
+file."
+  (interactive "sISBN: ")
+  (browse-url
+   (format
+    "http://lead.to/amazon/en/?key=%s+&si=all&op=bt&bn=&so=sa&ht=us"
+    isbn)))
+
+
+;; Here we get isbn metadata and build a bibtex entry.
+
+;;;###autoload
+(defun isbn-to-bibtex (isbn bibfile)
+  "Get bibtex entry for ISBN and insert it into BIBFILE.
+Nothing happens if an entry with the generated key already exists
+in the file. Data comes from www.ebook.de."
+  (interactive
+   (list
+    (read-string
+     "ISBN: "
+     ;; now set initial input
+     (cond
+      ;; If region is active and it starts with a number, we use it
+      ((and  (region-active-p)
+             (org-ref--string-match "^[0-9]" (buffer-substring (region-beginning) (region-end))))
+       (buffer-substring (region-beginning) (region-end)))
+      ;; if first entry in kill ring starts with a number assume it is an isbn
+      ;; and use it as the guess
+      ((stringp (car kill-ring))
+       (when (org-ref--string-match "^[0-9]" (car kill-ring))
+        (car kill-ring)))
+      ;; type or paste it in
+      (t
+       nil)))
+    (completing-read "Bibfile: " (org-ref-possible-bibfiles))))
+
+  (let* ((url (format "https://www.ebook.de/de/tools/isbn2bibtex?isbn=%s" isbn))
+        (entry))
+    (with-current-buffer (url-retrieve-synchronously url t t)
+      (goto-char (point-min))
+      (when (re-search-forward "@[a-zA-Z]+{.+\\(\n\s+[^\n]+\\)+}$" nil t)
+       (setq entry (match-string 0))))
+
+    (if (not entry)
+       (message "Nothing found.")
+      (find-file bibfile)
+      (goto-char (point-max))
+      (insert (with-temp-buffer
+               (insert (concat entry "\n}"))
+               (goto-char (point-min))
+               ;; [2020-06-06 Sat] I got a report that ottobib returns entries
+               ;; with ,, in the first line. here if we find one, I eliminate
+               ;; one of them.
+               (when (re-search-forward ",," nil t)
+                 (delete-char -1))
+               (org-ref-isbn-clean-bibtex-entry)
+               (org-ref-clean-bibtex-entry)
+               (bibtex-fill-entry)
+               (string-trim (buffer-string))))
+      (save-buffer))))
+
+
+(defun isbn-to-bibtex-open-library (isbn bibfile)
+  "Retrieve bibtex entry for a book with ISBN using openlibrary.org.
+
+API: https://openlibrary.org/developers/api
+"
+  (interactive
+   (list
+    (read-string
+     "ISBN: "
+     ;; now set initial input
+     (cond
+      ;; If region is active and it starts with a number, we use it
+      ((and  (region-active-p)
+             (org-ref--string-match "^[0-9]" (buffer-substring (region-beginning) (region-end))))
+       (buffer-substring (region-beginning) (region-end)))
+      ;; if first entry in kill ring starts with a number assume it is an isbn
+      ;; and use it as the guess
+      ((stringp (car kill-ring))
+       (when (org-ref--string-match "^[0-9]" (car kill-ring))
+        (car kill-ring)))
+      ;; type or paste it in
+      (t
+       nil)))
+    (completing-read "Bibfile: " (org-ref-possible-bibfiles))))
+
+  (let* ((url (format "https://openlibrary.org/isbn/%s.json" isbn))
+        (json (with-current-buffer (url-retrieve-synchronously url)
+                (json-read-from-string (string-trim (buffer-substring url-http-end-of-headers (point-max))))))
+        (title (cdr (assoc 'title json)))
+        (publisher (string-join (cdr (assoc 'publishers json)) ", "))
+        (year (cdr (assoc 'publish_date  json)))
+        ;; this is a list of urls
+        (author-urls (cdr (assoc 'authors json)))
+        (authors (string-join
+                         (cl-loop for aurl across author-urls
+                                  collect
+                                  (with-current-buffer (url-retrieve-synchronously
+                                                        (format "https://openlibrary.org%s.json"
+                                                                (cdr (assoc 'key  aurl))))
+                                    (cdr (assoc 'personal_name
+                                                (json-read-from-string
+                                                 (string-trim (buffer-substring url-http-end-of-headers (point-max))))))))
+                         " and "))
+        (burl (format "https://openlibrary.org%s" (cdr (assoc 'key json))))
+        (bibtex (format "@Book{,
+  author =      {%s},
+  title =       {%s},
+  publisher =   {%s},
+  year =        {%s},
+  url = {%s}
+}"
+                        authors
+                        title
+                        publisher
+                        year
+                        burl)))
+
+    (with-current-buffer (find-file-noselect bibfile)
+      (goto-char (point-max))
+      (insert "\n\n")
+      (insert bibtex)
+      (org-ref-clean-bibtex-entry)
+      (save-buffer))))
+
+(provide 'org-ref-isbn)
+;;; org-ref-isbn.el ends here
diff --git a/elpa/org-ref-20251206.1422/org-ref-ivy.el b/elpa/org-ref-20251206.1422/org-ref-ivy.el
new file mode 100644 (file)
index 0000000..0d13a28
--- /dev/null
@@ -0,0 +1,175 @@
+;;; org-ref-ivy.el --- org-ref with ivy completion -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2016-2024  John Kitchin
+
+;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
+;; URL: https://github.com/jkitchin/org-ref
+;; Keywords: org-mode, cite, ref, label
+;; Package-Requires: ((org-ref "0") (ivy-bibtex "0"))
+
+;; This file is not currently part of GNU Emacs.
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+;; This customizes org-ref specifically around using ivy and ivy-bibtex. The
+;; citation selection looks like `ivy-bibtex' but it is a customized ivy
+;; function with customized actions.
+
+;; ivy-bibtex is optional, and it causes compiling errors if not installed. I
+;; think this might fix that.
+(when (and (bound-and-true-p byte-compile-current-file)
+           (not (locate-library "ivy-bibtex")))
+  (message "org-ref-ivy: skipping byte-compile; ivy-bibtex not installed.")
+  (setq byte-compile-current-file nil)
+  (throw 'byte-compile-top-level nil))
+
+
+(require 'org-ref-core)
+(require 'ivy-bibtex)
+
+;; Declare variable before any potential use (including in macros)
+;; Initialize with nil to avoid "void variable" error
+(defvar org-ref-citation-alternate-insert-actions nil
+  "Actions for ivy citation insertion. Set by defcustom below.")
+
+;; all these functions are defined in ivy-bibtex, but not in a variable. Here
+;; you can set them as you see fit.
+(defcustom org-ref-citation-alternate-insert-actions
+  '(("p" ivy-bibtex-open-pdf "Open PDF file (if present)")
+    ("u" ivy-bibtex-open-url-or-doi "Open URL or DOI in browser")
+    ;; this insert-citation only inserts an org-ref cite.
+    ;; ("c" ivy-bibtex-insert-citation "Insert citation")
+    ("R" ivy-bibtex-insert-reference "Insert formatted reference")
+    ("k" ivy-bibtex-insert-key "Insert BibTeX key")
+    ("b" ivy-bibtex-insert-bibtex "Insert BibTeX entry")
+    ("a" ivy-bibtex-add-PDF-attachment "Attach PDF to email")
+    ("e" ivy-bibtex-edit-notes "Edit notes")
+    ("s" ivy-bibtex-show-entry "Show entry")
+    ("l" ivy-bibtex-add-pdf-to-library "Add PDF to library")
+    ("h" (lambda (candidate)
+          (org-insert-heading)
+          (insert (bibtex-completion-apa-format-reference
+                   (cdr (assoc "=key=" candidate)))
+                  " "
+                  (format "cite:&%s" (cdr (assoc "=key=" candidate)))))
+     "Insert org-heading")
+    ("m" (lambda (candidate)
+          (insert (bibtex-completion-apa-format-reference
+                   (cdr (assoc "=key=" candidate)))))
+     "Insert formatted citation")
+    ("f" (lambda (_candidate) (ivy-bibtex-fallback ivy-text)) "Fallback options")
+    ("d" (lambda (_)
+          "Add a bibtex entry from doi and insert cite to it at point."
+          (funcall-interactively 'doi-utils-add-bibtex-entry-from-doi
+                                 (read-string
+                                  "DOI: "
+                                  ;; now set initial input
+                                  (doi-utils-maybe-doi-from-region-or-current-kill)))
+          (org-ref-insert-cite-key
+           (current-kill 0 t)))
+     "Insert from a DOI"))
+  "Alternate actions to do instead of inserting."
+  :type '(list (repeat (string function string)))
+  :group 'org-ref)
+
+
+;; This is modified from ivy-bibtex which had " " instead of "" which breaks marking.
+(defun org-ref-ivy-bibtex-display-transformer (candidate)
+  "Prepare bib entry CANDIDATE for display."
+  (let* ((width (- (frame-width) 2))
+        (idx (get-text-property 1 'idx candidate))
+        (entry (cdr (nth idx (ivy-state-collection ivy-last)))))
+    (concat (if (string-prefix-p ivy-mark-prefix candidate) ivy-mark-prefix "")
+             (bibtex-completion-format-entry entry width))))
+
+
+(ivy-configure 'org-ref-cite-insert-ivy :display-transformer-fn 'org-ref-ivy-bibtex-display-transformer)
+
+
+(defun org-ref-cite-multi-insert-ivy (candidates)
+  "A multi-action function to insert CANDIDATES."
+  (with-ivy-window
+    (org-ref-insert-cite-keys
+     (mapcar (lambda (entry)
+              (cdr (assoc "=key=" (cdr entry))))
+            candidates)
+     ivy-current-prefix-arg)))
+
+
+(defun org-ref-cite-insert-ivy ()
+  "Function for inserting a citation."
+  (interactive)
+  ;; Set this in the function so it is updated if you change the functions while
+  ;; writing
+  (ivy-set-actions
+   'org-ref-cite-insert-ivy
+   org-ref-citation-alternate-insert-actions)
+
+  ;; This initializes bibtex if the variable is not defined.
+  (unless bibtex-completion-display-formats-internal
+    (bibtex-completion-init))
+
+  (let* ((bibtex-completion-bibliography (org-ref-find-bibliography))
+        (candidates (bibtex-completion-candidates)))
+    (ivy-read "org-ref-ivy BibTeX entries: " candidates
+             :preselect (ivy-thing-at-point)
+             :multi-action #'org-ref-cite-multi-insert-ivy
+             :action '(1
+                       ("o" (lambda (candidate)
+                              (org-ref-insert-cite-key
+                               (cdr (assoc "=key=" (cdr candidate)))
+                               ivy-current-prefix-arg))
+                        "insert")
+                       ("r" (lambda (candidate)
+                              (let* ((object (org-element-context))
+                                     (type (org-element-property :type object))
+                                     (begin (org-element-property :begin object))
+                                     (end (org-element-property :end object))
+                                     (link-string (org-element-property :path object))
+                                     (data (org-ref-parse-cite-path link-string))
+                                     (references (plist-get data :references))
+                                     (cp (point))
+                                     (key)
+                                     keys i)
+                                ;;   We only want this to work on citation links
+                                (when (assoc type org-ref-cite-types)
+                                  (setq key (org-ref-get-bibtex-key-under-cursor))
+                                  (if (null key)
+                                      ;; delete the whole cite
+                                      (cl--set-buffer-substring begin end "")
+                                    (setq i (seq-position
+                                             references key
+                                             (lambda (el key)
+                                               (string= key
+                                                        (plist-get el :key)))))
+                                    (setf (plist-get (nth i references) :key)
+                                          (cdr (assoc "=key=" (cdr candidate))))
+                                    (setq data (plist-put data :references references))
+                                    (save-excursion
+                                      (goto-char begin)
+                                      (re-search-forward link-string)
+                                      (replace-match (org-ref-interpret-cite-data data)))
+                                    (goto-char cp)))))
+                        "Replace key at point"))
+             :caller 'org-ref-cite-insert-ivy)))
+
+
+(setq org-ref-insert-cite-function 'org-ref-cite-insert-ivy)
+
+
+(provide 'org-ref-ivy)
+
+;;; org-ref-ivy.el ends here
diff --git a/elpa/org-ref-20251206.1422/org-ref-label-link.el b/elpa/org-ref-20251206.1422/org-ref-label-link.el
new file mode 100644 (file)
index 0000000..4859c76
--- /dev/null
@@ -0,0 +1,62 @@
+;;; org-ref-label-link.el --- -*- lexical-binding: t; -*-
+;;
+;; Copyright (C) 2024  John Kitchin
+
+;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
+;; Keywords: convenience
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+;;
+;;; Commentary:
+;;
+
+;;; Code:
+
+(declare-function org-ref-get-labels "org-ref-ref-links" ())
+
+
+(defface org-ref-label-face
+  `((t (:inherit org-link :foreground "dark magenta")))
+  "Color for ref links in `org-ref'."
+  :group 'org-ref-faces)
+
+
+;;** label link (maybe deprecated)
+
+
+(org-link-set-parameters
+ "label"
+ :export (lambda (path _desc format)
+          (cond
+           ((eq format 'latex)
+            (format "\\label{%s}" path))))
+ :face 'org-ref-label-face
+ :help-echo "A label")
+
+
+;;;###autoload
+(defun org-ref-insert-label-link ()
+  "Insert a new label with completion.
+The completion helps ensure you use a unique label."
+  (interactive)
+  (let* ((known-labels (mapcar 'car (org-ref-get-labels)))
+        (new-label (completing-read "Label: " known-labels nil)))
+    (when (member new-label known-labels)
+      (warn "Inserting duplicate label"))
+    (insert (format "label:%s" new-label))))
+
+
+(provide 'org-ref-label-link)
+
+;;; org-ref-label-link.el ends here
diff --git a/elpa/org-ref-20251206.1422/org-ref-latex.el b/elpa/org-ref-20251206.1422/org-ref-latex.el
new file mode 100644 (file)
index 0000000..53d65d3
--- /dev/null
@@ -0,0 +1,322 @@
+;;; org-ref-latex.el --- org-ref functionality for LaTeX files  -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2015-2024  John Kitchin
+
+;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
+;; Keywords: languages
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary: Make cites in LaTeX documents clickable, and with tooltips.
+;; We use font-lock to add some functionality to the keys.
+
+;;; Code:
+
+(require 'org-ref-citation-links)
+(require 'bibtex-completion)
+(require 'tex-mode)
+
+(defvar org-ref-cite-types)
+
+(defcustom orl-cite-keymap
+  (let ((map (copy-keymap latex-mode-map)))
+    (define-key map (kbd "S-<left>") #'orl-cite-shift-left)
+    (define-key map (kbd "S-<right>") #'orl-cite-shift-right)
+    (define-key map (kbd "S-<up>") #'orl-sort-cite-keys)
+    (define-key map (kbd "S-<down>") (lambda () (interactive) (orl-sort-cite-keys t)))
+    (define-key map (kbd "<tab>") #'org-ref-latex-insert-citation)
+
+    (define-key map [mouse-1] (lambda ()
+                               (interactive)
+                               (let ((bibtex-completion-bibliography (org-ref-latex-get-bibliography)))
+                                 (bibtex-completion-show-entry (list (org-ref-latex-key-at-point)))
+                                 (bibtex-beginning-of-entry))))
+    map)
+  "Key map for cite keys."
+  :group 'org-ref-latex
+  :type '(restricted-sexp
+          :match-alternatives
+          ((lambda (x)
+             (or (keymapp x) ; Can be a keymap var.
+                (and (symbolp x)
+                      (boundp x)
+                      (keymapp (symbol-value x))))))))
+
+
+(defvar org-ref-latex-cite-re
+  (concat "\\\\\\(?1:" (mapconcat
+                       (lambda (x)
+                         (replace-regexp-in-string "\\*" "\\\\*" x))
+                       (mapcar 'car org-ref-cite-types)
+                       "\\|")
+         "\\)"
+         "\\(?2:\\[[^]]*\\]\\)?"       ; optional []
+         "\\(?3:\\[[^]]*\\]\\)?"       ; optional []
+         "{\\(?4:[^}]*\\)}")           ; group 4 contains the keys
+  "Regexp for LaTeX citations. \\citetype[opti{o}nal][optiona{l}]{some,keys}.
+The clickable part are the keys.")
+
+
+(defun org-ref-latex--scan-buffer-for-bibliography ()
+  "Scan current buffer for bibliography commands.
+Returns a list of bibliography files found via \\bibliography{}
+and \\addbibresource{} commands.
+
+This is a helper function for `org-ref-latex-get-bibliography'."
+  (save-excursion
+    (let ((bibliography '()))
+      ;; Look for \bibliography{file1,file2,...} (BibTeX format)
+      (goto-char (point-min))
+      (while (re-search-forward "\\\\bibliography{\\(?1:.*\\)}" nil t)
+        (setq bibliography
+              (append bibliography
+                      (mapcar (lambda (f)
+                                (concat f ".bib"))
+                              (split-string (match-string-no-properties 1) ",")))))
+      ;; Look for \addbibresource{file.bib} (BibLaTeX format)
+      (goto-char (point-min))
+      (while (re-search-forward "\\\\addbibresource{\\(?1:.*\\)}" nil t)
+        (setq bibliography
+              (append bibliography
+                      (list (match-string-no-properties 1)))))
+      bibliography)))
+
+(defun org-ref-latex-get-bibliography ()
+  "Find bibliographies in the tex file.
+
+First searches the current buffer for \\bibliography{} or
+\\addbibresource{} commands.
+
+If no bibliography is found and the `TeX-master' variable is set
+to a filename (indicating this is an included file in a multi-file
+project), searches the master file for bibliography commands.
+
+This enables bibliography discovery in multi-file LaTeX projects
+where chapter/section files are included into a main file that
+contains the bibliography declaration.
+
+Returns a list of bibliography file paths."
+  (let ((bibliography (org-ref-latex--scan-buffer-for-bibliography)))
+    ;; If no bibliography found in current buffer, check TeX-master
+    (when (and (null bibliography)
+               (boundp 'TeX-master)
+               (stringp TeX-master))
+      ;; TeX-master is a filename (relative or absolute)
+      ;; Build the full path to the master file
+      (let* ((master-file
+              (expand-file-name
+               ;; Add .tex extension if not present
+               (if (string-match-p "\\.tex\\'" TeX-master)
+                   TeX-master
+                 (concat TeX-master ".tex"))
+               ;; Resolve relative to current buffer's directory
+               (file-name-directory (buffer-file-name))))
+             (master-buffer
+              (when (file-exists-p master-file)
+                (find-file-noselect master-file))))
+        (when master-buffer
+          (with-current-buffer master-buffer
+            (setq bibliography (org-ref-latex--scan-buffer-for-bibliography))))))
+    bibliography))
+
+
+(defun org-ref-next-latex-cite (&optional limit)
+  "Font-lock function to make cites in LaTeX documents clickable."
+  (while (re-search-forward org-ref-latex-cite-re limit t)
+    (setq font-lock-extra-managed-props (delq 'help-echo font-lock-extra-managed-props))
+
+    ;; save data on cite. This is useful later for modifying cites, clicking, etc.
+    (add-text-properties (match-beginning 0) (match-end 0) 
+                        `(org-ref-latex-cite (
+                                              :cite-begin ,(match-beginning 0)
+                                              :cite-end ,(match-end 0)
+                                              :cite-key-begin ,(+ 1 (match-beginning 4))
+                                              :cite-key-end ,(- (match-end 4) 1)
+                                              :cite-type ,(match-string-no-properties 1)
+                                              :optional-1 ,(match-string-no-properties 2)
+                                              :optional-2 ,(match-string-no-properties 3)
+                                              :keys ,(mapcar
+                                                      #'string-trim
+                                                      (split-string
+                                                       (match-string-no-properties 4)
+                                                       ",")))))
+
+    (goto-char (match-beginning 0))
+    (let ((end (match-end 0)))
+      (cl-loop for key in (mapcar #'string-trim (split-string (match-string-no-properties 4) ","))
+              unless (string-empty-p key)
+              do
+              (save-match-data
+                (search-forward key)
+                (add-text-properties
+                 (match-beginning 0)
+                 (match-end 0)
+                 `(
+                   org-ref-cite-key ,key
+                   mouse-face highlight
+                   local-map ,orl-cite-keymap
+                   help-echo ,(let* ((bibtex-completion-bibliography (org-ref-latex-get-bibliography)))
+                                (condition-case nil
+                                    (bibtex-completion-apa-format-reference key)
+                                  (error (display-warning :warning (format "Key %s missing." key)))))))))
+      (goto-char end))))
+
+
+(defun org-ref-latex-cite-on ()
+  "Add the font-lock on for citations."
+  (font-lock-add-keywords
+   'latex-mode
+   '((org-ref-next-latex-cite 0 font-lock-constant-face))))
+
+(add-hook 'LaTeX-mode-hook 'org-ref-latex-cite-on)
+(add-hook 'LaTeX-mode-hook 'org-ref-latex-cite-on)
+
+
+;; * Insert cite link
+
+(defun org-ref-latex-on-citation-p ()
+  "Return non-nil if on a citation."
+  (get-text-property (point) 'org-ref-latex-cite))
+
+
+(defun org-ref-latex-key-at-point ()
+  "Return key at point if there is one."
+  (interactive)
+  (get-text-property (point) 'org-ref-cite-key))
+
+(defun orl-insert-key (key)
+  (cond
+   ;; on a key
+   ((get-text-property (point) 'org-ref-cite-key)
+    (forward-sexp)
+    (insert (format ",%s" key)))
+   ;; on the leading \
+   ((and (get-text-property (point) 'org-ref-latex-cite)
+        (looking-at "\\\\"))
+    (search-forward "{")
+    (insert (format "%s," key)))
+   ;; on {
+   ((and (get-text-property (point) 'org-ref-latex-cite)
+        (looking-at "{"))
+    (forward-char)
+    (insert (format "%s," key)))
+   ;; on }
+   ((and (get-text-property (point) 'org-ref-latex-cite)
+        (looking-at "}")) 
+    (insert (format ",%s" key)))
+   ;; on citetype
+   ((and (get-text-property (point) 'org-ref-latex-cite)
+        (get-text-property (point) 'org-ref-latex-cite-type))
+    (search-forward "{")
+    (insert (format "%s," key)))
+   ;; everything else
+   (t
+    (insert (format "\\cite{%s}" key)))))
+
+
+(defun org-ref-latex-insert-citation ()
+  "Insert a citation key with completion.
+Should DWIM inserting into existing or new citations."
+  (interactive)
+
+  ;; This initializes bibtex if the variable is not defined.
+  (unless bibtex-completion-display-formats-internal
+    (bibtex-completion-init))
+
+  (let* ((bibtex-completion-bibliography (org-ref-latex-get-bibliography))
+        (candidates (bibtex-completion-candidates)))
+    (ivy-read "org-ref-ivy BibTeX entries: " candidates
+             :preselect (ivy-thing-at-point) 
+             :action '(1
+                       ("o" (lambda (candidate)
+                              (orl-insert-key (cdr (assoc "=key=" (cdr candidate)))))
+                        "insert")))))
+
+(defun orl-swap-citation (direction)
+  (let* ((key (org-ref-latex-key-at-point))
+        (data (get-text-property (point) 'org-ref-latex-cite))
+        (keys (plist-get data :keys))
+        (i (seq-position keys key #'string=))
+        cite-string)
+    (if (> direction 0)
+       (org-ref-swap-list-elements i (min (+ i 1) (- (length keys) 1)) keys)
+      (org-ref-swap-list-elements i (max (- i 1) 0) keys))
+    (setq data (plist-put data :keys keys))
+
+    ;; now render it
+    (setq cite-string (concat (format "\\%s" (plist-get data :cite-type))
+                             (or (plist-get data :optional-1) "")
+                             (or (plist-get data :optional-2) "")
+                             (format  "{%s}" (string-join (plist-get data :keys) ","))))
+    (cl--set-buffer-substring (plist-get data :cite-begin)
+                             (plist-get data :cite-end)
+                             cite-string)
+    (search-forward key)
+    (goto-char (match-beginning 0))))
+
+
+(defun orl-cite-shift-left ()
+  "Shift cite key at point to the left."
+  (interactive)
+  (orl-swap-citation -1))
+
+
+(defun orl-cite-shift-right ()
+  "Shift cite-key at point to the right."
+  (interactive)
+  (orl-swap-citation +1))
+
+
+(defun orl-sort-cite-keys (&optional descending)
+  "Sort keys in ascending order by year.
+With prefix arg DESCENDING, sort in descending order."
+  (interactive "P")
+  (let* ((data (get-text-property (point) 'org-ref-latex-cite))
+        (keys (plist-get data :keys)) 
+        cite-string)
+
+    (setq data (plist-put data :keys
+                         (cl-loop for entry in
+                                  (cl-sort (cl-loop for key in keys collect
+                                                    (list :key key :year (bibtex-completion-get-value
+                                                                          "year"
+                                                                          (bibtex-completion-get-entry
+                                                                           key))))
+                                           (if descending
+                                               (lambda (x y)
+                                                 (> (string-to-number (plist-get x :year))
+                                                    (string-to-number (plist-get y :year))))
+                                             (lambda (x y)
+                                               (< (string-to-number (plist-get x :year))
+                                                  (string-to-number (plist-get y :year))))))
+                                  collect
+                                  (plist-get entry :key))))
+    
+    
+
+    ;; now render it
+    (setq cite-string (concat (format "\\%s" (plist-get data :cite-type))
+                             (or (plist-get data :optional-1) "")
+                             (or (plist-get data :optional-2) "")
+                             (format  "{%s}" (string-join (plist-get data :keys) ","))))
+    (cl--set-buffer-substring (plist-get data :cite-begin)
+                             (plist-get data :cite-end)
+                             cite-string)
+    (search-forward (car (plist-get data :keys)))
+    (goto-char (match-beginning 0))))
+
+
+
+(provide 'org-ref-latex)
+;;; org-ref-latex.el ends here
diff --git a/elpa/org-ref-20251206.1422/org-ref-misc-links.el b/elpa/org-ref-20251206.1422/org-ref-misc-links.el
new file mode 100644 (file)
index 0000000..fe1a7a7
--- /dev/null
@@ -0,0 +1,305 @@
+;;; org-ref-misc-links.el --- Miscellaneous links -*- lexical-binding: t; -*-
+;;
+;; Copyright (C) 2021-2024  John Kitchin
+
+;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
+;; Keywords: convenience
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+;;
+;; * Miscellaneous links
+
+
+;;; Commentary:
+;;
+
+;;; Code:
+
+;;** List of figures
+
+;;;###autoload
+(defun org-ref-list-of-figures (&optional _arg)
+  "Generate buffer with list of figures in them.
+ARG does nothing.
+Ignore figures in COMMENTED sections."
+  (interactive)
+  (save-excursion
+    (widen)
+    (let* ((c-b (buffer-name))
+          (counter 0)
+          (list-of-figures
+           (org-element-map (org-ref-parse-buffer) 'link
+             (lambda (link)
+               "create a link for to the figure"
+               (when
+                   (and (string= (org-element-property :type link) "file")
+                        (string-match-p
+                         "[^.]*\\.\\(png\\|jpg\\|eps\\|pdf\\|svg\\)$"
+                         (org-element-property :path link))
+                        ;; ignore commented sections
+                        (save-excursion
+                          (goto-char (org-element-property :begin link))
+                          (not (or (org-in-commented-heading-p)
+                                   (org-at-comment-p)
+                                   (seq-intersection (org-get-tags) org-export-exclude-tags)))))
+                 (cl-incf counter)
+
+                 (let* ((start (org-element-property :begin link))
+                        (linenum (progn (goto-char start) (line-number-at-pos)))
+                        (fname (org-element-property :path link))
+                        (parent (car (cdr
+                                      (org-element-property :parent link))))
+                        (caption (cl-caaar (plist-get parent :caption)))
+                        (name (plist-get parent :name)))
+
+                   (if caption
+                       (format "[[file:%s::%s][Figure %s:]] %s\n" c-b linenum counter caption)
+                     ;; if it has no caption, try the name
+                     ;; if it has no name, use the file name
+                     (cond (name
+                            (format "[[file:%s::%s][Figure %s:]] %s\n" c-b linenum counter name))
+                           (fname
+                            (format "[[file:%s::%s][Figure %s:]] %s\n"
+                                    c-b linenum counter fname))))))))))
+      (switch-to-buffer "*List of Figures*")
+      (setq buffer-read-only nil)
+      (org-mode)
+      (erase-buffer)
+      (insert (mapconcat 'identity list-of-figures ""))
+      (goto-char (point-min))
+      ;; open links in the same window
+      (setq-local org-link-frame-setup
+                 '((file . find-file)))
+      (setq buffer-read-only t)
+      (use-local-map (copy-keymap org-mode-map))
+      (local-set-key "q" #'(lambda () (interactive) (kill-buffer))))))
+
+
+(org-link-set-parameters "list-of-figures"
+                        :follow #'org-ref-list-of-figures
+                        :export (lambda (_path _desc format)
+                                  (cond
+                                   ((eq format 'latex)
+                                    (format "\\listoffigures")))))
+
+;;** List of tables
+;;;###autoload
+(defun org-ref-list-of-tables (&optional _arg)
+  "Generate a buffer with a list of tables.
+ARG does nothing."
+  (interactive)
+  (save-excursion
+    (widen)
+    (let* ((c-b (buffer-name))
+           (counter 0)
+           (list-of-tables
+            (org-element-map (org-ref-parse-buffer 'element) 'table
+              (lambda (table)
+                "create a link for to the table"
+               (save-excursion
+                 (goto-char (org-element-property :begin table))
+                 (when
+                     ;; ignore commented sections
+                     (not (or (org-in-commented-heading-p)
+                              (seq-intersection (org-get-tags) org-export-exclude-tags)
+                              (looking-at "#\\+RESULTS:") ))
+                   (cl-incf counter)
+                   (let* ((start (org-element-property :begin table))
+                          (linenum (progn (goto-char start) (line-number-at-pos)))
+                          (caption (cl-caaar (org-element-property :caption table)))
+                          (name (org-element-property :name table)))
+                     (if caption
+                         (format "[[file:%s::%s][Table %s:]] %s\n" c-b linenum counter caption)
+                       ;; if it has no caption, try the name
+                       ;; if it has no name, use generic name
+                       (cond (name
+                              (format "[[file:%s::%s][Table %s:]] %s\n"
+                                      c-b linenum counter name))
+                             (t
+                              (format "[[file:%s::%s][Table %s:]] No caption\n"
+                                      c-b linenum counter)))))))))))
+      (switch-to-buffer "*List of Tables*")
+      (setq buffer-read-only nil)
+      (org-mode)
+      (erase-buffer)
+      (insert (mapconcat 'identity list-of-tables ""))
+      (goto-char (point-min))
+      ;; open links in the same window
+      (setq-local org-link-frame-setup
+                 '((file . find-file)))
+      (setq buffer-read-only t)
+      (use-local-map (copy-keymap org-mode-map))
+      (local-set-key "q" #'(lambda () (interactive) (kill-buffer))))))
+
+
+(org-link-set-parameters "list-of-tables"
+                        :follow #'org-ref-list-of-tables
+                        :export (lambda (_path _desc format)
+                                  (cond
+                                   ((eq format 'latex)
+                                    (format "\\listoftables")))))
+
+
+;;* Index link
+;;
+;; You need these lines in the header
+;; 
+;; #+latex_header: \usepackage{makeidx}
+;; #+latex_header: \makeindex
+(org-link-set-parameters "index"
+                        :follow (lambda (path)
+                                  (occur path))
+                        :export (lambda (path _desc format)
+                                  (cond
+                                   ((eq format 'latex)
+                                    (format "\\index{%s}" path)))))
+
+
+;; this will generate a temporary index of entries in the file when clicked on.
+;;;###autoload
+(defun org-ref-index (&optional _path)
+  "Open an *index* buffer with links to index entries.
+PATH is required for the org-link, but it does nothing here."
+  (interactive)
+  (let ((*index-links* '())
+       (*initial-letters* '()))
+
+    ;; get links
+    (org-element-map (org-ref-parse-buffer) 'link
+      (lambda (link)
+       (let ((plist (nth 1 link)))
+
+         (when (equal (plist-get plist ':type) "index")
+           (add-to-list
+            '*index-links*
+            (cons (plist-get plist :path)
+                  (format
+                   "[[elisp:(progn (switch-to-buffer \"%s\") (goto-char %s) (org-cycle '(64)))][%s]] "
+                   (current-buffer)
+                   (plist-get plist :begin) ;; position of link
+                   ;; grab a description
+                   (save-excursion
+                     (goto-char (plist-get plist :begin))
+                     (if (thing-at-point 'sentence)
+                         ;; get a sentence
+                         (let ((s (thing-at-point 'sentence)))
+                           (cl-loop for char in '("[" "]" "\n")
+                                    do
+                                    (setq s (replace-regexp-in-string
+                                             (regexp-quote char) " " s)))
+                           (concat s " "))
+                       ;; or call it a link
+                       "link")))))))))
+
+    ;; sort the links
+    (setq *index-links* (cl-sort *index-links* 'string-lessp :key 'car))
+
+    ;; now separate out into chunks first letters
+    (dolist (link *index-links*)
+      (push (substring (car link) 0 1) *initial-letters*))
+
+    (setq *initial-letters* (reverse *initial-letters*))
+
+    ;; now create the index
+    (switch-to-buffer (get-buffer-create "*index*"))
+    (org-mode)
+    (erase-buffer)
+    (insert "#+TITLE: Index\n\n")
+    (dolist (letter *initial-letters*)
+      (insert (format "* %s\n" (upcase letter)))
+      ;; now process the links
+      (while (and
+             *index-links*
+             (string= letter (substring (car (car *index-links*)) 0 1)))
+       (let ((link (pop *index-links*)))
+         (insert (format "%s %s\n\n" (car link) (cdr link))))))
+    (switch-to-buffer "*index*")))
+
+
+(org-link-set-parameters "printindex"
+                        :follow #'org-ref-index
+                        :export (lambda (_path _desc format)
+                                  (cond
+                                   ((eq format 'latex)
+                                    (format "\\printindex")))))
+
+
+(defun org-ref-idxproc (_backend)
+  "Preprocess index entries.
+Each entry is replaced by a radio target. The printindex is
+replaced by links to them."
+  (let* ((index-links (reverse (org-element-map (org-element-parse-buffer) 'link
+                                (lambda (lnk)
+                                  (when (string= "index" (org-element-property :type lnk))
+                                    lnk)))))
+        (sorted-groups (seq-sort-by
+                        (lambda (x)
+                          "Alphabetically sort groups"
+                          (car x))
+                        #'string-lessp
+                        (seq-group-by
+                         (lambda (lnk)
+                           (org-element-property :path lnk))
+                         index-links)))
+        (link-replacements '()))
+
+    ;; Sort within each group
+    (cl-loop for (key . links) in sorted-groups do
+            (setf (cdr (assoc key sorted-groups))
+                  (sort links (lambda (a b)
+                                (< (org-element-property :begin a)
+                                   (org-element-property :begin b))))))
+    
+    ;; Compute replacements for each index link.
+    (cl-loop for (key . links) in sorted-groups do
+            (cl-loop for i from 0 for lnk in links do
+                     (cl-pushnew (cons
+                                  (org-element-property :begin lnk)
+                                  (format "<<%s-%s>>" key i))
+                                 link-replacements)))
+
+    (cl-loop for il in index-links collect
+            (cl--set-buffer-substring
+             (org-element-property :begin il)
+             (org-element-property :end il)
+             (cdr (assoc (org-element-property :begin il) link-replacements))))
+
+    ;; Now we replace the printindex link
+    (org-element-map (org-element-parse-buffer) 'link
+      (lambda (lnk)
+       (when (string= "printindex" (org-element-property :type lnk))
+         (cl--set-buffer-substring (org-element-property :begin lnk)
+                                   (org-element-property :end lnk)
+                                   ;; If sorted-groups is empty, we should do nothing I think.
+                                   (if sorted-groups
+                                       (format "*Index*\n\n%s"
+                                               (string-join
+                                                (cl-loop for (key . links) in sorted-groups collect
+                                                         (format "%s: %s"
+                                                                 key
+                                                                 (string-join 
+                                                                  (cl-loop for i from 0 for lnk in links collect
+                                                                           (format "[[%s-%s][%s-%s]] "
+                                                                                   (org-element-property :path lnk)
+                                                                                   i
+                                                                                   (org-element-property :path lnk)
+                                                                                   i))
+                                                                  ", ")))
+                                                "\n\n"))
+                                     "")))))))
+
+
+(provide 'org-ref-misc-links)
+
+;;; org-ref-misc-links.el ends here
diff --git a/elpa/org-ref-20251206.1422/org-ref-natbib-bbl-citeproc.el b/elpa/org-ref-20251206.1422/org-ref-natbib-bbl-citeproc.el
new file mode 100644 (file)
index 0000000..1806de4
--- /dev/null
@@ -0,0 +1,521 @@
+;;; org-ref-natbib-bbl-citeproc.el --- A bibtex + natbib BBL-based citeproc -*- lexical-binding: t; -*-
+;;
+;; Copyright (C) 2021-2024  John Kitchin
+
+;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
+;; Keywords:
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+;;
+;;; Commentary:
+;;
+;; This is a citation processor that uses the bbl from bibtex and natbib.
+;;
+;; It is kind of hacky. I parse the bbl file into entries, and then replace the
+;; in-text citations and the bibliography with data from the parsed bbl.
+;;
+;; The CSL exporter is probably better all around than this, but this does have
+;; the advantage of using LaTeX/bibtex for formatting.
+;;
+;; TODO: pre/post notes are not handled in the bbl file. They have to be handled
+;; separately
+;;
+;; This seems to work ok for
+;; See https://gking.harvard.edu/files/natnotes2.pdf
+;;
+;; Basically supports stylying options in natbib including [numbers, super, authoryear] for style,
+;; and [round, square, curly, angle] for in-text citations
+;; and [comma, semicolon; colon] for citation separators
+;; and [sort, compress, sort&compress] if you want to sort and/or compress citation numbers.
+;;
+;; longnamesfirst is not currently supported.
+;;
+;; To use this for HTML export you do something like this:
+;; (let ((org-export-before-parsing-hook '(org-ref-bbl-preprocess)))
+;;   (org-open-file (org-html-export-to-html)))
+;;
+;;
+;;; Code:
+
+(declare-function org-ref-get-cite-links "org-ref-core" ())
+(declare-function org-ref-parse-cite-path "org-ref-core" (path))
+
+(defvar org-ref-natmove)                       ;silence compiler
+
+(defun org-bbl-clean-string (s)
+  "Clean S of markups.
+This replaces some LaTeX markup and bibtex markups including:
+\\emph{}, \\doi{}, \\url{},\\citename, and {\\em ...} {\\bf ...},
+removes things like \\protect and \\penalty0, and replaces ~ with
+a space. This function is surely not complete, and it does not
+cover any math (yet)."
+  (with-temp-buffer
+    (insert s)
+    ;; I convert these to org syntax.
+    ;; \emph... -> org italics
+    ;; TODO This list is surely not complete.
+    ;; convert \cmd{stuff} to the format string
+    (let (p1 p2 p3 p4 ss cmd-p)
+      (cl-loop for (cmd . repl-format) in '(("emph" . "/%s/")
+                                           ("doi" . "%s")
+                                           ("url" . "%s")
+                                           ("citename" . "%s")
+                                           ;; natexlab seems to be for differentiating similar authors.
+                                           ("natexlab" . "(%s)")
+                                           ;; I use \ce{} a lot, and just strip it here.
+                                           ("ce" . "%s"))
+              do
+              (goto-char (point-min))
+              (while (search-forward (format "\\%s{" cmd) nil t)
+                (setq p1 (match-beginning 0)
+                      p2 (point))
+                (backward-char)
+                (forward-list)
+                (setq p4 (point)
+                      p3 (- (point) 1))
+                (setq s (buffer-substring p2 p3))
+                (cl--set-buffer-substring p1 p4 (format repl-format s))))
+
+      ;; some times we have these markups TODO I bet there are more Note I use
+      ;; non-breaking spaces here to make the org syntax ok. It doesn't seem to
+      ;; do quite the right thing in the bib-items though.
+      (cl-loop for (markup . fmt) in '(("\\em" . " /%s/ ")
+                                      ("\\it" . " /%s/ ")
+                                      ("\\bf" . " *%s* ")
+                                      ("\\tt" . " =%s= "))
+              do
+              (goto-char (point-min))
+              (while (search-forward (concat "{" markup) nil t)
+                (setq p1 (match-beginning 0)
+                      p2 (point))
+                (goto-char (match-beginning 0))
+                (forward-list)
+                (setq p4 (point)
+                      p3 (- (point) 1))
+                (setq ss (string-trim (buffer-substring p2 p3)))
+                (cl--set-buffer-substring p1 p4 (format fmt ss))))
+
+      ;; {text} for protecting case. This is tricky to do reliably. I try to check
+      ;; if this is not part of a command, and skip it if so. This leaves
+      ;; un-cleaned commands in, which is desirable to me so you can see if there
+      ;; are ones we might handle in the future.
+      (goto-char (point-min))
+      (while (search-forward "{" nil t)
+       ;; I think if we go back a word, and are then looking back at \\, we are in a command.
+       ;; this would fail on a latex command like \word-word{} but I can't think of any right now.
+       (save-excursion
+         (backward-word)
+         (setq cmd-p (looking-back "\\\\" 1)))
+       ;; This looks back for a \cmd, basically things not a closing }
+       (unless cmd-p
+         (setq p1 (match-beginning 0)
+               p2 (point))
+         (backward-char)
+         (forward-list)
+         (setq p4 (point)
+               p3 (- (point) 1))
+         (setq s (buffer-substring p2 p3))
+         (cl--set-buffer-substring p1 p4 s))))
+
+
+    (let ((result (buffer-string)))
+      (cl-loop for (s . repl) in '(("~" . " ")
+                                  ("\\\\&" . "&")
+                                  ("\\\\protect" . "")
+                                  ("\\\\penalty0" . "")
+                                  ("\\\\ " . " "))
+              do
+              (setq result (replace-regexp-in-string s repl result)))
+      result)))
+
+
+(defun org-ref-bbl-get-natbib-options ()
+  "Return natbib-options (including the brackets).
+Defaults to [numbers,super,sort]"
+  (goto-char (point-min))
+  (if (re-search-forward "\\\\usepackage\\(?1:\\[.*\\]\\)?{natbib}")
+      (match-string 1)
+    "[numbers,super,sort]"))
+
+
+
+(defun org-ref-bbl-entry (entry)
+  "ENTRY is a string containing the contents of a bibitem from a bbl file.
+Return the bibliography string associated with the entry. This is
+done in a temp-buffer so we don't actually modify the bbl file."
+  (with-temp-buffer
+    (insert (org-bbl-clean-string entry))
+    (goto-char (point-min))
+    (let (p1
+         p2 
+         authors
+         blocks
+         entry)
+      (setq p1 (point))
+      (search-forward "\\newblock")
+      (setq p2 (match-beginning 0))
+      (setq authors (string-join
+                    (mapcar 'string-trim
+                            (split-string (buffer-substring p1 p2) "\n"))
+                    " "))
+      (goto-char (- p2 1))
+      (while (search-forward "\\newblock" nil t)
+       (setq p1 (point))
+       (setq p2 (save-excursion
+                  (if (search-forward "\\newblock" nil t)
+                      (match-beginning 0)
+                    (point-max))))
+
+       (cl-pushnew (string-join
+                    (mapcar 'string-trim
+                            (split-string (buffer-substring p1 p2) "\n"))
+                    " ")
+                   blocks))
+
+      (setq entry (string-join (append (list authors) blocks) " "))
+      entry)))
+
+
+(defun org-ref-bbl-bibliography-data ()
+  "Get an p-list for each entry in the buffer.
+Assumes you are in a bbl file.
+Returns a plist (list bibitem-key :entry (org-ref-bbl-entry bibitem-entry)
+                         :index counter :bracket-data bibitem-bracket)"
+  (let ((data '())
+       N ss
+       p1 p2 bbl-max
+       bibitem-bracket
+       bibitem-key
+       bibitem-entry
+       (counter 0))
+
+    (goto-char (point-min))
+    (search-forward "\\end{thebibliography}")
+    ;; this is the character that the last line starts on.
+    (setq bbl-max (match-beginning 0))
+
+    (goto-char (point-min))
+    (when (looking-at "\\\\begin{thebibliography}{\\(?1:[0-9]*\\)}")
+      (setq N (string-to-number (match-string 1))))
+
+    ;; This might only work for numeric types
+    (if (> 0 N)
+       (cl-loop for i from 1 to N do
+                (search-forward "\\bibitem[")
+                ;; get text in [...]
+                (setq p1 (point))
+                (forward-list)
+                (setq p2 (point))
+                ;; the bracket usually contains [stuff (year) more stuff]
+                (setq ss (org-bbl-clean-string
+                          (buffer-substring-no-properties p1 p2)))
+
+                (let* ((s (string-match "(" ss))
+                       (e (string-match ")" ss s)))
+                  ;; in numerical mode I think this is ignored, but we get it
+                  ;; just in case for some later day.
+                  (setq bibitem-bracket (format "%s%s"
+                                                (substring ss 0 s)
+                                                (if (string= "()" (substring ss s (+ e 1)))
+                                                    ""
+                                                  (concat " " (substring ss s (+ e 1)))))))
+
+                ;; Now get the key. From the last
+                (search-forward "{")
+                (goto-char (match-beginning 0))
+                (setq p1 (+ 1 (point)))
+                (forward-list)
+                (setq p2 (- (point) 1)
+                      bibitem-key (buffer-substring p1 p2))
+
+                ;; Now get up to the next bibitem
+                (setq p1 (point))
+                (save-excursion
+                  (setq p2 (or (when (search-forward "\\bibitem[" nil t)
+                                 (match-beginning 0))
+                               bbl-max)))
+                (setq bibitem-entry (string-trim (buffer-substring p1 p2)))
+
+                (cl-pushnew (list bibitem-key :entry (org-ref-bbl-entry bibitem-entry)
+                                  :index i :bracket-data bibitem-bracket)
+                            data))
+      ;; no number found probably author year
+      (while (search-forward "\\bibitem[" nil t)
+       (cl-incf counter)
+       ;; get text in [...]
+       (setq p1 (point))
+       (search-forward "]")
+       (backward-char)
+       (setq p2 (point))
+
+       (setq ss (org-bbl-clean-string
+                 (buffer-substring-no-properties p1 p2)))
+
+       (let* ((s (string-match "(" ss))
+              (e (string-match ")" ss s)))
+
+         (setq bibitem-bracket (format "%s%s"
+                                       (substring ss 0 s)
+                                       (if (string= "()" (substring ss s (+ e 1)))
+                                           ""
+                                         (concat " " (substring ss s (+ e 1)))))))
+
+
+       ;; Now get the key. From the last
+       (search-forward "{")
+       (goto-char (match-beginning 0))
+       (setq p1 (+ 1 (point)))
+       (forward-list)
+       (setq p2 (- (point) 1)
+             bibitem-key (buffer-substring p1 p2))
+
+       ;; Now get up to the next bibitem
+       (setq p1 (point))
+       (save-excursion
+         (setq p2 (or (when (search-forward "\\bibitem[" nil t)
+                        (match-beginning 0))
+                      bbl-max)))
+       (setq bibitem-entry (string-trim (buffer-substring p1 p2)))
+
+       (cl-pushnew (list bibitem-key :entry (org-ref-bbl-entry bibitem-entry)
+                         :index counter :bracket-data bibitem-bracket)
+                   data)))
+    (reverse data)))
+
+
+(defun org-ref-bbl-compress-numbers (lst)
+  "Take a list like (1 2 3 6) and return \"1-3,6\"."
+  (let* ((a (pop lst))
+        b
+        (sequence (list a))
+        (sequentials '()))
+    (while lst
+      (setq b (pop lst))
+      (if (= (- b a) 1)
+         ;; we have a sequence, add it, set a=b and continue
+         (setq sequence (append sequence (list b))
+               a b)
+       ;; lost sequence, store the sequence
+       (setq sequentials (append sequentials (list sequence))
+             sequence (list b)
+             a b)))
+    ;; store last one
+    (setq sequentials (append sequentials (list sequence)))
+
+    ;; Now construct strings for each group
+    (cl-loop for group in sequentials collect
+            (pcase (length group)
+              (1 (format "[[%s]]" (car group)))
+              (2 (format "[[%s]],[[%s]]" (cl-first group) (cl-second group)))
+              (_ (format "[[%s]]-[[%s]]" (cl-first group) (car (last group))))))))
+
+
+(defun org-ref-replace-cite-link (link bibdata NATBIB-OPTIONS backend)
+  "NATBIB-OPTIONS is the string to options.
+Argument LINK is an org link for a citation.
+Argument BIBDATA the data parsed from a bbl file.
+Argument BACKEND is the export format."
+  (let* ((refs (plist-get (org-ref-parse-cite-path (org-element-property :path link)) :references))
+        (keys (cl-loop for ref in refs collect (plist-get ref :key)))
+        items replacements replacement joiner p1 p2)
+
+    ;; Numeric types
+    (cond
+     ((or (string-match-p "numbers" NATBIB-OPTIONS)
+         (string-match-p "super" NATBIB-OPTIONS))
+      (setq items (cl-loop for key in keys
+                          collect (plist-get (cdr (assoc key bibdata)) :index)))
+
+      (when (string-match-p "sort" NATBIB-OPTIONS)
+       (setq items (sort items #'<)))
+
+      (setq replacements (if (string-match-p "compress" NATBIB-OPTIONS)
+                            (org-ref-bbl-compress-numbers items)
+                          ;; these are fuzzy org links to the target in item.
+                          (cl-loop for item in items collect (format "[[%s]]" item)))))
+
+     ;; authoryear types
+     ;; This html provides an anchor that is named. Targets are usually replaced with numbers, not the text.
+     ((string-match-p "authoryear" NATBIB-OPTIONS)
+      (setq replacements (cl-loop for key in keys
+                                 collect
+                                 (cond
+                                  ((eq backend 'html)
+                                   (format "@@html:<a href=\"#%s\">%s</a>@@"
+                                           (plist-get (cdr (assoc key bibdata)) :bracket-data) 
+                                           (plist-get (cdr (assoc key bibdata)) :bracket-data)))
+                                  (t
+                                   (format "[[%s]]" (plist-get (cdr (assoc key bibdata)) :bracket-data)))))))
+     (t
+      (error "%s not supported yet" NATBIB-OPTIONS)))
+
+    ;; Now join all the replacements for each reference
+    (setq joiner (cond
+                 ((string-match-p "comma" NATBIB-OPTIONS)
+                  ",")
+                 ((or (string-match-p "semicolon" NATBIB-OPTIONS)
+                      (string-match-p "colon" NATBIB-OPTIONS))
+                  ";")
+                 (t
+                  ";")))
+
+    ;; Finally create the overall replacement
+    (setq replacement (cond
+                      ((string-match-p "super" NATBIB-OPTIONS)
+                       (format "^{%s}" (string-join replacements joiner)))
+
+                      ((string-match-p "square" NATBIB-OPTIONS)
+                       (format "[%s]" (string-join replacements joiner)))
+
+                      ((string-match-p "round" NATBIB-OPTIONS)
+                       (format "(%s)" (string-join replacements joiner)))
+
+                      ((string-match-p "curly" NATBIB-OPTIONS)
+                       (format "{%s}" (string-join replacements joiner)))
+
+                      ((string-match-p "angle" NATBIB-OPTIONS)
+                       (format "<%s>" (string-join replacements joiner)))
+
+                      ((string-match-p "authoryear" NATBIB-OPTIONS)
+                       (string-join replacements joiner))
+
+                      (t
+                       (error "Cannot compute replacement for %s" NATBIB-OPTIONS))))
+
+    ;; When super is the style, we need to replace any blanks back to the last
+    ;; non-space. We just look back and move point if needed here.
+    (if (not (string-match-p "super" NATBIB-OPTIONS))
+       (setq p1 (org-element-property :begin link))
+      (goto-char (org-element-property :begin link))
+      (while (looking-back " " 1)
+       (backward-char))
+      (setq p1 (point)))
+
+    (setq p2 (org-element-property :end link))
+
+    ;; org-ref-natmove is dynamically bound here
+    (when org-ref-natmove
+      (save-excursion
+       (goto-char (org-element-property :end link))
+       (skip-chars-backward " ")
+
+       (when (string-match-p "[[:punct:]]" (buffer-substring (point) (+ (point) 1)))
+         ;; Get the character
+         (setq replacement (concat (buffer-substring (org-element-property :end link)
+                                                     (+ 1 (org-element-property :end link)))
+                                   replacement)
+               p2 (+ 1 (org-element-property :end link))))))
+
+    (cl--set-buffer-substring p1 p2
+                             (concat replacement (make-string (org-element-property :post-blank link) ? )))))
+
+
+(defun org-ref-bbl-replace-bibliography (bib-link bibdata NATBIB-OPTIONS backend)
+  "Get a replacement bibliography string for BIBDATA and NATBIB-OPTIONS.
+BIBDATA comes from `org-ref-bbl-bibliography-data'.
+Argument BIB-LINK an org link for a bibliography.
+Argument BACKEND is the export format."
+  (cl--set-buffer-substring (org-element-property :begin bib-link)
+                           (org-element-property :end bib-link)
+                           (cond
+                            ((or (string-match-p "numbers" NATBIB-OPTIONS)
+                                 (string-match-p "super" NATBIB-OPTIONS))
+                             (concat "\n* Bibliography\n\n"
+                                     (string-join
+                                      (cl-loop for entry in bibdata collect
+                                               (format "%s. <<%s>> %s"
+                                                       (plist-get (cdr entry) :index)
+                                                       (plist-get (cdr entry) :index)
+                                                       (plist-get (cdr entry) :entry)))
+                                      "\n\n")))
+
+
+                            ((string-match-p "authoryear" NATBIB-OPTIONS)
+                             (concat "\n* Bibliography\n\n"
+                                     (string-join
+                                      (cl-loop for entry in bibdata collect
+                                               (cond
+                                                ((eq backend 'html)
+                                                 (format "- @@html:<a id=\"%s\"></a>@@(%s) %s\n"
+                                                         (plist-get (cdr entry) :bracket-data)
+                                                         (plist-get (cdr entry) :bracket-data)
+                                                         (plist-get (cdr entry) :entry)))
+                                                (t
+                                                 (format "- <<%s>> %s"
+                                                         (plist-get (cdr entry) :bracket-data)
+                                                         (plist-get (cdr entry) :entry)))))
+                                      
+                                      
+                                      "\n")))
+                            (t
+                             (error "%s not supported yet" NATBIB-OPTIONS)))))
+
+
+
+(defun org-ref-bbl-preprocess (&optional backend)
+  "Should work on a copy of the buffer.
+Meant to be used in `org-export-before-parsing-hook'.
+Optional argument BACKEND The export backend.
+
+You need a LaTeX file and a bbl file for it. This hook generates
+those, then gets the data, replaces the citations and the
+bibliography.
+"
+  (let* ((org-export-before-parsing-functions nil)
+        (tex-file (org-latex-export-to-latex))
+        (bbl-file (concat (file-name-sans-extension tex-file) ".bbl"))
+        natbib-options bibdata org-ref-natmove
+        buf)
+
+    (when-let* (buf (find-buffer-visiting tex-file))
+      (kill-buffer buf))
+
+    (when-let* (buf (find-buffer-visiting bbl-file))
+      (kill-buffer buf))
+
+    ;; refresh these
+    (call-process-shell-command (format "latex -shell-escape %s" tex-file))
+    (call-process-shell-command (format "bibtex %s" (file-name-sans-extension tex-file)))
+
+    (setq buf (find-file-noselect tex-file))
+    (with-current-buffer buf
+      (goto-char (point-min))
+      (setq natbib-options (org-ref-bbl-get-natbib-options))
+      (goto-char (point-min))
+      (setq org-ref-natmove (search-forward "\\usepackage{natmove}" nil t)))
+    (kill-buffer buf)
+
+    (setq buf (find-file-noselect bbl-file))
+    (with-current-buffer buf
+      (goto-char (point-min))
+      (setq bibdata (org-ref-bbl-bibliography-data)))
+    (kill-buffer buf)
+
+    ;; Replace all the cite links
+    (cl-loop for cl in (reverse (org-ref-get-cite-links)) do
+            (org-ref-replace-cite-link cl bibdata natbib-options backend))
+
+    (org-ref-bbl-replace-bibliography
+     (org-element-map (org-element-parse-buffer) 'link
+       (lambda (lnk)
+        (when (string= (org-element-property :type lnk) "bibliography")
+          lnk))
+       nil
+       t)
+     bibdata natbib-options backend)))
+
+
+(provide 'org-ref-natbib-bbl-citeproc)
+
+;;; org-ref-natbib-bbl-citeproc.el ends here
diff --git a/elpa/org-ref-20251206.1422/org-ref-pdf.el b/elpa/org-ref-20251206.1422/org-ref-pdf.el
new file mode 100644 (file)
index 0000000..8b3e756
--- /dev/null
@@ -0,0 +1,186 @@
+;;; org-ref-pdf.el --- Drag-n-drop PDF onto bibtex files  -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2015-2024  John Kitchin
+
+;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
+;; Keywords:
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This library provides functions to enable drag-n-drop of pdfs onto a bibtex
+;; buffer to add bibtex entries to it.
+;;
+;; [2021-08-29 Sun] I have not found drag-and-drop to be especially reliable,
+;; and don't recommend you use it. This code relies 'pdf-tools, which is slow to
+;; load for me. pdf-tools is no longer automatically installed, so if you use
+;; this, you should install it yourself.
+
+;; TODO: If no DOI is found, figure out a way to do a crossref/google query to
+;; get a doi. This needs a reliable title/citation.
+
+;;; Code:
+
+;; pdf-tools is optional, and I think this will skip compiling this file and
+;; outputting an error.
+(when (and (bound-and-true-p byte-compile-current-file)
+           (not (locate-library "pdf-tools")))
+  (message "org-ref-pdf: skipping byte-compile; pdf-tools not installed.")
+  (setq byte-compile-current-file nil)
+  (throw 'byte-compile-top-level nil))
+
+(require 'pdf-tools)
+
+(require 'org-ref-utils)
+
+
+(eval-when-compile
+  (require 'cl-lib))
+
+(declare-function org-ref-normalize-bibtex-completion-bibliography "org-ref-utils")
+
+(defvar bibtex-completion-bibliography)
+
+(defgroup org-ref-pdf nil
+  "Customization group for org-ref-pdf"
+  :tag "Org Ref PDF"
+  :group 'org-ref-pdf)
+
+
+(defcustom pdftotext-executable
+  "pdftotext"
+  "Executable for pdftotext. Set if the executable is not on your
+path, or you want to use another version."
+  :type 'file
+  :group 'org-ref-pdf)
+
+
+(defcustom org-ref-pdf-doi-regex
+  "10\\.[0-9]\\{4,9\\}/[-+._;()/:A-Z0-9]+"
+  "Regular expression to match DOIs in a pdf converted to text."
+  :type 'regexp
+  :group 'org-ref-pdf)
+
+
+(defcustom org-ref-pdf-to-bibtex-function
+  'copy-file
+  "Function for getting  a pdf to a directory.
+Defaults to `copy-file', but could also be `rename-file'."
+  :type 'File :group 'org-ref-pdf)
+
+
+(defun org-ref-extract-doi-from-pdf (pdf)
+  "Try to extract a doi from a PDF file.
+There may be more than one doi in the file. This function returns
+all the ones it finds based on two patterns: doi: up to a quote,
+bracket, space or end of line. dx.doi.org/up to a quote, bracket,
+space or end of line.
+
+If there is a trailing . we chomp it off. Returns a list of doi
+strings, or nil."
+  (with-temp-buffer
+    (insert (shell-command-to-string (format "%s %s -"
+                                            pdftotext-executable
+                                            (shell-quote-argument pdf))))
+    (goto-char (point-min))
+    (let ((matches '()))
+      (while (re-search-forward org-ref-pdf-doi-regex nil t)
+       ;; I don't know how to avoid a trailing . on some dois with the
+       ;; expression above, so if it is there, I chomp it off here.
+       (let ((doi (match-string 0)))
+         (when (or (string-suffix-p "." doi) (string-suffix-p ";" doi))
+           (setq doi (substring doi 0 (- (length doi) 1))))
+         (cl-pushnew doi matches :test #'equal)))
+      matches)))
+
+
+(defun org-ref-pdf-doi-candidates (dois)
+  "Generate candidate list for a completion source.
+Used when multiple dois are found in a pdf file."
+  (cl-loop for doi in dois
+          collect
+          (condition-case nil
+              (cons
+               (plist-get (doi-utils-get-json-metadata doi) :title)
+               doi)
+            (error (cons (format "%s read error" doi) doi)))))
+
+
+(defun org-ref-bibtex-key-from-doi (doi)
+  "Return a bibtex entry's key from a DOI.
+BIB is an optional filename to get the entry from."
+  (catch 'key
+    (cl-loop for bibfile in (org-ref-normalize-bibtex-completion-bibliography)
+            do
+            (with-temp-buffer
+              (insert-file-contents (expand-file-name bibfile))
+              (when (search-forward doi)
+                (bibtex-beginning-of-entry)
+                (throw 'key (cdr (assoc "=key=" (bibtex-parse-entry)))))))))
+
+
+;;;###autoload
+(defun org-ref-pdf-to-bibtex ()
+  "Add pdf of current buffer to bib file and save pdf. The pdf
+should be open in Emacs using the `pdf-tools' package."
+  (interactive)
+  (when (not (org-ref--file-ext-p (downcase (buffer-file-name)) "pdf"))
+    (error "Buffer is not a pdf file"))
+  ;; Get doi from pdf of current buffer
+  (let* ((dois (org-ref-extract-doi-from-pdf (buffer-file-name)))
+         (doi-utils-download-pdf nil)
+         (doi (if (= 1 (length dois))
+                  (car dois)
+                (completing-read "Select DOI: " dois))))
+    ;; Add bib entry from doi:
+    (doi-utils-add-bibtex-entry-from-doi doi)
+    ;; Copy pdf to a directory
+    (let ((key (org-ref-bibtex-key-from-doi doi)))
+      (funcall org-ref-pdf-to-bibtex-function
+              (buffer-file-name)
+               (expand-file-name (format "%s.pdf" key) (org-ref-library-path))))))
+
+
+;;;###autoload
+(defun org-ref-pdf-debug-pdf (pdf-file)
+  "Try to debug getting a doi from a pdf.
+Opens a buffer with the pdf converted to text, and `occur' on the
+variable `org-ref-pdf-doi-regex'."
+  (interactive "fPDF: ")
+  (switch-to-buffer (get-buffer-create "*org-ref-pdf debug*"))
+  (erase-buffer)
+  (insert (shell-command-to-string (format "%s %s -"
+                                          pdftotext-executable
+                                          (shell-quote-argument pdf-file))))
+  (goto-char (point-min))
+  (highlight-regexp org-ref-pdf-doi-regex)
+  (occur org-ref-pdf-doi-regex)
+  (switch-to-buffer-other-window "*Occur*"))
+
+
+;;;###autoload
+(defun org-ref-pdf-crossref-lookup ()
+  "Lookup highlighted text in PDFView in CrossRef."
+  (interactive)
+  (require 'pdf-view)
+  (unless (pdf-view-active-region-p)
+    (error "The region is not active"))
+  (let* ((txt (pdf-view-active-region-text)))
+    (pdf-view-deactivate-region)
+    (crossref-lookup (mapconcat 'identity txt "         \n"))))
+
+
+(provide 'org-ref-pdf)
+;;; org-ref-pdf.el ends here
diff --git a/elpa/org-ref-20251206.1422/org-ref-pgk.el b/elpa/org-ref-20251206.1422/org-ref-pgk.el
new file mode 100644 (file)
index 0000000..33a2d15
--- /dev/null
@@ -0,0 +1,14 @@
+(define-package "org-ref" "3.1.0" "citations, cross-references and bibliographies in org-mode"
+  '((dash "0")
+    (s "0")
+    (f "0")
+    (transient "0")
+    (htmlize "0")
+    (parsebib "0")
+    (bibtex-completion "0")
+    (emacs "29")))
+
+
+;; Local Variables:
+;; no-byte-compile: t
+;; End:
diff --git a/elpa/org-ref-20251206.1422/org-ref-pkg.el b/elpa/org-ref-20251206.1422/org-ref-pkg.el
new file mode 100644 (file)
index 0000000..c7f71bd
--- /dev/null
@@ -0,0 +1,18 @@
+;; -*- no-byte-compile: t; lexical-binding: nil -*-
+(define-package "org-ref" "20251206.1422"
+  "Citations, cross-references and bibliographies in org-mode."
+  '((org               "9.4")
+    (htmlize           "0")
+    (transient         "0")
+    (avy               "0")
+    (parsebib          "0")
+    (bibtex-completion "0")
+    (citeproc          "0")
+    (ox-pandoc         "0")
+    (request           "0"))
+  :url "https://github.com/jkitchin/org-ref"
+  :commit "dc2481d430906fe2552f9318f4405242e6d37396"
+  :revdesc "dc2481d43090"
+  :keywords '("org-mode" "cite" "ref" "label")
+  :authors '(("John Kitchin" . "jkitchinNOSPAMandrew.cmu.edu"))
+  :maintainers '(("John Kitchin" . "jkitchinNOSPAMandrew.cmu.edu")))
diff --git a/elpa/org-ref-20251206.1422/org-ref-publish.el b/elpa/org-ref-20251206.1422/org-ref-publish.el
new file mode 100644 (file)
index 0000000..9a619b7
--- /dev/null
@@ -0,0 +1,109 @@
+;;; org-ref-publish.el --- org-publish with org-ref -*- lexical-binding: t; -*-\r
+\r
+;;; Commentary:\r
+;; First draft proposed by madhu 230826 (Madhu <enomethNOSPAMmeer.net>)\r
+;; This code provides publishing capability that leverages\r
+\r
+;;; Code:\r
+\r
+(declare-function org-ref-process-buffer "org-ref-core" (backend &optional subtreep))\r
+\r
+;; modified from org-publish-org-to to call org-ref-process-buffer before\r
+;; calling org-export-to-file\r
+(defun org-ref-publish-org-to (backend filename extension plist &optional pub-dir)\r
+  "Publish an Org file to a specified backend using org-ref.\r
+\r
+BACKEND is a symbol representing the backend used for\r
+transcoding.  FILENAME is the filename of the Org file to be\r
+published.  EXTENSION is the extension used for the output\r
+string, with the leading dot.  PLIST is the property list for the\r
+given project.\r
+\r
+Optional argument PUB-DIR, when non-nil is the publishing\r
+directory.\r
+\r
+Return output file name."\r
+  (unless (or (not pub-dir) (file-exists-p pub-dir))\r
+    (make-directory pub-dir t))\r
+  ;; Check if a buffer visiting FILENAME is already open.\r
+  (let* ((org-inhibit-startup t)\r
+        (visiting (find-buffer-visiting filename))\r
+        (work-buffer (or visiting (find-file-noselect filename))))\r
+    (unwind-protect\r
+       (with-current-buffer work-buffer\r
+         (let* ((output (org-export-output-file-name extension nil pub-dir)))\r
+           (org-export-with-buffer-copy\r
+            (org-export-expand-include-keyword)\r
+            (goto-char (point-min))\r
+            (org-ref-process-buffer backend nil) ;no subtreep\r
+            (goto-char (point-min))\r
+            (org-export-to-file backend output\r
+              nil nil nil (plist-get plist :body-only)\r
+              ;; Add `org-publish--store-crossrefs' and\r
+              ;; `org-publish-collect-index' to final output filters.\r
+              ;; The latter isn't dependent on `:makeindex', since we\r
+              ;; want to keep it up-to-date in cache anyway.\r
+              (org-combine-plists\r
+               plist\r
+               `(:crossrefs\r
+                 ,(org-publish-cache-get-file-property\r
+                   ;; Normalize file names in cache.\r
+                   (file-truename filename) :crossrefs nil t)\r
+                 :filter-final-output\r
+                 (org-publish--store-crossrefs\r
+                  org-publish-collect-index\r
+                  ,@(plist-get plist :filter-final-output))))))))\r
+      ;; Remove opened buffer in the process.\r
+      (unless visiting (kill-buffer work-buffer)))))\r
+\r
+;; modified from org-html-publish-to-html to call org-ref-publish-org-to instead\r
+;; of org-publish-org-to\r
+(defun org-ref-publish-to-html (plist filename pub-dir)\r
+  "Publish an org file to HTML through org-ref.\r
+\r
+FILENAME is the filename of the Org file to be published.  PLIST\r
+is the property list for the given project.  PUB-DIR is the\r
+publishing directory.\r
+\r
+Return output file name."\r
+  (org-ref-publish-org-to 'html filename\r
+                         (concat (when (> (length org-html-extension) 0) ".")\r
+                                 (or (plist-get plist :html-extension)\r
+                                     org-html-extension\r
+                                     "html"))\r
+                         plist pub-dir))\r
+\r
+\r
+;; modified from org-latex-publish-to-latex to call org-ref-publish-org-to\r
+;; instead of org-publish-org-to\r
+(defun org-ref-publish-to-latex (plist filename pub-dir)\r
+  "Publish an Org file to LaTeX using org-ref.\r
+\r
+FILENAME is the filename of the Org file to be published.  PLIST\r
+is the property list for the given project.  PUB-DIR is the\r
+publishing directory.\r
+\r
+Return output file name."\r
+  (org-ref-publish-org-to 'latex filename ".tex" plist pub-dir))\r
+\r
+;; modified from org-latex-publish-to-pdf to call org-ref-publish-org-to instead of org-publish-org-to\r
+(defun org-ref-publish-to-pdf (plist filename pub-dir)\r
+  "Publish an Org file to PDF (via LaTeX) using org-ref.\r
+\r
+FILENAME is the filename of the Org file to be published.  PLIST\r
+is the property list for the given project.  PUB-DIR is the\r
+publishing directory.\r
+\r
+Return output file name."\r
+  (org-publish-attachment\r
+   plist\r
+   (let ((default-directory (file-name-directory filename)))\r
+     (org-latex-compile\r
+      (org-ref-publish-org-to\r
+       'latex filename ".tex" plist (file-name-directory filename))))\r
+   pub-dir))\r
+\r
+(provide 'org-ref-publish)\r
+\r
+;;; org-ref-publish.el ends here\r
+\r
diff --git a/elpa/org-ref-20251206.1422/org-ref-pubmed.el b/elpa/org-ref-20251206.1422/org-ref-pubmed.el
new file mode 100644 (file)
index 0000000..08bc9b1
--- /dev/null
@@ -0,0 +1,265 @@
+;;; org-ref-pubmed.el --- Links and functions for Pubmed and NIH databases  -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2015-2024  John Kitchin
+
+;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
+;; Keywords: convenience
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;* Introduction
+
+;; This document is an experiment at creating a literate program to provide
+;; functions for interacting with pubmed databases.
+
+;; This library provides links that go to pubmed resources, e.g.
+
+;; pmcid:PMC3498956
+;;
+;; pmid:23162369
+;;
+;; and nihmsid:NIHMS395714
+;;
+;; See http://www.ncbi.nlm.nih.gov/pmc/about/public-access-info/#p3 for details
+;; of these identifiers.
+;;
+;; For PMID there is one interactive function that inserts a bibtex entry:
+;; pubmed-insert-bibtex-from-pmid.
+
+;; This library is complementary to [[./doi-utils.org]].
+
+;;; Code:
+
+;;* PMID (from PubMed) link and functions
+
+;; A PMID is a number that identifies an entry in the Pubmed database.  The PMID
+;; is a unique reference number for PubMed citations. The PMID is a distinctly
+;; different number from the PMCID and is used only for PubMed records.
+
+(require 'org)
+(require 'org-ref-utils)
+
+(org-link-set-parameters "pmid"
+                        :follow (lambda (link-string) (browse-url (format "http://www.ncbi.nlm.nih.gov/pubmed/%s" link-string)))
+                        :export (lambda (keyword desc format)
+                                  (cond
+                                   ((eq format 'html)
+                                    (format "<a href=\"http://www.ncbi.nlm.nih.gov/pmc/articles/mid/%s\">pmid:%s</a>" keyword (or desc keyword))) ; no output for html
+                                   ((eq format 'latex)
+                                    ;; write out the latex command
+                                    (format "\\url{http://www.ncbi.nlm.nih.gov/pmc/articles/mid/%s}{%s}" keyword (or desc keyword))))))
+
+;;** Get MEDLINE metadata
+
+;; We can get bibliographic metadata from a pmid. Here we get the MEDLINE
+;; text. The website wraps the data in <pre></pre> tags.
+
+(defun pubmed-get-medline (pmid)
+  "Get MEDLINE text for PMID as a string."
+  (with-current-buffer
+      (url-retrieve-synchronously
+       (format "https://pubmed.ncbi.nlm.nih.gov/%s/?format=pubmed" pmid))
+    (goto-char (point-min))
+    (let ((p1 (search-forward "<pre class=\"article-details\" id=\"article-details\">"))
+          (p2 (search-forward "</pre>")))
+      (replace-regexp-in-string "\r" "" (buffer-substring (+ 1 p1) (- p2 6))))))
+
+;;** Parse the PMID MEDLINE data
+
+;; We can parse this into a data structure.
+(defun pubmed-parse-medline (pmid)
+  "Parse the medline text for PMID and return a list of cons cells."
+  (let ((data '())
+        (p1)
+        (p2)
+        (tag)
+        (value))
+    (with-temp-buffer (insert (pubmed-get-medline pmid))
+                      (goto-char (point-min))
+                      (while (re-search-forward "\\(^[A-Z]\\{2,4\\}\\)\\s-*- "
+                                               nil t)
+                        (setq tag (match-string 1))
+                        ;; point is at end of the search
+                        (setq p1 (point))
+                        ;; now go to next tag
+                        (re-search-forward "\\(^[A-Z]\\{2,4\\}\\)\\s-*- " nil t)
+                        (setq p2 (- (match-beginning 1) 1))
+                        (setq value (buffer-substring p1 p2))
+                        (setq data (append data (list (cons tag value))))
+                        ;; now go back to last tag to get the next one
+                        (goto-char p1)))
+    data))
+
+;;** PMID to bibtex entry
+
+;; The point of parsing the MEDLINE text is so we can make bibtex entries. We
+;; only support Journal articles for now.
+
+(defun pubmed-pmid-to-bibtex (pmid)
+  "Convert a PMID to a bibtex entry."
+  (let* ((data (pubmed-parse-medline pmid))
+         (type (downcase (cdr (assoc "PT" data))))
+         (title (cdr (assoc "TI" data)))
+         (authors (mapconcat 'cdr
+                             (seq-filter (lambda (x)
+                                        (string= (car x) "FAU"))
+                                      data)
+                             " and "))
+         (abstract (cdr (assoc "AB" data)))
+         (volume (cdr (assoc "VI" data)))
+         (issue (cdr (assoc "IP" data)))
+         (journal (cdr (assoc "JT" data)))
+         (year (cdr (assoc "DP" data)))
+         (pages (cdr (assoc "PG" data)))
+         (aid (cdr (assoc "AID" data))))
+
+    (cond
+     ((string= type "journal article")
+      (concat "@article{,
+ author = {" authors "},
+ title = {" title "},
+ abstract = {" abstract "},
+ journal = {" journal "},
+ volume = {" volume "},
+ number = {" issue "},
+ year = {" (car (split-string year)) "},
+ pages = {" pages "},
+ doi = {" (replace-regexp-in-string " \\[doi\\]" "" (or aid "")) "},
+}"))
+     (t
+      (message "No conversion for type: %s" type)))))
+
+;; And we probably want to be able to insert a bibtex entry
+
+;;;###autoload
+(defun pubmed-insert-bibtex-from-pmid (pmid)
+  "Insert a bibtex entry at point derived from PMID.
+You must clean the entry after insertion."
+  (interactive "sPMID: ")
+  (insert (pubmed-pmid-to-bibtex pmid)))
+
+
+;;* Pubmed Central (PMC) link
+
+;; A PMCID starts with PMC and is followed by numbers. The PMCID is a unique
+;; reference number or identifier that is assigned to every article that is
+;; accepted into PMC. The PMCID is also used by recipients of NIH funding to
+;; demonstrate compliance with the NIH Public Access policy. The PMCID can be
+;; found in both PMC and PubMed.
+
+;; Here we define a new link. Clicking on it simply opens a webpage to the
+;; article.
+
+(org-link-set-parameters "pmcid"
+                        :follow (lambda (link-string) (browse-url (format "http://www.ncbi.nlm.nih.gov/pmc/articles/%s" link-string)))
+                        :export (lambda (keyword desc format)
+                                  (cond
+                                   ((eq format 'html)
+                                    (format "<a href=\"http://www.ncbi.nlm.nih.gov/pmc/articles/%s\">pmcid:%s</a>" keyword (or desc keyword)))
+                                   ((eq format 'latex)
+                                    (format "\\url{http://www.ncbi.nlm.nih.gov/pmc/articles/%s}{%s}" keyword (or desc keyword))))))
+
+;;* NIHMSID
+
+;; The NIHMSID is a preliminary article identifier that applies only to
+;; manuscripts deposited through the NIHMS system. The NIHMSID is only valid for
+;; compliance reporting for 90 days after the publication date of an
+;; article. Once the Web version of the NIHMS submission is approved for
+;; inclusion in PMC and the corresponding citation is in PubMed, the article
+;; will also be assigned a PMCID.
+
+(org-link-set-parameters "nihmsid"
+                        :follow (lambda (link-string) (browse-url (format "http://www.ncbi.nlm.nih.gov/pmc/articles/mid/%s" link-string)))
+                        :export (lambda (keyword desc format)
+                                  (cond
+                                   ((eq format 'html)
+                                    (format "<a href=\"http://www.ncbi.nlm.nih.gov/pmc/articles/mid//%s\">nihmsid:%s</a>" keyword (or desc keyword)))
+                                   ((eq format 'latex)
+                                    ;; write out the latex command
+                                    (format "\\url{http://www.ncbi.nlm.nih.gov/pmc/articles/mid/%s}{%s}" keyword (or desc keyword))))))
+
+
+;;* Searching pubmed
+
+;;;###autoload
+(defun pubmed ()
+  "Open http://www.ncbi.nlm.nih.gov/pubmed in a browser."
+  (interactive)
+  (browse-url "http://www.ncbi.nlm.nih.gov/pubmed"))
+
+
+;;;###autoload
+(defun pubmed-advanced ()
+  "Open http://www.ncbi.nlm.nih.gov/pubmed/advanced in a browser."
+  (interactive)
+  (browse-url "http://www.ncbi.nlm.nih.gov/pubmed/advanced"))
+
+
+;;;###autoload
+(defun pubmed-simple-search (query)
+  "Open QUERY in Pubmed in a browser."
+  (interactive "sQuery: ")
+  (browse-url
+   (format "http://www.ncbi.nlm.nih.gov/pubmed/?term=%s" (url-hexify-string query))))
+
+
+(org-link-set-parameters "pubmed-search"
+                        :follow (lambda (query)
+                                  "Open QUERY in a `pubmed-simple-search'."
+                                  (pubmed-simple-search query))
+                        :export (lambda (query desc format)
+                                  (let ((url (format "http://www.ncbi.nlm.nih.gov/pubmed/?term=%s" (url-hexify-string query))))
+                                    (cond
+                                     ((eq format 'html)
+                                      (format "<a href=\"%s\">%s</a>" url (or desc (concat "pubmed-search:" query))))
+                                     ((eq format 'latex)
+                                      (format "\\href{%s}{%s}" url (or desc (concat "pubmed-search:" query))))))))
+
+;; ** Pubmed clinical
+;; These functions were suggested by Colin Melville <casm40NOSPAMgmail.com>.
+;;;###autoload
+(defun pubmed-clinical ()
+  "Open http://www.ncbi.nlm.nih.gov/pubmed/clinical in a browser."
+  (interactive)
+  (browse-url "http://www.ncbi.nlm.nih.gov/pubmed/clinical"))
+
+
+;;;###autoload
+(defun pubmed-clinical-search (query)
+  "Open QUERY in pubmed-clinical."
+  (interactive "sQuery: ")
+  (browse-url
+   (format "https://www.ncbi.nlm.nih.gov/pubmed/clinical?term=%s" (url-hexify-string query))))
+
+
+(org-link-set-parameters "pubmed-clinical"
+                        :follow (lambda (query)
+                                  "Open QUERY in a `pubmed-clinical-search'."
+                                  (pubmed-clinical-search query))
+                        :export (lambda (query desc format)
+                                  (let ((url (format "http://www.ncbi.nlm.nih.gov/pubmed/clinical?term=%s"
+                                                     (url-hexify-string query))))
+                                    (cond
+                                     ((eq format 'html)
+                                      (format "<a href=\"%s\">%s</a>" url
+                                              (or desc (concat "pubmed-clinical-search:" query))))
+                                     ((eq format 'latex)
+                                      (format "\\href{%s}{%s}" url
+                                              (or desc (concat "pubmed-clinical-search:" query))))))))
+
+
+(provide 'org-ref-pubmed)
+;;; org-ref-pubmed.el ends here
diff --git a/elpa/org-ref-20251206.1422/org-ref-ref-links.el b/elpa/org-ref-20251206.1422/org-ref-ref-links.el
new file mode 100644 (file)
index 0000000..07a6f2c
--- /dev/null
@@ -0,0 +1,961 @@
+;;; org-ref-ref-links.el --- cross-reference links for org-ref -*- lexical-binding: t; -*-
+;;
+;; Copyright (C) 2021-2024  John Kitchin
+
+;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
+;; Keywords: convenience
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+;;
+;;; Commentary:
+;;
+
+;;; Code:
+(eval-and-compile (require 'org-macs))
+(eval-and-compile (require 'ol))
+
+;; Declare functions from org-element
+(declare-function org-element-context "org-element" (&optional element))
+(declare-function org-element-property "org-element" (property element))
+(declare-function org-element-type "org-element" (element))
+(declare-function org-element-parse-buffer "org-element" (&optional granularity visible-only))
+(declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated))
+(declare-function org-element-interpret-data "org-element" (data))
+
+;; Declare functions from org
+(declare-function org-mark-ring-push "org" (&optional pos buffer))
+(declare-function org-file-image-p "org" (file &optional extensions))
+(declare-function org-at-table-p "org" (&optional table-type))
+(declare-function org-table-begin "org" (&optional table-type))
+
+;; Declare functions from ox (org-export)
+(declare-function org-export-get-caption "ox" (element &optional short))
+
+(defcustom org-ref-default-ref-type "ref"
+  "Default ref link type to use when inserting ref links."
+  :type 'string
+  :group 'org-ref)
+
+
+(defcustom org-ref-activate-ref-links t
+  "If non-nil use font lock to activate ref links.
+Activation can be slow in large documents with a lot of ref
+links. Set this to nil to turn off activation."
+  :type 'boolean
+  :group 'org-ref)
+
+
+(defcustom org-ref-show-equation-images-in-tooltips nil
+  "If non-nil, show rendered equation images in tooltips for equation references.
+Requires that equations have been previewed with `org-latex-preview' or
+a compatible preview package (like math-preview).
+
+When enabled, hovering over an equation reference (eqref, ref, etc.) will
+display the rendered equation image in a tooltip instead of raw LaTeX code.
+
+This feature works best in GUI Emacs. In terminal Emacs, falls back to
+text display."
+  :type 'boolean
+  :group 'org-ref)
+
+
+(defcustom org-ref-enable-multi-file-references t
+  "If non-nil, collect labels from files included via #+INCLUDE directives.
+
+When enabled, org-ref will search for labels not only in the current buffer,
+but also in all files referenced via #+INCLUDE directives. This allows
+cross-references to work across multiple files in a project.
+
+Labels are cached per-file and only re-scanned when files change, using
+timestamp-based change detection for performance.
+
+For single-file documents, this feature has minimal overhead since no
+#+INCLUDE directives are present. Set to nil to disable if needed."
+  :type 'boolean
+  :group 'org-ref)
+
+
+(defface org-ref-ref-face
+  `((t (:inherit org-link :foreground "dark red")))
+  "Face for ref links in org-ref."
+  :group 'org-ref-faces)
+
+
+(defvar org-ref-label-re
+  (rx-to-string
+   '(group-n 1 (one-or-more (any word "-.:?!`'/*@+|(){}<>&_^$#%~"))))
+  "Regexp for labels.")
+
+
+(defvar org-ref-label-link-re
+  (rx-to-string
+   `(seq "label:" (group-n 1 (one-or-more (any word "-.:?!`'/*@+|(){}<>&_^$#%~")))))
+  "Regexp for label links.")
+
+
+(defvar org-ref-ref-label-regexps
+  (list
+   (concat ":ID:\\s-+" org-ref-label-re "\\_>")
+   ;; CUSTOM_ID in a heading
+   (concat ":CUSTOM_ID:\\s-+" org-ref-label-re "\\_>")
+   ;; #+name
+   (concat "^\\s-*#\\+name:\\s-+" org-ref-label-re "\\_>")
+   ;; labels in latex
+   (concat "\\\\label{" org-ref-label-re "}")
+   ;; A target, code copied from org-target-regexp and group 1 numbered.
+   (let ((border "[^<>\n\r \t]"))
+     (format "<<\\(?1:%s\\|%s[^<>\n\r]*%s\\)>>"
+            border border border))
+   ;; A label link
+   (concat "label:" org-ref-label-re "\\_>")
+   "\\\\lstset{.*label=\\(?1:.*?\\),.*}")
+  "List of regular expressions to labels.
+The label should always be in group 1.")
+
+
+(defvar org-ref-ref-types
+  '(("ref" "A regular cross-reference to a label")
+    ("eqref" "A cross-reference to an equation")
+    ("pageref" "to the page number a label is on")
+    ("nameref" "to the name associated with a label (e.g. a caption)")
+    ("autoref" "from hyperref, adds automatic prefixes")
+    ("Autoref" "from hyperref, capitalized version of autoref")
+    ("cref" "from cleveref, adds automatic prefixes, and condenses multiple refs")
+    ("Cref" "from cleveref, capitalized version of cref")
+    ("crefrange" "from cleveref, makes a range of refs from two refs with a prefix")
+    ("Crefrange" "from cleveref, capitalized prefix version of crefrange"))
+  "List of ref link types (type description).")
+
+
+(defun org-ref-select-ref-type ()
+  "Select a ref type with annotated completion."
+  (let* ((type-annotation (lambda (s)
+                           (let ((item (assoc s minibuffer-completion-table)))
+                             (when item (concat
+                                         (make-string (- 12 (length s)) ? )
+                                         "-- "
+                                         (cl-second item))))))
+        (completion-extra-properties `(:annotation-function ,type-annotation)))
+    (completing-read "Type: " org-ref-ref-types)))
+
+
+(defun org-ref-change-ref-type (new-type)
+  "Change the ref type to NEW-TYPE."
+  (interactive (list (org-ref-select-ref-type)))
+  (let* ((cite-link (org-element-context))
+        (old-type (org-element-property :type cite-link))
+        (begin (org-element-property :begin cite-link))
+        (end (org-element-property :end cite-link))
+        (bracketp (eq 'bracket (org-element-property :format cite-link)))
+        (path (org-element-property :path cite-link))
+        (deltap (- (point) begin)))
+    ;; note this does not respect brackets
+    (cl--set-buffer-substring begin end
+                             (concat
+                              (if bracketp "[[" "")
+                              new-type ":" path
+                              (if bracketp "]]" "")))
+    ;; try to preserve the character the point is on.
+    (goto-char (+ begin deltap (- (length new-type) (length old-type))))))
+
+
+(defvar-local org-ref-label-cache nil
+  "Buffer-local cache variable for labels.")
+
+
+(defvar-local org-ref-buffer-chars-modified-tick nil
+  "Buffer-local variable to hold `buffer-chars-modified-tick'.")
+
+
+(defvar-local org-ref-preview-image-cache nil
+  "Buffer-local cache of (label . image-spec) for preview images.")
+
+
+(defvar-local org-ref-preview-cache-tick nil
+  "Buffer modification tick when preview image cache was last updated.")
+
+
+;; Multi-file reference support - global caches
+(defvar org-ref-project-label-cache (make-hash-table :test 'equal)
+  "Hash table mapping project-root -> ((file . labels-alist) ...).
+Used when `org-ref-enable-multi-file-references' is non-nil to cache
+labels from multiple files in a project.")
+
+
+(defvar org-ref-file-timestamps (make-hash-table :test 'equal)
+  "Hash table mapping file-path -> (mtime . size) for change detection.
+Used to determine if a file needs to be re-scanned for labels without
+actually opening and parsing the file.")
+
+
+(defun org-ref-get-included-files ()
+  "Return list of absolute paths to files included in current buffer.
+Parses #+INCLUDE directives and returns a list of existing files.
+Only returns files that actually exist on disk."
+  (save-excursion
+    (goto-char (point-min))
+    (let ((files '()))
+      (while (re-search-forward "^[ \t]*#\\+INCLUDE:[ \t]+\"\\([^\"]+\\)\"" nil t)
+        (let* ((file (match-string-no-properties 1))
+               (expanded-file (expand-file-name file)))
+          (when (file-exists-p expanded-file)
+            (push expanded-file files))))
+      (nreverse files))))
+
+
+(defun org-ref-file-changed-p (file)
+  "Check if FILE has changed since last scan using timestamp and size.
+This is an O(1) operation that doesn't require parsing the file.
+Returns t if the file has changed or hasn't been scanned yet."
+  (let* ((attrs (file-attributes file))
+         (mtime (nth 5 attrs))
+         (size (nth 7 attrs))
+         (cached (gethash file org-ref-file-timestamps)))
+    (or (not cached)
+        (not (equal mtime (car cached)))
+        (not (equal size (cdr cached))))))
+
+
+(defun org-ref-mark-file-scanned (file)
+  "Record timestamp and size of FILE to detect future changes."
+  (let* ((attrs (file-attributes file))
+         (mtime (nth 5 attrs))
+         (size (nth 7 attrs)))
+    (puthash file (cons mtime size) org-ref-file-timestamps)))
+
+
+(defun org-ref-scan-buffer-for-labels ()
+  "Scan current buffer for labels and return list of (label . context) cons cells.
+This is the core scanning logic used by both single-file and multi-file modes."
+  (let ((case-fold-search t)
+        (rx (string-join org-ref-ref-label-regexps "\\|"))
+        (labels '())
+        oe ;; org-element
+        context)
+    (save-excursion
+      (org-with-wide-buffer
+       (goto-char (point-min))
+       (while (re-search-forward rx nil t)
+         (save-match-data
+           ;; Here we try to get some relevant context for different things you
+           ;; might reference.
+           (setq oe (org-element-context)
+                 context (string-trim
+                          (pcase (car oe)
+                            ('latex-environment (buffer-substring
+                                                 (org-element-property :begin oe)
+                                                 (org-element-property :end oe)))
+                            ;; figure
+                            ('paragraph (buffer-substring
+                                         (org-element-property :begin oe)
+                                         (org-element-property :end oe)))
+                            ('table (buffer-substring
+                                     (org-element-property :begin oe)
+                                     (org-element-property :end oe)))
+                            ;; Headings fall here.
+                            (_ (buffer-substring (line-beginning-position)
+                                                 (line-end-position)))))))
+         (cl-pushnew (cons (match-string-no-properties 1) context)
+                     labels))))
+    ;; reverse so they are in the order we find them.
+    (delete-dups (reverse labels))))
+
+
+(defun org-ref-get-labels-single-file ()
+  "Get labels from current buffer only (original single-file behavior).
+Uses buffer-local cache and buffer-chars-modified-tick for invalidation."
+  (if (or
+       ;; if we have not checked we have to check
+       (null org-ref-buffer-chars-modified-tick)
+       ;; Now check if buffer has changed since last time we looked. We check
+       ;; this with the buffer-chars-modified-tick which keeps track of changes.
+       ;; If this hasn't changed, no chars have been modified.
+       (not (= (buffer-chars-modified-tick)
+               org-ref-buffer-chars-modified-tick)))
+      ;; We need to search for all the labels either because we don't have them,
+      ;; or the buffer has changed since we looked last time.
+      (setq
+       org-ref-buffer-chars-modified-tick (buffer-chars-modified-tick)
+       org-ref-label-cache (org-ref-scan-buffer-for-labels))
+    ;; retrieve the cached data
+    org-ref-label-cache))
+
+
+(defun org-ref-scan-file-for-labels (file)
+  "Scan FILE for labels and return list of (label . context) cons cells.
+Opens the file in a temporary buffer and scans it."
+  (with-temp-buffer
+    (insert-file-contents file)
+    (org-mode)
+    (org-ref-scan-buffer-for-labels)))
+
+
+(defun org-ref-get-labels-multi-file ()
+  "Get labels from current file and all included files.
+Only re-scans files that have actually changed (timestamp-based detection).
+Uses global project cache for efficiency."
+  (when (buffer-file-name)
+    (let* ((current-file (buffer-file-name))
+           (included-files (org-ref-get-included-files))
+           (all-files (cons current-file included-files))
+           (all-labels '()))
+
+      ;; For each file, check if it changed and re-scan only if needed
+      (dolist (file all-files)
+        (when (org-ref-file-changed-p file)
+          ;; File changed, re-scan it
+          (let ((file-labels (if (string= file current-file)
+                                 ;; For current file, use the regular scan
+                                 (org-ref-scan-buffer-for-labels)
+                               ;; For included files, scan from disk
+                               (org-ref-scan-file-for-labels file))))
+            ;; Cache the labels for this file
+            (puthash file file-labels org-ref-project-label-cache)
+            ;; Mark file as scanned
+            (org-ref-mark-file-scanned file)))
+
+        ;; Retrieve cached labels for this file
+        (let ((file-labels (gethash file org-ref-project-label-cache)))
+          (when file-labels
+            (setq all-labels (append all-labels file-labels)))))
+
+      ;; Remove duplicates (in case same label appears in multiple files)
+      (delete-dups all-labels))))
+
+
+(defun org-ref-get-labels ()
+  "Return a list of referenceable labels in the document.
+You can reference:
+A NAME keyword
+A CUSTOM_ID property on a heading
+A LaTeX label
+A target.
+A label link
+A setting in lstset
+
+See `org-ref-ref-label-regexps' for the patterns that find these.
+
+Returns a list of cons cells (label . context).
+
+If `org-ref-enable-multi-file-references' is non-nil, also includes
+labels from files referenced via #+INCLUDE directives.
+
+It is important for this function to be fast, since we use it in
+font-lock."
+  (if org-ref-enable-multi-file-references
+      (org-ref-get-labels-multi-file)
+    (org-ref-get-labels-single-file)))
+
+
+(defun org-ref-find-label-in-buffer (label)
+  "Search for LABEL in current buffer.
+Returns t if found and moves point to the label, nil otherwise."
+  (let ((case-fold-search t)
+        (rx (string-join org-ref-ref-label-regexps "\\|")))
+    (save-excursion
+      (goto-char (point-min))
+      (catch 'found
+        (while (re-search-forward rx nil t)
+          (when (string= label (match-string-no-properties 1))
+            (goto-char (match-beginning 1))
+            (throw 'found t)))))))
+
+
+(defun org-ref-find-label-in-file (label file)
+  "Search for LABEL in FILE.
+Returns the position if found, nil otherwise."
+  (with-current-buffer (find-file-noselect file)
+    (save-excursion
+      (goto-char (point-min))
+      (let ((case-fold-search t)
+            (rx (string-join org-ref-ref-label-regexps "\\|")))
+        (catch 'found
+          (while (re-search-forward rx nil t)
+            (when (string= label (match-string-no-properties 1))
+              (throw 'found (match-beginning 1)))))))))
+
+
+(defun org-ref-ref-jump-to (&optional path)
+  "Jump to the target for the ref link at point.
+If `org-ref-enable-multi-file-references' is non-nil and the label
+is not found in the current buffer, searches in included files."
+  (interactive)
+  (let ((case-fold-search t)
+       (label (get-text-property (point) 'org-ref-ref-label))
+       (labels (split-string path ","))
+       (rx (string-join org-ref-ref-label-regexps "\\|")))
+    (when (null label)
+      (pcase (length labels)
+       (1
+        (setq label (cl-first labels)))
+       (_
+        (setq label (completing-read "Label: " labels)))))
+    (when label
+      (org-mark-ring-push)
+      ;; First, try to find in current buffer
+      (widen)
+      (goto-char (point-min))
+      (let ((found nil))
+        (catch 'found
+          (while (re-search-forward rx nil t)
+            (when (string= label (match-string-no-properties 1))
+              (save-match-data (org-mark-ring-push))
+              (goto-char (match-beginning 1))
+              (org-fold-show-entry)
+              (message
+               (substitute-command-keys
+                "Go back with (org-mark-ring-goto) \\[org-mark-ring-goto]."))
+              (setq found t)
+              (throw 'found t))))
+
+        ;; If not found in current buffer and multi-file mode is enabled,
+        ;; search in included files
+        (when (and (not found)
+                   org-ref-enable-multi-file-references
+                   (buffer-file-name))
+          (let ((included-files (org-ref-get-included-files)))
+            (catch 'found-in-file
+              (dolist (file included-files)
+                (let ((pos (org-ref-find-label-in-file label file)))
+                  (when pos
+                    ;; Found in an included file - open it and jump to position
+                    (find-file file)
+                    (goto-char pos)
+                    (org-fold-show-entry)
+                    (message
+                     (substitute-command-keys
+                      "Go back with (org-mark-ring-goto) \\[org-mark-ring-goto]."))
+                    (throw 'found-in-file t)))))
+
+            ;; If we get here, label wasn't found anywhere
+            (unless found
+              (message "Label '%s' not found in current file or included files" label))))))))
+
+
+
+(defun org-ref-find-overlay-with-image (begin end)
+  "Find an overlay with an image display property between BEGIN and END.
+Returns the image display spec or nil if none found."
+  (catch 'found
+    (let ((pos begin))
+      (while (< pos end)
+        (dolist (ov (overlays-at pos))
+          ;; Check for org-mode preview overlay or math-preview overlay
+          (when (or (eq (overlay-get ov 'org-overlay-type) 'org-latex-overlay)
+                    (overlay-get ov 'preview-image))
+            (let ((display (overlay-get ov 'display)))
+              (when (and display (listp display) (eq (car display) 'image))
+                (throw 'found display)))))
+        (setq pos (next-overlay-change pos))))
+    nil))
+
+
+(defun org-ref-get-preview-image-at-label (label)
+  "Return the preview image display spec for LABEL if it exists.
+Searches for LABEL in the buffer (both \\label{LABEL} and #+name: LABEL forms)
+and checks if there is an org-latex preview overlay at that location.
+Returns the image display spec that can be used in a propertized string,
+or nil if no preview exists.
+
+Uses caching for performance - cache is invalidated when buffer is modified."
+  ;; Check cache first
+  (let ((cached (and org-ref-preview-image-cache
+                     (equal org-ref-preview-cache-tick (buffer-chars-modified-tick))
+                     (assoc label org-ref-preview-image-cache))))
+    (if cached
+        (cdr cached)
+      ;; Not in cache, search for it
+      (let ((image-spec
+             (save-excursion
+               (save-restriction
+                 (widen)
+                 (goto-char (point-min))
+                 (or
+                  ;; Try 1: Search for \label{LABEL} in LaTeX environments
+                  (when (re-search-forward (format "\\\\label{%s}" (regexp-quote label)) nil t)
+                    (let* ((elem (org-element-context))
+                           (begin (org-element-property :begin elem))
+                           (end (org-element-property :end elem)))
+                      (when (and begin end (eq (org-element-type elem) 'latex-environment))
+                        (org-ref-find-overlay-with-image begin end))))
+
+                  ;; Try 2: Search for #+name: LABEL before latex-environment
+                  (progn
+                    (goto-char (point-min))
+                    (when (re-search-forward (format "^[ \t]*#\\+name:[ \t]+%s[ \t]*$"
+                                                    (regexp-quote label)) nil t)
+                      (forward-line 1)
+                      (let* ((elem (org-element-context))
+                             (begin (org-element-property :begin elem))
+                             (end (org-element-property :end elem)))
+                        (when (and begin end (eq (org-element-type elem) 'latex-environment))
+                          (org-ref-find-overlay-with-image begin end))))))))))
+
+        ;; Update cache
+        (when (or (null org-ref-preview-cache-tick)
+                  (not (equal org-ref-preview-cache-tick (buffer-chars-modified-tick))))
+          (setq org-ref-preview-image-cache nil
+                org-ref-preview-cache-tick (buffer-chars-modified-tick)))
+
+        ;; Add to cache (even if nil, to avoid repeated searches)
+        (push (cons label image-spec) org-ref-preview-image-cache)
+
+        image-spec))))
+
+
+(defun org-ref-ref-help-echo (_win _obj position)
+  "Tooltip for context on a ref label with optional image support.
+POSITION is the point under the mouse.
+
+Strategy: If previews exist on equations, show them in the minibuffer.
+Otherwise show text.
+
+When `org-ref-show-equation-images-in-tooltips' is non-nil and running in
+GUI Emacs, checks if a preview image exists for the referenced equation.
+If found, displays the image in the minibuffer using message. Otherwise,
+displays the LaTeX text context as usual.
+
+Always returns a string (empty string if no context is found)."
+  (let* ((label (get-text-property position 'org-ref-ref-label))
+         (context (cdr (assoc label (org-ref-get-labels))))
+         (fallback (if label
+                       (format "Reference to %s" label)
+                     "")))
+    ;; Try to show image if conditions are met
+    (or (if (and org-ref-show-equation-images-in-tooltips
+                 label
+                 (display-graphic-p))  ; Images only work in GUI
+            ;; Try to find and display preview image
+            (let ((image-spec (org-ref-get-preview-image-at-label label)))
+              (if image-spec
+                  ;; Extract file from the overlay's image spec
+                  (let ((file (plist-get (cdr image-spec) :file)))
+                    ;; Only show image if file exists
+                    (if (and file (file-exists-p file))
+                        (condition-case nil
+                            ;; Show image in minibuffer using message
+                            ;; Use the same image-spec from the overlay to preserve size
+                            (progn
+                              (message "%s" (propertize " " 'display image-spec))
+                              ;; Still return context for any fallback tooltip
+                              context)
+                          ;; If image display fails, show text
+                          (error context))
+                      ;; File doesn't exist, show text
+                      context))
+                ;; No image spec found, show text
+                context))
+          ;; Feature disabled or not in GUI, show text
+          context)
+        ;; Fallback when context is nil
+        fallback)))
+
+
+(defun org-ref-ref-activate (start _end path _bracketp)
+  "Activate a ref link.
+The PATH should be a comma-separated list of labels.
+Argument START is the start of the link.
+Argument END is the end of the link."
+  (when org-ref-activate-ref-links
+    (let ((labels (mapcar 'car (org-ref-get-labels))))
+      (goto-char start)
+      (cl-loop for label in (split-string path ",") do
+              (search-forward label)
+              ;; store property so we can follow it later.
+              (put-text-property (match-beginning 0)
+                                 (match-end 0)
+                                 'org-ref-ref-label
+                                 label)
+
+              (unless (member label labels)
+                
+                (put-text-property (match-beginning 0)
+                                   (match-end 0)
+                                   'face
+                                   'font-lock-warning-face)
+                (put-text-property (match-beginning 0)
+                                   (match-end 0)
+                                   'help-echo
+                                   "Label not found"))))))
+
+
+(defun org-ref-ref-export (cmd keyword _desc backend)
+  "An export function for ref links.
+Argument CMD is the LaTeX command to export to.
+Argument KEYWORD is the path of the ref link.
+Argument BACKEND is the export backend.
+This is meant to be used with `apply-partially' in the link definitions."
+  (cond
+   ((eq backend 'latex)
+    (format "\\%s{%s}" cmd keyword))))
+
+
+(defun org-ref-complete-link (refstyle &optional _arg)
+  "Complete a ref link to an existing label."
+  (concat refstyle ":" (completing-read "Label: " (org-ref-get-labels))))
+
+
+(defun org-ref-store-ref-link (&optional reftype)
+  "Store a ref link to a label.  The output will be a ref to that label."
+  ;; First we have to make sure we are on a label link.
+  (unless reftype (setq reftype "ref"))
+  (let* ((object (and (eq major-mode 'org-mode) (org-element-context)))
+        (label (cond
+                ;; here literally on a label link.
+                ((and
+                  (equal (org-element-type object) 'link)
+                  (equal (org-element-property :type object) "label"))
+                 (org-element-property :path object))
+
+                ;; here on a file link. if it has a caption with a label in it, we store
+                ;; it.
+                ((and
+                  (equal (org-element-type object) 'link)
+                  (equal (org-element-property :type object) "file")
+                  (org-file-image-p (org-element-property :path object)))
+
+                 (if (org-element-property :name object)
+                     (org-element-property :name object)
+                   ;; maybe we have a caption to get it from.
+                   (let* ((parent (org-element-property :parent object)))
+                     (when (and parent
+                                (equal (org-element-type parent) 'paragraph))
+                       (if (org-element-property :name parent)
+                           ;; caption paragraph may have a name which we use if it is there
+                           (org-element-property :name parent)
+                         ;; else search caption
+                         (let ((caption (string-join
+                                         (mapcar 'org-no-properties
+                                                 (org-export-get-caption parent))
+                                         "")))
+                           (when (string-match org-ref-label-re caption)
+                             (match-string 1 caption))))))))
+
+                ;; here on a paragraph (eg in a caption of an image). it is a paragraph with a caption
+                ;; in a caption, with no name, but maybe a label
+                ((equal (org-element-type object) 'paragraph)
+                 (if (org-element-property :name object)
+                     (org-element-property :name object)
+
+                   ;; See if it is in the caption name
+                   (let ((caption (string-join (mapcar 'org-no-properties
+                                                       (org-export-get-caption object)) "")))
+                     (when (string-match org-ref-label-re caption)
+                       (match-string 1 caption)))))
+
+                ;; If you are in a table, we need to be at the beginning to
+                ;; make sure we get the name. Note when in a caption it appears
+                ;; you are in a table but org-at-table-p is nil there.
+                ((or (equal (org-element-type object) 'table) (org-at-table-p))
+                 (save-excursion
+                   (goto-char (org-table-begin))
+                   (let* ((table (org-element-context))
+                          (label (org-element-property :name table))
+                          (caption (string-join "" (mapcar 'org-no-properties
+                                                      (org-export-get-caption table)))))
+                     (when (null label)
+                       ;; maybe there is a label in the caption?
+                       (when (string-match org-ref-label-link-re caption)
+                         (match-string 1 caption))))))
+
+                ;; and to #+namel: lines
+                ((and (equal (org-element-type object) 'paragraph)
+                      (org-element-property :name object))
+                 (org-element-property :name object))
+
+                ;; in a latex environment
+                ((equal (org-element-type object) 'latex-environment)
+                 (let ((value (org-element-property :value object)))
+                   (when (string-match "\\\\label{\\(?1:[+a-zA-Z0-9:\\._-]*\\)}" value)
+                     (match-string-no-properties 1 value))))
+
+                ;; Match targets, like <<label>>
+                ((equal (org-element-type object) 'target)
+                 (org-element-property :value object))
+
+                (t
+                 nil))))
+    
+    (when label
+      (org-link-store-props
+       :type reftype
+       :link (concat reftype ":" label)) 
+      t)))
+
+
+;; ** ref link
+
+(org-link-set-parameters "ref"
+                        :store (defun org-ref-store-ref () (org-ref-store-ref-link "ref"))
+                        :complete (apply-partially #'org-ref-complete-link "ref")
+                        :activate-func #'org-ref-ref-activate
+                        :follow #'org-ref-ref-jump-to
+                        :export (apply-partially #'org-ref-ref-export "ref")
+                        :face 'org-ref-ref-face
+                        :help-echo #'org-ref-ref-help-echo)
+
+
+;;** pageref link
+
+(org-link-set-parameters "pageref"
+                        :store (defun org-ref-store-pageref () (org-ref-store-ref-link "pageref"))
+                        :complete (apply-partially #'org-ref-complete-link "pageref")
+                        :activate-func #'org-ref-ref-activate
+                        :follow #'org-ref-ref-jump-to
+                        :export (apply-partially #'org-ref-ref-export "pageref")
+                        :face 'org-ref-ref-face
+                        :complete (lambda (&optional arg) (org-ref-complete-link arg "pageref"))
+                        :help-echo #'org-ref-ref-help-echo)
+
+
+;;** nameref link
+
+(org-link-set-parameters "nameref"
+                        :store (defun org-ref-store-nameref () (org-ref-store-ref-link "nameref"))
+                        :complete (apply-partially #'org-ref-complete-link "nameref")
+                        :activate-func #'org-ref-ref-activate
+                        :follow #'org-ref-ref-jump-to
+                        :export (apply-partially #'org-ref-ref-export "nameref")
+                        :face 'org-ref-ref-face
+                        :help-echo #'org-ref-ref-help-echo)
+
+;;** eqref link
+
+(org-link-set-parameters "eqref"
+                        :store (defun org-ref-store-eqref () (org-ref-store-ref-link "eqref"))
+                        :complete (apply-partially #'org-ref-complete-link "eqref")
+                        :activate-func #'org-ref-ref-activate
+                        :follow #'org-ref-ref-jump-to
+                        :export (apply-partially #'org-ref-ref-export "eqref")
+                        :face 'org-ref-ref-face
+                        :help-echo #'org-ref-ref-help-echo)
+
+;;** autoref link
+
+(org-link-set-parameters "autoref"
+                        :store (defun org-ref-store-autoref () (org-ref-store-ref-link "autoref"))
+                        :complete (apply-partially #'org-ref-complete-link "autoref")
+                        :activate-func #'org-ref-ref-activate
+                        :follow #'org-ref-ref-jump-to
+                        :export (apply-partially #'org-ref-ref-export "autoref")
+                        :face 'org-ref-ref-face
+                        :help-echo #'org-ref-ref-help-echo)
+
+
+(org-link-set-parameters "Autoref"
+                        :store (defun org-ref-store-Autoref () (org-ref-store-ref-link "Autoref"))
+                        :complete (apply-partially #'org-ref-complete-link "Autoref")
+                        :activate-func #'org-ref-ref-activate
+                        :follow #'org-ref-ref-jump-to
+                        :export (apply-partially #'org-ref-ref-export "Autoref")
+                        :face 'org-ref-ref-face
+                        :help-echo #'org-ref-ref-help-echo)
+
+;;** cref link
+;; for LaTeX cleveref package:
+;; https://www.ctan.org/tex-archive/macros/latex/contrib/cleveref
+
+
+(org-link-set-parameters "cref"
+                        :store (defun org-ref-store-cref () (org-ref-store-ref-link "cref"))
+                        :complete (apply-partially #'org-ref-complete-link "cref")
+                        :activate-func #'org-ref-ref-activate
+                        :follow #'org-ref-ref-jump-to
+                        :export (apply-partially #'org-ref-ref-export "cref")
+                        :face 'org-ref-ref-face
+                        :help-echo #'org-ref-ref-help-echo)
+
+
+(org-link-set-parameters "Cref"
+                        :store (defun org-ref-store-Cref () (org-ref-store-ref-link "Cref"))
+                        :complete (apply-partially #'org-ref-complete-link "Cref")
+                        :activate-func #'org-ref-ref-activate
+                        :follow #'org-ref-ref-jump-to
+                        :export (apply-partially #'org-ref-ref-export "Cref")
+                        :face 'org-ref-ref-face
+                        :help-echo #'org-ref-ref-help-echo)
+
+
+(defun org-ref-crefrange-export (path _desc backend)
+  (pcase backend
+    ('latex
+     (let ((labels (split-string path ",")))
+       (format "\\crefrange{%s}{%s}" (cl-first labels) (cl-second labels))))))
+
+
+(defun org-ref-Crefrange-export (path _desc backend)
+  (pcase backend
+    ('latex
+     (let ((labels (split-string path ",")))
+       (format "\\Crefrange{%s}{%s}" (cl-first labels) (cl-second labels))))))
+
+
+(defun org-ref-crefrange-complete (cmd &optional _arg)
+  "Completing function for the c/Crefrange links."
+  (concat cmd ":"
+         (completing-read "Label 1: " (org-ref-get-labels))
+         ","
+         (completing-read "Label 2: " (org-ref-get-labels))))
+
+
+(org-link-set-parameters "crefrange"
+                        :complete (apply-partially #'org-ref-crefrange-complete "crefrange")
+                        :activate-func #'org-ref-ref-activate
+                        :follow #'org-ref-ref-jump-to
+                        :export #'org-ref-crefrange-export
+                        :face 'org-ref-ref-face
+                        :help-echo #'org-ref-ref-help-echo)
+
+
+(org-link-set-parameters "Crefrange"
+                        :complete (apply-partially #'org-ref-crefrange-complete "Crefrange")
+                        :activate-func #'org-ref-ref-activate
+                        :follow #'org-ref-ref-jump-to
+                        :export #'org-ref-Crefrange-export
+                        :face 'org-ref-ref-face
+                        :help-echo #'org-ref-ref-help-echo)
+
+
+;; ** remove store functions
+(defun org-ref-ref-remove-store ()
+  "Remove the store functions from ref links.
+These tend to clobber the org store links. You can use C-u C-u
+C-c C-l to not use them, but if you prefer not to use them, this
+function removes the store functions from the links."
+  (interactive)
+  (cl-loop for reflink in '("ref" "pageref" "nameref" "eqref" "autoref" "Autoref"
+                           "cref" "Cref" "crefrange" "Crefrange")
+          do
+          (setf (cdr (assoc reflink org-link-parameters))
+                (org-plist-delete (cdr (assoc reflink org-link-parameters)) :store))))
+
+;; * Insert link
+(defvar org-ref-equation-environments
+  '("equation"
+    "equation*"
+    "align"
+    "align*"
+    "multline"
+    "multline*")
+  "LaTeX environments that should be treated as equations when referencing.")
+
+
+(defvar org-ref-ref-type-inference-alist
+  '((org-ref-equation-label-p . "eqref"))
+  "Alist of predicate functions taking a label name and the
+  desired reference type if the predicate returns true.")
+
+
+(defun org-ref-enclosing-environment (label)
+  "Returns the name of the innermost LaTeX environment containing
+the first instance of the label, or nil of there is none."
+  (or
+   (save-excursion
+     (save-restriction
+       (widen)
+       (goto-char (point-min))
+       (let ((label-point (search-forward (format "\\label{%s}" label) nil t)))
+        (when label-point
+           (catch 'return
+             (let (last-begin-point last-env)
+               (while (setq
+                       last-begin-point (re-search-backward "\\\\begin{\\([^}]+\\)}" nil t)
+                       last-env (match-string-no-properties 1))
+                (let ((env-end-point
+                       (search-forward (format "\\end{%s}" last-env) nil t)))
+                   (if (and env-end-point
+                            (> env-end-point label-point))
+                       (throw 'return last-env)
+                     (goto-char last-begin-point))))))))))
+   ;; Check latex-environments for names, and matching environment
+   (org-element-map (org-element-parse-buffer) 'latex-environment
+     (lambda (le)
+       (when (and (string= label (org-element-property :name le))
+                 (string-match
+                  (concat "begin{\\("
+                          (regexp-opt org-ref-equation-environments)
+                          "\\)}")
+                  (org-element-property :value le)))
+        (match-string 1 (org-element-property :value le))))
+     nil t)))
+
+
+(defun org-ref-equation-label-p (label)
+  "Return non-nil if LABEL is an equation label."
+  (let ((maybe-env (org-ref-enclosing-environment label)))
+    (when maybe-env
+      (member maybe-env org-ref-equation-environments))))
+
+
+(defun org-ref-infer-ref-type (label)
+  "Return inferred type for LABEL."
+  (or (cl-dolist (pred-pair org-ref-ref-type-inference-alist)
+       (when (funcall (car pred-pair) label)
+         (cl-return (eval (cdr pred-pair)))))
+      org-ref-default-ref-type))
+
+
+(defun org-ref-ref-link-p ()
+  "Return the link at point if point is on a ref link."
+  (let ((el (org-element-context)))
+    (and (eq (org-element-type el) 'link)
+        (assoc (org-element-property :type el) org-ref-ref-types)
+        el)))
+
+
+(defun org-ref-select-label ()
+  "Select a label in the buffer with annotated completion."
+  (let*  ((type-annotation (lambda (s)
+                            (let ((item (assoc s minibuffer-completion-table))) 
+                              (when item
+                                (with-temp-buffer
+                                  (insert "\n" (cdr item))
+                                  (indent-rigidly (point-min) (point-max) 20)
+                                  (buffer-string))))))
+         (completion-extra-properties `(:annotation-function ,type-annotation)))
+    (completing-read "Label: " (org-ref-get-labels))))
+
+
+(defun org-ref-insert-ref-link (&optional set-type)
+  "Insert a ref link.
+If on a link, append a label to the end.
+With a prefix arg SET-TYPE choose the ref type."
+  (interactive "P")
+  (let* ((minibuffer-setup-hook '(org-ref-minibuffer-prefix))
+        (label (org-ref-select-label)) 
+        (type (if (or set-type org-ref-prefix-arg)
+                  (org-ref-select-ref-type)
+                ;; in general, we prefer to infer the type, so that equations
+                ;; get a better default. However, if you customize
+                ;; `org-ref-default-ref-type', we use that instead. The most
+                ;; common use case for this is setting that variable to cref,
+                ;; which does its own automatic inference of the type.
+                (if (string= "ref" org-ref-default-ref-type)
+                    (org-ref-infer-ref-type label)
+                  org-ref-default-ref-type))))
+    (if-let* ((lnk (org-ref-ref-link-p))
+             (path (org-element-property :path lnk))
+             (beg (org-element-property :begin lnk))
+             (end (org-element-property :end lnk)))
+       (progn
+         (setf (plist-get (cadr lnk) :path) (concat path "," label))
+         (cl--set-buffer-substring beg end (org-element-interpret-data lnk)))
+
+      (insert (format  "%s:%s" type label)))
+    (goto-char (org-element-property :end (org-element-context)))))
+
+
+(provide 'org-ref-ref-links)
+
+;;; org-ref-ref-links.el ends here
diff --git a/elpa/org-ref-20251206.1422/org-ref-refproc.el b/elpa/org-ref-20251206.1422/org-ref-refproc.el
new file mode 100644 (file)
index 0000000..5c1024d
--- /dev/null
@@ -0,0 +1,481 @@
+;;; org-ref-refproc.el --- refproc - for exporting ref links in non-LaTeX backends -*- lexical-binding: t; -*-
+
+;; For autoref and cref* links, a clever prefix is added at export.
+;; Prefixes are found in `org-ref-refproc-clever-prefixes'
+;; Use a keyword like this to set the style of clever prefixes. You can use a full or abbreviated prefix
+;;
+;; #+refproc: :abbreviate t :capitalize t
+
+
+;;; Commentary:
+;;
+
+;;; Code:
+(require 'org-ref-ref-links)
+
+
+(defcustom org-ref-refproc-clever-prefixes
+  '((section :full "section" :abbrv "sec." :org-element headline)
+    (figure :full "figure" :abbrv "fig." :org-element link)
+    (table :full "table" :abbrv "tab." :org-element table)
+    (equation :full "equation" :abbrv "eq." :org-element latex-environment)
+    (proof :full "proof" :abbrv "pf." :org-element latex-environment)
+    (listing :full "listing" :abbrv "lst." :org-element src-block)
+    (lemma :full "lemma" :abbrv "lem." :org-element special-block)
+    (theorem :full "theorem" :abbrv "thm." :org-element special-block)
+    (corollary :full "corollary" :abbrv "cor." :org-element special-block))
+  "Prefixes for cleveref links.
+plist with :full and :abbrv forms for each type.
+:org-element is the element these are defined in."
+  :type 'sexp
+  :group 'org-ref)
+
+
+
+;; * refproc
+;;
+
+(defun org-ref-refproc-get-options ()
+  "Return a plist of options from a #+refproc keyword.
+Supported options are:
+:abbreviate (nil or non-nil)
+:capitalize (nil or non-nil)
+
+These options only affect the cref* links."
+  (read (format "(%s)" (cadr (assoc "REFPROC"
+                                   (org-collect-keywords
+                                    '("REFPROC")))))))
+
+
+(defun org-ref-get-ref-links ()
+  "Return a list of ref links in the buffer."
+  (org-element-map (org-element-parse-buffer) 'link
+    (lambda (lnk)
+      (when (assoc (org-element-property :type lnk) org-ref-ref-types)
+       lnk))))
+
+
+(defun org-ref-refproc-referenceables ()
+  "Return a list of referenceable items, grouped by type.
+This will be a list of (type label1 label2 ...).
+
+Not all styles of target are currently supported. This supports
+named tables, figures and src-blocks, headlines with a custom_id,
+and latex_environments with a latex label or name (these are all
+considered equations, which might be wrong for other
+environments)."
+  (let* ((parse-data (org-element-parse-buffer))
+        type el
+        ;; for each type, we specify what org-element to get the labels from.
+        (referencables (cl-loop for entry in org-ref-refproc-clever-prefixes
+                                do
+                                (setq type (car entry)
+                                      el (plist-get (cdr entry) :org-element))
+                                collect
+                                (cons type
+                                      (org-element-map parse-data el
+                                        (lambda (e)
+                                          (pcase el
+                                            ;; Headlines
+                                            ('headline
+                                             (cond
+                                              ;; There is a custom_id, we use it.
+                                              ((org-element-property :CUSTOM_ID e)
+                                               (org-element-property :CUSTOM_ID e))
+                                              ;; See if there is a target in the heading
+                                              ((string-match org-target-regexp
+                                                             (org-element-property :raw-value e))
+                                               (match-string 1 (org-element-property :raw-value e)))
+                                              ;; Check for a label link
+                                              ((string-match (concat "label:" org-ref-label-re)
+                                                             (org-element-property :raw-value e))
+                                               (match-string 1 (org-element-property :raw-value e)))))
+
+                                            ;;  Figures
+                                            ('link
+                                             (cond
+                                              ;; file link with a name property
+                                              ((and (org-file-image-p (org-element-property :path e))
+                                                    (org-element-property
+                                                     :name (org-element-property :parent e)))
+                                               (org-element-property
+                                                :name (org-element-property :parent e)))
+                                              ;; a label link in the caption
+                                              ((and  (org-file-image-p (org-element-property :path e))
+                                                     (org-element-property
+                                                      :caption (org-element-property :parent e))
+
+                                                     (string-match (concat "label:" org-ref-label-re)
+                                                                   (org-element-interpret-data
+                                                                    (org-element-property
+                                                                     :caption
+                                                                     (org-element-property :parent e)))))
+                                               (match-string 1 (org-element-interpret-data
+                                                                (org-element-property
+                                                                 :caption
+                                                                 (org-element-property :parent e)))))))
+
+                                            ;; Tables
+                                            ('table
+                                             (cond
+                                              ;; A name keyword is preferred
+                                              ((org-element-property :name e)
+                                               (org-element-property :name e))
+                                              ;; a label link in a caption also works
+                                              ((string-match (concat "label:" org-ref-label-re)
+                                                             (or (org-element-interpret-data
+                                                                  (org-element-property :caption e))
+                                                                 ""))
+                                               (match-string 1 (org-element-interpret-data
+                                                                (org-element-property :caption e))))))
+
+                                            ;; equations, proofs, and other latex environments
+                                            ('latex-environment
+                                             (when (or (and (eq type 'equation)
+                                                            (string-match "\\\\begin{equation}"
+                                                                          (org-element-property :value e)))
+                                                       (and (eq type 'equation)
+                                                            (string-match "\\\\begin{align}"
+                                                                          (org-element-property :value e)))
+                                                       (and (eq type 'proof) (string-match "\\\\begin{proof}"
+                                                                                           (org-element-property :value e))))
+
+                                               (cond
+                                                ;; Name keyword
+                                                ((org-element-property :name e)
+                                                 (org-element-property :name e))
+
+                                                ;; latex label in the value
+                                                ((string-match "\\\\label{\\(.*\\)}" (org-element-property :value e))
+                                                 (save-match-data
+                                                   (let ((pos 1)
+                                                         matches)
+                                                     (while (string-match "\\\\label{\\(.*\\)}" (org-element-property :value e) pos)
+                                                       (push (match-string 1 (org-element-property :value e)) matches)
+                                                       (setq pos (match-end 0)))
+                                                     matches))))))
+
+                                            ;; special blocks
+                                            ('special-block
+                                             (cond
+                                              ((and (eq type 'lemma)
+                                                    (org-element-property :name e)
+                                                    (string= "lemma" (org-element-property :type e)))
+                                               (org-element-property :name e))
+
+                                              ((and (eq type 'corollary)
+                                                    (org-element-property :name e)
+                                                    (string= "corollary" (org-element-property :type e)))
+                                               (org-element-property :name e))
+
+                                              ((and (eq type 'theorem)
+                                                    (org-element-property :name e)
+                                                    (string= "theorem" (org-element-property :type e)))
+                                               (org-element-property :name e))))
+
+
+                                            ;; Listings of code blocks
+                                            ('src-block
+                                             (when-let* ((name (org-element-property :name e)))
+                                               name)))))))))
+    ;; the align equation environment needs to be flattened
+    (cl-loop for type in referencables
+            collect (cons (car type) (org-ref--flatten-list (cdr type))))))
+
+
+(defun org-ref-refproc-get-type (label referenceables)
+  "Get the type of reference LABEL refers to.
+REFERENCEABLES comes from `org-ref-refproc-referenceables'.
+Returns a plist (:type type :label label :index index)"
+  (cl-loop for type in referenceables
+          if (member label type)
+          return (list :type (car  type) :label label :index (seq-position (cdr type) label 'equal))))
+
+
+(defun org-ref-refproc-group-sort-labels (lbls referenceables)
+  "Group and sort the labels in LBLS.
+REFERENCEABLES comes from `org-ref-refproc-referenceables'.
+Returns a list of (list (type l1 i1) (type l2, i2)...) where l1
+is label1, i1 is index1, etc.
+
+This data structure has all the references from a single link
+grouped by type. For some links there will only be one type, and
+one label, because that is all that is allowed, e.g. for ref,
+eqref, pageref, nameref and autoref.
+
+For the cref* links though you can have many labels, even to
+different kinds of things, and these are why we do the fancy
+grouping and sorting here."
+
+  (cl-loop for entry in
+          (seq-group-by (lambda (el)
+                          (plist-get el :type))
+                        (cl-loop for label in lbls collect
+                                 (org-ref-refproc-get-type label referenceables)))
+          collect
+          (sort (cdr entry) (lambda (a b)
+                              (< (plist-get a :index) (plist-get b :index))))))
+
+
+;; * Refproc - a reference processor for org-mode
+;;
+;; The strategy is to compute string replacements that are just org-syntax, then
+;; replace each link with the replacement.
+(defun org-ref-refproc-replacement (ref-link referenceables backend)
+  "Compute a replacement for REF-LINK (an org-element).
+REFERENCEABLES comes from `org-ref-refproc-referenceables'.
+BACKEND is the export backend."
+  (let* ((ref-type (org-element-property :type ref-link))
+        (labels (split-string (org-element-property :path ref-link) ","))
+        (post-blanks (org-element-property :post-blank ref-link))
+        (data (cl-loop for label in labels collect (org-ref-refproc-get-type label referenceables))))
+
+    (pcase ref-type
+      ;; These types only allow one label in the reference
+      ("ref"
+       (when (>  (length data) 1)
+        (error "A ref link can only have one label in it"))
+       (setq data (cl-first data))
+       (format "[[%s%s]]%s"
+              (if (eq 'section (plist-get data :type))
+                  "#"
+                "")
+              (plist-get data :label)
+              ;; add back post blank spaces.
+              (make-string post-blanks ? )))
+
+      ("eqref"
+       (when (>  (length data) 1)
+        (error "An eqref link can only have one label in it"))
+       (setq data (cl-first data))
+       (format (if (eq backend 'html)
+                  "[[%s]]%s"
+                "([[%s]])%s")
+              (plist-get data :label)
+              ;; add back post blank spaces.
+              (make-string post-blanks ? )))
+
+      ;; This one doesn't make much sense in unpaginated exports, and I don't
+      ;; have a way to get a page number anyway, so we make this a regular ref.
+      ("pageref"
+       (when (>  (length data) 1)
+        (error "A pageref link can only have one label in it"))
+       (setq data (cl-first data))
+       (format "[[%s%s]]%s"
+              (if (eq 'section (plist-get data :type))
+                  "#"
+                "")
+              (plist-get data :label)
+              ;; add back post blank spaces.
+              (make-string post-blanks ? )))
+
+      ;; this will use the heading name, or caption of the ref
+      ("nameref"
+       (when (>  (length data) 1)
+        (error "A nameref link can only have one label in it"))
+       (setq data (cl-first data))
+
+       ;; Basically I follow the link, and depending on the ref type get a
+       ;; "name" for it. Right now there is no error if there is not a heading
+       ;; or caption, you would just get an empty string.
+       (save-excursion
+        (goto-char (org-element-property :begin ref-link))
+        (search-forward ":")
+        (org-ref-ref-jump-to (org-element-property :path ref-link))
+        (pcase (plist-get data :type)
+          ('section
+           (org-previous-visible-heading 1)
+           (format "[[#%s][%s]]%s"
+                   (plist-get data :label)
+                   (cl-fifth (org-heading-components))
+                   (make-string post-blanks ? )))
+
+          ('table
+           (format "[[%s][%s]]%s"
+                   (plist-get data :label)
+                   (org-element-interpret-data (org-element-property :caption (org-element-context)))
+                   (make-string post-blanks ? )))
+
+          ('figure
+           (format "[[%s][%s]]%s"
+                   (plist-get data :label)
+                   (org-element-interpret-data (org-element-property :caption (org-element-context)))
+                   (make-string post-blanks ? )))
+
+          ('listing
+           (format "[[%s][%s]]%s"
+                   (plist-get data :label)
+                   (org-element-interpret-data (org-element-property :caption (org-element-context)))
+                   (make-string post-blanks ? )))
+          ;; does equation even make sense? is there ever a caption?
+          (_
+           (error "The nameref link is not implemented for %S" data)))))
+
+      ;; autoref is the first place we have to be clever.
+      ("autoref"
+       (when (>  (length data) 1)
+        (error "A pageref link can only have one label in it"))
+       (setq data (cl-first data))
+
+       (let* ((prefix-data (cdr (assoc (plist-get data :type) org-ref-refproc-clever-prefixes)))
+             (options (org-ref-refproc-get-options))
+             (prefix (plist-get prefix-data  (if (plist-get options :abbreviate)
+                                                 :abbrv
+                                               :full))))
+        (when (plist-get options :capitalize) (setq prefix (capitalize prefix)))
+        (format "%s [[%s%s]]%s"
+                prefix
+                (if (eq 'section (plist-get data :type))
+                    "#"
+                  "")
+                (plist-get data :label)
+                (make-string post-blanks ? ))))
+
+      ;; Now we get to the cref* links. These are complicated, so I will pass
+      ;; this out to dedicated functions. At this point, I have the ref-link,
+      ("cref"
+       (org-ref-refproc-cref-replacement ref-link referenceables nil))
+
+      ("Cref"
+       (org-ref-refproc-cref-replacement ref-link referenceables t))
+
+      (_
+       (error "%s links are not supported yet" ref-type)))))
+
+
+(defun org-ref-refproc-cref-replacement (ref-link referenceables capitalize)
+  "Calculate a replacement for a REF-LINK.
+
+REFERENCEABLES comes from `org-ref-refproc-referenceables'.
+
+If CAPITALIZE is non-nil, capitalize the first entry (this is for
+Cref) and is different than the capitalize option in #+refproc:
+which capitalizes each prefix."
+  (let* ((options (org-ref-refproc-get-options))
+        (labels (split-string (org-element-property :path ref-link) ","))
+        (post-blanks (org-element-property :post-blank ref-link))
+        (data (cl-loop for label in labels collect (org-ref-refproc-get-type label referenceables)))
+        (groups (seq-group-by (lambda (entry)
+                                (plist-get entry :type))
+                              data))
+        ;; this will be a list of sorted entries.
+        (sorted-groups (cl-loop for group in groups collect
+                                (sort (cdr group) (lambda (a b)
+                                                    (< (plist-get a :index) (plist-get b :index))))))
+        ;; temp vars
+        prefix
+        prefix-data
+        ;; Now we have to be clever on each sorted group. One day I should add compression to the groups, e.g. 1,2,3 - > 1 to 3
+        ;; For each group we need a prefix, and it may have to be a plural prefix.
+        ;; If there are two members of a group, they are joined by and
+        ;; if there are more than two members of a group, they are separated by commas with and at the end.
+        (replacements (cl-loop for collection in sorted-groups collect
+                               (pcase (length collection)
+                                 ;; One thing in the list
+                                 (1
+                                  (setq collection (cl-first collection)
+                                        prefix-data (cdr (assoc (plist-get collection :type) org-ref-refproc-clever-prefixes))
+                                        prefix (plist-get  prefix-data (if (plist-get options :abbreviate)
+                                                                           :abbrv
+                                                                         :full)))
+                                  (when (plist-get options :capitalize)
+                                    (setq prefix (capitalize prefix)))
+                                  (format "%s %s"
+                                          ;; prefix
+                                          prefix
+                                          (concat
+                                           (cond
+                                            ((eq 'section (plist-get collection :type))
+                                             (format "[[#%s]]" (plist-get collection :label)))
+                                            ((eq 'equation (plist-get collection :type))
+                                             (format "\\ref{%s}" (plist-get collection :label)))
+                                            (t
+                                             (format "[[%s]]" (plist-get collection :label)))))))
+                                 (2
+                                  ;; the prefix can be found from the first label, but we have to make it plural.
+                                  (setq prefix-data (cdr (assoc (plist-get (cl-first collection) :type)
+                                                                org-ref-refproc-clever-prefixes))
+                                        prefix (plist-get  prefix-data (if (plist-get options :abbreviate)
+                                                                           :abbrv
+                                                                         :full)))
+                                  (when (plist-get options :capitalize)
+                                    (setq prefix (capitalize prefix)))
+
+                                  ;; Make it plural (substring "fig." -1)
+                                  (setq prefix (if (string= "." (substring prefix -1))
+                                                   (concat (substring prefix 0 -1) "s.")
+                                                 (concat prefix "s")))
+
+                                  (format "%s [[%s]] and [[%s]]"
+                                          prefix
+                                          (concat
+                                           (if (eq 'section (plist-get (cl-first collection) :type)) "#" "")
+                                           (plist-get (cl-first collection) :label))
+                                          (concat
+                                           (if (eq 'section (plist-get (cl-second collection) :type)) "#" "")
+                                           (plist-get (cl-second collection) :label))))
+
+                                 (_
+                                  ;; the prefix can be found from the first label, but we have to make it plural.
+                                  (setq prefix-data (cdr (assoc (plist-get (cl-first collection) :type)
+                                                                org-ref-refproc-clever-prefixes))
+                                        prefix (plist-get  prefix-data (if (plist-get options :abbreviate)
+                                                                           :abbrv
+                                                                         :full)))
+                                  (when (plist-get options :capitalize)
+                                    (setq prefix (capitalize prefix)))
+
+                                  ;; Make it plural. If the prefix ends in .
+                                  ;; (i.e. it is abbreviated) we remove it and
+                                  ;; add s.
+                                  (setq prefix (if (string= "." (substring prefix -1))
+                                                   (concat (substring prefix 0 -1) "s.")
+                                                 (concat prefix "s")))
+
+                                  ;; now get
+                                  (format "%s %s and [[%s]]"
+                                          prefix
+                                          (string-join
+                                           (cl-loop for entry in (butlast collection) collect
+                                                    (format "[[%s]]"
+                                                            (concat
+                                                             (if (eq 'section (plist-get entry :type)) "#" "")
+                                                             (plist-get entry :label))))
+                                           ", ")
+                                          ;; the last one
+                                          (concat
+                                           (if (eq 'section (plist-get (car (last collection)) :type)) "#" "")
+                                           (plist-get (car (last collection)) :label))))))))
+
+
+    (when capitalize (setf (car replacements) (concat (capitalize (substring (car replacements) 0 1)) (substring (car replacements) 1))))
+
+    ;; Finally, join them together with commas, and add post-blank spaces.
+    (concat
+     (pcase (length replacements)
+       (1
+       (cl-first replacements))
+       (2
+       (concat (cl-first replacements) " and " (cl-second replacements)))
+       (_
+       (concat (string-join (butlast replacements) ", ") " and " (car (last replacements)))))
+
+     (make-string post-blanks ? ))))
+
+
+(defun org-ref-refproc (&optional backend)
+  "Process the buffer replacing all ref links with org syntax.
+BACKEND is the
+Meant to be used in an `org-export-before-parsing-hook' on a copy
+of the buffer."
+  (let ((ref-links (org-ref-get-ref-links))
+       (referenceables (org-ref-refproc-referenceables)))
+
+    (cl-loop for ref in (reverse ref-links) do
+            (cl--set-buffer-substring (org-element-property :begin ref)
+                                      (org-element-property :end ref)
+                                      (org-ref-refproc-replacement ref referenceables backend)))))
+
+(provide 'org-ref-refproc)
+
+;;; org-ref-refproc.el ends here
diff --git a/elpa/org-ref-20251206.1422/org-ref-sci-id.el b/elpa/org-ref-20251206.1422/org-ref-sci-id.el
new file mode 100644 (file)
index 0000000..30b3cdd
--- /dev/null
@@ -0,0 +1,54 @@
+;;; org-ref-sci-id.el --- org-mode links for scientific IDs  -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2015-2024  John Kitchin
+
+;; Author: John Kitchin <jkitchin@andrew.cmu.edu>
+;; Keywords:
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; New org-mode links for scientific IDs like orcid (http://orcid.org) and researcherid (http://www.researcherid.com)
+;; orcid:0000-0003-2625-9232
+;; researcherid:A-2363-2010
+
+;;; Code:
+
+(require 'org)
+(require 'org-ref-utils)
+
+(org-link-set-parameters "orcid"
+                        :follow (lambda
+                                  (link-string)
+                                  (browse-url
+                                   (format "http://orcid.org/%s" link-string)))
+                        :export (lambda (keyword desc format)
+                                  (cond
+                                   ((eq format 'html)
+                                    (format "<a href=\"http://orcid.org/%s\">orcid:%s</a>" keyword (or desc keyword))))))
+
+(org-link-set-parameters "researcherid"
+                        :follow (lambda
+                                  (link-string)
+                                  (browse-url
+                                   (format "http://www.researcherid.com/rid/%s" link-string)))
+                        :export (lambda (keyword desc format)
+                                  (cond
+                                   ((eq format 'html)
+                                    (format "<a href=\"http://www.researcherid.com/rid/%s\">ResearcherID:%s</a>"
+                                            keyword (or desc keyword))))))
+
+(provide 'org-ref-sci-id)
+;;; org-ref-sci-id.el ends here
diff --git a/elpa/org-ref-20251206.1422/org-ref-scifinder.el b/elpa/org-ref-20251206.1422/org-ref-scifinder.el
new file mode 100644 (file)
index 0000000..68b6617
--- /dev/null
@@ -0,0 +1,35 @@
+;;; org-ref-scifinder.el --- Emacs interface to SciFinder -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2015-2024  John Kitchin
+
+;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
+;; Keywords:
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;; Hopefully this eventually integrates the Scifinder API into Emacs. For now,
+;; there is just one function that opens Scifinder for you.
+
+;;; Code:
+
+;;;###autoload
+(defun scifinder ()
+  "Open https://scifinder.cas.org/scifinder/view/scifinder/scifinderExplore.jsf in a browser."
+  (interactive)
+  (browse-url "https://scifinder.cas.org/scifinder/view/scifinder/scifinderExplore.jsf"))
+
+(provide 'org-ref-scifinder)
+
+;;; org-ref-scifinder.el ends here
diff --git a/elpa/org-ref-20251206.1422/org-ref-scopus.el b/elpa/org-ref-20251206.1422/org-ref-scopus.el
new file mode 100644 (file)
index 0000000..0efc048
--- /dev/null
@@ -0,0 +1,239 @@
+;;; org-ref-scopus.el --- Emacs-lisp interface to the Scopus API  -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2015-2024  John Kitchin
+
+;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
+;; Keywords:
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;  See http://dev.elsevier.com/index.html for more information about the Scopus API
+;;
+;; New org-links:
+;; eid:2-s2.0-72649092395 with a transient menu
+;; [[scopus-search:alloy Au segregation]]
+;; [[scopus-advanced-search:au-id(24176978500)]]
+
+;;; Code:
+
+(require 'org)
+(require 'transient)
+(require 'xml)
+(require 'org-ref-utils)
+
+(defvar url-request-method)
+(defvar url-mime-accept-string)
+(defvar url-http-end-of-headers)
+(defvar url-request-extra-headers)
+
+(defvar *scopus-api-key* nil
+  "Your Scopus API key.
+You need to set this in your init files.  Get a key here:
+http://dev.elsevier.com/myapikey.html.")
+
+
+;; (defun scopus-doi-to-xml (doi)
+;;   "Return a parsed xml from the Scopus article retrieval api for DOI.
+;; This does not always seem to work for the most recent DOIs."
+;;   (let* ((url-request-method "GET")
+;;      (url-request-extra-headers  (list (cons "X-ELS-APIKey" *scopus-api-key*)))
+;;      (url (format  "http://api.elsevier.com/content/article/doi/%s" doi))
+;;      (xml))
+;;     (setq xml
+;;       (with-current-buffer  (url-retrieve-synchronously url)
+;;         (xml-parse-region url-http-end-of-headers (point-max))))
+;;     (if (eq 'service-error (caar xml))
+;;     (progn (message-box "%s\n%s\n%s" doi url xml)
+;;            nil)
+;;       xml)))
+
+(defun scopus-doi-to-eid (doi)
+  "Get a Scopus eid from a DOI.
+Requires `*scopus-api-key*' to be defined."
+  (unless *scopus-api-key* (error "You must define `*scopus-api-key*'"))
+  (let* ((url-request-method "GET")
+         (url-mime-accept-string "application/xml")
+         (url-request-extra-headers  (list (cons "X-ELS-APIKey" *scopus-api-key*)
+                                           '("field" . "eid")))
+         (url (format  "http://api.elsevier.com/content/search/scopus?query=doi(%s)" doi))
+         (xml (with-current-buffer  (url-retrieve-synchronously url)
+                (xml-parse-region url-http-end-of-headers (point-max))))
+         (results (car xml))
+         (entry (car (xml-get-children results 'entry))))
+    (car (xml-node-children (car (xml-get-children entry 'eid))))))
+
+
+;;;###autoload
+(defun scopus-related-by-keyword-url (doi)
+  "Return a Scopus url to articles related by keyword for DOI."
+  (interactive)
+  (unless *scopus-api-key* (error "You must define `*scopus-api-key*'"))
+  (let ((eid (scopus-doi-to-eid doi)))
+    (when eid (format "http://www.scopus.com/search/submit/mlt.url?eid=%s&src=s&all=true&origin=recordpage&method=key&zone=relatedDocuments" eid))))
+
+
+;;;###autoload
+(defun scopus-related-by-author-url (doi)
+  "Return a Scopus url to articles related by author for DOI."
+  (interactive)
+  (unless *scopus-api-key* (error "You must define `*scopus-api-key*'"))
+  (let ((eid (scopus-doi-to-eid doi)))
+    (when eid (format "http://www.scopus.com/search/submit/mlt.url?eid=%s&src=s&all=true&origin=recordpage&method=aut&zone=relatedDocuments" eid))))
+
+
+;;;###autoload
+(defun scopus-related-by-references-url (doi)
+  "Return a Scopus url to articles related by references for DOI."
+  (interactive)
+  (unless *scopus-api-key* (error "You must define `*scopus-api-key*'"))
+  (let ((eid (scopus-doi-to-eid doi)))
+    (when eid (format "http://www.scopus.com/search/submit/mlt.url?eid=%s&src=s&all=true&origin=recordpage&method=ref&zone=relatedDocuments" eid))))
+
+
+(defun scopus-citing-url (doi)
+  "Return a Scopus url to articles citing DOI."
+  (format "http://www.scopus.com/results/citedbyresults.url?sort=plf-f&cite=%s&src=s&imp=t&sot=cite&sdt=a&sl=0&origin=recordpage" (scopus-doi-to-eid doi)))
+
+
+;;;###autoload
+(defun scopus-open-eid (eid)
+  "Open article with EID in browser."
+  (interactive "sEID: ")
+  (browse-url (format "http://www.scopus.com/record/display.url?eid=%s&origin=resultslist" eid)))
+
+
+(defun scopus ()
+  "Open http://scopus.com is a browser."
+  (browse-url "http://www.scopus.com"))
+
+
+;;;###autoload
+(defun scopus-basic-search (query)
+  "Open QUERY as a basic title-abstract-keyword search at scopus.com."
+  (interactive "sQuery: ")
+  (browse-url
+   (format
+    "http://www.scopus.com/results/results.url?sort=plf-f&src=s&sot=b&sdt=b&sl=%s&s=TITLE-ABS-KEY%%28%s%%29&origin=searchbasic"
+    (length (url-unhex-string (concat "TITLE-ABS-KEY%28" (url-hexify-string query) "%29")))
+    (url-hexify-string query))))
+
+
+;;;###autoload
+(defun scopus-advanced-search (query)
+  "Open QUERY as an advanced search at scopus.com."
+  (interactive "sQuery: ")
+  (browse-url
+   (format
+    "http://www.scopus.com/results/results.url?sort=plf-f&src=s&sot=a&sdt=a&sl=%s&s=%s&origin=searchadvanced"
+    (length query)
+    (url-hexify-string query))))
+
+
+;;; Org-mode EID link and an action menu
+;; These functions use a global var to track the current EID.
+(defvar org-ref-scopus--current-eid nil
+  "Global variable to pass an EID from an `org-mode' link to a transient function.")
+
+(define-obsolete-variable-alias '*hydra-eid* 'org-ref-scopus--current-eid "3.1")
+
+(transient-define-prefix org-ref-scopus-menu ()
+  "Scopus actions for the current EID."
+  [["Open"
+    ("o" "Open in Scopus" (lambda () (interactive) (scopus-open-eid org-ref-scopus--current-eid)))]
+   ["Related"
+    ("a" "Related by author" (lambda () (interactive)
+           (browse-url (format
+                        "http://www.scopus.com/search/submit/mlt.url?eid=%s&src=s&all=true&origin=recordpage&method=aut&zone=relatedDocuments"
+                        org-ref-scopus--current-eid))))
+    ("k" "Related by keyword" (lambda () (interactive)
+           (browse-url (format
+                        "http://www.scopus.com/search/submit/mlt.url?eid=%s&src=s&all=true&origin=recordpage&method=key&zone=relatedDocuments"
+                        org-ref-scopus--current-eid))))
+    ("r" "Related by references" (lambda () (interactive)
+           (browse-url (format
+                        "http://www.scopus.com/search/submit/mlt.url?eid=%s&src=s&all=true&origin=recordpage&method=ref&zone=relatedDocuments"
+                        org-ref-scopus--current-eid))))
+    ("c" "Citing articles" (lambda () (interactive)
+           (browse-url (format
+                        "http://www.scopus.com/results/citedbyresults.url?sort=plf-f&cite=%s&src=s&imp=t&sot=cite&sdt=a&sl=0&origin=recordpage"
+                        org-ref-scopus--current-eid))))]
+   ["Quit"
+    ("q" "Quit" transient-quit-one)]])
+
+(define-obsolete-function-alias 'scopus-hydra/body
+  #'org-ref-scopus-menu "3.1")
+
+
+(org-link-set-parameters "eid"
+                        :follow (lambda (eid)
+                                  "Opens the transient menu."
+                                  (setq org-ref-scopus--current-eid eid)
+                                  (org-ref-scopus-menu))
+                        :export (lambda (keyword desc format)
+                                  (cond
+                                   ((eq format 'html)
+                                    (format "<a href=\" http://www.scopus.com/record/display.url?eid=%s&origin=resultslist\">%s</a>" keyword (or desc keyword)))
+                                   ((eq format 'latex)
+                                    (format "\\href{http://www.scopus.com/record/display.url?eid=%s&origin=resultslist}{%s}"
+                                            keyword (or desc keyword))))))
+
+
+(org-link-set-parameters "scopus-search"
+                        :follow (lambda (query)
+                                  (scopus-basic-search query))
+                        :export (lambda (query desc format)
+                                  (let ((url (format
+                                              "http://www.scopus.com/results/results.url?sort=plf-f&src=s&sot=b&sdt=b&sl=%s&s=TITLE-ABS-KEY%%28%s%%29&origin=searchbasic"
+                                              (length (url-unhex-string (concat "TITLE-ABS-KEY%28" (url-hexify-string query) "%29")))
+                                              (url-hexify-string query))))
+                                    (cond
+                                     ((eq format 'html)
+                                      (format "<a href=\"%s\">%s</a>" url (or desc query)))
+                                     ((eq format 'latex)
+                                      (format "\\href{%s}{%s}" url (or desc query)))))))
+
+(org-link-set-parameters "scopus-advanced-search"
+                        :follow (lambda (query)
+                                  (scopus-advanced-search query))
+                        :export (lambda (query desc format)
+                                  (let ((url (format
+                                              "http://www.scopus.com/results/results.url?sort=plf-f&src=s&sot=a&sdt=a&sl=%s&s=%s&origin=searchadvanced"
+                                              (length (url-hexify-string query))
+                                              (url-hexify-string query))))
+                                    (cond
+                                     ((eq format 'html)
+                                      (format "<a href=\"%s\">%s</a>" url (or desc query)))
+                                     ((eq format 'latex)
+                                      (format "\\href{%s}{%s}" url (or desc query)))))))
+
+(org-link-set-parameters "scopusid"
+                        :follow (lambda
+                                  (link-string)
+                                  (browse-url
+                                   (format
+                                    "http://www.scopus.com/authid/detail.url?origin=AuthorProfile&authorId=%s"
+                                    link-string)))
+                        :export (lambda (keyword desc format)
+                                  (cond
+                                   ((eq format 'latex)
+                                    (format "\\href{http://www.scopus.com/authid/detail.url?origin=AuthorProfile&authorId=%s}{%s}"
+                                            keyword (or desc (concat "scopusid:" keyword))))
+                                   ((eq format 'html)
+                                    (format "<a href=\"http://www.scopus.com/authid/detail.url?origin=AuthorProfile&authorId=%s\">%s</a>"
+                                            keyword (or desc (concat "scopusid:" keyword)))))))
+
+
+(provide 'org-ref-scopus)
+;;; org-ref-scopus.el ends here
diff --git a/elpa/org-ref-20251206.1422/org-ref-url-utils.el b/elpa/org-ref-20251206.1422/org-ref-url-utils.el
new file mode 100644 (file)
index 0000000..f71cd25
--- /dev/null
@@ -0,0 +1,310 @@
+;;; org-ref-url-utils.el --- Utility functions to scrape DOIs from urls  -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2015-2024  John Kitchin
+
+;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
+;; Keywords:
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Drag a webpage onto a bibtex file to insert a bibtex entry.
+;;
+;; [2021-08-29 Sun] I have not found drag-and-drop reliable or convenient. I
+;; don't recommend using this, but I am also not deleting it (yet).
+
+;; This works by scraping DOIs from the content at the URL using patterns in
+;; `org-ref-doi-regexps'. If one DOI is found, it is added as an entry. If
+;; multiple DOIs are found, you will get a selection buffer to choose what
+;; you want to add. You can add new patterns to `org-ref-doi-regexps'.
+
+;; You can press Control to "debug" a URL, which will open a buffer of the
+;; content with the current DOI patterns highlighted. If you want to get all the
+;; DOIs at a URL, you can press Meta during the drag-n-drop.
+
+;; You can also insert formatted bibtex entries using the
+;; `org-ref-url-html-to-bibtex' command, which converts a web page to
+;; bibtex or biblatex entry using URL. The org-cliplink package can
+;; help cleanup HTML code. Installing it is recommended.
+
+;;; Code:
+(defvar org-ref-bibliography-entry-format)
+(defvar org-ref-cite-types)
+(defvar org-cliplink-escape-alist)
+
+(declare-function org-ref-get-bibtex-key-and-file "org-ref-core")
+(declare-function org-ref-find-bibliography "org-ref-core")
+(declare-function org-ref-clean-bibtex-entry "org-ref-bibtex")
+
+(declare-function dnd-handle-one-url "dnd")
+(declare-function dnd--unescape-uri "dnd")
+
+(require 'doi-utils)
+(require 'org-ref-utils)
+(eval-when-compile
+  (require 'cl-lib))
+
+
+(defgroup org-ref-url nil
+  "Customization group for org-ref-url-utils"
+  :tag "Org Ref URL"
+  :group 'org-ref-url-utils)
+
+
+(defcustom org-ref-doi-regexps
+  '("scheme=\"doi\" content=\"\\([^\"]*\\)\""
+    "citation_doi\" content=\"\\([^\"]*\\)\""
+    "data-doi=\"\\([^\"]*\\)\""
+    "content=\"\\([^\"]*\\)\" name=\"citation_doi"
+    "objectDOI\" : \"\\([^\"]*\\)\""
+    "doi = '\\([^']*\\)'"
+    "\"http://dx.doi.org/\\([^\"]*\\)\""
+    "/doi/\\([^\"]*\\)\">"
+    "doi/full/\\(.*\\)&"
+    "doi=\\([^&]*\\)&amp")
+  "List of regexps to match a DOI.
+The doi should be in group 1 so that (match-string 1) contains
+the DOI."
+  :type '(repeat regexp)
+  :group 'org-ref-url-utils)
+
+
+(defvar org-ref-url-title-re
+  "<title[^>]*>\\(.*?\\)</title>"
+  "Regular expression for matching title.")
+
+
+(defvar org-ref-url-author-re
+  "<meta name=\"author\" content=\"\\(.+\\)\"\s?/?>"
+  "Regular expression for matching author.")
+
+
+(defvar org-ref-url-date-re
+  "<[a-z][^>]+ class=\\([^>]*date[^>]*\\)>\\(.*?\\)</[a-z][^>]+>"
+  "Regular expression for matching date.")
+
+
+(defvar org-ref-url-bibtex-template
+  "@misc{key,
+  title        = {${:title}},
+  author       = {${:author}},
+  howpublished = {${:url}},
+  year         = {${:year}},
+  note         = {Online; accessed ${:urldate}}
+}"
+  "BibTeX entry template for online sources.")
+
+(defvar org-ref-url-biblatex-template
+  "@online{key,
+title   = {${:title}},
+author  = {${:author}},
+url     = {${:url}}
+year    = {${:year}},
+urldate = {Online; accessed ${:urldate}}
+}"
+  "Biblatex entry template for online sources.")
+
+
+;;* Scrape DOIs from a URL
+
+(defun org-ref-url-scrape-dois (url)
+  "Scrape all dois from a URL matching a pattern in `org-ref-doi-regexps'.
+Returns a list of collected DOIs in the order found."
+  (let ((dois '()))
+    (with-current-buffer (url-retrieve-synchronously url)
+      (cl-loop for doi-pattern in org-ref-doi-regexps
+              do
+              (goto-char (point-min))
+              (while (re-search-forward doi-pattern nil t)
+                (cl-pushnew (match-string 1) dois :test #'equal)))
+      (reverse dois))))
+
+
+(defun org-ref-url-dnd-protocol (url action)
+  "Protocol function for use in `dnd-protocol-alist'.
+We scrape DOIs from the url first. If there is one, we add it. If
+there is more than one, we offer a completion buffer of selections. If
+no DOI is found, we create a misc entry, with a prompt for a key."
+  ;; make sure we are on a bib-file
+  (if (and (buffer-file-name)
+          (org-ref--file-ext-p (buffer-file-name) "bib"))
+      (let ((dois (org-ref-url-scrape-dois url)))
+       (cond
+        ;; One doi found. Assume it is what we want.
+        ((= 1 (length dois))
+         (doi-utils-add-bibtex-entry-from-doi
+          (car dois)
+          (buffer-file-name))
+         action)
+        ;; Multiple DOIs found
+        ((> (length dois) 1)
+         (let ((doi (completing-read "Select a DOI: " dois)))
+           (doi-utils-add-bibtex-entry-from-doi doi (buffer-file-name))))
+        ;; No DOIs found, add a misc entry.
+        (t
+          (org-ref-url-html-to-bibtex (buffer-file-name) url)
+         action)))
+    ;; pass back to dnd. Copied from `org-download-dnd'. Apparently
+    ;; returning nil does not do this.
+    (let ((dnd-protocol-alist
+          (rassq-delete-all
+           'org-ref-url-dnd-protocol
+           (copy-alist dnd-protocol-alist))))
+      (dnd-handle-one-url nil action url))))
+
+
+(add-to-list 'dnd-protocol-alist '("^https?" . org-ref-url-dnd-protocol))
+
+;;* Enable a DOI to be dragged onto a bibtex buffer
+(defun org-ref-doi-dnd-protocol (doi action)
+  "Protocol for when a doi is dragged onto a bibtex file.
+A doi will be either doi:10.xxx  or 10.xxx."
+  (if (and (buffer-file-name)
+          (org-ref--file-ext-p (buffer-file-name) "bib"))
+      (let ((doi (dnd--unescape-uri doi)))
+       ;; Get the actual doi now
+       (string-match "\\(?:DOI\\|doi\\)?:? *\\(10.*\\)" doi)
+       (setq doi (match-string 1 doi))
+       (when doi
+         (doi-add-bibtex-entry doi (buffer-file-name))
+         (save-buffer)
+         action))
+    ;; not on a bib file
+    (let ((dnd-protocol-alist
+          (rassq-delete-all
+           'org-ref-url-dnd-protocol
+           (copy-alist dnd-protocol-alist))))
+      (dnd-handle-one-url nil action doi))))
+
+(add-to-list 'dnd-protocol-alist '("^doi" . org-ref-doi-dnd-protocol))
+(add-to-list 'dnd-protocol-alist '("^10" . org-ref-doi-dnd-protocol))
+
+
+;;* Debugging DOIs from a URL
+
+;; You can use this to see if there are any DOIs in a URL, and to use re-builder
+;; to add new patterns to `org-ref-doi-regexps'.
+;;;###autoload
+(defun org-ref-url-debug-url (url)
+  "Open a buffer to URL with all doi patterns highlighted."
+  (interactive "sURL: ")
+  (switch-to-buffer
+   (url-retrieve-synchronously url))
+  (highlight-regexp
+   (mapconcat 'identity org-ref-doi-regexps "\\|")))
+
+
+;;* HTML to BibTeX functions
+
+(defun org-ref-url-html-replace (string)
+  "Replace HTML entities in STRING with their unicode equivalent."
+  (let (result
+       (case-fold-search nil))
+    (with-temp-buffer
+      (insert string)
+      (mapc (lambda (char)
+             (goto-char (point-min))
+             (while (re-search-forward (car char) nil t)
+               (replace-match (cdr char))))
+           org-cliplink-escape-alist)
+      (setq result (buffer-substring (point-min) (point-max))))
+    result))
+
+
+(defun org-ref-url-add-nil (list)
+  "Add nil to all missing keys in LIST."
+  (let (newlist)
+    (mapc (lambda (key)
+           (unless (alist-get key list)
+             (push (cons key "nil") newlist)))
+         (list :title :author :url :urldate :year))
+    (append list newlist)))
+
+
+(defun org-ref-url-html-read (url)
+  "Read URL content and return fields.
+Fields include author, title, url, urldate, and year."
+  ;; Start with fields we already know
+  (let ((fields `((:url . ,url)
+                 (:urldate . ,(format-time-string "%d %B %Y")))))
+    (with-current-buffer
+       (url-retrieve-synchronously url t t)
+
+      ;; find pubdate
+      (goto-char (point-min))
+      (when (re-search-forward org-ref-url-date-re nil t)
+       (let ((string (match-string 2)))
+         (when (string-match "\\([0-9]\\{4\\}\\)" string)
+           (push (cons :year (match-string 1 string)) fields))))
+
+      ;; find author
+      (goto-char (point-min))
+      (let ((author (if (re-search-forward org-ref-url-author-re nil t)
+                        (match-string 1)
+                      "Unknown")))
+        (push (cons :author author) fields))
+
+      ;; find title
+      (goto-char (point-min))
+      (when (re-search-forward org-ref-url-title-re nil t)
+       (push (cons :title
+                   (string-trim (decode-coding-string (match-string 1) 'utf-8)))
+             fields)))
+
+    ;; Finally add nil value to missing fields
+    (org-ref-url-add-nil fields)))
+
+
+;;;###autoload
+(defun org-ref-url-html-to-bibtex (bibfile &optional url)
+  "Convert URL to a bibtex or biblatex entry in BIBFILE.
+If URL is the first in the kill ring, use it. Otherwise, prompt for
+one in the minibuffer."
+  (interactive (if (member (buffer-file-name) (org-ref-find-bibliography))
+                  (list (buffer-file-name))
+                (list (completing-read "Bibtex file: " (org-ref-find-bibliography)))))
+  (let ((url (if url url
+              (if (org-ref--string-match "^http" (current-kill 0 'do-not-move))
+                  (format "%s" (current-kill 0 'do-not-move))
+                (read-from-minibuffer "URL: ")))))
+    (with-current-buffer
+       (find-file-noselect bibfile)
+      ;; Maybe check dialect if set as local variable
+      (let* ((dialect bibtex-dialect)
+            (alist (org-ref-url-html-read url))
+            (entry (org-ref--format-template
+                    ;; Check dialect and format entry accordingly
+                    (if (eq dialect 'biblatex)
+                        org-ref-url-biblatex-template
+                      org-ref-url-bibtex-template)
+                    alist)))
+       (goto-char (point-max))
+       ;; Place new entry one line after the last entry. Sometimes we are in a
+       ;; new file though, in which case we don't want to do this.
+       (unless (bobp)
+         (while (not (looking-back "^}\n" 2))
+           (delete-char -1)))
+       (insert "\n")
+       (insert (if (require 'org-cliplink nil 'noerror)
+                   ;; Sanitize values by replacing html entities
+                   (org-ref-url-html-replace entry)
+                 entry))
+       (insert "\n")
+       (bibtex-beginning-of-entry)
+       (org-ref-clean-bibtex-entry)
+       (save-buffer)))))
+
+(provide 'org-ref-url-utils)
+;;; org-ref-url-utils.el ends here
diff --git a/elpa/org-ref-20251206.1422/org-ref-utils.el b/elpa/org-ref-20251206.1422/org-ref-utils.el
new file mode 100644 (file)
index 0000000..bf87d4e
--- /dev/null
@@ -0,0 +1,1479 @@
+;;; org-ref-utils.el --- Utility functions for org-ref  -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2016-2024  John Kitchin
+
+;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
+;; Keywords:
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;
+
+(eval-when-compile (require 'cl-lib))
+
+(require 'org)
+(eval-and-compile (require 'org-macs))
+(require 'subr-x) ; for string-trim and string-blank-p
+
+
+(defvar org-ref-cite-types)
+(defvar pdftotext-executable)
+
+(declare-function org-ref-get-bibtex-key-and-file "org-ref-core.el")
+(declare-function org-ref-find-bibliography "org-ref-core.el")
+(declare-function org-ref-bib-citation "org-ref-core.el")
+(declare-function org-ref-get-bibtex-key-under-cursor "org-ref-core.el")
+(declare-function org-ref-parse-cite-path "org-ref-citation-links.el")
+(declare-function org-ref-get-labels "org-ref-ref-links.el")
+
+;; org-element functions (org.el)
+(declare-function org-element-parse-buffer "org-element")
+(declare-function org-element-map "org-element")
+(declare-function org-element-property "org-element")
+(declare-function org-mark-ring-push "org")
+
+;; bibtex functions
+(declare-function bibtex-kill-entry "bibtex")
+(declare-function bibtex-validate "bibtex")
+(declare-function bibtex-global-key-alist "bibtex")
+(declare-function bibtex-autokey-get-field "bibtex")
+(declare-function bibtex-search-entry "bibtex")
+(declare-function bibtex-set-dialect "bibtex")
+(declare-function bibtex-copy-entry-as-kill "bibtex")
+(declare-function parsebib-find-bibtex-dialect "parsebib")
+
+;; bibtex-completion functions
+(declare-function bibtex-completion-get-entry "bibtex-completion")
+(declare-function bibtex-completion-get-value "bibtex-completion")
+(declare-function bibtex-completion-show-entry "bibtex-completion")
+(declare-function bibtex-completion-edit-notes "bibtex-completion")
+(declare-function bibtex-completion-find-pdf "bibtex-completion")
+(declare-function bibtex-completion-find-pdf-in-library "bibtex-completion")
+(declare-function bibtex-completion-apa-format-reference "bibtex-completion")
+
+;; doi-utils functions
+(declare-function doi-utils-ads "doi-utils")
+(declare-function doi-utils-wos "doi-utils")
+(declare-function doi-utils-wos-citing "doi-utils")
+(declare-function doi-utils-wos-related "doi-utils")
+(declare-function doi-utils-pubmed "doi-utils")
+(declare-function doi-utils-crossref "doi-utils")
+(declare-function doi-utils-get-bibtex-entry-pdf "doi-utils")
+
+;; other functions
+(declare-function biblio-lookup "biblio")
+(declare-function message-goto-body "message")
+(declare-function message-goto-subject "message")
+(declare-function org-ref-bibtex-get-file-move-func "org-ref-bibtex")
+
+;;; Code:
+
+;;** Dash.el replacement utilities
+
+;; These functions replace dash.el dependencies with native Emacs equivalents.
+;; They use seq.el (Emacs 25+) and cl-lib (built-in).
+
+(defun org-ref--flatten-list (list)
+  "Flatten nested LIST structure.
+Compatible replacement for dash's `-flatten'.
+For Emacs 27+, consider using `flatten-tree' instead."
+  (cond ((null list) nil)
+        ((listp list)
+         (append (org-ref--flatten-list (car list))
+                 (org-ref--flatten-list (cdr list))))
+        (t (list list))))
+
+(defun org-ref--split-at (n list)
+  "Split LIST at position N, returning (FIRST REST).
+Compatible replacement for dash's `-split-at'."
+  (list (seq-take list n) (seq-drop list n)))
+
+(defun org-ref--remove-at-indices (indices list)
+  "Remove elements at INDICES from LIST.
+Compatible replacement for dash's `-remove-at-indices'."
+  (cl-loop for item in list
+           for i from 0
+           unless (member i indices)
+           collect item))
+
+(defun org-ref--remove-at (index list)
+  "Remove element at INDEX from LIST.
+Compatible replacement for dash's `-remove-at'."
+  (append (seq-take list index)
+          (seq-drop list (1+ index))))
+
+(defun org-ref--insert-at (index element list)
+  "Insert ELEMENT at INDEX in LIST.
+Compatible replacement for dash's `-insert-at'."
+  (append (seq-take list index)
+          (list element)
+          (seq-drop list index)))
+
+;;** S.el replacement utilities
+
+;; These functions replace s.el dependencies with native Emacs equivalents.
+;; Most use built-in functions, some require subr-x (Emacs 24.4+).
+
+(defun org-ref--format-template (template alist)
+  "Format TEMPLATE string replacing ${key} with values from ALIST.
+ALIST should be an association list of (KEY . VALUE) pairs where
+KEY is a string. If a key in the template is not found in ALIST,
+it is replaced with an empty string.
+Compatible replacement for s-format with ${var} template syntax."
+  (let ((result template))
+    (dolist (pair alist)
+      (let* ((key (car pair))
+             (value (cdr pair))
+             (pattern (format "${%s}" key))
+             (replacement (if value (format "%s" value) "")))
+        (setq result (string-replace pattern replacement result))))
+    result))
+
+(defun org-ref--string-match (regexp string &optional start)
+  "Match REGEXP against STRING and return list of match groups.
+Returns a list where the first element is the entire match,
+and subsequent elements are the captured groups (subexpressions).
+Returns nil if no match is found.
+Optional START specifies where to start searching in STRING.
+Compatible replacement for s-match."
+  (when (string-match regexp string start)
+    (let ((result nil)
+          (i 0))
+      (while (match-beginning i)
+        (push (match-string i string) result)
+        (setq i (1+ i)))
+      (nreverse result))))
+
+;;** F.el replacement utilities
+
+;; These functions replace f.el dependencies with native Emacs equivalents.
+;; Uses file-name-extension, directory-files, and file-name-concat (Emacs 28+).
+
+(defun org-ref--file-ext-p (file ext)
+  "Return t if FILE has extension EXT.
+EXT should not include the dot and comparison is case-insensitive.
+Compatible replacement for f-ext?."
+  (when file
+    (string= (downcase (or (file-name-extension file) ""))
+             (downcase ext))))
+
+(defun org-ref--directory-files (directory predicate)
+  "Return files in DIRECTORY matching PREDICATE.
+PREDICATE is a function that takes a filename and returns non-nil
+if the file should be included. Excludes . and .. entries.
+Compatible replacement for f-entries."
+  (when (file-directory-p directory)
+    (seq-filter predicate
+                (directory-files directory t "\\`[^.]"))))
+
+(defun org-ref--file-join (&rest parts)
+  "Join PARTS into a file path.
+Uses file-name-concat if available (Emacs 28+), otherwise uses
+expand-file-name for compatibility with older Emacs versions.
+Compatible replacement for f-join."
+  (if (fboundp 'file-name-concat)
+      (apply #'file-name-concat parts)
+    ;; Fallback for Emacs < 28
+    (let ((path (car parts)))
+      (dolist (part (cdr parts))
+        (setq path (expand-file-name part path)))
+      path)))
+
+;;** bibtex-completion-bibliography utilities
+
+(defvar bibtex-completion-bibliography)
+
+(defun org-ref-normalize-bibtex-completion-bibliography ()
+  "Return `bibtex-completion-bibliography' as a list of strings.
+This function handles three cases:
+1. If it's a function, call it and return the result
+2. If it's a list, return it as-is
+3. If it's a string, return it wrapped in a list
+
+This ensures consistent handling across org-ref functions."
+  (cond
+   ((functionp bibtex-completion-bibliography)
+    (funcall bibtex-completion-bibliography))
+   ((listp bibtex-completion-bibliography)
+    bibtex-completion-bibliography)
+   (t
+    (list bibtex-completion-bibliography))))
+
+;;** org-ref functions
+;;;###autoload
+(defun org-ref-version ()
+  "Provide a version string for org-ref.
+Copies the string to the clipboard."
+  (interactive)
+  ;; version in the el file.
+  (let* ((org-ref-el (concat
+                     (file-name-sans-extension
+                      (locate-library "org-ref"))
+                     ".el"))
+        (org-ref-dir (file-name-directory org-ref-el))
+        org-version
+        git-commit
+        version-string)
+
+    (setq org-version (with-temp-buffer
+                       (insert-file-contents org-ref-el)
+                       (goto-char (point-min))
+                       (if
+                           (re-search-forward ";; Version:" nil t)
+                           (string-trim (buffer-substring (point)
+                                                     (line-end-position)))
+                         org-ref-dir)))
+
+    (setq git-commit
+         ;; If in git, get current commit
+         (let ((default-directory org-ref-dir))
+           (when (and
+                  ;; this is tricky, as a submodule, .git is a file
+                  (or (file-directory-p ".git") (file-exists-p ".git"))
+                  (= 0 (shell-command "git rev-parse --git-dir")))
+             (format "%s in %s"
+                     (string-trim (shell-command-to-string "git rev-parse HEAD"))
+                     (string-trim (shell-command-to-string "git rev-parse --show-toplevel"))))))
+
+    (setq version-string (format "org-ref: Version %s%s"
+                                org-version
+                                (if git-commit
+                                    (format " (git-commit %s)" git-commit)
+                                  "")))
+    (kill-new version-string)
+    (message version-string)))
+
+
+(defun org-ref-report-issue ()
+  "Report an issue in org-ref.
+Opens https://github.com/jkitchin/org-ref/issues/new."
+  (save-window-excursion
+    (org-ref-debug)
+    (kill-new (buffer-string)))
+  (message "org-ref-debug has been run. You can paste the results in the issue website if you like.")
+  (browse-url "https://github.com/jkitchin/org-ref/issues/new"))
+
+
+;;* Debug
+;; this is just for me to have a nicer debug statement.
+(defmacro ords (&rest body)
+  "Evaluate BODY and return a string."
+  `(format "%s" (progn ,@body)))
+
+
+;;;###autoload
+(defun org-ref-debug ()
+  "Print some debug information to a buffer."
+  (interactive)
+  (switch-to-buffer "*org-ref-debug*")
+  (erase-buffer)
+  (org-mode)
+  (insert
+   (org-ref--format-template "#+TITLE: org-ref debug
+
+${org-ref-version}
+
+* System
+
+- system-type :: ${system}
+- system-configuration :: ${system-configuration}
+- window system :: ${window-system}
+- Emacs :: ${emacs-version}
+- org-version :: ${org-version}
+
+* about org-ref
+
+org-ref installed in [[${org-ref-location}]].
+
+* org-ref setup
+
+-  org-ref-insert-link-function :: ${org-ref-insert-link-function}
+-  org-ref-insert-cite-function :: ${org-ref-insert-cite-function}
+-  org-ref-insert-label-function :: ${org-ref-insert-label-function}
+-  org-ref-insert-ref-function :: ${org-ref-insert-ref-function}
+-  org-ref-cite-onclick-function :: ${org-ref-cite-onclick-function}
+
+* bibtex-completion setup
+
+- bibtex-completion-bibliography :: ${bibtex-completion-bibliography}
+- bibtex-completion-library-path :: ${bibtex-completion-library-path}
+- bibtex-completion-notes-path :: ${bibtex-completion-notes-path}
+
+* org-ref libraries
+
+** org-ref-helm (loaded: ${org-ref-helm-p})
+** org-ref-ivy  (loaded: ${org-ref-ivy-p})
+** org-ref-pdf (loaded: ${org-ref-pdf-p})
+
+- system pdftotext :: ${pdftotext}
+
+You set =pdftotext-executable= to ${pdftotext-executable} (exists: ${pdftotext-executable-p})
+
+** org-ref-url-utils (loaded: ${org-ref-url-p})
+
+* export variables
+
+- org-latex-pdf-process :: ${org-latex-pdf-process}
+"
+            `(("org-ref-version" . ,(org-ref-version))
+              ("org-latex-pdf-process" . ,(format "%S" org-latex-pdf-process))
+              ("org-ref-location" . ,(format "%s" (locate-library "org-ref")))
+
+              ("system" . ,(format "System: %s" system-type))
+              ("system-configuration" . ,(ords system-configuration))
+              ("window-system" . ,(format "Window system: %s" window-system))
+              ("emacs-version" . ,(ords (emacs-version)))
+              ("org-version" . ,(org-version))
+
+              ("org-ref-pdf-p" . ,(ords (featurep 'org-ref-pdf)))
+              ("org-ref-helm-p" . ,(ords (featurep 'org-ref-helm)))
+              ("org-ref-ivy-p" . ,(ords (featurep 'org-ref-ivy)))
+
+              ("pdftotext" . ,(ords (if (featurep 'org-ref-pdf)
+                                        (executable-find "pdftotext")
+                                      "org-ref-pdf not loaded")))
+              ("pdftotext-executable" . ,(ords (if (featurep 'org-ref-pdf)
+                                                   pdftotext-executable
+                                                 "org-ref-pdf not loaded")))
+              ("pdftotext-executable-p" . ,(ords (if (boundp 'pdftotext-executable)
+                                                     (or
+                                                      (executable-find pdftotext-executable)
+                                                      (file-exists-p pdftotext-executable))
+                                                   "pdftotext-executable is not bound")))
+              ("org-ref-url-p" . ,(ords (featurep 'org-ref-url)))
+              ("org-ref-insert-link-function" . ,org-ref-insert-link-function)
+              ("org-ref-insert-cite-function" . ,org-ref-insert-cite-function)
+              ("org-ref-insert-label-function" . ,org-ref-insert-label-function)
+              ("org-ref-insert-ref-function" . ,org-ref-insert-ref-function)
+              ("org-ref-cite-onclick-function" . ,org-ref-cite-onclick-function)
+
+              ("bibtex-completion-bibliography" . ,bibtex-completion-bibliography)
+              ("bibtex-completion-library-path" . ,bibtex-completion-library-path)
+              ("bibtex-completion-notes-path" . ,bibtex-completion-notes-path)))))
+
+
+(defun org-ref-get-bibtex-entry-citation (key)
+  "Return a string for the bibliography entry corresponding to KEY."
+  (bibtex-completion-apa-format-reference key))
+
+
+(defun org-ref-get-bibtex-entry (key)
+  "Return the bibtex entry as a string."
+  (save-window-excursion
+    (bibtex-completion-show-entry (list key))
+    (bibtex-copy-entry-as-kill)
+    (pop bibtex-entry-kill-ring)))
+
+(defun org-ref-library-path ()
+  "return the library path"
+  (cond
+   ((stringp bibtex-completion-library-path)
+    bibtex-completion-library-path)
+   ((and (listp bibtex-completion-library-path)
+        (= 1 (length bibtex-completion-library-path)))
+    (car bibtex-completion-library-path))
+   (t
+    (completing-read "Dir: " bibtex-completion-library-path))))
+
+;;*** key at point functions
+(defun org-ref-get-pdf-filename (key)
+  "Return the pdf filename associated with a bibtex KEY.
+This searches for the pattern KEY*.pdf. If one result is found it
+is returned, but if multiple results are found, e.g. there are
+related files to the KEY you are prompted for which one you want."
+  (let ((results (bibtex-completion-find-pdf-in-library key)))
+    (cond
+     ((null results)
+      nil)
+     ((= 1 (length results))
+      (car results))
+     (t
+      (completing-read "PDF: " results)))))
+
+;; TODO: do we even need this?
+(defun org-ref-get-mendeley-filename (key)
+  "Return the pdf filename indicated by mendeley file field.
+Falls back to `org-ref-get-pdf-filename' if file field does not exist.
+Contributed by https://github.com/autosquid.
+Argument KEY is the bibtex key."
+  (let* ((results (org-ref-get-bibtex-key-and-file key))
+         (bibfile (cdr results)))
+    (with-temp-buffer
+      (insert-file-contents bibfile)
+      (bibtex-set-dialect (parsebib-find-bibtex-dialect) t)
+      (bibtex-search-entry key nil 0)
+      (let ((e (bibtex-autokey-get-field "file")))
+       (if (> (length e) 4)
+            (let ((clean-field (replace-regexp-in-string "{\\|}\\|\\\\" "" e)))
+              (let ((first-file (car (split-string clean-field ";" t))))
+               (format "/%s" (substring first-file 1
+                                        (- (length first-file) 4)))))
+          (expand-file-name (format "%s.pdf" key) (cond
+                                                  ((stringp bibtex-completion-library-path)
+                                                   bibtex-completion-library-path)
+                                                  ((= 1 (length bibtex-completion-library-path))
+                                                   (car bibtex-completion-library-path))
+                                                  (t
+                                                   (completing-read "PDF dir: " bibtex-completion-library-path)))))))))
+
+
+(defun org-ref-get-pdf-filename-bibtex-completion (key)
+  "Use bibtex-completion to retrieve a PDF filename for KEY.
+bibtex-completion looks in both the configured directory
+`bibtex-completion-library-path' and in the fields of the bibtex
+item for a filename. It understands file fields exported by
+Jabref, Mendeley and Zotero. See `bibtex-completion-find-pdf'."
+  (let ((bibtex-completion-bibliography (org-ref-find-bibliography)))
+    (or (car (bibtex-completion-find-pdf key)) "")))
+
+
+;;;###autoload
+(defun org-ref-open-pdf-at-point ()
+  "Open the pdf for bibtex key under point if it exists."
+  (interactive)
+  (let* ((bibtex-completion-bibliography (org-ref-find-bibliography))
+        (results (org-ref-get-bibtex-key-and-file))
+         (key (car results))
+         (pdf-file (bibtex-completion-find-pdf key t)))
+    (pcase (length pdf-file)
+      (0
+       (message "no pdf found for %s" key)
+       (save-window-excursion
+        (org-ref-open-citation-at-point) 
+        (doi-utils-get-bibtex-entry-pdf)))
+      (1
+       (funcall bibtex-completion-pdf-open-function (car pdf-file)))
+      (_
+       (funcall bibtex-completion-pdf-open-function
+               (completing-read "pdf: " pdf-file))))))
+
+
+;;;###autoload
+(defun org-ref-add-pdf-at-point (&optional prefix)
+  "Add the pdf for bibtex key under point if it exists.
+
+Similar to org-ref-bibtex-assoc-pdf-with-entry prompt for pdf
+associated with bibtex key at point and rename it.  Check whether a
+pdf already exists in `bibtex-completion-library' with the name
+'[bibtexkey].pdf'. If the file does not exist, rename it to
+'[bibtexkey].pdf' using
+`org-ref-bibtex-assoc-pdf-with-entry-move-function' and place it
+in a directory. Optional PREFIX argument toggles between
+`rename-file' and `copy-file'."
+
+  (interactive)
+  (let* ((bibtex-completion-bibliography (org-ref-find-bibliography))
+        (results (org-ref-get-bibtex-key-and-file))
+         (key (car results))
+         (pdf-file (bibtex-completion-find-pdf-in-library key)))
+    (if pdf-file
+        (message "PDF for key [%s] already exists %s" key pdf-file)
+      (let* ((source-file-name (read-file-name
+                               (format "Select pdf file associated with key [%s]: " key)
+                               org-ref-bibtex-pdf-download-dir))
+            (dest-file-name (expand-file-name (format "%s.pdf" key)
+                                              (org-ref-library-path)))
+            (file-move-func (org-ref-bibtex-get-file-move-func prefix)))
+        (progn
+          (funcall file-move-func source-file-name dest-file-name)
+          (message "added file %s to key %s" dest-file-name key))))))
+
+;;;###autoload
+(defun org-ref-open-url-at-point ()
+  "Open the url for bibtex key under point."
+  (interactive)
+  (let* ((bibtex-completion-bibliography (org-ref-find-bibliography))
+        (results (org-ref-get-bibtex-key-and-file))
+         (key (car results))
+         (bibfile (cdr results)))
+    (save-excursion
+      (with-temp-buffer
+        (insert-file-contents bibfile)
+        (bibtex-set-dialect (parsebib-find-bibtex-dialect) t)
+        (bibtex-search-entry key)
+        ;; I like this better than bibtex-url which does not always find
+        ;; the urls
+        (catch 'done
+          (let ((url (string-trim (bibtex-autokey-get-field "url"))))
+            (unless (string-blank-p url)
+              (browse-url url)
+              (throw 'done nil)))
+
+          (let ((doi (string-trim (bibtex-autokey-get-field "doi"))))
+            (unless (string-blank-p doi)
+              (if (string-match "^http" doi)
+                  (browse-url doi)
+                (browse-url (format "http://dx.doi.org/%s" doi)))
+              (throw 'done nil))))))))
+
+
+;;;###autoload
+(defun org-ref-open-notes-at-point (&optional thekey)
+  "Open the notes for bibtex key under point in a cite link in a buffer.
+Can also be called with THEKEY in a program."
+  (interactive)
+  (org-mark-ring-push)
+  (when (null thekey)
+    (setq thekey (org-ref-get-bibtex-key-under-cursor)))
+  (let ((bibtex-completion-bibliography (org-ref-find-bibliography)))
+    (bibtex-completion-edit-notes (list thekey))))
+
+
+;;;###autoload
+(defun org-ref-open-citation-at-point ()
+  "Open bibtex file to key at point."
+  (interactive)
+  (org-mark-ring-push)
+  (let ((bibtex-completion-bibliography (org-ref-find-bibliography)))
+    (bibtex-completion-show-entry (list (org-ref-get-bibtex-key-under-cursor)))))
+
+
+;;*** cite menu
+
+;;;###autoload
+(defun org-ref-copy-entry-as-summary ()
+  "Copy the bibtex entry for the citation at point as a summary."
+  (interactive)
+  (kill-new (org-ref-bib-citation)))
+
+
+(defun org-ref-get-doi-at-point ()
+  "Get doi for key at point."
+  (let* ((results (org-ref-get-bibtex-key-and-file))
+         (key (car results))
+         (bibfile (cdr results))
+         doi)
+    (save-excursion
+      (with-temp-buffer
+        (insert-file-contents bibfile)
+        (bibtex-set-dialect (parsebib-find-bibtex-dialect) t)
+        (bibtex-search-entry key)
+        (setq doi (bibtex-autokey-get-field "doi"))
+        ;; in case doi is a url, remove the url part.
+        (replace-regexp-in-string "^http://dx.doi.org/" "" doi)))))
+
+
+;;**** functions that operate on key at point for click menu
+
+;;;###autoload
+(defun org-ref-ads-at-point ()
+  "Open the doi in ADS for bibtex key under point."
+  (interactive)
+  (doi-utils-ads (org-ref-get-doi-at-point)))
+
+
+;;;###autoload
+(defun org-ref-wos-at-point ()
+  "Open the doi in wos for bibtex key under point."
+  (interactive)
+  (doi-utils-wos (org-ref-get-doi-at-point)))
+
+
+;;;###autoload
+(defun org-ref-wos-citing-at-point ()
+  "Open the doi in wos citing articles for bibtex key under point."
+  (interactive)
+  (doi-utils-wos-citing (org-ref-get-doi-at-point)))
+
+
+;;;###autoload
+(defun org-ref-wos-related-at-point ()
+  "Open the doi in wos related articles for bibtex key under point."
+  (interactive)
+  (doi-utils-wos-related (org-ref-get-doi-at-point)))
+
+
+;;;###autoload
+(defun org-ref-google-scholar-at-point ()
+  "Search google scholar for bibtex key under point using the title."
+  (interactive)
+  (browse-url
+   (url-encode-url
+    (format
+     "http://scholar.google.com/scholar?q=%s"
+     (bibtex-completion-get-value
+      "title"
+      (bibtex-completion-get-entry (org-ref-get-bibtex-key-under-cursor)))))))
+
+
+;;;###autoload
+(defun org-ref-biblio-at-point ()
+  "Do a biblio search for bibtex key under point using the title."
+  (interactive)
+  (biblio-lookup
+   nil
+   (bibtex-completion-get-value
+    "title"
+    (bibtex-completion-get-entry (org-ref-get-bibtex-key-under-cursor)))))
+
+
+;;;###autoload
+(defun org-ref-pubmed-at-point ()
+  "Open the doi in pubmed for bibtex key under point."
+  (interactive)
+  (doi-utils-pubmed (org-ref-get-doi-at-point)))
+
+
+;;;###autoload
+(defun org-ref-crossref-at-point ()
+  "Open the doi in crossref for bibtex key under point."
+  (interactive)
+  (doi-utils-crossref (org-ref-get-doi-at-point)))
+
+
+;;;###autoload
+(defun org-ref-email-at-point ()
+  "Email the citation(s) at point."
+  (interactive)
+  (let* ((cite (org-element-context))
+        (keys ()))
+    (compose-mail)
+    (message-goto-body)
+    (cl-loop for ref in (plist-get
+                        (org-ref-parse-cite-path (org-element-property :path cite))
+                        :references)
+            do
+            (let* ((key (plist-get ref :key))
+                   (entry (save-window-excursion
+                            (bibtex-completion-show-entry (list key))
+                            (bibtex-copy-entry-as-kill)
+                            (pop bibtex-entry-kill-ring)))
+                   (pdfs (bibtex-completion-find-pdf key)))
+              (setq keys (append keys (list key)))
+              (insert entry)
+              (cl-loop for pdf in pdfs do (mml-attach-file pdf))))
+
+    (message-goto-subject)
+    (insert "References: " (string-join keys ","))))
+
+
+;;* General org-ref utilities
+
+
+(defun org-ref-get-bibtex-keys (&optional sort)
+  "Return a list of unique keys in the buffer.
+Use SORT to specify alphabetical order by key."
+  (let ((keys '()))
+    (org-element-map (org-element-parse-buffer) 'link
+      (lambda (link)
+        (let ((plist (nth 1 link)))
+          (when (assoc (plist-get plist ':type) org-ref-cite-types)
+           (setq keys (append keys (cl-loop for ref in
+                                            (plist-get (org-ref-parse-cite-path
+                                                        (org-element-property :path link))
+                                                       :references)
+                                            collect (plist-get ref :key)))))))
+      ;; set with-affiliated to get keys in captions
+      nil nil nil t)
+    (when sort
+      ;; Sort keys alphabetically
+      (setq keys (cl-sort keys 'string-lessp :key 'downcase)))
+    (delete-dups keys)))
+
+
+(defun org-ref-pdf-p (filename)
+  "Check if FILENAME is PDF file.
+
+From the PDF specification 1.7:
+
+    The first line of a PDF file shall be a header consisting of
+    the 5 characters %PDF- followed by a version number of the
+    form 1.N, where N is a digit between 0 and 7."
+  (let* ((header (with-temp-buffer
+                  (set-buffer-multibyte nil)
+                  (insert-file-contents-literally filename nil 0 5)
+                  (buffer-string)))
+        (valid (string-equal (encode-coding-string header 'utf-8) "%PDF-")))
+    (if valid
+       valid
+      (message "Invalid pdf. Header = %s" header)
+      nil)))
+
+
+
+
+;; This section creates some code that should speed up org-ref for large files.
+;; I use org-element-parse-buffer a lot for getting information about labels
+;; etc. However, it gets called a lot, and this is slow in large documents. Here
+;; we try to use a cache that helps speed this up at least on loading. Some
+;; notes for the future: on loading, it seems like fontification triggers buffer
+;; changes, so here we only consider char changes. I am not sure this is the
+;; best strategy overall. It is faster to use regexps for finding this
+;; information, but those are substantially more difficult to debug in my
+;; experience. There is an unfortunate number of ways to reference things in
+;; org-mode, and so far this has been most reliable. An alternative might be to
+;; leveralge what happens in font-lock somehow to update local variables
+;; containing org-ref labels, refs, cites, etc. That would miss some #+names
+;; though, and maybe some other things like custom-ids.
+
+(defvar-local org-ref-char-change-tick nil
+  "Local variable to track character changes.")
+
+
+(defvar-local org-ref-parse-buffer-cache nil
+  "Local variable to store parse buffer data.")
+
+
+(defun org-ref-parse-buffer (&optional force)
+  "This is a thin wrapper around `org-element-parse-buffer'.
+The idea is to cache the data, and return it unless we can tell
+the buffer has been modified since the last time we ran it.
+if FORCE is non-nil reparse the buffer no matter what."
+  (if force
+      (progn
+       (message "Forcing update.")
+       (setq-local org-ref-char-change-tick (buffer-chars-modified-tick))
+       (setq-local org-ref-parse-buffer-cache (org-element-parse-buffer)))
+
+    (cond
+     ((null org-ref-parse-buffer-cache)
+      ;; (message "First parse.")
+      (setq-local org-ref-char-change-tick (buffer-chars-modified-tick))
+      (setq-local org-ref-parse-buffer-cache (org-element-parse-buffer)))
+
+     ((not (eq org-ref-char-change-tick (buffer-chars-modified-tick)))
+      ;; (message "Updating from a char change in the buffer.")
+      (setq-local org-ref-char-change-tick (buffer-chars-modified-tick))
+      (setq-local org-ref-parse-buffer-cache (org-element-parse-buffer)))
+
+     (t
+      ;; (message "Using cache.")
+      org-ref-parse-buffer-cache))))
+
+
+
+;;** bad citations, labels, refs and files in orgfile
+;;  These are used i
+(defvar bibtex-files)
+(defvar bibtex-file-path)
+(defun org-ref-bad-cite-candidates ()
+  "Return a list of conses (key . marker) where key does not exist in the known bibliography files, and marker points to the key."
+  (let* ((cp (point))                  ; save to return to later
+         (bibtex-files (cl-loop for f in (org-ref-find-bibliography)
+                               if (file-exists-p f)
+                               collect (file-truename f)))
+         (bibtex-file-path (mapconcat
+                            (lambda (x)
+                              (file-name-directory (file-truename x)))
+                            bibtex-files ":"))
+         (bibtex-key-alist (bibtex-global-key-alist))
+         ;; Handle both old alist format and new completion table format
+         (bibtex-keys (if (functionp bibtex-key-alist)
+                          ;; New format: completion table (function)
+                          ;; Call with nil to get all completions
+                          (all-completions "" bibtex-key-alist)
+                        ;; Old format: alist
+                        (mapcar (lambda (x) (car x)) bibtex-key-alist)))
+         (bad-citations '()))
+
+    (org-element-map (org-ref-parse-buffer) 'link
+      (lambda (link)
+        (let ((plist (nth 1 link)))
+          (when (assoc (plist-get plist :type) org-ref-cite-types)
+           (when (not (string= "*" (plist-get plist :path)))
+             (cl-loop for ref in (plist-get (org-ref-parse-cite-path (plist-get plist :path)) :references)
+                      do
+                      (when (not (member (plist-get ref :key) bibtex-keys))
+                        (goto-char (org-element-property :begin link))
+                        (re-search-forward (plist-get ref :key))
+                        (push (cons (plist-get ref :key) (point-marker)) bad-citations)))))))
+      ;; add with-affiliates to get cites in caption
+      nil nil nil t)
+    (goto-char cp)
+    bad-citations))
+
+
+(defun org-ref-bad-ref-candidates ()
+  "Return a list of conses (ref . marker) where ref is a ref link that does not point to anything (i.e. a label)."
+  ;; first get a list of legitimate labels
+  (let ((cp (point))
+        (labels (mapcar 'car (org-ref-get-labels)))
+        (bad-refs '()))
+    ;; now loop over ref links
+    (goto-char (point-min))
+    (org-element-map (org-ref-parse-buffer) 'link
+      (lambda (link)
+        (let ((plist (nth 1 link)))
+         (when (assoc (plist-get plist ':type)  org-ref-ref-types)
+           (cl-loop for label in (split-string (plist-get plist :path) ",")
+                    do
+                    (unless (member label labels)
+                      (goto-char (org-element-property :begin link))
+                      (add-to-list
+                       'bad-refs
+                       (cons label (point-marker)))))))))
+    (goto-char cp)
+    bad-refs))
+
+
+(defun org-ref-count-labels (label)
+  "Return the number of times LABEL appears in the buffer."
+  (let ((rx (string-join org-ref-ref-label-regexps "\\|"))
+       (labels '()))
+    (save-excursion
+      (org-with-wide-buffer
+       (goto-char (point-min))
+       (while (re-search-forward rx nil t)
+        (cl-pushnew (match-string-no-properties 1) labels))))
+    (cl-count-if (lambda (x) (and (stringp x) (string= x label))) labels)))
+
+
+(defun org-ref-bad-label-candidates ()
+  "Return a list of labels where label is multiply defined."
+  (let ((labels (mapcar 'car (org-ref-get-labels)))
+        (multiple-labels '()))
+    ;; labels should be a unique list.
+    (dolist (label labels)
+      (when (> (org-ref-count-labels label) 1)
+       (let ((cp (point)))
+          (goto-char (point-min))
+         ;; regular org label:tag links
+          (while (re-search-forward
+                  (format  "[^#+]label:%s\\s-" label) nil t)
+            (cl-pushnew (cons label (point-marker)) multiple-labels
+                       :test (lambda (a b)
+                               (and (string= (car a) (car b))
+                                    (= (marker-position (cdr a))
+                                       (marker-position (cdr b)))))))
+
+          (goto-char (point-min))
+         ;; latex style
+          (while (re-search-forward
+                  (format  "\\label{%s}\\s-?" label) nil t)
+            (cl-pushnew (cons label (point-marker)) multiple-labels
+                       :test (lambda (a b)
+                               (and (string= (car a) (car b))
+                                    (= (marker-position (cdr a))
+                                       (marker-position (cdr b)))))))
+
+         ;; keyword style
+          (goto-char (point-min))
+          (while (re-search-forward
+                  (format  "^\\( \\)*#\\+label:\\s-*%s" label) nil t)
+            (cl-pushnew (cons label (point-marker)) multiple-labels
+                       :test (lambda (a b)
+                               (and (string= (car a) (car b))
+                                    (= (marker-position (cdr a))
+                                       (marker-position (cdr b)))))))
+
+          (goto-char (point-min))
+          (while (re-search-forward
+                  (format "^\\( \\)*#\\+tblname:\\s-*%s" label) nil t)
+            (cl-pushnew (cons label (point-marker)) multiple-labels
+                       :test (lambda (a b)
+                               (and (string= (car a) (car b))
+                                    (= (marker-position (cdr a))
+                                       (marker-position (cdr b)))))))
+          (goto-char cp))))
+    multiple-labels))
+
+
+(defun org-ref-bad-file-link-candidates ()
+  "Return list of conses (link . marker) where the file in the link does not exist."
+  (let* ((bad-files '()))
+    (org-element-map (org-ref-parse-buffer) 'link
+      (lambda (link)
+        (let ((type (org-element-property :type link)))
+          (when (or  (string= "file" type)
+                     (string= "attachfile" type))
+            (unless (file-exists-p (org-element-property :path link))
+              (add-to-list 'bad-files
+                           (cons (org-element-property :path link)
+                                 (save-excursion
+                                   (goto-char
+                                    (org-element-property :begin link))
+                                   (point-marker)))))))))
+    ;; Let us also check \attachfile{fname}
+    (save-excursion
+      (goto-char (point-min))
+      (while (re-search-forward "\\\\attachfile{\\([^}]*\\)}" nil t)
+        (unless (file-exists-p (match-string 1))
+          (push  (cons (match-string 1) (point-marker)) bad-files))))
+    bad-files))
+
+
+;; * org-ref command
+(defun org-ref ()
+  "Check the current org-buffer for potential issues."
+  (interactive)
+  (let* ((buf (get-buffer-create "*org-ref*"))
+        (cb (current-buffer))
+        (fname (buffer-file-name))
+        ;; Check if elc is ok before anything else because if it is not, it
+        ;; causes problems in org-ref.
+        (elc-ok (let* ((org-ref-el (concat
+                                    (file-name-sans-extension
+                                     (locate-library "org-ref"))
+                                    ".el"))
+                       (orel-mod)
+                       (org-ref-elc (concat
+                                     (file-name-sans-extension
+                                      (locate-library "org-ref"))
+                                     ".elc"))
+                       (orelc-mod)
+                       (elc-version))
+                  (when (file-exists-p org-ref-el)
+                    (setq orel-mod (file-attribute-modification-time (file-attributes org-ref-el))))
+                  (when (file-exists-p org-ref-elc)
+                    (setq orelc-mod (file-attribute-modification-time (file-attributes org-ref-elc))))
+
+                  (with-current-buffer buf
+                    (read-only-mode -1)
+                    (erase-buffer)
+                    (org-mode)
+                    (insert (format "#+title: org-ref report on [[%s][%s]]\n\n" (buffer-file-name cb) (buffer-name cb)))
+                    (insert (format "org-ref called from %s\n\n" (buffer-file-name cb)))
+
+                    (unless (time-less-p orel-mod orelc-mod)
+                      (insert (format "org-ref.elc (%s) is older than org-ref.el (%s). That is probably not right. Please delete %s.\n"
+                                      (format-time-string "%Y-%m-%d %H:%M:%S" orelc-mod)
+                                      (format-time-string "%Y-%m-%d %H:%M:%S" orel-mod)
+                                      org-ref-elc))
+                      (insert (format "- load-prefer-newer = %s\n" load-prefer-newer))
+                      (insert (format  "  consider
+- deleting %s
+- [[elisp:(delete-file \"%s\")]]
+- add (setq load-prefer-newer t) to your init files
+- using https://github.com/emacscollective/auto-compile.\n" org-ref-elc org-ref-elc))
+
+                      ;; Check for byte-compiling compatibility with current emacs
+                      (when (and org-ref-elc
+                                 (file-exists-p org-ref-elc))
+                        (setq elc-version (with-temp-buffer
+                                            (insert-file-contents org-ref-elc)
+                                            (goto-char (point-min))
+                                            (when (re-search-forward ";;; in Emacs version \\([0-9]\\{2\\}\\.[0-9]+\\)"
+                                                                     nil t)
+                                              (match-string 1))))
+                        (unless (string= elc-version
+                                         (format "%s.%s" emacs-major-version emacs-minor-version))
+                          (insert (format "%s compiled with Emacs %s but you are running %s. That could be a problem.\n"
+                                          elc-version emacs-major-version emacs-minor-version))))))))
+        (bad-citations (org-ref-bad-cite-candidates))
+        (bad-refs (org-ref-bad-ref-candidates))
+        (bad-labels (org-ref-bad-label-candidates))
+        (bad-files (org-ref-bad-file-link-candidates))
+        (bib-candidates '())
+        (unreferenced-labels '())
+        natbib-required
+        natbib-used
+        cleveref-required
+        cleveref-used
+        biblatex-required
+        biblatex-used
+        mbuffer
+        mchar
+        (org-latex-prefer-user-labels (and (boundp 'org-latex-prefer-user-labels)
+                                           org-latex-prefer-user-labels)))
+
+    (when elc-ok nil)                  ; this is to silence a compiler error
+                                       ; about elc-ok not being used. I use it
+                                       ; as a side-effect above
+
+    ;; See if natbib, biblatex or cleveref are required
+    (org-element-map (org-element-parse-buffer) 'link
+      (lambda (link)
+       (when (member (org-element-property :type link) org-ref-natbib-types)
+         (setq natbib-required t))
+       (when (member (org-element-property :type link) org-ref-biblatex-types)
+         (setq biblatex-required t))
+       (when (member (org-element-property :type link) '("cref" "Cref"))
+         (setq cleveref-required t)))
+      nil t)
+
+    ;; See if natbib is probably used. This will miss a case where natbib is included somehow.
+    (setq natbib-used
+         (or
+          (member "natbib" (mapcar (lambda (x) (when (listp x) (nth 1 x))) org-latex-default-packages-alist))
+          (member "natbib" (mapcar (lambda (x) (when (listp x) (nth 1 x))) org-latex-packages-alist))
+          ;; see of something like \usepackage{natbib} exists.
+          (save-excursion
+            (goto-char (point-min))
+            (re-search-forward "{natbib}" nil t))))
+
+    (setq biblatex-used
+         (or
+          (member "biblatex" (mapcar (lambda (x) (when (listp x) (nth 1 x))) org-latex-default-packages-alist))
+          (member "biblatex" (mapcar (lambda (x) (when (listp x) (nth 1 x))) org-latex-packages-alist))
+          ;; see of something like \usepackage{biblatex} exists.
+          (save-excursion
+            (goto-char (point-min))
+            (re-search-forward "{biblatex}" nil t))))
+
+    (setq cleveref-used
+         (or
+          (member "cleveref" (mapcar (lambda (x) (when (listp x) (nth 1 x))) org-latex-default-packages-alist))
+          (member "cleveref" (mapcar (lambda (x) (when (listp x) (nth 1 x))) org-latex-packages-alist))
+          ;; see of something like \usepackage{cleveref} exists.
+          (save-excursion
+            (goto-char (point-min))
+            (re-search-forward  "{cleveref}" nil t))))
+
+    ;; setup bib-candidates. This checks a variety of things in the
+    ;; bibliography, bibtex files. check for which bibliographies are used
+
+    (cl-loop for bibfile in (org-ref-find-bibliography)
+            do
+            (let ((bibdialect))
+              (with-current-buffer (find-file-noselect bibfile)
+                (setq bibdialect bibtex-dialect))
+              (cl-pushnew
+               (format "[[%s]] (dialect = %s)\n" bibfile bibdialect)
+               bib-candidates)))
+
+
+    ;; Check bibliography style exists
+    (save-excursion
+      (goto-char 0)
+      (unless (re-search-forward "bibliographystyle:\\|\\\\bibliographystyle{" nil t)
+       (cl-pushnew
+        "No bibliography style found. This may be ok, if your latex class style sets that up, but if not this is an error. Try adding something like:
+    bibliographystyle:unsrt
+    at the end of your file.\n"
+        bib-candidates)))
+
+    ;; Check if latex knows of the bibliographystyle. We only check links here.
+    ;;  I also assume this style exists as a bst file that kpsewhich can find.
+    (save-excursion
+      (goto-char 0)
+      (when (re-search-forward "bibliographystyle:" nil t)
+       ;; on a link. get style
+       (let ((path (org-element-property :path (org-element-context))))
+          (unless (= 0 (shell-command (format "kpsewhich %s.bst" path)))
+            (cl-pushnew
+            (format "bibliographystyle \"%s\" may be unknown" path)
+            bib-candidates)))))
+
+    ;; check for multiple bibliography links
+    (let* ((bib-links (seq-filter
+                       (lambda (el)
+                        (string= (org-element-property :type el) "bibliography"))
+                       (org-element-map (org-element-parse-buffer) 'link 'identity)))
+           (n-bib-links (length bib-links)))
+
+      (when (> n-bib-links 1)
+       (mapc (lambda (link)
+               (setq
+                bib-candidates
+                (append
+                  bib-candidates
+                  (list (format  "Multiple bibliography link: %s"
+                                (org-element-property :raw-link link))))))
+              bib-links)))
+
+    ;; Check for bibliography files existence.
+    (mapc (lambda (bibfile)
+            (unless (file-exists-p bibfile)
+              (cl-pushnew
+              (format "%s does not exist." bibfile)
+              bib-candidates)))
+          (org-ref-find-bibliography))
+
+    ;; check for spaces in bibliography
+    (let ((bibfiles (mapcar 'expand-file-name
+                            (org-ref-find-bibliography))))
+      (mapc (lambda (bibfile)
+              (when (string-match " " bibfile)
+               (cl-pushnew
+                (format "One or more spaces found in path to %s. No spaces are allowed in bibtex file paths. We recommend replacing them with -. Underscores usually cause other problems." bibfile)
+                bib-candidates)))
+            bibfiles))
+
+    ;; validate bibtex files
+    (let ((bibfiles (mapcar 'expand-file-name
+                            (org-ref-find-bibliography))))
+      (mapc
+       (lambda (bibfile)
+        (unless (with-current-buffer
+                     (find-file-noselect bibfile)
+                   (bibtex-validate))
+           (cl-pushnew
+           (format  "Invalid bibtex file found. [[file:%s]]\n" bibfile)
+           bib-candidates)))
+       bibfiles)
+      ;; check types
+      (mapc
+       (lambda (bibfile)
+        (with-current-buffer
+             (find-file-noselect bibfile)
+          (goto-char (point-min))
+          (while (re-search-forward "^@\\(.*?\\)[({]" nil t)
+            (when (and (not (string= "string" (downcase (match-string-no-properties 1))))
+                       (not (member (string-trim (downcase (match-string-no-properties 1)))
+                                    (cdr (assoc bibtex-dialect
+                                                (list
+                                                 (cons 'BibTeX (mapcar (lambda (e) (downcase (car e)))
+                                                                       bibtex-BibTeX-entry-alist))
+                                                 (cons 'biblatex (mapcar (lambda (e) (downcase (car e)))
+                                                                         bibtex-biblatex-entry-alist))))))))
+              (cl-pushnew
+               (format  "Invalid bibtex entry type (%s) found in [[file:%s::%s]]\n" (match-string-no-properties 1)
+                        bibfile (line-number-at-pos))
+               bib-candidates)))))
+       bibfiles))
+
+    ;; unreferenced labels
+    (save-excursion
+      (save-restriction
+       (widen)
+       (goto-char (point-min))
+       (let ((matches '()))
+         ;; these are the org-ref label:stuff  kinds
+         (while (re-search-forward
+                 "[^#+]label:\\([a-zA-Z0-9:-]*\\)" nil t)
+           (cl-pushnew (cons
+                        (match-string-no-properties 1)
+                        (point))
+                       matches))
+         ;; now add all the other kinds of labels.
+         ;; #+label:
+         (save-excursion
+           (goto-char (point-min))
+           (while (re-search-forward "^#\\+label:\\s-+\\(.*\\)\\b" nil t)
+             ;; do not do this for tables. We get those in `org-ref-get-tblnames'.
+             ;; who would have thought you have save match data here? Trust me. When
+             ;; I wrote this, you did.
+             (unless (save-match-data  (equal (car (org-element-at-point)) 'table))
+               (cl-pushnew (cons (match-string-no-properties 1) (point)) matches))))
+
+         ;; \label{}
+         (save-excursion
+           (goto-char (point-min))
+           (while (re-search-forward "\\\\label{\\([a-zA-Z0-9:-]*\\)}"
+                                     nil t)
+             (cl-pushnew (cons (match-string-no-properties 1) (point)) matches)))
+
+         ;; #+tblname: and actually #+label
+         (cl-loop for cell in (org-element-map (org-element-parse-buffer 'element) 'table
+                                (lambda (table)
+                                  (cons (org-element-property :name table)
+                                        (org-element-property :begin table))))
+                  do
+                  (cl-pushnew cell matches))
+
+         ;; CUSTOM_IDs
+         (org-map-entries
+          (lambda ()
+            (let ((custom_id (org-entry-get (point) "CUSTOM_ID")))
+              (when (not (null custom_id))
+                (cl-pushnew (cons custom_id (point)) matches)))))
+
+         (goto-char (point-min))
+         (while (re-search-forward "^#\\+name:\\s-+\\(.*\\)" nil t)
+           (cl-pushnew (cons (match-string 1) (point)) matches))
+
+
+         ;; unreference labels
+         (let ((refs (org-element-map (org-element-parse-buffer) 'link
+                       (lambda (el)
+                         (when (or (string= "ref" (org-element-property :type el))
+                                   (string= "eqref" (org-element-property :type el))
+                                   (string= "pageref" (org-element-property :type el))
+                                   (string= "nameref" (org-element-property :type el))
+                                   (string= "autoref" (org-element-property :type el))
+                                   (string= "cref" (org-element-property :type el))
+                                   (string= "Cref" (org-element-property :type el)))
+                           (org-element-property :path el))))))
+           (cl-loop for (label . p) in matches
+                    do
+                    (when (and label (not (member label refs)))
+                      (cl-pushnew
+                       (cons label (set-marker (make-marker) p))
+                       unreferenced-labels)))))))
+
+
+    (with-current-buffer buf
+      (when bad-citations
+       (insert "\n* Bad citations\n")
+       (cl-loop for (key . marker) in bad-citations
+                do
+                (setq mbuffer (buffer-name (marker-buffer marker))
+                      mchar (marker-position marker))
+                (insert (format "- [[elisp:(progn (switch-to-buffer %S) (goto-char %S)(org-show-entry))][%s]]\n"
+                                mbuffer mchar key))))
+      (when bad-refs
+       (insert "\n* Bad ref links\n")
+       (cl-loop for (key . marker) in bad-refs
+                do
+                (setq mbuffer (buffer-name (marker-buffer marker))
+                      mchar (marker-position marker))
+                (insert (format "- [[elisp:(progn (switch-to-buffer %S) (goto-char %S)(org-show-entry))][%s]]\n"
+                                mbuffer mchar key))))
+
+      (when bad-labels
+       (insert "\n* Multiply defined label links\n")
+       (cl-loop for (key . marker) in bad-labels
+                do
+                (setq mbuffer (buffer-name (marker-buffer marker))
+                      mchar (marker-position marker))
+                (insert (format "- [[elisp:(progn (switch-to-buffer %S) (goto-char %S)(org-show-entry))][%s]]\n"
+                                mbuffer mchar key))))
+
+      (when bad-files
+       (insert "\n* Bad files\n")
+       (cl-loop for (fname pos) in bad-files do
+                (insert (format "- [[elisp:(goto-char %s)][%s]]\n" pos fname))))
+
+      (when unreferenced-labels
+       (insert "\n* Unreferenced label links\n")
+       (cl-loop for (key . marker) in unreferenced-labels
+                when (not (string= key ""))
+                do
+                (setq mbuffer (buffer-name (marker-buffer marker))
+                      mchar (marker-position marker))
+                (insert (format "- [[elisp:(progn (switch-to-buffer %S) (goto-char %S)(org-show-entry))][%s]]\n"
+                                mbuffer mchar key))))
+
+      (when bib-candidates
+       (insert "\n* Bibliography\n\n")
+       (cl-loop for candidate in bib-candidates
+                do
+                (insert (format "- %s" candidate))))
+
+      (insert "\n* Miscellaneous\n\n")
+      (cl-loop for s in `(,(format "org-latex-prefer-user-labels = %s"
+                                  org-latex-prefer-user-labels)
+                         ,(format "bibtex-dialect = %s" bibtex-dialect)
+                         ,(format "biblatex is%srequired." (if biblatex-required " " " not "))
+                         ,(format "biblatex is%sused." (if biblatex-used " " " not "))
+                         ,(format "emacs-version = %s" (emacs-version))
+                         ,(format "org-version = %s" (org-version))
+                         ,(org-ref-version)
+                         ,(format "org-ref.el installed at %s" (concat
+                                                                (file-name-sans-extension
+                                                                 (locate-library "org-ref"))
+                                                                ".el"))
+                         ,(format "org-ref-insert-cite-function = %s" org-ref-insert-cite-function)
+                         ,(format "org-ref-insert-label-function = %s" org-ref-insert-label-function)
+                         ,(format "org-ref-insert-ref-function = %s" org-ref-insert-ref-function)
+                         ,(format "org-ref-cite-onclick-function = %s" org-ref-cite-onclick-function)
+                         ,(format "org-latex-pdf-process is defined as %s" org-latex-pdf-process)
+                         ,(format "natbib is%srequired." (if natbib-required " " " not "))
+                         ,(format "natbib is%sin %s or %s."
+                                  (if natbib-used " " " not ")
+                                  (propertize "org-latex-default-packages-alist"
+                                              'help-echo (format "%S" (mapconcat
+                                                                       (lambda (s)
+                                                                         (format "%s" s))
+                                                                       org-latex-default-packages-alist
+                                                                       "\n"))
+                                              'font-lock-face '(:foreground "red3"))
+                                  (propertize "org-latex-packages-alist"
+                                              'help-echo (format "%S" (mapconcat
+                                                                       (lambda (s)
+                                                                         (format "%s" s))
+                                                                       org-latex-packages-alist
+                                                                       "\n"))
+                                              'font-lock-face '(:foreground "red3")))
+                         ,(format "cleveref is%srequired." (if cleveref-required " " " not "))
+                         ,(format "cleveref is%sin %s or %s."
+                                  (if cleveref-used " " " not ")
+                                  (propertize "org-latex-default-packages-alist"
+                                              'help-echo (format "%S" (mapconcat
+                                                                       (lambda (s)
+                                                                         (format "%s" s))
+                                                                       org-latex-default-packages-alist
+                                                                       "\n"))
+                                              'font-lock-face '(:foreground "red3"))
+                                  (propertize "org-latex-packages-alist"
+                                              'help-echo (format "%S" (mapconcat
+                                                                       (lambda (s)
+                                                                         (format "%s" s))
+                                                                       org-latex-packages-alist
+                                                                       "\n"))
+                                              'font-lock-face '(:foreground "red3")))
+                         ,(format "bibtex-completion installed = %s" (featurep 'bibtex-completion))
+                         ,(format "bibtex-completion loaded = %s" (fboundp 'bibtex-completion-candidates)))
+              do
+              (insert "- " s "\n"))
+      (insert (format "- org-latex-default-packages-alist\n"))
+      (cl-loop for el in org-latex-default-packages-alist
+              do
+              (insert (format "  %S\n" el)))
+
+      (if (null org-latex-packages-alist)
+         (insert "-  org-latex-packages-alist is nil\n")
+       (insert "-  org-latex-packages-alist\n")
+       (cl-loop for el in org-latex-packages-alist
+                do
+                (insert (format "  %S\n" el))))
+
+
+      (insert (format "- ox-bibtex loaded = %s\n" (featurep 'ox-bibtex)))
+      (insert (format "- ox-bibtex loaded after org-ref = %s\n"
+                     (let ((org-ref-i (seq-position load-history (assoc (locate-library "org-ref") load-history)) )
+                           (ox-bibtex-i (seq-position load-history (assoc (locate-library "ox-bibtex") load-history))))
+                       (and org-ref-i ox-bibtex-i
+                            (> org-ref-i ox-bibtex-i)))))
+
+      (insert (format "- ebib loaded = %s\n" (featurep 'ebib)))
+      (insert (format "- ebib loaded after org-ref = %s\n"
+                     (let ((org-ref-i (seq-position load-history (assoc (locate-library "org-ref") load-history)) )
+                           (ebib-i (seq-position load-history (assoc (locate-library "ebib") load-history))))
+                       (and org-ref-i ebib-i
+                            (> org-ref-i ebib-i)))))
+
+
+
+      (insert "- cite link definition:\n" (with-temp-buffer
+                                           (insert (format "%S" (assoc "cite" org-link-parameters)))
+                                           (pp-buffer)
+                                           (buffer-string)))
+
+      (insert "\n* LaTeX setup\n\n")
+      (cl-loop for executable in '("latex" "pdflatex" "bibtex" "biblatex"
+                                  "makeindex" "makeglossaries")
+              do
+              (insert (format "%s is installed at %s\n" executable (executable-find executable))))
+
+      (insert "\n* Warnings\n")
+      (if (get-buffer "*Warnings*")
+         (cl-loop for line in (split-string "\n" (with-current-buffer "*Warnings*"
+                                              (buffer-string)))
+                  if (string-prefix-p  "Warning (org-ref):" line)
+                  do
+                  (insert " - " line "\n"))
+       (insert "- No (org-ref) Warnings found."))
+
+
+      (insert (format  "\n* Utilities
+
+- [[elisp:(progn (find-file %S) (ispell))][Spell check document]]
+- [[elisp:(progn (find-file %S) (org-ref))][recheck document with org-ref]]
+" fname fname))
+      (goto-char (point-min))
+
+      ;; (setq header-line-format "Press q to quit.")
+      ;; (local-set-key "q"
+      ;;                    #'(lambda ()
+      ;;                        (interactive)
+      ;;                        (delete-window)))
+      (read-only-mode))
+
+    (display-buffer-in-side-window buf '((side . right)))))
+
+
+
+;;** Find non-ascii characters
+;;;###autoload
+(defun org-ref-find-non-ascii-characters ()
+  "Find non-ascii characters in the buffer.  Useful for cleaning up bibtex files."
+  (interactive)
+  (occur "[^[:ascii:]]"))
+
+
+;;* Utilities
+
+;;** Extract bibtex entries in org-file
+
+;;;###autoload
+(defun org-ref-extract-bibtex-to-file (bibfile &optional clobber)
+  "Extract all bibtex entries for citations buffer to BIBFILE.
+If BIBFILE exists, append, unless you use a prefix arg (C-u),
+which will CLOBBER the file."
+  (interactive
+   (list (read-file-name "Bibfile: " nil nil nil
+                        (file-name-nondirectory
+                         (concat (file-name-sans-extension
+                                  (buffer-file-name))
+                                 ".bib")))
+        current-prefix-arg))
+
+  (let* ((bibtex-files (org-ref-find-bibliography))
+        (keys (reverse (org-ref-get-bibtex-keys)))
+        (bibtex-entry-kill-ring-max (length keys))
+        (bibtex-entry-kill-ring '())
+        (kill-cb (not (find-buffer-visiting bibfile)))
+        (cb (find-file-noselect bibfile))
+        (current-bib-entries (with-current-buffer cb
+                               (prog1
+                                   (buffer-string)
+                                 (when kill-cb (kill-buffer cb))))))
+
+    (save-window-excursion
+      (cl-loop for key in keys
+              do
+              (bibtex-search-entry key t)
+              (bibtex-kill-entry t)))
+
+    (with-temp-file bibfile
+      (unless clobber (insert current-bib-entries))
+      (insert (mapconcat
+              'identity
+              bibtex-entry-kill-ring
+              "\n\n")))))
+
+
+;;;###autoload
+(defun org-ref-extract-bibtex-entries ()
+  "Extract the bibtex entries in the current buffer into a bibtex src block."
+  (interactive)
+  (let* ((bibtex-files (org-ref-find-bibliography))
+        (keys (reverse (org-ref-get-bibtex-keys)))
+        (bibtex-entry-kill-ring-max (length keys))
+        (bibtex-entry-kill-ring '()))
+
+    (save-window-excursion
+      (cl-loop for key in keys
+              do
+              (bibtex-search-entry key t)
+              (bibtex-kill-entry t)))
+
+    (goto-char (point-max))
+    (insert "\n\n")
+    (org-insert-heading)
+    (insert (format " Bibtex entries
+
+#+BEGIN_SRC bibtex :tangle %s
+%s
+#+END_SRC"
+                   (let ((bibfile (concat (file-name-base
+                                           (or (buffer-file-name) "references"))
+                                          ".bib")))
+                     (if (file-exists-p bibfile)
+                         (file-name-nondirectory
+                          (read-file-name "Bibfile: " nil nil nil bibfile))
+                       bibfile))
+                   (mapconcat
+                    'identity
+                    bibtex-entry-kill-ring
+                    "\n\n")))))
+
+
+;;** Extract cited pdfs
+;;;###autoload
+(defun org-ref-extract-cited-pdfs (newdir)
+  "Copy PDFs in citations in current buffer to NEWDIR."
+  (interactive (list (read-directory-name "Copy to: ")))
+  ;; Make sure newdir exists
+  (unless (file-directory-p newdir)
+    (mkdir newdir t))
+  
+  (cl-loop for key in (org-ref-get-bibtex-keys) do
+          (let ((pdf (org-ref-get-pdf-filename key)))
+            (if (file-exists-p pdf)
+                (progn
+                  (message "Copying %s to %s." pdf newdir)
+                  (copy-file pdf newdir t))
+              (message "%s not found" pdf)))))
+
+
+(provide 'org-ref-utils)
+;;; org-ref-utils.el ends here
+
+;; Local Variables:
+;; byte-compile-warnings: (not docstrings-wide)
+;; End:
diff --git a/elpa/org-ref-20251206.1422/org-ref-worldcat.el b/elpa/org-ref-20251206.1422/org-ref-worldcat.el
new file mode 100644 (file)
index 0000000..1100e7a
--- /dev/null
@@ -0,0 +1,20 @@
+;;; org-ref-worldcat.el --- Worldcat library -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; Provides a function to query world cat
+;; See:
+;; https://www.worldcat.org/wcpa/content/affiliate/default.jsp
+;; https://www.worldcat.org/affiliate/tools?atype=text
+
+;;; Code:
+
+(defun worldcat-query-all (query)
+  "Open browser to Worldcat QUERY."
+  (browse-url
+   (format
+    "http://www.worldcat.org/search?qt=worldcat_org_all&q=%s"
+    query)))
+
+(provide 'org-ref-worldcat)
+
+;;; org-ref-worldcat.el ends here
diff --git a/elpa/org-ref-20251206.1422/org-ref-wos.el b/elpa/org-ref-20251206.1422/org-ref-wos.el
new file mode 100644 (file)
index 0000000..3298bbe
--- /dev/null
@@ -0,0 +1,106 @@
+;;; org-ref-wos.el --- Web of Science functions              -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2015-2024  John Kitchin
+
+;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
+;; Keywords:
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Adds a new org-mode link for a search in Web of Science.
+;;; and an org-mode link for a link to an Accession number.
+
+(require 'org)
+(require 'org-ref-utils)
+
+;;; Code:
+(org-link-set-parameters "wos"
+                        :follow (lambda (accession-number)
+                                  (browse-url
+                                   (concat
+                                    "http://ws.isiknowledge.com/cps/openurl/service?url_ver=Z39.88-2004&rft_id=info:ut/"
+                                    accession-number)))
+                        :export (lambda (accession-number desc format)
+                                  (cond
+                                   ((eq format 'html)
+                                    (format "<a href=\"http://ws.isiknowledge.com/cps/openurl/service?url_ver=Z39.88-2004&rft_id=info:ut/%s\">%s</a>"
+                                            accession-number
+                                            (or desc (concat "wos:" accession-number)))))))
+
+(org-link-set-parameters "wos-search"
+                        :follow (lambda (path)
+                                  (browse-url
+                                   (format  "http://gateway.webofknowledge.com/gateway/Gateway.cgi?topic=%s&GWVersion=2&SrcApp=WEB&SrcAuth=HSB&DestApp=UA&DestLinkType=GeneralSearchSummary"
+                                            (string-join (split-string path) "+"))))
+                        :export (lambda (link desc format)
+                                  (cond
+                                   ((eq format 'html)
+                                    (format "<a href=\"%s\">%s</a>"
+                                            (format  "http://gateway.webofknowledge.com/gateway/Gateway.cgi?topic=%s&GWVersion=2&SrcApp=WEB&SrcAuth=HSB&DestApp=UA&DestLinkType=GeneralSearchSummary"
+                                                     (string-join (split-string link) "+"))
+                                            (or desc link))))))
+
+;;;###autoload
+(defun wos-search ()
+  "Open the word at point or selection in Web of Science as a topic query."
+  ;; the url was derived from this page: http://wokinfo.com/webtools/searchbox/
+  (interactive)
+  (browse-url
+   (format "http://gateway.webofknowledge.com/gateway/Gateway.cgi?topic=%s&GWVersion=2&SrcApp=WEB&SrcAuth=HSB&DestApp=UA&DestLinkType=GeneralSearchSummary"
+           (if (region-active-p)
+               (mapconcat 'identity (split-string
+                                     (buffer-substring (region-beginning)
+                                                       (region-end))) "+")
+             (thing-at-point 'word)))))
+
+
+;;;###autoload
+(defun wos ()
+  "Open Web of Science search page in a browser."
+  (interactive)
+  (browse-url "http://apps.webofknowledge.com"))
+
+;;* Accession numbers
+;; see http://kitchingroup.cheme.cmu.edu/blog/2015/06/08/Getting-a-WOS-Accession-number-from-a-DOI/
+(defvar *wos-redirect* nil
+  "Holds the redirect from a `url-retrieve' callback function.")
+
+(defvar *wos-waiting* nil
+  "Non-nil when waiting for a `url-retrieve' redirect.")
+
+
+(defun wos-get-wos-redirect (url)
+  "Return final redirect URL for open-url."
+  (setq *wos-waiting* t)
+  (url-retrieve
+   url
+   (lambda (status)
+     (setq *wos-redirect* (car (last status)))
+     (setq *wos-waiting* nil)))
+  (while *wos-waiting* (sleep-for 0.1))
+  (url-unhex-string *wos-redirect*))
+
+
+(defun wos-doi-to-accession-number (doi)
+  "Return a WOS Accession number for a DOI."
+  (let* ((open-url (concat "http://ws.isiknowledge.com/cps/openurl/service?url_ver=Z39.88-2004&rft_id=info:doi/" doi))
+         (redirect (wos-get-wos-redirect open-url)))
+    (message redirect)
+    (string-match "&KeyUT=WOS:\\([^&]*\\)&" redirect)
+    (match-string 1 redirect)))
+
+(provide 'org-ref-wos)
+;;; org-ref-wos.el ends here
diff --git a/elpa/org-ref-20251206.1422/org-ref.bib b/elpa/org-ref-20251206.1422/org-ref.bib
new file mode 100644 (file)
index 0000000..0526093
--- /dev/null
@@ -0,0 +1,333 @@
+@book{Dominik201408,
+  keywords = {org-mode},
+  url = {http://amazon.com/o/ASIN/9881327709/},
+  isbn = 9789881327703,
+  year = 2014,
+  publisher = {Samurai Media Limited},
+  author = {Carsten Dominik},
+  title = {The Org Mode 8 Reference Manual - Organize your life with GNU
+                  Emacs},
+}
+@article{xu-2015-relat-between,
+  title =       {Relationships Between the Surface Electronic and Chemical
+                  Properties of Doped 4d and 5d Late Transition Metal Dioxides},
+  eid =                 104703,
+  url =
+                  "http://scitation.aip.org/content/aip/journal/jcp/142/10/10.1063/1.4914093",
+  doi =                 {10.1063/1.4914093},
+  year =        2015,
+  pages =       104703,
+  number =      10,
+  volume =      142,
+  journal =     "The Journal of Chemical Physics",
+  keywords =    {DESC0004031, early-career, orgmode},
+  author =      "Xu, Zhongnan and Kitchin, John R.",
+}
+
+@article{xu-2015-linear-respon,
+  title =       {A Linear Response {DFT}+{U} Study of Trends in the Oxygen
+                  Evolution Activity of Transition Metal Rutile Dioxides},
+  eprint =      { http://dx.doi.org/10.1021/jp511426q },
+  url =                 { http://dx.doi.org/10.1021/jp511426q },
+  doi =                 {10.1021/jp511426q},
+  year =        2015,
+  pages =       {4827-4833},
+  number =      9,
+  volume =      119,
+  journal =     {The Journal of Physical Chemistry C},
+  keywords =    {DESC0004031, early-career, orgmode, },
+  author =      {Xu, Zhongnan and Rossmeisl, Jan and Kitchin, John R.},
+}
+
+@article{boes-2015-suppor-infor,
+  title =       {Supporting Information: Estimating Bulk-Composition-Dependent
+                  \ce{H2} Adsorption Energies on \ce{Cu_{x}Pd_{1-x}} Alloy (111)
+                  Surfaces},
+  url =
+                  {http://pubs.acs.org/doi/suppl/10.1021/cs501585k/suppl_file/cs501585k_si_001.pdf},
+  doi =                 {10.1021/cs501585k},
+  year =        2015,
+  pages =       {1020-1026},
+  volume =      5,
+  journal =     {ACS Catalysis},
+  keywords =    {orgmode},
+  author =      {Jacob R. Boes and Gamze Gumuslu and James B. Miller and Andrew
+                  J. Gellman and John R. Kitchin},
+}
+
+@article{boes-2015-estim-bulk,
+  title =       {Estimating Bulk-Composition-Dependent \ce{H2} Adsorption
+                  Energies on \ce{Cu_{x}Pd_{1-x}} Alloy (111) Surfaces},
+  url =                 {http://dx.doi.org/10.1021/cs501585k},
+  doi =                 {10.1021/cs501585k},
+  year =        2015,
+  pages =       {1020-1026},
+  volume =      5,
+  keywords =    {orgmode},
+  journal =     {ACS Catalysis},
+  author =      {Jacob R. Boes and Gamze Gumuslu and James B. Miller and Andrew
+                  J. Gellman and John R. Kitchin},
+}
+
+@article{curnan-2014-effec-concen,
+  title =       {Effects of Concentration, Crystal Structure, Magnetism, and
+                  Electronic Structure Method on First-Principles Oxygen Vacancy
+                  Formation Energy Trends in Perovskites},
+  eprint =      { http://dx.doi.org/10.1021/jp507957n },
+  url =                 {http://dx.doi.org/10.1021/jp507957n},
+  doi =                 {10.1021/jp507957n},
+  year =        2014,
+  pages =       {28776-28790},
+  number =      49,
+  volume =      118,
+  journal =     {The Journal of Physical Chemistry C},
+  keywords =    {orgmode, },
+  author =      {Curnan, Matthew T. and Kitchin, John R.},
+}
+
+@article{miller-2014-simul-temper,
+  title =       {Simulating Temperature Programmed Desorption of Oxygen on
+                  {P}t(111) Using {DFT} Derived Coverage Dependent Desorption
+                  Barriers},
+  url =                 {http://dx.doi.org/10.1007/s11244-013-0166-3},
+  doi =                 {10.1007/s11244-013-0166-3},
+  year =        2014,
+  pages =       {106-117},
+  number =      {1-4},
+  volume =      57,
+  journal =     {Topics in Catalysis},
+  keywords =    {DESC0004031, early-career, orgmode, },
+  author =      {Spencer D. Miller and Vladimir V. Pushkarev and Andrew
+                  J. Gellman and John R. Kitchin},
+}
+
+@article{xu-2014-probin-cover,
+  title =       {Probing the Coverage Dependence of Site and Adsorbate
+                  Configurational Correlations on (111) Surfaces of Late
+                  Transition Metals},
+  url =                 {http://dx.doi.org/10.1021/jp508805h},
+  doi =                 {10.1021/jp508805h},
+  year =        2014,
+  pages =       {25597-25602},
+  number =      44,
+  volume =      118,
+  journal =     {J. Phys. Chem. C},
+  keywords =    {DESC0004031, early-career, orgmode, },
+  author =      {Zhongnan Xu and John R. Kitchin},
+}
+
+@article{xu-2014-relat-elect,
+  title =       {Relating the Electronic Structure and Reactivity of the 3d
+                  Transition Metal Monoxide Surfaces},
+  abstract =    "Abstract We performed a series of density functional theory
+                  calculations of dissociative oxygen adsorption on fcc metals
+                  and their corresponding rocksalt monoxides to elucidate the
+                  relationship between the oxide electronic structure and its
+                  corresponding reactivity. We decomposed the dissociative
+                  adsorption energy of oxygen on an oxide surface into a sum of
+                  the adsorption energy on the metal and a change in adsorption
+                  energy caused by both expanding and oxidizing the lattice. We
+                  were able to identify the key features of the electronic
+                  structure that explains the trends in adsorption energies on
+                  3d transition metal monoxide surfaces. ",
+  issn =        "1566-7367",
+  url =                 {http://dx.doi.org/10.1016/j.catcom.2013.10.028},
+  doi =                 {10.1016/j.catcom.2013.10.028},
+  year =        2014,
+  pages =       {60-64},
+  volume =      52,
+  journal =     {Catalysis Communications},
+  keywords =    {DESC0004031, early-career, orgmode, },
+  author =      {Zhongnan Xu and John R. Kitchin},
+}
+
+@article{mehta-2014-ident-poten,
+  title =       {Identifying Potential \ce{BO2} Oxide Polymorphs for Epitaxial
+                  Growth Candidates},
+  eprint =      {http://pubs.acs.org/doi/pdf/10.1021/am4059149},
+  url =                 {http://dx.doi.org/10.1021/am4059149},
+  doi =                 {10.1021/am4059149},
+  year =        2014,
+  pages =       {3630-3639},
+  number =      5,
+  volume =      6,
+  journal =     {ACS Appl. Mater. Interfaces},
+  keywords =    {orgmode, },
+  author =      {Prateek Mehta and Paul A. Salvador and John R. Kitchin},
+}
+
+@article{hallenbeck-2013-effec,
+  title =       {Effects of \ce{O_2} and \ce{SO_2} on the Capture Capacity of a
+                  Primary-Amine Based Polymeric \ce{CO_2} Sorbent},
+  eprint =      "http://pubs.acs.org/doi/pdf/10.1021/ie400582a",
+  url =                 "http://pubs.acs.org/doi/abs/10.1021/ie400582a",
+  doi =                 "10.1021/ie400582a",
+  year =        2013,
+  pages =       "10788-10794",
+  journal =     "Industrial \& Engineering Chemistry Research",
+  keywords =    {RUA, orgmode},
+  author =      "Hallenbeck, Alexander P. and Kitchin, John R.",
+}
+
+
+@article{kitchin-2016-autom-data,
+  abstract =    "In the current scientific publishing landscape, there is a
+                  need for an authoring workflow that easily integrates data and
+                  code into manuscripts and that enables the data and code to be
+                  published in reusable form. Automated embedding of data and
+                  code into published output will enable superior communication
+                  and data archiving. In this work, we demonstrate a proof of
+                  concept for a workflow, org-mode, which successfully provides
+                  this authoring capability and workflow integration. We
+                  illustrate this concept in a series of examples for potential
+                  uses of this workflow. First, we use data on citation counts
+                  to compute the h-index of an author, and show two code
+                  examples for calculating the h-index. The source for each
+                  example is automatically embedded in the PDF during the export
+                  of the document. We demonstrate how data can be embedded in
+                  image files, which themselves are embedded in the document.
+                  Finally, metadata about the embedded files can be
+                  automatically included in the exported PDF, and accessed by
+                  computer programs. In our customized export, we embedded
+                  metadata about the attached files in the PDF in an Info field.
+                  A computer program could parse this output to get a list of
+                  embedded files and carry out analyses on them. Authoring tools
+                  such as Emacs + org-mode can greatly facilitate the
+                  integration of data and code into technical writing. These
+                  tools can also automate the embedding of data into document
+                  formats intended for consumption.",
+  author =      "Kitchin, John R. and Van Gulick, Ana E. and Zilinski, Lisa D.",
+  keywords =    {orgmode},
+  doi =                 "10.1007/s00799-016-0173-7",
+  issn =        "1432-1300",
+  journal =     "International Journal on Digital Libraries",
+  pages =       "1--6",
+  title =       {Automating Data Sharing Through Authoring Tools},
+  url =                 "http://dx.doi.org/10.1007/s00799-016-0173-7",
+  year =        2016,
+}
+
+@article{kitchin-2015-data-surfac-scien,
+  author =      "John R. Kitchin",
+  title =       {Data Sharing in Surface Science},
+  journal =     "Surface Science ",
+  volume =      {647},
+  pages =       {103-107},
+  year =        2015,
+  doi =                 {10.1016/j.susc.2015.05.007},
+  url =
+                  "http://www.sciencedirect.com/science/article/pii/S0039602815001326",
+  issn =        "0039-6028",
+  keywords =    {DESC0004031, early-career, orgmode, Data sharing },
+}
+
+@article{kitchin-2015-examp,
+  author =      {Kitchin, John R.},
+  title =       {Examples of Effective Data Sharing in Scientific Publishing},
+  journal =     {ACS Catalysis},
+  volume =      {5},
+  number =      {6},
+  pages =       {3894-3899},
+  year =        2015,
+  doi =                 {10.1021/acscatal.5b00538},
+  url =                 { http://dx.doi.org/10.1021/acscatal.5b00538 },
+  keywords =    {DESC0004031, early-career, orgmode, Data sharing },
+  eprint =      { http://dx.doi.org/10.1021/acscatal.5b00538 },
+}
+
+@misc{jkitchin76:online,
+  author =      {John Kitchin},
+  title =       {jkitchin/org-ref: org-mode modules for citations,
+                  cross-references, bibliographies in org-mode and useful bibtex
+                  tools to go with it.},
+  url =                 {https://github.com/jkitchin/org-ref},
+  urldate =     {12/04/2016}
+}
+
+@book{chen-2006-handb-data-visual,
+  author =      {Hrsg. Chun-houh Chen ; Hrsg. Wolfgang H{\"a}rdle ; Hrsg.
+                  Antony Unwin},
+  title =       {Handbook of Data Visualization},
+  year =        2006,
+  publisher =   {Springer Berlin},
+  url =                 {http://www.worldcat.org/oclc/150289486?referer=xid},
+  city =        {Berlin},
+  ed =          {1. Ed.},
+  form =        {BA},
+  isbn =        9783540330363,
+  lang =        {eng},
+  lccn =        2007931825,
+  oclcnum =     {150289486 214357554 232302403 314615038 474712418 494787249
+                  645208009 743424036 751135412 76799021 804152581 849253364
+                  873514520 612218650},
+}
+
+@article{geng-2017-first-princ,
+  author =      {Feiyang Geng and Jacob R. Boes and John R. Kitchin},
+  title =       {First-Principles Study of the {Cu-Pd} Phase Diagram},
+  journal =     {Calphad},
+  volume =      56,
+  pages =       {224-229},
+  year =        2017,
+  doi =                 {10.1016/j.calphad.2017.01.009},
+  url =                 {https://doi.org/10.1016/j.calphad.2017.01.009},
+  DATE_ADDED =  {Wed Feb 22 09:13:55 2017},
+}
+
+@article{boes-2017-model-segreg,
+  author =       {Boes, Jacob Russell and Kitchin, John R.},
+  title =        {Modeling Segregation on {AuPd}(111) Surfaces With Density
+                  Functional Theory and Monte Carlo Simulations},
+  journal =      {The Journal of Physical Chemistry C},
+  volume =      {121},
+  number =      {6},
+  pages =       {3479-3487},
+  year =         2017,
+  doi =          {10.1021/acs.jpcc.6b12752},
+  url =          {https://doi.org/10.1021/acs.jpcc.6b12752},
+  eprint =       { http://dx.doi.org/10.1021/acs.jpcc.6b12752 },
+}
+
+@article{xu-2017-first-princ,
+  author =      {Xu, Zhongnan and Salvador, Paul A. and Kitchin, John R.},
+  title =       {First-Principles Investigation of the Epitaxial Stabilization
+                  of Oxide Polymorphs: \ce{TiO2} on \ce{(Sr{,}Ba)TiO3}},
+  journal =     {ACS Applied Materials \& Interfaces},
+  volume =      {9},
+  number =      {4},
+  pages =       {4106-4118},
+  year =        2017,
+  doi =                 {10.1021/acsami.6b11791},
+  url =                 {https://doi.org/10.1021/acsami.6b11791},
+  eprint =      { http://dx.doi.org/10.1021/acsami.6b11791 },
+  note =        {PMID: 28004912},
+}
+
+@article{boes-2017-neural-networ,
+  author =      {Jacob R. Boes and John R. Kitchin},
+  title =       {Neural Network Predictions of Oxygen Interactions on a Dynamic
+                  {Pd} Surface},
+  journal =     {Molecular Simulation},
+  pages =       {1-9},
+  year =        2017,
+  doi =                 {10.1080/08927022.2016.1274984},
+  url =                 {https://doi.org/10.1080/08927022.2016.1274984},
+  keywords =    {CBET-1506770, orgmode},
+}
+
+
+@article{boes-2016-neural-networ,
+  author =      {Jacob R. Boes and Mitchell C. Groenenboom and John A. Keith
+                  and John R. Kitchin},
+  title =       {Neural Network and {Reaxff} Comparison for {Au} Properties},
+  journal =     {Int. J. Quantum Chem.},
+  volume =      116,
+  number =      13,
+  pages =       {979-987},
+  year =        2016,
+  doi =                 {10.1002/qua.25115},
+  url =                 {http://dx.doi.org/10.1002/qua.25115},
+  issn =        {1097-461X},
+  keywords =    {Kohn-Sham density functional theory, neural networks, reactive
+                  force fields, potential energy surfaces, machine learning},
+}
\ No newline at end of file
diff --git a/elpa/org-ref-20251206.1422/org-ref.el b/elpa/org-ref-20251206.1422/org-ref.el
new file mode 100644 (file)
index 0000000..4920698
--- /dev/null
@@ -0,0 +1,54 @@
+;;; org-ref.el --- citations, cross-references and bibliographies in org-mode -*- lexical-binding: t; -*-
+
+;; Copyright(C) 2014-2024 John Kitchin
+
+;; Author: John Kitchin <jkitchinNOSPAMandrew.cmu.edu>
+;; URL: https://github.com/jkitchin/org-ref
+;; Package-Version: 20251206.1422
+;; Package-Revision: dc2481d43090
+;; Keywords: org-mode, cite, ref, label
+;; Package-Requires: ((org "9.4") (htmlize "0") (transient "0") (avy "0") (parsebib "0") (bibtex-completion "0") (citeproc "0") (ox-pandoc "0") (request "0"))
+;; This file is not currently part of GNU Emacs.
+
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation; either version 2, or (at
+;; your option) any later version.
+
+;; This program is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program ; see the file COPYING.  If not, write to
+;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+;;
+;; Lisp code to setup bibliography, cite, ref and label org-mode links. The
+;; links are clickable and do things that are useful.
+;;
+;; This uses vanilla completing-read in Emacs. You can customize by requiring
+;; `org-ref-helm' or `org-ref-ivy' after this.
+
+;; You should really read org-ref.org in this package for details.
+;;
+
+;;; Code:
+
+(require 'org-ref-core)
+
+
+(setq org-ref-insert-link-function 'org-ref-insert-link
+      org-ref-insert-cite-function 'org-ref-insert-cite-link
+      org-ref-insert-label-function 'org-ref-insert-label-link
+      org-ref-insert-ref-function 'org-ref-insert-ref-link
+      org-ref-cite-onclick-function (lambda (_) (org-ref-citation-menu)))
+
+
+;;* The end
+(provide 'org-ref)
+
+;;; org-ref.el ends here
diff --git a/elpa/org-ref-20251206.1422/org-ref.org b/elpa/org-ref-20251206.1422/org-ref.org
new file mode 100644 (file)
index 0000000..43cd878
--- /dev/null
@@ -0,0 +1,1109 @@
+#+TITLE: The org-ref manual (version 3)
+#+AUTHOR: John Kitchin
+#+DATE: [2021-08-25 Wed]
+#+OPTIONS: toc:nil ^:{}
+#+LATEX_HEADER: \usepackage{natbib}
+#+LATEX_HEADER: \usepackage[version=3]{mhchem}
+#+latex_header: \usepackage{makeidx}
+#+latex_header: \usepackage{cleveref}
+#+latex_header: \makeindex
+# This ridiculousness is to make the index start in the middle of a page.
+# https://tex.stackexchange.com/questions/23870/index-shouldnt-start-new-page
+#+latex_header: \makeatletter
+#+latex_header: \renewenvironment{theindex}
+#+latex_header:                {\section*{\indexname}%
+#+latex_header:                 \@mkboth{\MakeUppercase\indexname}%
+#+latex_header:                         {\MakeUppercase\indexname}%
+#+latex_header:                 \thispagestyle{plain}\parindent\z@
+#+latex_header:                 \parskip\z@ \@plus .3\p@\relax
+#+latex_header:                 \columnseprule \z@
+#+latex_header:                 \columnsep 35\p@
+#+latex_header:                 \let\item\@idxitem}
+#+latex_header:                {}
+#+latex_header: \makeatother
+
+#+latex_header: \usepackage{glossaries}
+#+latex_header: \makeglossaries
+#+latex_header_extra: \newglossaryentry{acronym}{name={acronym},description={An acronym is an abbreviation used as a word which is formed from the initial components in a phrase or a word. Usually these components are individual letters (as in NATO or laser) or parts of words or names (as in Benelux)}}
+#+latex_header_extra: \newacronym{tla}{TLA}{Three Letter Acronym}
+
+@@latex:\maketitle@@
+@@latex:\tableofcontents@@
+
+* Introduction to org-ref
+
+Org-ref is a library for org-mode [[cite:&Dominik201408]] that provides rich support for citations, labels and cross-references in org-mode. org-ref is especially suitable for org-mode documents destined for LaTeX export and scientific publication. org-ref is also extremely useful for research documents and notes. org-ref bundles several other libraries that provide functions to create and modify bibtex entries from a variety of sources, but most notably from a DOI.
+
+The basic idea of org-ref is that it defines a convenient interface to insert citations from a reference database (e.g. from a bibtex file(s)), cross-references to targets in the document, and a set of functional org-mode links for citations, cross-references and labels that export properly to LaTeX, and that provide clickable functionality to the user. org-ref uses [[https://github.com/tmalsburg/helm-bibtex][bibtex-completion]] for the candidates you can use for citations.
+
+org-ref provides a fairly large number of utilities for finding bad citations, extracting bibtex entries from citations in an org-file, and functions for interacting with bibtex entries. We find these utilities indispensable in scientific writing.
+
+org-ref has been in development since sometime in 2013. It was written to aid in the preparation of scientific manuscripts. These are the first dozen scientific articles we wrote with it:
+
+- cite:hallenbeck-2013-effec
+- cite:mehta-2014-ident-poten
+- cite:xu-2014-relat-elect
+- cite:xu-2014-probin-cover
+- cite:miller-2014-simul-temper
+- cite:curnan-2014-effec-concen
+- cite:boes-2015-estim-bulk
+- cite:xu-2015-linear-respon
+- cite:xu-2015-relat-between
+- cite:boes-2016-neural-networ
+- cite:boes-2017-neural-networ
+- cite:xu-2017-first-princ
+
+
+Be sure to check out the supporting information files for each of these. The org source for the supporting information is usually embedded in the supporting information. You may also find these two perspective articles cite:kitchin-2015-examp,kitchin-2015-data-surfac-scien interesting, as well as this article on data sharing cite:kitchin-2016-autom-data we wrote.
+
+
+Biblatex users should read section ref:sec-biblatex-users.
+
+If you want to export this document to another format like PDF or HTML, see section ref:sec-other-forms.
+
+** 2021 version 2 vs version 3
+
+A new citation syntax was recently (2021) integrated into org-mode. Initially I thought this would make at least the citation part of org-ref obsolete. I no longer think that is the case though. One of the goals of org-ref is to provide complete coverage of natbib/biblatex citation commands, with syntax that is close to what you would write in LaTeX, and that is close to what you would read in the LaTeX documentation. The new org-mode citation syntax does not do that. It uses a very different notion of citation and bibliography style syntax. I still think there is significant value to new writers, as well as more experienced writers who are very familiar with LaTeX to use the org-ref approach.
+
+An early criticism of org-ref was its limited capability to support prenote/postnote syntax, especially for multiple citations. It turns out to be reasonably straightforward to support this, and version 3 does fully support the same syntax as the org-mode citation syntax, and it supports common prefix/suffix text, as well as local prefix/suffix text on each citation reference. I have intentionally chosen to use =&= as the prefix for bibtex keys in org-ref, so that it is explicitly different than the one org-cite uses (=@=) to reduce confusion about which syntax you are using.
+
+ [[citep:See; in &kitchin-2015-examp page 12; in &kitchin-2015-data-surfac-scien figure 6; for examples]]
+
+You can use both version 2 and version 3 syntax in the same document (although you should not mix them in the same citation). Here are the same citations from above in version 3 syntax.
+
+- cite:&hallenbeck-2013-effec
+- cite:&mehta-2014-ident-poten
+- cite:&xu-2014-relat-elect
+- cite:&xu-2014-probin-cover
+- cite:&miller-2014-simul-temper
+- cite:&curnan-2014-effec-concen
+- cite:&boes-2015-estim-bulk
+- cite:&xu-2015-linear-respon
+- cite:&xu-2015-relat-between
+- cite:&boes-2016-neural-networ
+- cite:&boes-2017-neural-networ
+- cite:&xu-2017-first-princ
+
+You should not mix org-ref links and org-cite citations. They are treated separately and you are not likely to get what you want.
+
+Another criticism was that non-LaTeX exports were usually not that good because org-ref either implemented a minimal formatting engine, and because my early effort at developing a citeproc in org-ref fizzled out. Now, there is citeproc-el, and org-ref supports that for export.
+
+The new citation syntax does not cover labels and cross-references, which are essential in our scientific writing. org-ref continues to support this. We anticipate a long life for org-ref.
+
+Should you use org-ref? If your main export target is LaTeX, and you want cross-references, then probably so.
+
+If you have no need for cross-references (either you don't use them, or vanilla org syntax is adequate), or if you don't like using ivy, and don't want to roll your own citation inserter, then you may not need org-ref.
+
+At this time, I have not integrated the org-cite capability I wrote in https://github.com/jkitchin/org-ref-cite into org-ref. I have not decided if that is a good or bad idea to do.
+
+
+** known issues with org-ref and org-citations
+
+You should not try to define a cite/*: (i.e. do not define a link type that starts with cite/) link. org-cite will probably think it is an org-citation.
+
+** Basic configuration <<basic-configuration>>
+
+You have to setup bibtex-completion variables if you want default bibliographies, notes, pdfs, and other features. You should also set the bibtex-autokey-* variables for generating bibtex keys if you use doi-utils.
+
+Here is the setup I use.
+
+#+BEGIN_SRC emacs-lisp
+(use-package ivy-bibtex
+  :init
+  (setq bibtex-completion-bibliography '("~/Dropbox/emacs/bibliography/references.bib"
+                                        "~/Dropbox/emacs/bibliography/dei.bib"
+                                        "~/Dropbox/emacs/bibliography/master.bib"
+                                        "~/Dropbox/emacs/bibliography/archive.bib")
+       bibtex-completion-library-path '("~/Dropbox/emacs/bibliography/bibtex-pdfs/")
+       bibtex-completion-notes-path "~/Dropbox/emacs/bibliography/notes/"
+       bibtex-completion-notes-template-multiple-files "* ${author-or-editor}, ${title}, ${journal}, (${year}) :${=type=}: \n\nSee [[cite:&${=key=}]]\n"
+
+       bibtex-completion-additional-search-fields '(keywords)
+       bibtex-completion-display-formats
+       '((article       . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${journal:40}")
+         (inbook        . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} Chapter ${chapter:32}")
+         (incollection  . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${booktitle:40}")
+         (inproceedings . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${booktitle:40}")
+         (t             . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*}"))
+       bibtex-completion-pdf-open-function
+       (lambda (fpath)
+         (call-process "open" nil 0 nil fpath))))
+
+(use-package org-ref
+  :ensure nil
+  :load-path (lambda () (expand-file-name "org-ref" scimax-dir))
+  :init
+  (add-to-list 'load-path
+              (expand-file-name "org-ref" scimax-dir))
+  (require 'bibtex)
+  (setq bibtex-autokey-year-length 4
+       bibtex-autokey-name-year-separator "-"
+       bibtex-autokey-year-title-separator "-"
+       bibtex-autokey-titleword-separator "-"
+       bibtex-autokey-titlewords 2
+       bibtex-autokey-titlewords-stretch 1
+       bibtex-autokey-titleword-length 5)
+  (define-key bibtex-mode-map (kbd "H-b") 'org-ref-bibtex-entry-menu)
+  (define-key org-mode-map (kbd "C-c ]") 'org-ref-insert-link)
+  (define-key org-mode-map (kbd "s-[") 'org-ref-insert-link-menu)
+  (require 'org-ref-ivy)
+  (require 'org-ref-arxiv)
+  (require 'org-ref-scopus)
+  (require 'org-ref-wos))
+
+
+(use-package org-ref-ivy
+  :ensure nil
+  :load-path (lambda () (expand-file-name "org-ref" scimax-dir))
+  :init (setq org-ref-insert-link-function 'org-ref-insert-link-menu
+             org-ref-insert-cite-function 'org-ref-cite-insert-ivy
+             org-ref-insert-label-function 'org-ref-insert-label-link
+             org-ref-insert-ref-function 'org-ref-insert-ref-link
+             org-ref-cite-onclick-function (lambda (_) (org-ref-citation-menu))))
+#+END_SRC
+
+
+** Basic usage of org-ref
+
+*** Bibliography links
+index:bibliography index:bibliographystyle
+
+org-ref provides a bibliography link to specify which bibtex files to use in the document.
+
+1. A comma separated list of relative or absolute paths
+2. A comma separated list of files found in your BIBINPUTS environment variable
+
+This link is clickable; clicking on a filename will open the file. On export, the bibliography will appear at the position where the link is defined. Usually this link goes near the end of your document, e.g. like [[bibliography link][here]].
+
+There is also a nobibliography link, which is useful for specifying a bibliography file, but not listing a bibliography in the exported document.
+
+There is also a bibliographystyle link that specifies the style. This link does nothing but export to a LaTeX command. For LaTeX export a bibliography and bibliographystyle link is /required/ if you use bibtex. If you use biblatex see ref:sec-biblatex-users.
+
+These links support completion, so you can type C-c C-l, choose one of them, and it will help you complete the link.
+
+*** Citations <<citations>>
+
+index:cite
+
+org-ref uses the [[bibliography link]] to determine which bibtex files to get citations from, and falls back to the bibtex files defined in the variable ~bibtex-completion-bibliography~  if no bibliography link is found. Note that you *must* include a [[bibliography link]] in your document if you are exporting your document to pdf; ~bibtex-completion-bibliography~ is not used by the [[BibTeX users][LaTeX exporter]].
+
+For simple citation needs, ords, year, BibTeX key and entry types. If you want to match any other field, you need to add it to the variable ~bibtex-completion-additional-search-fields~.
+
+If the cursor is on a citation key, you should see a tooltip that summarizes which citation it refers to. If you click on a key, you should get a transient menu with some actions to choose, including opening the bibtex entry, opening/getting a pdf for the entry, searching the entry in Web of Science, etc...
+
+The default citation type is customizable (=org-ref-default-citation-link=), and set to "cite".
+
+See http://tug.ctan.org/macros/latex/contrib/natbib/natnotes.pdf for the cite commands supported in bibtex index:natbib, and http://ctan.mirrorcatalogs.com/macros/latex/contrib/biblatex/doc/biblatex.pdf for the commands supported in biblatex. index:biblatex.
+
+If the cursor is on a citation, or at the end of the citation, and you add another citation, it will be appended to the current citation.
+
+[[index:cite!shift]]
+Finally, if you do not like the order of the keys in a citation, you can put your cursor on a key and use shift-arrows (left or right) to move the key around. Alternatively, you can use shift-up or you can run the command ~org-ref-sort-citation-link~ which will sort the keys by year, oldest to newest.
+
+Alternatively, there is a keymap defined on cite links. By default this map is defined in the variable ~org-ref-cite-keymap~.
+
+There are navigation bindings that work on a cite link.
+
+| C-left  | Jump to previous key  |
+| C-right | Jump to next key      |
+| S-left  | move key to the left  |
+| S-right | move key to the right |
+
+You can also sort a cite link with multiple keys by year.
+
+| S-up | sort keys by ascending year |
+
+*** Pre/post text support
+
+org-ref has two versions of syntax. In version 2 there is very limited support for pre/post text in citations. You can get pre/post text by using a description in a cite link, with pre/post text separated by ::. For example, [[citep:Dominik201408][See page 20::, for example]]. I do not recommend you use this anymore.
+
+version 3 is much more capable, similar to the new org-cite syntax. The general syntax is:
+
+=Common prefix; prenote 1 &key1 postnote1; prenote n &keyn postnote n; Common suffix=
+
+The tradeoff is you have to prefix the keys with &,&nbt; use biblatex with a multicite if you need that in your citations. There are still a few caveats. Natbib only supports a single set of pre/post notes; some citation styles with biblatex support the full syntax. Not all cite types in LaTeX support pre/post text (e.g. cite, citenum do not support them), so be careful when you use them.
+
+
+*** labels
+    :PROPERTIES:
+    :CUSTOM_ID: sec-label-link
+    :END:
+index:label
+
+LaTeX uses labels to define places you can refer to. These can be labels in the captions of figures and tables, or labels in sections. We illustrate some uses here. You can use label links, but it is preferred to use name keywords or other native org label mechanisms.
+
+Here is a way to use a label link:
+
+#+caption: Another simple table. label:tab-ydata
+| y |
+| 4 |
+| 5 |
+
+This is the preferred way to label a table.
+
+#+name: tab-ydata-name
+#+caption: Another simple table. 
+| y |
+| 4 |
+| 5 |
+
+org-ref can help you insert unique labels with the command =org-ref-insert-label-link=. This will show you the existing labels, and insert your new label as a link. There is no default key-binding for this.
+
+*** ref links <<ref-links>>
+index:ref
+
+A ref link refers to a label of some sort. You can use the label in a name keyword, a LaTeX label, a CUSTOM_ID property, a label link (ref:sec-label-link), or a radio target.
+
+
+For example, you can refer to a table name, e.g. Table ref:table-1. You have to provide the context before the ref link, e.g. Table, Figure, Equation, Section, and so on.
+
+#+name: table-1
+#+caption: A simple table.
+| x |
+| 1 |
+| 2 |
+
+Or you can refer to an org-mode label as in Table ref:table-3.
+
+
+Note: You may need to set org-latex-prefer-user-labels to t if you refer to things by their "name" for the export to use the name you create.
+
+#+BEGIN_SRC emacs-lisp :results silent
+(setq org-latex-prefer-user-labels t)
+#+END_SRC
+
+
+#+caption: Another simple table. label:table-3
+| y |
+|---|
+| 3 |
+| 2 |
+
+You can also refer to an org-ref label link as in Table ref:tab-ydata.
+
+To help you insert ref links, use the "Org -> org-ref -> Insert ref" menu, or run the command = org-ref-insert-ref-link=.
+
+ref links are functional. If you put the cursor on a ref link, you will see a tooltip with some context of the corresponding label. If you click on the ref link, you will open a transient menu to jump to it or change the ref type.
+
+You can make a ref link to a section with a CUSTOM_ID. For this to work, you should set ~org-latex-prefer-user-labels~ to t.
+
+Also note that "#+tblname:" and "#+label:" are deprecated in org-mode now, and "#+name:" is preferred.
+
+**** Miscellaneous ref links  label:sec-misc
+index:ref!pageref index:ref!nameref index:ref!eqref
+
+org-ref also provides these links:
+
+- pageref :: The page a label is on
+- nameref :: The name of a section a label is in
+- eqref :: Puts the equation number in parentheses
+- autoref :: A command from hyperref that automatically prefixes the reference number. (requires hyperref)
+- cref & Cref :: [[https://www.ctan.org/tex-archive/macros/latex/contrib/cleveref?lang=en][cleveref – Intelligent cross-referencing]]
+- crefrange & Crefrange ::  [[https://www.ctan.org/tex-archive/macros/latex/contrib/cleveref?lang=en][cleveref – Intelligent cross-referencing]]
+
+Note for eqref, you must use a LaTeX label like this:
+
+\begin{equation} \label{eq:1}
+e^x = 4
+\end{equation}
+
+or a named equation like this:
+
+#+name: eq-in-name
+\begin{equation}
+e^x = 4
+\end{equation}
+
+Then you can refer to Eq. eqref:eq:1 or ref:eq-in-name in your documents.
+
+Autoref works like this: autoref:table-3, autoref:sec-misc.
+
+The crefranges require two labels to define the range: Crefrange:table-1,table-3  and crefrange:table-1,table-3
+
+These links do not have much meaning outside of LaTeX.
+
+*** Some other links
+[[index:list of tables]] [[index:list of figures]]
+
+org-ref provides clickable links for a =[[list-of-tables:]]= and =[[list-of-figures:]]=. These links don't need a path, so you have to put them in brackets. These export as listoftables and listoffigures LaTeX commands, and they are clickable links that open a mini table of contents with links to the tables and figures in the buffer. There are also interactive commands for this: elisp:org-ref-list-of-tables and elisp:org-ref-list-of-figures.
+
+
+** Some basic org-ref utilities
+[[index:bibtex!clean entry]]
+
+The command ~org-ref~ does a lot for you automatically. It will check the buffer for errors, e.g. multiply-defined labels, bad citations or ref links, and provide easy access to a few commands through a side-window buffer.
+
+~org-ref-clean-bibtex-entry~ will sort the fields of a bibtex entry, clean it, and give it a bibtex key. By default, this function does a lot of cleaning:
+
+1. adds a comma if needed in the first line of the entry
+2. makes sure the DOI field is an actual DOI, and not a URL
+3. fixes bad year entries
+4. fixes empty pages
+5. escapes ampersand and percentage signs
+6. generate a key according to your setup
+7. runs your hook functions
+8. sorts the fields in the entry
+9. checks the entry for non-ascii characters
+10. converts article title to title case (note: see below to convert titles in other entry types)
+
+
+
+This function has a hook ~org-ref-clean-bibtex-entry-hook~, which you can add functions to of your own. Each function must work on a bibtex entry at point. (Note: the default behavior can be changed by removing the relevant functions from the initial value of ~org-ref-clean-bibtex-entry-hook~.)
+
+Here are the functions run on cleaning:
+
+#+BEGIN_SRC emacs-lisp :exports both
+org-ref-clean-bibtex-entry-hook
+#+END_SRC
+
+#+RESULTS:
+| org-ref-bibtex-format-url-if-doi | orcb-key-comma | org-ref-replace-nonascii | orcb-& | orcb-% | org-ref-title-case-article | orcb-clean-year | orcb-key | orcb-clean-doi | orcb-clean-pages | orcb-check-journal | org-ref-sort-bibtex-entry | orcb-fix-spacing |
+
+You can add your own function to the hook like this.
+
+#+BEGIN_SRC emacs-lisp
+(add-hook 'org-ref-clean-bibtex-entry-hook 'org-ref-replace-nonascii)
+#+END_SRC
+
+~org-ref-extract-bibtex-entries~ will create a bibtex file from the citations in the current buffer.
+
+** LaTeX export
+index:export!LaTeX
+
+All org-ref links are designed to export to the corresponding LaTeX commands for citations, labels, refs and the bibliography/bibliography style. Once you have the LaTeX file, you have to build it, using the appropriate latex and bibtex commands. You can have org-mode do this for you with a setup like:
+
+#+BEGIN_SRC emacs-lisp
+(setq org-latex-pdf-process
+      '("pdflatex -interaction nonstopmode -output-directory %o %f"
+       "bibtex %b"
+       "pdflatex -interaction nonstopmode -output-directory %o %f"
+       "pdflatex -interaction nonstopmode -output-directory %o %f"))
+#+END_SRC
+
+I have also had success with this setup:
+
+#+BEGIN_SRC emacs-lisp
+(setq org-latex-pdf-process (list "latexmk -shell-escape -bibtex -f -pdf %f"))
+#+END_SRC
+
+*** BibTeX users
+
+To have your citations compiled by BibTex, you *must* include a [[bibliography link]].  You will also need to include a [[bibliographystyle link]], unless you are using a LaTeX style that includes that for you.
+
+Note that some citation types may require additional LaTeX packages to be included in your export settings.
+
+Here are the natbib types (these will export in LaTeX with the unsrtnat style). These will export differently in author-year styles.
+
+Here are some examples of the pre/post note syntax for each natbib type. Not all of these make sense. For example the plain cite command does not take pre/post notes, even with natbib. If you use these a lot, you should use citet/citep. Not all of the commands take pre/post notes, e.g. citenum.
+
+
+- =[[citet:See &kitchin-2015-examp page 2]]= :: [[citet:See &kitchin-2015-examp page 2]]
+- =[[citet*:See &kitchin-2015-examp page 2]]= :: [[citet*:See &kitchin-2015-examp page 2]]
+- =[[citep:See &kitchin-2015-examp page 2]]= :: [[citep:See &kitchin-2015-examp page 2]]
+- =[[citep*:See &kitchin-2015-examp page 2]]= :: [[citep*:See &kitchin-2015-examp page 2]]
+- =[[citealt:See &kitchin-2015-examp page 2]]= :: [[citealt:See &kitchin-2015-examp page 2]]
+- =[[citealt*:See &kitchin-2015-examp page 2]]= :: [[citealt*:See &kitchin-2015-examp page 2]]
+- =[[citealp:See &kitchin-2015-examp page 2]]= :: [[citealp:See &kitchin-2015-examp page 2]]
+- =[[citealp*:See &kitchin-2015-examp page 2]]= :: [[citealp*:See &kitchin-2015-examp page 2]]
+- =[[citenum:&kitchin-2015-examp]]= :: [[citenum:&kitchin-2015-examp]]
+- =[[citetext:See &kitchin-2015-examp page 2]]= :: [[citetext:See &kitchin-2015-examp page 2]]
+- =[[citeauthor:See &kitchin-2015-examp page 2]]= :: [[citeauthor:See &kitchin-2015-examp page 2]]
+- =[[citeauthor*:See &kitchin-2015-examp page 2]]= :: [[citeauthor*:See &kitchin-2015-examp page 2]]
+- =[[citeyear:See &kitchin-2015-examp page 2]]= :: [[citeyear:See &kitchin-2015-examp page 2]]
+- =[[citeyearpar:See &kitchin-2015-examp page 2]]= :: [[citeyearpar:See &kitchin-2015-examp page 2]]
+- =[[Citet:See &kitchin-2015-examp page 2]]= :: [[Citet:See &kitchin-2015-examp page 2]]
+- =[[Citet*:See &kitchin-2015-examp page 2]]= :: [[Citet*:See &kitchin-2015-examp page 2]]
+- =[[Citep:See &kitchin-2015-examp page 2]]= :: [[Citep:See &kitchin-2015-examp page 2]]
+- =[[Citep*:See &kitchin-2015-examp page 2]]= :: [[Citep*:See &kitchin-2015-examp page 2]]
+- =[[Citealt:See &kitchin-2015-examp page 2]]= :: [[Citealt:See &kitchin-2015-examp page 2]]
+- =[[Citealt*:See &kitchin-2015-examp page 2]]= :: [[Citealt*:See &kitchin-2015-examp page 2]]
+- =[[Citealp:See &kitchin-2015-examp page 2]]= :: [[Citealp:See &kitchin-2015-examp page 2]]
+- =[[Citealp*:See &kitchin-2015-examp page 2]]= :: [[Citealp*:See &kitchin-2015-examp page 2]]
+- =[[Citeauthor:See &kitchin-2015-examp page 2]]= :: [[Citeauthor:See &kitchin-2015-examp page 2]]
+- =[[Citeauthor*:See &kitchin-2015-examp page 2]]= :: [[Citeauthor*:See &kitchin-2015-examp page 2]]
+
+
+*** biblatex users  <<sec-biblatex-users>>
+
+In the latex header you specify the style and bibliography file using addbibresource. Here is an example:
+
+#+BEGIN_EXAMPLE
+#+latex_header: \usepackage[citestyle=authoryear-icomp,bibstyle=authoryear, hyperref=true,backref=true,maxcitenames=3,url=true,backend=biber,natbib=true] {biblatex}
+#+latex_header: \addbibresource{tests/test-1.bib}
+#+END_EXAMPLE
+
+Sometimes it is necessary to tell bibtex what dialect you are using to support the different bibtex entries that are possible in biblatex. You can do it like this globally.
+
+#+BEGIN_SRC emacs-lisp
+(setq bibtex-dialect 'biblatex)
+#+END_SRC
+
+#+RESULTS:
+: biblatex
+
+Or like this in a bibtex file:
+#+BEGIN_EXAMPLE
+% -*- mode:bibtex; eval: (bibtex-set-dialect 'biblatex); -*-
+#+END_EXAMPLE
+
+Make sure you invoke biblatex in the org-latex-pdf-process. Here is one way to do it.
+
+#+BEGIN_SRC emacs-lisp
+(setq  org-latex-pdf-process '("latexmk -shell-escape -bibtex -pdf %f"))
+#+END_SRC
+
+Finally, where you want the bibliography put this empty link:
+
+#+BEGIN_EXAMPLE
+[[printbibliography:]]
+#+END_EXAMPLE
+
+The regular biblatex cite links support common pre/post notes, and multiple keys. These are:
+
+#+BEGIN_SRC emacs-lisp :exports both
+org-ref-biblatex-types
+#+END_SRC
+
+#+RESULTS:
+| Cite         |
+| parencite    |
+| Parencite    |
+| footcite     |
+| footcitetext |
+| textcite     |
+| Textcite     |
+| smartcite    |
+| Smartcite    |
+| cite*        |
+| parencite*   |
+| supercite    |
+| autocite     |
+| Autocite     |
+| autocite*    |
+| Autocite*    |
+| Citeauthor*  |
+| citetitle    |
+| citetitle*   |
+| citedate     |
+| citedate*    |
+| citeurl      |
+| fullcite     |
+| footfullcite |
+| notecite     |
+| Notecite     |
+| pnotecite    |
+| Pnotecite    |
+| fnotecite    |
+
+The multitype links support common pre/postnotes, and individual pre/post notes.  These are the multicite commands:
+
+#+BEGIN_SRC emacs-lisp :exports both
+org-ref-biblatex-multitypes
+#+END_SRC
+
+#+RESULTS:
+| cites         |
+| Cites         |
+| parencites    |
+| Parencites    |
+| footcites     |
+| footcitetexts |
+| smartcites    |
+| Smartcites    |
+| textcites     |
+| Textcites     |
+| supercites    |
+| autocites     |
+| Autocites     |
+
+
+Here is a full example. This only exports correctly in biblatex or with CSL, so I include it as an example here.
+
+#+BEGIN_EXAMPLE
+ [[cites:See; in &kitchin-2015-examp page 1;in &kitchin-2015-data-surfac-scien page 2;and in &kitchin-2016-autom-data page 3; for examples]]
+#+END_EXAMPLE
+
+
+** Other exports
+index:export!html index:export!ascii  index:export!latex  index:export!markdown  index:export!odt
+
+All other exports are handled by citeproc now. This is done by preprocessing in a dedicated exporter called org-ref. There is a new entry in the export menu
+
+| C-c C-e r h | html       |
+| C-c C-e r m | md         |
+| C-c C-e r a | ascii      |
+| C-c C-c r o | odt        |
+| C-c C-e r l | latex      |
+| C-c C-c r O | org buffer |
+
+
+* org-ref-export
+
+org-ref now supports the use of citeproc-el to export citations to non-LaTeX backends. See section [[sec-other-forms]] for more details. You can also use [[./org-ref-natbib-bbl-citeproc.el]]
+
+* org-refproc
+
+org-ref also supports exporting cross-references to other formats using [[./org-ref-refproc.el]]. This library also works by pre-processing a copy of the buffer to convert org-ref cross-reference links to org-syntax before exporting to the target backend. This even support cleveref style links with automatic prefixing and sorting. Compression of the references is not yet supported.
+
+See  [[./examples/refproc.org]] for a pretty comprehensive set of examples.
+
+* Other libraries in org-ref
+
+These are mostly functions for adding entries to bibtex files, modifying entries or for operating on bibtex files. Some new org-mode links are defined.
+
+** doi-utils
+index:doi
+
+This library adds two extremely useful tools for getting bibtex entries and pdf files of journal manuscripts. Add this to your emacs setup:
+#+BEGIN_SRC emacs-lisp
+(require 'doi-utils)
+#+END_SRC
+
+This provides two important commands:
+
+- ~doi-utils-add-bibtex-entry-from-doi~
+This will prompt you for a DOI, and a bibtex file, and then try to get the bibtex entry. Adds the entry to the bibtex file if successful. Automatically calls ~org-ref-clean-bibtex-entry~.
+
+- ~doi-utils-add-entry-from-crossref-query~
+This will prompt you for a query string, which is usually the title of an article, or a free-form text citation of an article. Searches using [[https://www.crossref.org/][Crossref.org]], then prompts in the minibuffer with a list of matching items, which you can choose from to insert a new bibtex entry into a bibtex file. Also calls ~org-ref-clean-bibtex-entry~.
+
+This library also redefines the org-mode doi link. Now, when you click on this link you will get a menu of options, e.g. to open a bibtex entry or a pdf if you have it, or to search the doi in some scientific search engines. Try it out  doi:10.1021/jp511426q.
+
+*** Bibtex key format
+
+The key is formatted according to the settings of bibtex-autokey-* variables. I use these settings. Look at the documentation of them to see how to get the format you want. The function (bibtex-generate-autokey) does this.
+
+The settings I use are:
+
+#+BEGIN_SRC emacs-lisp
+(setq bibtex-autokey-year-length 4
+       bibtex-autokey-name-year-separator "-"
+       bibtex-autokey-year-title-separator "-"
+       bibtex-autokey-titleword-separator "-"
+       bibtex-autokey-titlewords 2
+       bibtex-autokey-titlewords-stretch 1
+       bibtex-autokey-titleword-length 5)
+#+END_SRC
+
+*** Troubleshooting doi-utils
+
+Occasionally weird things happen with a DOI. The first thing you should check is if the json data for the DOI can be retrieved. You can do that at the command line, or in a sh block like this:
+
+#+BEGIN_SRC sh
+curl -LH "Accept: application/citeproc+json" "http://doi.org/10.1021/jp511426q"
+#+END_SRC
+
+If you do not get json data, doi-utils will not be able to generate the bibtex entry.
+
+Not all PDFs can be retrieved. doi-utils uses a set of functions to attempt this. Here is the list.
+
+#+BEGIN_SRC emacs-lisp :exports both
+doi-utils-pdf-url-functions
+#+END_SRC
+
+#+RESULTS:
+| aps-pdf-url                 |
+| science-pdf-url             |
+| nature-pdf-url              |
+| wiley-pdf-url               |
+| springer-chapter-pdf-url    |
+| springer-pdf-url            |
+| acs-pdf-url-1               |
+| acs-pdf-url-2               |
+| acs-pdf-url-3               |
+| iop-pdf-url                 |
+| jstor-pdf-url               |
+| aip-pdf-url                 |
+| science-direct-pdf-url      |
+| linkinghub-elsevier-pdf-url |
+| tandfonline-pdf-url         |
+| ecs-pdf-url                 |
+| ecst-pdf-url                |
+| rsc-pdf-url                 |
+| pnas-pdf-url                |
+| copernicus-pdf-url          |
+| sage-pdf-url                |
+| jneurosci-pdf-url           |
+| ieee-pdf-url                |
+| ieee2-pdf-url               |
+| ieee3-pdf-url               |
+| acm-pdf-url                 |
+| osa-pdf-url                 |
+| asme-biomechanical-pdf-url  |
+| siam-pdf-url                |
+| agu-pdf-url                 |
+| plos-pdf-url                |
+| generic-full-pdf-url        |
+
+You can check if a url for the PDF can be found like this. If you get a url, you can probably download a pdf.
+
+#+BEGIN_SRC emacs-lisp :exports both
+(doi-utils-get-pdf-url "10.1021/jp511426q")
+#+END_SRC
+
+#+RESULTS:
+: https://pubs.acs.org/doi/pdf/10.1021/jp511426q
+
+** org-ref-bibtex
+
+These are functions I use often in bibtex files.
+
+*** Generate new bibtex files with adapted journal names
+
+The variable ~org-ref-bibtex-journal-abbreviations~ contains a mapping of a short string to a full journal title, and an abbreviated journal title. We can use these to create new versions of a bibtex file with full or abbreviated journal titles. You can add new strings like this:
+
+#+BEGIN_SRC emacs-lisp
+(add-to-list 'org-ref-bibtex-journal-abbreviations
+  '("JIR" "Journal of Irreproducible Research" "J. Irrep. Res."))
+#+END_SRC
+
+- org-ref-bibtex-generate-longtitles :: Generate a bib file with long titles as
+     defined in `org-ref-bibtex-journal-abbreviations'
+- org-ref-bibtex-generate-shorttitles :: Generate a bib file with short titles as
+     defined in `org-ref-bibtex-journal-abbreviations'
+
+*** Modifying bibtex entries
+
+- org-ref-stringify-journal-name :: replace a journal name with a string in
+     `org-ref-bibtex-journal-abbreviations'
+- org-ref-set-journal-string :: in a bibtex entry run this to replace the journal
+     with a string selected interactively.
+
+- org-ref-title-case-article :: title case the title in an article entry.
+- org-ref-title-case :: title case the title for entries listed in `org-ref-title-case-types'.
+- org-ref-sentence-case-article :: sentence case the title in an article entry.
+
+- org-ref-replace-nonascii :: replace nonascii characters in a bibtex
+     entry. Replacements are in `org-ref-nonascii-latex-replacements'. This
+     function is a hook function in org-ref-clean-bibtex-entry.
+
+The non-ascii characters are looked up in a list of cons cells. You can add your own non-ascii replacements like this. Note backslashes must be escaped doubly, so one =\= is =\\\\= in the cons cell.
+
+#+BEGIN_SRC emacs-lisp
+(add-to-list 'org-ref-nonascii-latex-replacements
+  '("æ" . "{\\\\ae}"))
+#+END_SRC
+
+These functions are compatible with ~bibtex-map-entries~, so it is possible to conveniently apply them to all the entries in a file like this:
+
+#+BEGIN_SRC emacs-lisp
+(bibtex-map-entries 'org-ref-title-case-article)
+#+END_SRC
+
+*** Bibtex entry navigation
+
+- org-ref-bibtex-next-entry :: bound to M-n
+- org-ref-bibtex-previous-entry :: bound to M-p
+
+*** Transient menus for bibtex entries and files
+
+- Functions to act on a bibtex entry or file
+  - org-ref-bibtex-entry-menu :: opens a transient menu with many useful functions
+       like opening the pdf, or the entry in a browser, or searching in a
+       variety of scientific search engines.
+  - org-ref-bibtex-new-entry-menu :: opens a transient menu to add new bibtex entries.
+  - org-ref-bibtex-file-menu :: opens a transient menu of actions for the bibtex file.
+
+You will want to bind the transient menus to a key. You only need to bind the first one, as the second and third can be accessed from the first menu.
+
+*** Formatted bibtex entry citations
+
+If you click on a citation link, there should be a menu option to copy a formatted citation, which will copy the citation string to the clipboard. This is a lightly formatted version using bibtex-completion.
+
+If you are on a bibtex entry, the `org-ref-bibtex-entry-menu' has an option to copy a formatted citation for the entry your cursor is in.
+
+
+** org-ref-wos
+This is a small utility for Web of Science/Knowledge (WOK) (http://apps.webofknowledge.com).
+
+#+BEGIN_SRC emacs-lisp
+(require 'org-ref-wos)
+#+END_SRC
+
+#+RESULTS:
+: org-ref-wos
+
+- wos :: Convenience function to open WOK in a browser.
+- wos-search :: Search WOK with the selected text or word at point
+
+There is also a new org-mode link that opens a search: [[wos-search:alloy and segregation]]
+
+** org-ref-scopus
+This is a small utility to interact with Scopus (http://www.scopus.com). Scopus is search engine for scientific literature. It is owned by Elsevier. You must have a license to use it (usually provided by your research institution).
+
+#+BEGIN_SRC emacs-lisp
+(require 'org-ref-scopus)
+#+END_SRC
+
+#+RESULTS:
+: org-ref-scopus
+
+Interactive functions:
+
+- scopus :: Convenience function to open Scopus in a browser.
+- scopus-basic-search :: Prompts for a query and opens it in a browser.
+- scopus-advanced-search :: Prompts for an advanced query and opens it in a browser.
+
+Some new links:
+Open a basic search in Scopus: [[scopus-search:alloy Au segregation]]
+
+Open an advanced search in Scopus: scopus-advanced-search:au-id(7004212771). See http://www.scopus.com/search/form.url?display=advanced&clear=t for details on the codes and syntax, and http://help.elsevier.com/app/answers/detail/a_id/2347/p/8150/incidents.c$portal_account_name/26389.
+
+A functional link to a document in Scopus by its "EID": eid:2-s2.0-72649092395. Clicking on this link will open a transient menu to open the document in Scopus, find different kinds of related documents by keywords, authors or references, and to open a page in Scopus of citing documents.
+
+There is also a scopusid link for authors that will open their author page in Scopus: scopusid:7004212771
+
+** org-ref-isbn
+index:isbn
+
+#+BEGIN_SRC emacs-lisp
+(require 'org-ref-isbn)
+#+END_SRC
+
+#+RESULTS:
+: org-ref-isbn
+
+This library provides some functions to get bibtex entries for books from their ISBN.
+
+- isbn-to-bibtex
+- isbn-to-bibtex-lead
+
+It also provides some variables for customizing the bibtex entry.
+
+- org-ref-isbn-clean-bibtex-entry-hook
+- org-ref-isbn-exclude-fields
+- org-ref-isbn-field-name-replacements
+
+** org-ref-pubmed
+index:pubmed
+
+[[http://www.ncbi.nlm.nih.gov/pubmed][PubMed]] comprises more than 24 million citations for biomedical literature from MEDLINE, life science journals, and online books. Citations may include links to full-text content from PubMed Central and publisher web sites. This library provides some functions to initiate searches of PubMed from Emacs, and to link to PubMed content.
+
+#+BEGIN_SRC emacs-lisp
+(require 'org-ref-pubmed)
+#+END_SRC
+
+#+RESULTS:
+: org-ref-pubmed
+
+This library provides a number of new org-mode links to PubMed entries. See http://www.ncbi.nlm.nih.gov/pmc/about/public-access-info/#p3 for details of these identifiers. These links open the page in PubMed for the identifier.
+
+pmcid:PMC3498956
+
+pmid:23162369
+
+nihmsid:NIHMS395714
+
+Also, you can retrieve a bibtex entry for a PMID with
+
+- ~pubmed-insert-bibtex-from-pmid~
+
+There are some utility functions that may be helpful.
+
+- pubmed :: Open [[http://www.ncbi.nlm.nih.gov/pubmed][PubMed]] in a browser
+- pubmed-advanced :: Open [[http://www.ncbi.nlm.nih.gov/pubmed/advanced][PubMed]] at advanced search page.
+- pubmed-simple-search :: Prompts you for a simple query and opens it in PubMed.
+
+There is a new org-mode link to PubMed searches: [[pubmed-search:alloy segregation]]
+
+** org-ref-arxiv
+index:arxiv
+
+This library provides an org-mode link to http://arxiv.org entries:  arxiv:cond-mat/0410285, and a function to get a bibtex entry and pdfs for arxiv entries:
+
+#+BEGIN_SRC emacs-lisp
+(require 'org-ref-arxiv)
+#+END_SRC
+
+#+RESULTS:
+: org-ref-arxiv
+
+- ~arxiv-add-bibtex-entry~
+- ~arxiv-get-pdf~
+
+** org-ref-sci-id
+
+index:orcid [[index:researcher id]]
+
+#+BEGIN_SRC emacs-lisp
+(require 'org-ref-sci-id)
+#+END_SRC
+
+#+RESULTS:
+: org-ref-sci-id
+
+This package just defines two new org-mode links for http://www.orcid.org, and http://www.researcherid.com. Here are two examples:
+
+orcid:0000-0003-2625-9232
+
+researcherid:A-2363-2010
+
+** x2bib
+index:bibtex!conversion
+
+#+BEGIN_SRC emacs-lisp
+(require 'x2bib)
+#+END_SRC
+
+#+RESULTS:
+: x2bib
+
+If you find you need to convert some bibliographies in some format into bibtex, this library is a starting point. This code is mostly wrappers around the command line utilities at http://sourceforge.net/p/bibutils/home/Bibutils. I thankfully have not had to use this often, but it is here when I need it again.
+
+- ris2bib :: Convert an RIS file to a bibtex file.
+- medxml2bib :: Convert PubMed XML to bibtex.
+- clean-entries :: Map over a converted bibtex file and "clean it".
+
+** org-ref-latex
+
+This provides some org-ref like capabilities in LaTeX files, e.g. the links are clickable with tooltips.
+
+** org-ref-pdf
+
+=org-ref-pdf= allows Emacs to get bibliography information from pdf files that contain a DOI. You must have =pdftotext= installed where Emacs can find it. This library is known to not work on Windows very well.
+
+** org-ref-url-utils
+
+Allows you to drag-n-drop a webpage from a browser onto a bibtex file to add a bibtex entry (as long as it is from a recognized publisher that org-ref knows about). This library does not work well on Windows.
+
+* Appendix
+
+** Other things org-ref supports
+
+*** org-completion
+index:completion index:link!completion
+
+Most org-ref links support org-mode completion. You can type ~C-c C-l~ to insert a link. You will get completion of the link type, type some characters and press tab. When you select the type, press tab to see the completion options. This works for the following link types:
+
+- bibliography
+- bibliographystyle
+- all cite types
+- ref
+
+*** Indexes
+index:index
+
+org-ref provides links to support making an index in LaTeX. (http://en.wikibooks.org/wiki/LaTeX/Indexing).
+
+- index :: creates an index entry.
+- printindex :: Generates a temporary index of clickable entries. Exports to the LaTeX command.
+
+You will need to use the makeidx package, and use this in the LaTeX header.
+
+#+begin_example
+#+LATEX_HEADER: \usepackage{makeidx}
+#+LATEX_HEADER: \makeindex
+#+end_example
+
+You will have to incorporate running makeindex into your PDF build command.
+
+This is not supported in anything but LaTeX export.
+
+*** Glossaries and acronyms
+index:glossary
+
+org-ref provides some support for glossary and acronym definitions.
+- gls :: a reference to a term
+- glspl :: plural reference to a term
+- Gsl :: capitalized reference to a term
+- Glspl :: capitalized plural reference to a term
+- gslink :: Link to alternative text in the link description.
+- glssymbol :: The symbol term
+- glsdesc :: The description of the term
+
+- ac :: a reference to an acronym
+- Ac :: capitalized reference to an acronym
+- acp :: a plural reference to an acronym
+- Acp :: capitalized plural reference to an acronym
+- acrshort :: Short version of the acronym
+- acrfull :: The full definition of the acronym
+- acrlong :: The full definition of the acronym with (abbrv).
+
+There are two useful commands:
+- org-ref-add-glossary-entry :: Add a new entry to the file
+- org-ref-add-acronym-entry :: Add a new acronym to the file
+
+Here is an example of glossary link for an [[gls:acronym][acronym]] and an actual [[acrshort:tla][TLA]]. Each link has a tool tip on it that shows up when you hover the mouse over it. These links will export as the LaTeX commands need by the glossaries package.
+
+You will need to incorporate running the command makeglossaries into your PDF build command. You also need use the glossaries LaTeX package.
+
+Here is a minimal working example of an org file that makes a glossary.
+
+#+BEGIN_SRC org
+,#+latex_header: \usepackage{glossaries}
+,#+latex_header: \makeglossaries
+
+,#+latex_header_extra: \newglossaryentry{computer}{name=computer,description={A machine}}
+,#+latex_header_extra: \newacronym{tla}{TLA}{Three letter acronym}
+
+A gls:computer is good for computing. Gls:computer is capitalized. We can also use a bunch of glspl:computer to make a cluster. Glspl:computer are the wave of the future. Don't forget what a ac:tla is.
+
+\printglossaries
+#+END_SRC
+
+This is not supported in anything but LaTeX export.
+
+If you have a lot of glossary entries and you want to have them in an external file, you can put them in a tex file, and then include them in the org file like this. Here the glossary entries are saved in a file in the same directory as glossary.tex. This should still work with the tooltips.
+
+#+BEGIN_EXAMPLE
+#+latex_header: \loadglsentries[main]{glossary}
+#+END_EXAMPLE
+
+Finally, you can define the glossary entries in org tables like this. They will be deleted before a LaTeX export.
+
+#+BEGIN_EXAMPLE
+,#+title: Test
+,#+latex_header: \usepackage{glossaries}
+,#+latex_header: \makeglossaries
+
+
+# This will not show in your export. It must be named glossary
+,#+name: glossary
+| label | name  | description   |
+|-------+-------+---------------|
+| tree  | Tree  | A woody plant |
+| shrub | Shrub | A woody bush  |
+
+Checkout how a gls:tree differs from a gls:shrub.
+
+
+,#+name: acronyms
+| Key  | Short | Long                           |
+|------+-------+--------------------------------|
+| mimo |       | multiple-input multiple output |
+| qos  | QoS   | quality-of-service             |
+| bb   | BB    | branch and bound               |
+
+
+First ac:bb. Second ac:bb. First ac:qos. Second ac:qos.
+
+# This is where your glossary and acronym entries will be put.
+,#+latex: \printglossaries
+#+END_EXAMPLE
+
+\glsaddall
+\printglossaries
+
+
+** Other forms of this document <<sec-other-forms>>
+
+*** Build notes
+
+Before building this file you need to require the following libraries so the links will be resolved.
+
+ #+BEGIN_SRC emacs-lisp :results silent
+(require 'org-ref-wos)
+(require 'org-ref-scopus)
+(require 'org-ref-pubmed)
+(require 'org-ref-sci-id)
+ #+END_SRC
+
+
+*** PDF
+
+You may want to build a pdf of this file. Here is an emacs-lisp block that will create and open the PDF.
+
+ #+BEGIN_SRC emacs-lisp :results silent
+(let ((org-export-with-broken-links t)
+      (org-latex-pdf-process
+       '("pdflatex -interaction nonstopmode -shell-escape -output-directory %o %f"
+        "bibtex %b"
+        "makeindex %b"
+        "pdflatex -interaction nonstopmode -shell-escape -output-directory %o %f"
+        "pdflatex -interaction nonstopmode -shell-escape -output-directory %o %f")))
+  (org-open-file (org-latex-export-to-pdf)))
+ #+END_SRC
+
+*** Best practices for other formats
+
+org-ref relies on bibtex entries for bibliographies. Bibtex was designed for LaTeX export, and it is common to have LaTeX markup in the BibTeX entries to get the highest quality output in LaTeX (e.g. properly formatted equations, chemical formulas, accents in author names, etc.). This markup will usually not export correctly to other formats without some translation efforts.
+
+It is not generally possible to have a single BibTeX file that easily, and correctly exports to all backends. If perfection in your exports is needed, you need separate bibtex files for each backend, where the markup is intended for that backend. For example you might have "\ce{H2O}" in an entry intended for LaTeX export, but "H<sub>2</sub>O" in an entry for HTML export, and "H_{2}O" for org export.
+
+Maybe you could try an approach where your bibtex file is only org-mode, and then generate a bibtex file by "export" so that at export time it would be in the right format. I haven't tried that yet. It sounds complicated.
+
+
+*** Other formats using CSL
+
+org-ref supports export to other formats using [[https://github.com/andras-simonyi/citeproc-el][citeproc]] in a preprocessing filter. This works by modifying a copy of your org-file during the export to replace the citation and bibliography links with formatted text using the CSL. These functions are defined in [[./org-ref-export.el]]. You set the style with `org-ref-csl-default-style' or with a =CSL-KEYWORD=. See  [[./examples/basic-csl.org]] for an example.
+
+org-ref provides a new exporter for convenience with the following export options: After C-c C-e r
+
+| a | to ascii and open      |                                                                 |
+| h | to html and open       |                                                                 |
+| l | to latex and open      | all cite links and bibliography are exported to latex           |
+| o | to OpenOffice and open |                                                                 |
+| O | to org buffer          | only goes to a buffer so you don't overwrite the current buffer |
+| e | to email               |                                                                 |
+
+These links will run export commands to get this document in different formats. It is worth noting that if your bibtex entries use LaTeX markup (e.g. subscripts, superscripts, chemical equations, etc.) in them, it will probably not render faithfully in the alternative backend. It is in general difficult to have a single format in bibtex that correctly renders in all backends. I don't know of a great solution for this, since LaTeX and CSL use different citation processors.
+
+[[elisp:(org-ref-export-to-html)]]
+
+[[elisp:(org-ref-export-to-latex)]]
+
+[[elisp:(org-ref-export-to-ascii)]]
+
+[[elisp:(org-ref-export-to-odt)]]
+
+[[elisp:(org-ref-export-to-message)]] export to body of an ascii email message
+
+Some basic styles are provide in [[./citeproc/csl-locales/]], and a US-English locale in [[./citeproc/csl-locales/]].
+
+#+BEGIN_SRC sh :exports both
+ls citeproc/csl-styles
+#+END_SRC
+
+#+RESULTS:
+| apa-5th-edition.csl                  |
+| apa-numeric-superscript-brackets.csl |
+| chicago-author-date-16th-edition.csl |
+| elsevier-harvard.csl                 |
+| elsevier-with-titles.csl             |
+
+
+An alternative to this exporter is to use an  `org-export-before-parsing-hook' to do the pre-processing like this. This should work for most backends with the usual export keys and commands.
+
+#+BEGIN_SRC emacs-lisp
+(add-hook 'org-export-before-parsing-hook 'org-ref-csl-preprocess-buffer)
+#+END_SRC
+
+Here is an example to generate a docx file from this document!
+
+#+BEGIN_SRC emacs-lisp
+(require 'ox-pandoc)
+(let ((org-export-before-parsing-hook '(org-ref-csl-preprocess-buffer)))
+  (org-open-file (plist-get (org-pandoc-export-to-docx) 'output-file) 'system))
+#+END_SRC
+
+#+RESULTS:
+
+*** Other formats without using CSL
+
+An alternative approach to using citeproc is to use LaTeX/bibtex more directly. [[./org-ref-natbib-bbl-citeproc.el]] defines another pre-processor that uses LaTeX and natbib/bibtex to create citations and bibliographies. The bbl file is still intended for consumption by LaTeX. org-ref does some light processing to remove LaTeX artifacts, but it is not complete so some artifacts may still appear in your export (e.g. LaTeX commands that are not handled, some backslashes, etc).
+
+Here is an example how to export to HTML with the bbl file produced by LaTeX and bibtex. Your org-file must compile without error once with LaTeX and once with bibtex.
+
+#+BEGIN_SRC emacs-lisp :exports none :results silent
+(let ((org-export-before-parsing-hook '(org-ref-bbl-preprocess)))
+  (org-open-file (org-html-export-to-html)))
+#+END_SRC
+
+The natbib options for [super, numbers, authoryear] are supported, and citation options [square, round, angle, curly], and separators [comma, colon, semicolon] are supported. You can also use [sort, compress, sort&compress] for numeric styles. The longnamesfirst option is not currently supported.
+
+The bibliography entries are formatted from the bbl file. See these examples [[./examples/bbl-super.org]], [[./examples/bbl-numbers.org]] and [[./examples/bbl-authoryear.org]].
+
+* Index
+
+This is a functional link that will open a buffer of clickable index entries:
+# This eliminates the duplicate Index section name
+@@latex:\renewcommand{\indexname}{}@@
+[[printindex:]]
+
+* References
+
+<<bibliographystyle link>>
+bibliographystyle:unsrtnat
+
+<<bibliography link>>
+bibliography:org-ref.bib
diff --git a/elpa/org-ref-20251206.1422/x2bib.el b/elpa/org-ref-20251206.1422/x2bib.el
new file mode 100644 (file)
index 0000000..13ff28d
--- /dev/null
@@ -0,0 +1,147 @@
+;;; x2bib.el --- Bibliography conversion to Bibtex -*- lexical-binding: t; -*-
+
+;;; Header:
+
+;;; Commentary:
+
+;; This module is more for my convenience to convert bibliography files to
+;; bibtex. This can be done at the command line, for example, but I want to do
+;; it in Emacs. There are a few scenarios where this happens.
+
+;; 1. Someone sends me a non-Bibtex file (Endnote, etc...)
+;; 2. From some online search I select many references and there is no export to
+;; Bibtex option, e.g. from Web of Science.
+
+;; This code is mostly wrappers around the command line utilities at
+;; http://sourceforge.net/p/bibutils/home/Bibutils.
+;;
+;; on a Mac: brew install bibutils
+
+;; Here are the commands that are available.
+
+;; bib2xml       - convert BibTeX to MODS XML intermediate
+;; biblatex2xml  - convert BibLaTeX to MODS XML intermediate
+;; copac2xml     - convert COPAC format references to MODS XML intermediate
+;; end2xml       - convert EndNote (Refer format) to MODS XML intermediate
+;; endx2xml      - convert EndNote XML to MODS XML intermediate
+;; isi2xml       - convert ISI web of science to MODS XML intermediate
+;; med2xml       - convert Pubmed XML references to MODS XML intermediate
+;; modsclean     - a MODS to MODS converter for testing puposes mostly
+;; ris2xml       - convert RIS format to MODS XML intermediate
+;; xml2ads       - convert MODS XML intermediate into Smithsonian Astrophysical
+;;                 Observatory (SAO)/National Aeronautics and Space
+;;                 Administration (NASA) Astrophyics Data System or ADS
+;;                 reference format (converter submitted by Richard Mathar)
+;;                 xml2bib - convert MODS XML intermediate into BibTeX
+;; xml2end       - convert MODS XML intermediate into format for EndNote
+;; xml2isi       - convert MODS XML intermediate to ISI format
+;; xml2ris       - convert MODS XML intermediate into RIS format
+;; xml2wordbib   - convert MODS XML intermediate into Word 2007 bibliography format
+
+
+;;; Code:
+(require 'bibtex)
+
+(declare-function org-ref-clean-bibtex-entry "org-ref-bibtex" ())
+
+
+;;* RIS to bibtex
+
+;; RIS can be pretty easily exported from Endnote. Here is a function to read an
+;; RIS file and convert it to bibtex which is inserted at point. Note that there
+;; is often other output from the commands. We try to comment them out here, but
+;; you should probably inspect the entries, and do other bibtex file compliance
+;; checks.
+
+;;;###autoload
+(defun ris2bib (risfile &optional verbose)
+  "Convert RISFILE to bibtex and insert at point.
+Without a prefix arg, stderr is diverted.
+If VERBOSE is non-nil show command output.
+If the region is active, assume it is a ris entry
+and convert it to bib format in place."
+  (interactive
+   (list (if (not (region-active-p))
+             (read-file-name "RIS file:"))
+         (prefix-numeric-value current-prefix-arg)))
+  (let ((result
+         (if risfile
+             (shell-command-to-string
+              (concat
+               (format
+                "ris2xml %s | xml2bib -w"
+                risfile)
+               (unless verbose " 2> /dev/null")))
+           (progn
+             (shell-command-on-region (region-beginning) (region-end)
+                                      "ris2xml 2> /dev/null | xml2bib -w 2> /dev/null" nil
+                                      t)
+             nil))))
+    ;; make some lines into comments.
+    (when result
+      (setq result (replace-regexp-in-string
+                    "^xml2bib:"
+                    "% xml2bib:"
+                    result))
+      (setq result (replace-regexp-in-string
+                    "^ris2xml:"
+                    "% ris2xml"
+                    result))
+      (setq result (replace-regexp-in-string
+                    "^ Defaulting"
+                    "% Defaulting"
+                    result))
+      (insert result))))
+
+;;* Pubmed XML to bibtex
+
+;; In http://www.ncbi.nlm.nih.gov/pubmed/ you can select entries, and then send
+;; them to a file. If you choose Pubmed XML as the format, then you can use this
+;; function to convert it to bibtex.
+
+;;;###autoload
+(defun medxml2bib (medfile &optional verbose)
+  "Convert MEDFILE (in Pubmed xml) to bibtex and insert at point.
+Without a prefix arg, stderr is diverted.
+Display output if VERBOSE is non-nil."
+  (interactive
+   (list (read-file-name "MED file:")
+         (prefix-numeric-value current-prefix-arg)))
+  (let ((result (shell-command-to-string
+                 (concat
+                  (format
+                   "med2xml %s | xml2bib -w"
+                   medfile)
+                  (unless verbose " 2> /dev/null")))))
+    ;; make some lines into comments.
+    (setq result (replace-regexp-in-string
+                  "^xml2bib:"
+                  "% xml2bib:"
+                  result))
+    (setq result (replace-regexp-in-string
+                  "^med2xml:"
+                  "% med2xml"
+                  result))
+    (setq result (replace-regexp-in-string
+                  "^   Defaulting"
+                  "%   Defaulting"
+                  result))
+    (insert result)))
+
+;;* Clean up all the entries
+
+;; Finally, after you put the new entries in, you probably need to do some clean
+;; up actions. This little function does that.
+
+;;;###autoload
+(defun clean-entries ()
+  "Map over bibtex entries and clean them."
+  (interactive)
+  (bibtex-map-entries
+   (lambda (_ _ _)
+     (ignore-errors
+       (org-ref-clean-bibtex-entry)))))
+
+(provide 'x2bib)
+
+;;; x2bib.el ends here