From fba03725d727b10262de2280a32ace8722fdce79 Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Sun, 22 Dec 2024 13:11:45 +0100 Subject: [PATCH] update org-ref Signed-off-by: Andreas Gerler --- elpa/org-ref-20230613.1849/openalex.el | 459 ------- elpa/org-ref-20230613.1849/org-ref-latex.el | 104 -- elpa/org-ref-20230613.1849/org-ref-pkg.el | 24 - .../citeproc/csl-locales/locales-en-US.xml | 0 .../citeproc/csl-styles/apa-5th-edition.csl | 0 .../apa-numeric-superscript-brackets.csl | 0 .../chicago-author-date-16th-edition.csl | 0 .../citeproc/csl-styles/elsevier-harvard.csl | 0 .../csl-styles/elsevier-with-titles.csl | 0 .../contrib.el | 16 +- .../doi-utils.el | 39 +- .../nist-webbook.el | 2 +- elpa/org-ref-20241124.2012/openalex.el | 1179 +++++++++++++++++ .../org-ref-arxiv.el | 22 +- .../org-ref-autoloads.el | 483 ++----- .../org-ref-bibliography-links.el | 8 +- .../org-ref-bibtex.el | 15 +- .../org-ref-citation-links.el | 131 +- .../org-ref-compat.el | 8 +- .../org-ref-core.el | 7 +- .../org-ref-export.el | 62 +- elpa/org-ref-20241124.2012/org-ref-extract.el | 190 +++ .../org-ref-glossary.el | 236 ++-- .../org-ref-helm.el | 3 +- .../org-ref-isbn.el | 4 +- .../org-ref-ivy.el | 3 +- .../org-ref-label-link.el | 2 +- elpa/org-ref-20241124.2012/org-ref-latex.el | 276 ++++ .../org-ref-misc-links.el | 2 +- .../org-ref-natbib-bbl-citeproc.el | 10 +- .../org-ref-pdf.el | 2 +- .../org-ref-pgk.el | 4 +- elpa/org-ref-20241124.2012/org-ref-pkg.el | 21 + elpa/org-ref-20241124.2012/org-ref-publish.el | 107 ++ .../org-ref-pubmed.el | 2 +- .../org-ref-ref-links.el | 11 +- .../org-ref-refproc.el | 30 +- .../org-ref-sci-id.el | 2 +- .../org-ref-scifinder.el | 4 +- .../org-ref-scopus.el | 2 +- .../org-ref-url-utils.el | 2 +- .../org-ref-utils.el | 49 +- .../org-ref-worldcat.el | 2 +- .../org-ref-wos.el | 2 +- .../org-ref.bib | 0 .../org-ref.el | 7 +- .../org-ref.org | 0 .../x2bib.el | 8 +- elpa/org-ref-readme.txt | 4 - 49 files changed, 2296 insertions(+), 1248 deletions(-) delete mode 100644 elpa/org-ref-20230613.1849/openalex.el delete mode 100644 elpa/org-ref-20230613.1849/org-ref-latex.el delete mode 100644 elpa/org-ref-20230613.1849/org-ref-pkg.el rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/citeproc/csl-locales/locales-en-US.xml (100%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/citeproc/csl-styles/apa-5th-edition.csl (100%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/citeproc/csl-styles/apa-numeric-superscript-brackets.csl (100%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/citeproc/csl-styles/chicago-author-date-16th-edition.csl (100%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/citeproc/csl-styles/elsevier-harvard.csl (100%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/citeproc/csl-styles/elsevier-with-titles.csl (100%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/contrib.el (80%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/doi-utils.el (98%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/nist-webbook.el (91%) create mode 100644 elpa/org-ref-20241124.2012/openalex.el rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/org-ref-arxiv.el (94%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/org-ref-autoloads.el (71%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/org-ref-bibliography-links.el (98%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/org-ref-bibtex.el (99%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/org-ref-citation-links.el (94%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/org-ref-compat.el (94%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/org-ref-core.el (98%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/org-ref-export.el (93%) create mode 100644 elpa/org-ref-20241124.2012/org-ref-extract.el rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/org-ref-glossary.el (88%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/org-ref-helm.el (98%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/org-ref-isbn.el (99%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/org-ref-ivy.el (99%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/org-ref-label-link.el (97%) create mode 100644 elpa/org-ref-20241124.2012/org-ref-latex.el rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/org-ref-misc-links.el (99%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/org-ref-natbib-bbl-citeproc.el (98%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/org-ref-pdf.el (99%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/org-ref-pgk.el (70%) create mode 100644 elpa/org-ref-20241124.2012/org-ref-pkg.el create mode 100644 elpa/org-ref-20241124.2012/org-ref-publish.el rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/org-ref-pubmed.el (99%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/org-ref-ref-links.el (99%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/org-ref-refproc.el (94%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/org-ref-sci-id.el (97%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/org-ref-scifinder.el (90%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/org-ref-scopus.el (99%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/org-ref-url-utils.el (99%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/org-ref-utils.el (97%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/org-ref-worldcat.el (85%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/org-ref-wos.el (98%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/org-ref.bib (100%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/org-ref.el (92%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/org-ref.org (100%) rename elpa/{org-ref-20230613.1849 => org-ref-20241124.2012}/x2bib.el (97%) delete mode 100644 elpa/org-ref-readme.txt diff --git a/elpa/org-ref-20230613.1849/openalex.el b/elpa/org-ref-20230613.1849/openalex.el deleted file mode 100644 index 256e58c8..00000000 --- a/elpa/org-ref-20230613.1849/openalex.el +++ /dev/null @@ -1,459 +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 Work and Author API -;; -;; See -;; https://docs.openalex.org/how-to-use-the-api/rate-limits-and-authentication#the-polite-pool -;; for why we add email to the request. - -(require 'dash) -(require 'request) - -;;; 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))) - - -;; * 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" - (if filter - (concat "?" filter entity-id) - (concat "/" entity-id)) - (if user-mail-address - (concat "?mailto=" user-mail-address) - ""))) - (req (request url :sync t :parser 'oa--response-parser)) - (data (request-response-data req))) - ;; this is for convenience to inspect data in a browser. - (plist-put data :oa-url url) - data)) - - -;; * Viewing works -;; -;; This section provides a replacer and helper function to format org-entries -;; from the results returned in OpenAlex. - -(defun oa--replacer (query object) - "Replacer function for `s-format'. -QUERY is a string that is either a sexp for a function to -evaluate or a dot notation path to data in OBJECT. If QUERY is a -sexp, it is read and evaluated. Otherwise, the path is split, and -looked up sequentially in object. - -OBJECT is a plist, usually from a Work request." - (if (s-starts-with? "(" query) - ;; this is a function - (eval (read query)) - ;; just get data - (let ((fields (s-split "\\." query)) - result) - (while fields - (setq object (plist-get object (intern-soft (concat ":" (pop fields)))))) - (or (string-replace "\\n" "" (format "%s" object)) "Not found")))) - - -;; ** 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 \"%s\")][%s]]" - (plist-get - (plist-get author :author) - :id) - (plist-get - (plist-get author :author) - :display_name))))) - - -;; 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) (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) (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) (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: ${host_venue.display_name} -:YEAR: ${publication_year} -:CITED_BY_COUNT: ${cited_by_count} -:AUTHOR: ${(oa--authors wrk)} -:DOI: ${doi} -:OPENALEX: ${id} -:END: - - -${(oa--elisp-get-bibtex wrk)} - -- ${(oa--elisp-get-oa-refs wrk)} -- ${(oa--elisp-get-oa-related wrk)} -- ${(oa--elisp-get-oa-cited-by wrk)} - -" - 'oa--replacer 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))) - - -;; There is something funny about pages here, maybe 25 results per page? -;; https://docs.openalex.org/how-to-use-the-api/get-lists-of-entities/paging I -;; am not sure how to do pages in this approach, so I am just getting these 25 -;; at a time. -(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 (s-join "|" (nth 0 split)) - "filter=openalex:"))))) - - (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: ${host_venue.display_name} -:AUTHOR: ${(oa--authors wrk)} -:DOI: ${doi} -:YEAR: ${publication_year} -:OPENALEX: ${id} -:END:" 'oa--replacer wrk)) - 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 (s-join "|" (nth 0 split)) - "filter=openalex:"))))) - (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: ${host_venue.display_name} -:AUTHOR: ${(oa--authors wrk)} -:DOI: ${doi} -:YEAR: ${publication_year} -:OPENALEX: ${id} -:END:" 'oa--replacer wrk)) - 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))) - (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 (format "%s&page=%s" url page) - :sync t - :parser 'oa--response-parser))) - (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: ${host_venue.display_name} -:AUTHOR: ${(oa--authors wrk)} -:DOI: ${doi} -:YEAR: ${publication_year} -:OPENALEX: ${id} -:END:\n\n" 'oa--replacer wrk)) - 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))))) - - -(defun oa-buffer-sort-cited-by-count (&optional ascending) - "Sort orgheadings 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"))) - #'>))) - - -;; * 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 "doi:" (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)))) - - -(defhydra+ org-ref-citation-hydra () ("ar" oa-related-works "Related documents" :column "OpenAlex")) -(defhydra+ org-ref-citation-hydra () ("ac" oa-cited-by-works "Cited by documents" :column "OpenAlex")) -(defhydra+ org-ref-citation-hydra () ("af" oa-referenced-works "References from" :column "OpenAlex")) - - -;; * 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)))) - -;; * Author object - -(defun oa--author (entity-id &optional filter) - "Get an Author object for entity-id" - (let* ((url (concat "https://api.openalex.org/authors" - (if filter - (concat "?" filter entity-id) - (concat "/" entity-id)) - (if user-mail-address - (concat "?mailto=" user-mail-address) - ""))) - (req (request url :sync t :parser 'oa--response-parser)) - (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 purl (concat url (format "&page=%s" i)) - works-data (request-response-data - (request purl - :sync t - :parser 'oa--response-parser)) - entries (append entries - (cl-loop for result in (plist-get works-data :results) - collect - (s-format "** ${title} -:PROPERTIES: -:ID: ${id} -:DOI: ${ids.doi} -:YEAR: ${publication_year} -:HOST_VENUE: ${host_venue.display_name} -:AUTHORS: ${(oa--authors result)} -:CITED_BY_COUNT: ${cited_by_count} -:END: - -${(oa--elisp-get-bibtex result)} - -- ${(oa--elisp-get-oa-refs result)} -- ${(oa--elisp-get-oa-related result)} -- ${(oa--elisp-get-oa-cited-by result)} - - " 'oa--replacer result))))) - entries)) - - -(defun oa-author (entity-id) - "View Author for ENTITY-ID in an org-buffer." - (let* ((buf (get-buffer-create "*OpenAlex - Author*")) - (data (oa--author entity-id)) - (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)))) - (with-current-buffer buf - (erase-buffer) - (insert (s-format "* ${display_name} ([[${oa-url}][json]]) -:PROPERTIES: -: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 - -#+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]] | - -" - 'oa--replacer data)) - (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))) - - -(provide 'openalex) - -;;; openalex.el ends here diff --git a/elpa/org-ref-20230613.1849/org-ref-latex.el b/elpa/org-ref-20230613.1849/org-ref-latex.el deleted file mode 100644 index 637e5b9f..00000000 --- a/elpa/org-ref-20230613.1849/org-ref-latex.el +++ /dev/null @@ -1,104 +0,0 @@ -;;; org-ref-latex.el --- org-ref functionality for LaTeX files -*- lexical-binding: t; -*- - -;; Copyright (C) 2015-2021 John Kitchin - -;; Author: John Kitchin -;; 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 . - -;;; 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) - -(defvar latex-mode-map) -(defvar org-ref-cite-types) - - -(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)) - (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) - `(mouse-face highlight - local-map ,(let ((map (copy-keymap latex-mode-map))) - (define-key map [mouse-1] - `(lambda () - (interactive) - (let ((bibtex-completion-bibliography (org-ref-latex-get-bibliography))) - (bibtex-completion-show-entry (list ,key)) - (bibtex-beginning-of-entry)))) - map) - 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) - - -(provide 'org-ref-latex) -;;; org-ref-latex.el ends here diff --git a/elpa/org-ref-20230613.1849/org-ref-pkg.el b/elpa/org-ref-20230613.1849/org-ref-pkg.el deleted file mode 100644 index 2c8e5520..00000000 --- a/elpa/org-ref-20230613.1849/org-ref-pkg.el +++ /dev/null @@ -1,24 +0,0 @@ -(define-package "org-ref" "20230613.1849" "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")) - :commit "26c06912c7833104c7b4c7b96b8f200e98067a68" :authors - '(("John Kitchin" . "jkitchin@andrew.cmu.edu")) - :maintainers - '(("John Kitchin" . "jkitchin@andrew.cmu.edu")) - :maintainer - '("John Kitchin" . "jkitchin@andrew.cmu.edu") - :keywords - '("org-mode" "cite" "ref" "label") - :url "https://github.com/jkitchin/org-ref") -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/elpa/org-ref-20230613.1849/citeproc/csl-locales/locales-en-US.xml b/elpa/org-ref-20241124.2012/citeproc/csl-locales/locales-en-US.xml similarity index 100% rename from elpa/org-ref-20230613.1849/citeproc/csl-locales/locales-en-US.xml rename to elpa/org-ref-20241124.2012/citeproc/csl-locales/locales-en-US.xml diff --git a/elpa/org-ref-20230613.1849/citeproc/csl-styles/apa-5th-edition.csl b/elpa/org-ref-20241124.2012/citeproc/csl-styles/apa-5th-edition.csl similarity index 100% rename from elpa/org-ref-20230613.1849/citeproc/csl-styles/apa-5th-edition.csl rename to elpa/org-ref-20241124.2012/citeproc/csl-styles/apa-5th-edition.csl diff --git a/elpa/org-ref-20230613.1849/citeproc/csl-styles/apa-numeric-superscript-brackets.csl b/elpa/org-ref-20241124.2012/citeproc/csl-styles/apa-numeric-superscript-brackets.csl similarity index 100% rename from elpa/org-ref-20230613.1849/citeproc/csl-styles/apa-numeric-superscript-brackets.csl rename to elpa/org-ref-20241124.2012/citeproc/csl-styles/apa-numeric-superscript-brackets.csl diff --git a/elpa/org-ref-20230613.1849/citeproc/csl-styles/chicago-author-date-16th-edition.csl b/elpa/org-ref-20241124.2012/citeproc/csl-styles/chicago-author-date-16th-edition.csl similarity index 100% rename from elpa/org-ref-20230613.1849/citeproc/csl-styles/chicago-author-date-16th-edition.csl rename to elpa/org-ref-20241124.2012/citeproc/csl-styles/chicago-author-date-16th-edition.csl diff --git a/elpa/org-ref-20230613.1849/citeproc/csl-styles/elsevier-harvard.csl b/elpa/org-ref-20241124.2012/citeproc/csl-styles/elsevier-harvard.csl similarity index 100% rename from elpa/org-ref-20230613.1849/citeproc/csl-styles/elsevier-harvard.csl rename to elpa/org-ref-20241124.2012/citeproc/csl-styles/elsevier-harvard.csl diff --git a/elpa/org-ref-20230613.1849/citeproc/csl-styles/elsevier-with-titles.csl b/elpa/org-ref-20241124.2012/citeproc/csl-styles/elsevier-with-titles.csl similarity index 100% rename from elpa/org-ref-20230613.1849/citeproc/csl-styles/elsevier-with-titles.csl rename to elpa/org-ref-20241124.2012/citeproc/csl-styles/elsevier-with-titles.csl diff --git a/elpa/org-ref-20230613.1849/contrib.el b/elpa/org-ref-20241124.2012/contrib.el similarity index 80% rename from elpa/org-ref-20230613.1849/contrib.el rename to elpa/org-ref-20241124.2012/contrib.el index 4e811deb..f726f755 100644 --- a/elpa/org-ref-20230613.1849/contrib.el +++ b/elpa/org-ref-20241124.2012/contrib.el @@ -1,9 +1,16 @@ -;;; contrib.el --- Code contributed by users +;;; 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 @@ -17,7 +24,7 @@ If not on a key, but on a cite, prompt for key." key ;; point is not on a key, but may still be on a cite link (let ((el (org-element-context)) - data + data text keys) (cond ;; on a cite-link type @@ -33,7 +40,7 @@ If not on a key, but on a cite, prompt for key." (dolist (key keys) (search-forward key) (goto-char (match-beginning 0)) - (get-text-property (point) 'cite-key) + ;; (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))) @@ -45,7 +52,8 @@ If not on a key, but on a cite, prompt for key." (defcustom org-ref-message-interval 0.5 "Time in seconds to wait for the idle timer that displays the cite message." - :group 'org-ref) + :group 'org-ref + :type 'float) (defun org-ref-link-message () diff --git a/elpa/org-ref-20230613.1849/doi-utils.el b/elpa/org-ref-20241124.2012/doi-utils.el similarity index 98% rename from elpa/org-ref-20230613.1849/doi-utils.el rename to elpa/org-ref-20241124.2012/doi-utils.el index 33cfc6b6..ddde49ab 100644 --- a/elpa/org-ref-20230613.1849/doi-utils.el +++ b/elpa/org-ref-20241124.2012/doi-utils.el @@ -4,7 +4,6 @@ ;; Author: John Kitchin ;; Keywords: convenience -;; Version: 0.1 ;; Package-Requires: ((org-ref)) ;; This program is free software; you can redistribute it and/or modify @@ -43,6 +42,10 @@ (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) @@ -54,6 +57,7 @@ (require 'org-bibtex)) ; org-bibtex-yank (require 'url-http) +(require 'url-handlers) (require 'org-ref-utils) (require 'hydra) @@ -590,9 +594,11 @@ REDIRECT-URL is where the pdf url will be in." -;;** ASME Biomechanical Journal +;;** 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 asme-biomechanical-pdf-url (*doi-utils-redirect*) +(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: @@ -602,13 +608,17 @@ It is in the citation_pdf_url. It would be better to parse this, but here I just use a regexp. " - (when (string-match "^http\\(s?\\)://biomechanical.asmedigitalcollection.asme.org" *doi-utils-redirect*) + (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) - (goto-char (point-min)) - (re-search-forward "citation_pdf_url\" content=\"\\(.*\\)\"" nil t) + (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))) @@ -706,7 +716,7 @@ It would be better to parse this, but here I just use a regexp. 'ieee3-pdf-url 'acm-pdf-url 'osa-pdf-url - 'asme-biomechanical-pdf-url + 'highwire-pdf-url 'siam-pdf-url 'agu-pdf-url 'plos-pdf-url @@ -999,7 +1009,9 @@ Opening %s" json-data url)) (url (plist-get results :URL)) (booktitle (plist-get results :container-title)) (school (or (plist-get results :school) - (plist-get (plist-get results :institution) :name))))) + (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 @@ -1059,13 +1071,17 @@ MATCHING-TYPES." (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") +(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) + 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") @@ -1097,7 +1113,8 @@ MATCHING-TYPES." (bibtex-set-field doi-utils-timestamp-field ts))) (org-ref-clean-bibtex-entry) - (save-buffer)) + (when (buffer-file-name) + (save-buffer))) ;;;###autoload diff --git a/elpa/org-ref-20230613.1849/nist-webbook.el b/elpa/org-ref-20241124.2012/nist-webbook.el similarity index 91% rename from elpa/org-ref-20230613.1849/nist-webbook.el rename to elpa/org-ref-20241124.2012/nist-webbook.el index 57764dd1..35b16088 100644 --- a/elpa/org-ref-20230613.1849/nist-webbook.el +++ b/elpa/org-ref-20241124.2012/nist-webbook.el @@ -1,4 +1,4 @@ -;;; nist-webbook.el --- Integration of Emacs with NIST Webbook +;;; nist-webbook.el --- Integration of Emacs with NIST Webbook -*- lexical-binding: t; -*- ;; Integration of Emacs with NIST webbook ;;; Commentary: diff --git a/elpa/org-ref-20241124.2012/openalex.el b/elpa/org-ref-20241124.2012/openalex.el new file mode 100644 index 00000000..78bcd796 --- /dev/null +++ b/elpa/org-ref-20241124.2012/openalex.el @@ -0,0 +1,1179 @@ +;;; 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 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-20230613.1849/org-ref-arxiv.el b/elpa/org-ref-20241124.2012/org-ref-arxiv.el similarity index 94% rename from elpa/org-ref-20230613.1849/org-ref-arxiv.el rename to elpa/org-ref-20241124.2012/org-ref-arxiv.el index 31572c55..c16739c7 100644 --- a/elpa/org-ref-20230613.1849/org-ref-arxiv.el +++ b/elpa/org-ref-20241124.2012/org-ref-arxiv.el @@ -1,6 +1,6 @@ ;;; org-ref-arxiv.el --- arxiv utilities for org-mode -*- lexical-binding: t; -*- -;; Copyright (C) 2015-2021 John Kitchin +;; Copyright (C) 2015-2024 John Kitchin ;; Author: John Kitchin ;; Keywords: @@ -137,9 +137,9 @@ Returns a formatted BibTeX entry." (org-ref-replace-nonascii) (bibtex-generate-autokey))) (doi (assq 'doi entry))) - (if doi - (doi-utils-doi-to-bibtex-string (nth 2 doi)) - ;; no doi, so we fall back to the simple template + (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))))) @@ -223,15 +223,7 @@ Returns a formatted BibTeX entry." (arxiv-maybe-arxiv-id-from-current-kill)) (read-string "PDF: "))) - (let ((pdf-url (with-current-buffer - (url-retrieve-synchronously - (concat - "http://arxiv.org/abs/" arxiv-number)) - ;; - (goto-char (point-min)) - (search-forward-regexp - "name=\\\"citation_pdf_url\\\" content=\\\"\\(.*\\)\\\"") - (match-string 1)))) + (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) @@ -301,3 +293,7 @@ key." (provide 'org-ref-arxiv) ;;; org-ref-arxiv.el ends here + +;; Local Variables: +;; byte-compile-warnings: (not docstrings) +;; End: diff --git a/elpa/org-ref-20230613.1849/org-ref-autoloads.el b/elpa/org-ref-20241124.2012/org-ref-autoloads.el similarity index 71% rename from elpa/org-ref-20230613.1849/org-ref-autoloads.el rename to elpa/org-ref-20241124.2012/org-ref-autoloads.el index 6888efa2..912667b0 100644 --- a/elpa/org-ref-20230613.1849/org-ref-autoloads.el +++ b/elpa/org-ref-20241124.2012/org-ref-autoloads.el @@ -1,27 +1,26 @@ -;;; org-ref-autoloads.el --- automatically extracted autoloads -*- lexical-binding: t -*- -;; +;;; 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 (directory-file-name - (or (file-name-directory #$) (car load-path)))) +(add-to-list 'load-path (or (and load-file-name (directory-file-name (file-name-directory load-file-name))) (car load-path))) + -;;;### (autoloads nil "contrib" "contrib.el" (0 0 0 0)) ;;; Generated autoloads from contrib.el (register-definition-prefixes "contrib" '("org-ref-")) -;;;*** -;;;### (autoloads nil "doi-utils" "doi-utils.el" (0 0 0 0)) ;;; 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 nil) - +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 @@ -38,8 +37,7 @@ prefix ARG, directly get the pdf from an open buffer (through work even if the entry has no DOI, and the pdf file is not checked. -\(fn &optional ARG)" t nil) - +(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 @@ -49,178 +47,140 @@ 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 nil) - +(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 nil) - +(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 nil) - +(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 nil) - +(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 nil) - +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 nil) - +(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 nil) - +(fn DOI)" t) (autoload 'doi-utils-wos-related "doi-utils" "\ Open Web of Science related articles page for DOI. -\(fn DOI)" t nil) - +(fn DOI)" t) (autoload 'doi-utils-ads "doi-utils" "\ Open ADS entry for DOI -\(fn DOI)" t nil) - +(fn DOI)" t) (autoload 'doi-utils-open "doi-utils" "\ Open DOI in browser. -\(fn DOI)" t nil) - +(fn DOI)" t) (autoload 'doi-utils-open-bibtex "doi-utils" "\ Search through variable `bibtex-completion-bibliography' for DOI. -\(fn DOI)" t nil) - +(fn DOI)" t) (autoload 'doi-utils-crossref "doi-utils" "\ Search DOI in CrossRef. -\(fn DOI)" t nil) - +(fn DOI)" t) (autoload 'doi-utils-google-scholar "doi-utils" "\ Google scholar the DOI. -\(fn DOI)" t nil) - +(fn DOI)" t) (autoload 'doi-utils-pubmed "doi-utils" "\ Search Pubmed for the DOI. -\(fn DOI)" t nil) - +(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 nil) - +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 nil) - +(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 nil) +(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")) -(register-definition-prefixes "doi-utils" '("*doi-utils-" "agu-pdf-url" "aip-pdf-url" "aps-pdf-url" "arxiv-pdf-url" "asme-biomechanical-pdf-url" "chemistry-europe-pdf-url" "copernicus-" "crossref-add-bibtex-entry" "doi-" "ecs" "frontiers-pdf-url" "generic-full-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")) - -;;;*** -;;;### (autoloads nil "nist-webbook" "nist-webbook.el" (0 0 0 0)) ;;; Generated autoloads from nist-webbook.el (autoload 'nist-webbook-formula "nist-webbook" "\ Search NIST webbook for FORMULA. -\(fn FORMULA)" t nil) - +(fn FORMULA)" t) (autoload 'nist-webbook-name "nist-webbook" "\ Search NIST webbook for NAME. -\(fn NAME)" t nil) +(fn NAME)" t) -;;;*** -;;;### (autoloads nil "openalex" "openalex.el" (0 0 0 0)) ;;; Generated autoloads from openalex.el (register-definition-prefixes "openalex" '("oa-" "org-ref-citation-hydra")) -;;;*** -;;;### (autoloads nil "org-ref-arxiv" "org-ref-arxiv.el" (0 0 0 0)) ;;; 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 nil) - +(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 nil) - +(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 nil) - +(fn ARXIV-NUMBER BIBFILE PDFDIR)" t) (register-definition-prefixes "org-ref-arxiv" '("arxiv-")) -;;;*** -;;;### (autoloads nil "org-ref-bibliography-links" "org-ref-bibliography-links.el" -;;;;;; (0 0 0 0)) ;;; Generated autoloads from org-ref-bibliography-links.el (register-definition-prefixes "org-ref-bibliography-links" '("org-ref-")) -;;;*** -;;;### (autoloads nil "org-ref-bibtex" "org-ref-bibtex.el" (0 0 0 -;;;;;; 0)) ;;; 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 nil) - +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 nil) - +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 nil) - +(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 nil) - +(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 nil) - +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 @@ -229,73 +189,58 @@ 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 nil) - +(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 nil) - +(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 nil) - +(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 nil) - +(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 nil) - +(fn &optional N)" t) (autoload 'org-ref-bibtex-visible-entry "org-ref-bibtex" "\ -Jump to visible entry." t nil) - +Jump to visible entry." t) (autoload 'org-ref-bibtex-visible-field "org-ref-bibtex" "\ -Jump to visible field." t nil) - +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 nil) - +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 nil) - +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 nil) - +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 nil) - +there is a DOI." t) (autoload 'org-ref-bibtex-crossref "org-ref-bibtex" "\ -Open the bibtex entry in Crossref by its doi." t nil) - +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 nil) - +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 nil) - +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 nil) - +(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 @@ -305,11 +250,9 @@ name '[bibtexkey].pdf'. If the file does not exist, rename it to a directory. Optional PREFIX argument toggles between `rename-file' and `copy-file'. -\(fn &optional PREFIX)" t nil) - +(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 nil) - +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 @@ -317,97 +260,71 @@ 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 nil) - +(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 nil) - +(fn BIBFILE)" t) (autoload 'org-ref-open-bibtex-pdf "org-ref-bibtex" "\ -Open pdf for a bibtex entry, if it exists." t nil) - +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 nil) - +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 nil) - +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 nil) - +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 nil) - +Sort fields of entry in standard order." t) (autoload 'org-ref-downcase-bibtex-entry "org-ref-bibtex" "\ -Downcase the entry type and fields." t nil) - +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 nil) - +See functions in `org-ref-clean-bibtex-entry-hook'." t) (register-definition-prefixes "org-ref-bibtex" '("orcb-" "org-ref-")) -;;;*** -;;;### (autoloads nil "org-ref-citation-links" "org-ref-citation-links.el" -;;;;;; (0 0 0 0)) ;;; 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 nil) - +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 nil) - +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 nil) - +(fn &optional COMMON)" t) (autoload 'org-ref-change-cite-type "org-ref-citation-links" "\ -Change the cite type of citation link at point." t nil) - +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 nil) - +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 nil) - +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 nil) - +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 nil) - +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 nil) - +(fn &optional SET-TYPE)" t) (register-definition-prefixes "org-ref-citation-links" '("org-ref-")) -;;;*** -;;;### (autoloads nil "org-ref-compat" "org-ref-compat.el" (0 0 0 -;;;;;; 0)) ;;; Generated autoloads from org-ref-compat.el (register-definition-prefixes "org-ref-compat" '("org-ref-to-org-cite")) -;;;*** -;;;### (autoloads nil "org-ref-core" "org-ref-core.el" (0 0 0 0)) ;;; Generated autoloads from org-ref-core.el (autoload 'org-ref-insert-link "org-ref-core" "\ @@ -419,54 +336,27 @@ If two prefix ARGs insert a label. This is a generic function. Specific backends might provide their own version. -\(fn ARG)" t nil) - +(fn ARG)" t) (autoload 'org-ref-help "org-ref-core" "\ -Open the `org-ref' manual." t nil) - +Open the `org-ref' manual." t) (register-definition-prefixes "org-ref-core" '("org-ref-")) -;;;*** -;;;### (autoloads nil "org-ref-export" "org-ref-export.el" (0 0 0 -;;;;;; 0)) ;;; Generated autoloads from org-ref-export.el (register-definition-prefixes "org-ref-export" '("org-ref")) -;;;*** -;;;### (autoloads nil "org-ref-glossary" "org-ref-glossary.el" (0 -;;;;;; 0 0 0)) -;;; Generated autoloads from org-ref-glossary.el - -(autoload 'org-ref-add-glossary-entry "org-ref-glossary" "\ -Insert a new glossary entry. -LABEL is how you refer to it with links. -NAME is the name of the entry to be defined. -DESCRIPTION is the definition of the entry. -Entry gets added after the last #+latex_header line. - -This is not a preferred way to add entries. It is preferred to -manually add them to the glossary table. +;;; Generated autoloads from org-ref-extract.el -\(fn LABEL NAME DESCRIPTION)" t nil) +(register-definition-prefixes "org-ref-extract" '("org-ref-")) -(autoload 'org-ref-add-acronym-entry "org-ref-glossary" "\ -Add an acronym entry with LABEL. - ABBRV is the abbreviated form. - FULL is the expanded acronym. - -This is not the preferred way to add acronyms, you should add -them manually to the acronyms table. - -\(fn LABEL ABBRV FULL)" t nil) + +;;; Generated autoloads from org-ref-glossary.el (register-definition-prefixes "org-ref-glossary" '("or-" "org-ref-")) -;;;*** -;;;### (autoloads nil "org-ref-helm" "org-ref-helm.el" (0 0 0 0)) ;;; Generated autoloads from org-ref-helm.el (autoload 'org-ref-cite-insert-helm "org-ref-helm" "\ @@ -483,63 +373,47 @@ 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 nil) - +(fn &optional ARG LOCAL-BIB INPUT)" t) (register-definition-prefixes "org-ref-helm" '("org-ref-helm-source-")) -;;;*** -;;;### (autoloads nil "org-ref-isbn" "org-ref-isbn.el" (0 0 0 0)) ;;; 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 nil) - +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 nil) - +(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 nil) - +(fn ISBN BIBFILE)" t) (register-definition-prefixes "org-ref-isbn" '("isbn-to-bibtex-open-library" "org-ref-isbn-" "oricb-")) -;;;*** -;;;### (autoloads nil "org-ref-ivy" "org-ref-ivy.el" (0 0 0 0)) ;;; Generated autoloads from org-ref-ivy.el (register-definition-prefixes "org-ref-ivy" '("org-ref-")) -;;;*** -;;;### (autoloads nil "org-ref-label-link" "org-ref-label-link.el" -;;;;;; (0 0 0 0)) ;;; 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 nil) +The completion helps ensure you use a unique label." t) -;;;*** -;;;### (autoloads nil "org-ref-latex" "org-ref-latex.el" (0 0 0 0)) ;;; Generated autoloads from org-ref-latex.el -(register-definition-prefixes "org-ref-latex" '("org-ref-")) +(register-definition-prefixes "org-ref-latex" '("org-ref-" "orl-")) -;;;*** -;;;### (autoloads nil "org-ref-misc-links" "org-ref-misc-links.el" -;;;;;; (0 0 0 0)) ;;; Generated autoloads from org-ref-misc-links.el (autoload 'org-ref-list-of-figures "org-ref-misc-links" "\ @@ -547,182 +421,139 @@ Generate buffer with list of figures in them. ARG does nothing. Ignore figures in COMMENTED sections. -\(fn &optional ARG)" t nil) - +(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 nil) - +(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 nil) - +(fn &optional PATH)" t) (register-definition-prefixes "org-ref-misc-links" '("org-ref-idxproc")) -;;;*** -;;;### (autoloads nil "org-ref-natbib-bbl-citeproc" "org-ref-natbib-bbl-citeproc.el" -;;;;;; (0 0 0 0)) ;;; Generated autoloads from org-ref-natbib-bbl-citeproc.el (register-definition-prefixes "org-ref-natbib-bbl-citeproc" '("org-")) -;;;*** -;;;### (autoloads nil "org-ref-pdf" "org-ref-pdf.el" (0 0 0 0)) ;;; 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 nil) - +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 nil) - +(fn PDF-FILE)" t) (autoload 'org-ref-pdf-crossref-lookup "org-ref-pdf" "\ -Lookup highlighted text in PDFView in CrossRef." t nil) - +Lookup highlighted text in PDFView in CrossRef." t) (register-definition-prefixes "org-ref-pdf" '("org-ref-" "pdftotext-executable")) -;;;*** -;;;### (autoloads nil "org-ref-pubmed" "org-ref-pubmed.el" (0 0 0 -;;;;;; 0)) +;;; Generated autoloads from org-ref-publish.el + +(register-definition-prefixes "org-ref-publish" '("org-ref-publish-")) + + ;;; 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 nil) - +(fn PMID)" t) (autoload 'pubmed "org-ref-pubmed" "\ -Open http://www.ncbi.nlm.nih.gov/pubmed in a browser." t nil) - +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 nil) - +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 nil) - +(fn QUERY)" t) (autoload 'pubmed-clinical "org-ref-pubmed" "\ -Open http://www.ncbi.nlm.nih.gov/pubmed/clinical in a browser." t nil) - +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 nil) - +(fn QUERY)" t) (register-definition-prefixes "org-ref-pubmed" '("pubmed-")) -;;;*** -;;;### (autoloads nil "org-ref-ref-links" "org-ref-ref-links.el" -;;;;;; (0 0 0 0)) ;;; Generated autoloads from org-ref-ref-links.el (register-definition-prefixes "org-ref-ref-links" '("org-ref-")) -;;;*** -;;;### (autoloads nil "org-ref-refproc" "org-ref-refproc.el" (0 0 -;;;;;; 0 0)) ;;; Generated autoloads from org-ref-refproc.el (register-definition-prefixes "org-ref-refproc" '("org-ref-")) -;;;*** -;;;### (autoloads nil "org-ref-scifinder" "org-ref-scifinder.el" -;;;;;; (0 0 0 0)) ;;; 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 nil) +Open https://scifinder.cas.org/scifinder/view/scifinder/scifinderExplore.jsf in a browser." t) -;;;*** -;;;### (autoloads nil "org-ref-scopus" "org-ref-scopus.el" (0 0 0 -;;;;;; 0)) ;;; 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 nil) - +(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 nil) - +(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 nil) - +(fn DOI)" t) (autoload 'scopus-open-eid "org-ref-scopus" "\ Open article with EID in browser. -\(fn EID)" t nil) - +(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 nil) - +(fn QUERY)" t) (autoload 'scopus-advanced-search "org-ref-scopus" "\ Open QUERY as an advanced search at scopus.com. -\(fn QUERY)" t nil) - +(fn QUERY)" t) (register-definition-prefixes "org-ref-scopus" '("*hydra-eid*" "*scopus-api-key*" "scopus")) -;;;*** -;;;### (autoloads nil "org-ref-url-utils" "org-ref-url-utils.el" -;;;;;; (0 0 0 0)) ;;; 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 nil) - +(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 nil) - +(fn BIBFILE &optional URL)" t) (register-definition-prefixes "org-ref-url-utils" '("org-ref-")) -;;;*** -;;;### (autoloads nil "org-ref-utils" "org-ref-utils.el" (0 0 0 0)) ;;; 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 nil) - +Copies the string to the clipboard." t) (autoload 'org-ref-debug "org-ref-utils" "\ -Print some debug information to a buffer." t nil) - +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 nil) - +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. @@ -735,94 +566,67 @@ pdf already exists in `bibtex-completion-library' with the name in a directory. Optional PREFIX argument toggles between `rename-file' and `copy-file'. -\(fn &optional PREFIX)" t nil) - +(fn &optional PREFIX)" t) (autoload 'org-ref-open-url-at-point "org-ref-utils" "\ -Open the url for bibtex key under point." t nil) - +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 nil) - +(fn &optional THEKEY)" t) (autoload 'org-ref-open-citation-at-point "org-ref-utils" "\ -Open bibtex file to key at point." t nil) - +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 nil) - +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 nil) - +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 nil) - +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 nil) - +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 nil) - +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 nil) - +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 nil) - +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 nil) - +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 nil) - +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 nil) - +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 nil) - +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 nil) - +(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 nil) - +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 nil) - +(fn NEWDIR)" t) (register-definition-prefixes "org-ref-utils" '("ords" "org-ref")) -;;;*** -;;;### (autoloads nil "org-ref-worldcat" "org-ref-worldcat.el" (0 -;;;;;; 0 0 0)) ;;; Generated autoloads from org-ref-worldcat.el (register-definition-prefixes "org-ref-worldcat" '("worldcat-query-all")) -;;;*** -;;;### (autoloads nil "org-ref-wos" "org-ref-wos.el" (0 0 0 0)) ;;; 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 nil) - +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 nil) - +Open Web of Science search page in a browser." t) (register-definition-prefixes "org-ref-wos" '("*wos-" "wos-")) -;;;*** -;;;### (autoloads nil "x2bib" "x2bib.el" (0 0 0 0)) ;;; Generated autoloads from x2bib.el (autoload 'ris2bib "x2bib" "\ @@ -832,29 +636,26 @@ 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 nil) - +(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 nil) - +(fn MEDFILE &optional VERBOSE)" t) (autoload 'clean-entries "x2bib" "\ -Map over bibtex entries and clean them." t nil) - -;;;*** +Map over bibtex entries and clean them." t) -;;;### (autoloads nil nil ("org-ref-pgk.el" "org-ref-pkg.el" "org-ref-sci-id.el" -;;;;;; "org-ref.el") (0 0 0 0)) +;;; End of scraped data + +(provide 'org-ref-autoloads) -;;;*** - ;; Local Variables: ;; version-control: never ;; no-byte-compile: t ;; no-update-autoloads: t -;; coding: utf-8 +;; no-native-compile: t +;; coding: utf-8-emacs-unix ;; End: + ;;; org-ref-autoloads.el ends here diff --git a/elpa/org-ref-20230613.1849/org-ref-bibliography-links.el b/elpa/org-ref-20241124.2012/org-ref-bibliography-links.el similarity index 98% rename from elpa/org-ref-20230613.1849/org-ref-bibliography-links.el rename to elpa/org-ref-20241124.2012/org-ref-bibliography-links.el index 332ec56a..6deb0b1b 100644 --- a/elpa/org-ref-20230613.1849/org-ref-bibliography-links.el +++ b/elpa/org-ref-20241124.2012/org-ref-bibliography-links.el @@ -1,6 +1,6 @@ -;;; org-ref-bibliography-links.el --- Bibliography and bibliographystyle links +;;; org-ref-bibliography-links.el --- Bibliography and bibliographystyle links -*- lexical-binding: t; -*- ;; -;; Copyright (C) 2021 John Kitchin +;; Copyright (C) 2024 John Kitchin ;; Author: John Kitchin ;; Keywords: convenience @@ -310,3 +310,7 @@ Optional argument BACKEND is the export backend." (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-20230613.1849/org-ref-bibtex.el b/elpa/org-ref-20241124.2012/org-ref-bibtex.el similarity index 99% rename from elpa/org-ref-20230613.1849/org-ref-bibtex.el rename to elpa/org-ref-20241124.2012/org-ref-bibtex.el index 8912ab12..3c666836 100644 --- a/elpa/org-ref-20230613.1849/org-ref-bibtex.el +++ b/elpa/org-ref-20241124.2012/org-ref-bibtex.el @@ -1,10 +1,9 @@ -;;; org-ref-bibtex.el -- org-ref-bibtex utilities +;;; org-ref-bibtex.el -- org-ref-bibtex utilities -*- lexical-binding: t; -*- -;; Copyright(C) 2014-2021 John Kitchin +;; Copyright(C) 2014-2024 John Kitchin ;; Author: John Kitchin ;; URL: https://github.com/jkitchin/org-ref -;; Version: 0.1 ;; Keywords: org-mode, bibtex ;; This file is not currently part of GNU Emacs. @@ -67,8 +66,10 @@ (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") @@ -1171,7 +1172,7 @@ will clobber the file." (format "%s = %s,\n" f v)))) (-uniq other-fields) "\n") "\n}")) - (bibtex-find-entry key) + (bibtex-search-entry key) (bibtex-fill-entry) (bibtex-clean-entry)))) @@ -1201,7 +1202,7 @@ will clobber the file." (cdr (assoc field entry)))) entry-fields "\n") "\n}\n\n")) - (bibtex-find-entry key) + (bibtex-search-entry key) (bibtex-fill-entry) (bibtex-clean-entry))) @@ -1460,3 +1461,7 @@ See functions in `org-ref-clean-bibtex-entry-hook'." (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-20230613.1849/org-ref-citation-links.el b/elpa/org-ref-20241124.2012/org-ref-citation-links.el similarity index 94% rename from elpa/org-ref-20230613.1849/org-ref-citation-links.el rename to elpa/org-ref-20241124.2012/org-ref-citation-links.el index 8c6e0c81..d030746e 100644 --- a/elpa/org-ref-20230613.1849/org-ref-citation-links.el +++ b/elpa/org-ref-20241124.2012/org-ref-citation-links.el @@ -1,6 +1,6 @@ ;;; org-ref-citation-links.el --- citation links for org-ref -*- lexical-binding: t; -*- ;; -;; Copyright (C) 2021 John Kitchin +;; Copyright (C) 2024 John Kitchin ;; Author: John Kitchin ;; Keywords: convenience @@ -47,11 +47,15 @@ ;; 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) @@ -592,13 +596,13 @@ PATH has the citations in it." "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))) + (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)))))) @@ -1000,46 +1004,75 @@ arg COMMON, edit the common prefixes instead." (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." - (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 + (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 - ((= 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) + ;; 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 - (when (re-search-forward ":" (line-end-position) t) - (prog1 - (get-text-property (point) 'cite-key) - (goto-char cp))))))))) + ;; 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 @@ -1390,3 +1423,7 @@ Here is an example use: (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-20230613.1849/org-ref-compat.el b/elpa/org-ref-20241124.2012/org-ref-compat.el similarity index 94% rename from elpa/org-ref-20230613.1849/org-ref-compat.el rename to elpa/org-ref-20241124.2012/org-ref-compat.el index 1e9beaf1..da287aa0 100644 --- a/elpa/org-ref-20230613.1849/org-ref-compat.el +++ b/elpa/org-ref-20241124.2012/org-ref-compat.el @@ -1,4 +1,4 @@ -;;; org-ref-compat.el --- Compatibility functions for org-cite +;;; org-ref-compat.el --- Compatibility functions for org-cite -*- lexical-binding: t; -*- ;;; Commentary: ;; @@ -35,14 +35,14 @@ 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) + :group 'org-ref + :type '(list (cons string string))) (defun org-ref-to-org-cite () (interactive) (let ((ref-cites (reverse (org-ref-get-cite-links))) - ref-type - path + type path beg end) ;; This takes care of the cite links (cl-loop for rc in ref-cites do diff --git a/elpa/org-ref-20230613.1849/org-ref-core.el b/elpa/org-ref-20241124.2012/org-ref-core.el similarity index 98% rename from elpa/org-ref-20230613.1849/org-ref-core.el rename to elpa/org-ref-20241124.2012/org-ref-core.el index 1c2d6d8b..c7b34ded 100644 --- a/elpa/org-ref-20230613.1849/org-ref-core.el +++ b/elpa/org-ref-20241124.2012/org-ref-core.el @@ -1,6 +1,6 @@ ;;; org-ref-core.el --- citations, cross-references and bibliographies in org-mode -*- lexical-binding: t; -*- -;; Copyright(C) 2014-2021 John Kitchin +;; Copyright(C) 2014-2024 John Kitchin ;; This file is not currently part of GNU Emacs. @@ -53,6 +53,7 @@ (require 'org-ref-utils) (require 'org-ref-bibtex) (require 'org-ref-glossary) +(require 'openalex) ;;* Custom variables @@ -337,3 +338,7 @@ provide their own version." (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-20230613.1849/org-ref-export.el b/elpa/org-ref-20241124.2012/org-ref-export.el similarity index 93% rename from elpa/org-ref-20230613.1849/org-ref-export.el rename to elpa/org-ref-20241124.2012/org-ref-export.el index 9902f480..983d47ec 100644 --- a/elpa/org-ref-20230613.1849/org-ref-export.el +++ b/elpa/org-ref-20241124.2012/org-ref-export.el @@ -1,6 +1,6 @@ ;;; org-ref-export.el --- org-ref-export library -*- lexical-binding: t; -*- ;; -;; Copyright (C) 2021 John Kitchin +;; Copyright (C) 2024 John Kitchin ;; Author: John Kitchin ;; Keywords: convenience @@ -52,6 +52,8 @@ (require 'citeproc) +(defvar org-cite-csl-styles-dir) + (defcustom org-ref-backend-csl-formats '((html . html) (latex . latex) @@ -66,11 +68,14 @@ (defcustom org-ref-cite-internal-links 'auto - "Should be one of -- '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 bib-links no-links auto nil) + "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) @@ -212,17 +217,16 @@ REF is a plist data structure returned from `org-ref-parse-cite-path'." (suffix . ,suffix) (locator . ,locator) (label . ,(when label (org-ref-dealias-label (string-trim label)))) - ;; 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")))))))) + ;; [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") @@ -513,9 +517,9 @@ VISIBLE-ONLY BODY-ONLY and 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-hook (append - org-export-before-parsing-hook - '(org-ref-csl-preprocess-buffer)))) + (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)))) @@ -595,8 +599,8 @@ VISIBLE-ONLY BODY-ONLY and INFO." (?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-hook' -;; (add-hook 'org-export-before-parsing-hook 'org-ref-csl-preprocess-buffer) +;; 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. @@ -627,27 +631,27 @@ I am not positive on this though." (when (and org-ref/citeproc org-ref/bblproc) (error "You cannot use CSL and BBL at the same time.")) - (let ((org-export-before-parsing-hook org-export-before-parsing-hook)) + (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-hook)) + (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-hook)) + (cl-pushnew 'org-ref-refproc org-export-before-parsing-functions)) (when org-ref/acrossproc - (cl-pushnew 'org-ref-acrossproc org-export-before-parsing-hook)) + (cl-pushnew 'org-ref-acrossproc org-export-before-parsing-functions)) (when org-ref/idxproc - (cl-pushnew 'org-ref-idxproc org-export-before-parsing-hook)) + (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-hook)) + (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-hook)) + (cl-pushnew 'org-ref-cite-natmove org-export-before-parsing-functions)) (org-export-dispatch arg))) diff --git a/elpa/org-ref-20241124.2012/org-ref-extract.el b/elpa/org-ref-20241124.2012/org-ref-extract.el new file mode 100644 index 00000000..bbd01f1f --- /dev/null +++ b/elpa/org-ref-20241124.2012/org-ref-extract.el @@ -0,0 +1,190 @@ +;;; org-ref-extract.el --- Extract BibTeX from HTML -*- lexical-binding: t; -*- + +;; Copyright (C) 2023 Justus Piater + +;; Author: Justus Piater +;; 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 . + +;;; 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" . + ("" . 1)) + '("area" . + ("\"Please_choose_the_closest_area_that_your_submission_falls_into\":\"\\(.+?\\)\"" . 1)) + '("keywords" . ("Keywords.*?\"note-content-value\">\\(.+?\\)" . 1)) + '("summary" . + ("\\(Summary\\|TL;DR\\).*?\"note-content-value\">\\(.+?\\)" . 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.*?\\)+?\\)\nSupplementary PDFAbstract[ \n]*?\\(

\\)+\\(.+?\\)

" . 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]*pdf" 1)) + (cons "url" url) + '("abstract" . ("id=\"abstract\">[ \n]*\\([^<]+\\)[ \n]*supp ;; Keywords: @@ -45,7 +45,7 @@ ;; #+name: acronyms ;; | key | abbreviation | full form | ;; |------+--------------+--------------------------------| -;; | mimo | | multiple-input multiple output | +;; | mimo | mimo | multiple-input multiple output | ;; | qos | QoS | quality-of-service | ;; | bb | BB | branch and bound | ;; @@ -102,7 +102,7 @@ This is not always fast, so we provide a way to disable it." :group 'org-ref-glossary) -(defvar org-ref-glsentries '() +(defcustom org-ref-glsentries '() "Variable to hold locations of glsentries load files.") @@ -152,7 +152,7 @@ changes." ;; 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))) + (setq-local org-ref-glossary-cache (make-hash-table :test 'equal))) ;; Now we search to get the data (save-excursion @@ -171,13 +171,14 @@ changes." external)))) org-ref-glsentries) (cdr (assoc external org-ref-glsentries)))))) - key value p1 p2) + 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) @@ -206,7 +207,8 @@ changes." (setq data (append data (list :label entry) (list (intern (format ":%s" key))) - (list value)))) + (list value) + (list :position position)))) (throw 'data data)) ;; check for a glossary table @@ -218,11 +220,15 @@ changes." (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))))) + (throw 'data (list :label entry + :name (cl-second result) + :description (cl-third result) + :position position)))) ;; then external (when (and glsentries @@ -231,7 +237,7 @@ changes." (with-current-buffer (find-file-noselect glsentries) (goto-char (point-min)) (when (re-search-forward - (format "\\newglossaryentry{%s}" entry) nil t) + (format "\\newglossaryentry{%s}" entry) nil t) (re-search-forward "{") (save-excursion (backward-char) @@ -255,65 +261,57 @@ changes." (setq data (append data (list :label entry) (list (intern (format ":%s" key))) - (list value)))) + (list value) + (list :position nil)))) (throw 'data data)))))) (puthash entry data org-ref-glossary-cache) data)))) -;;;###autoload -(defun org-ref-add-glossary-entry (label name description) - "Insert a new glossary entry. -LABEL is how you refer to it with links. -NAME is the name of the entry to be defined. -DESCRIPTION is the definition of the entry. -Entry gets added after the last #+latex_header line. -This is not a preferred way to add entries. It is preferred to -manually add them to the glossary table." - (interactive "sLabel: \nsName: \nsDescription: ") - (save-excursion - (goto-char (point-max)) - ;; get to the last latex_header line - (re-search-backward "#\\+latex_header" nil t) - (forward-line) - (when (not (looking-at "^$")) - (beginning-of-line) - (insert "\n") - (forward-line -1)) - (insert (format "#+latex_header_extra: \\newglossaryentry{%s}{name={%s},description={%s}}\n" - label name description)))) - - -(defun org-ref-glossary-face-fn (label) - "Return a face for a glossary link." - (if org-ref-activate-glossary-links - (save-match-data - (cond - ((or-parse-glossary-entry label) - 'org-ref-glossary-face) - (t - 'font-lock-warning-face))) - 'org-ref-glossary-face)) +;;** 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.") -;;** Glossary links (defun or-follow-glossary (entry) "Goto beginning of the glossary ENTRY." (org-mark-ring-push) - - (cond - ;; Try finding in the table - ((progn (goto-char (point-min)) - (and (re-search-forward "#\\+name: glossary" nil t) - (re-search-forward entry nil t))) - nil) + (goto-char (plist-get (get-text-property (point) 'or-glossary) :position))) - ((progn (goto-char (point-min)) (re-search-forward (format "\\newglossaryentry{%s}" entry) nil t)) - (goto-char (match-beginning 0))) - (t - (message "no entry found for %s" entry)))) +(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 @@ -330,7 +328,7 @@ manually add them to the glossary table." (dolist (command org-ref-glossary-gls-commands) (org-link-set-parameters (cl-first command) :follow #'or-follow-glossary - :face 'org-ref-glossary-face-fn + :activate-func #'or-activate-glossary :help-echo 'or-glossary-tooltip :export (lambda (path _ format) (cond @@ -342,6 +340,7 @@ manually add them to the glossary table." (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) @@ -351,33 +350,8 @@ manually add them to the glossary table." (t (format "%s" path))))) -;;** Tooltips on glossary entries -(defface org-ref-glossary-face - `((t (:inherit org-link :foreground "Mediumpurple3"))) - "Face for glossary links.") -(defun or-glossary-tooltip (_window _object position) - "Return tooltip for the glossary entry. -The entry is in WINDOW and OBJECT at POSITION. -Used in fontification." - (save-excursion - (goto-char position) - (let* ((label (org-element-property :path (org-element-context))) - (data (or (or-parse-glossary-entry label) - (or-parse-acronym-entry label))) - (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)))))) - ;; ** printglossaries links ;; There is a printglossary command in LaTeX, but I am not supporting it for now. @@ -440,26 +414,6 @@ This is intended to be run in `org-export-before-parsing-hook'." ;;* Acronyms -;;;###autoload -(defun org-ref-add-acronym-entry (label abbrv full) - "Add an acronym entry with LABEL. - ABBRV is the abbreviated form. - FULL is the expanded acronym. - -This is not the preferred way to add acronyms, you should add -them manually to the acronyms table." - (interactive "sLabel: \nsAcronym: \nsFull name: ") - (save-excursion - (re-search-backward "#\\+latex_header" nil t) - (forward-line) - (when (not (looking-at "^$")) - (beginning-of-line) - (insert "\n") - (forward-line -1)) - (insert (format "#+latex_header_extra: \\newacronym{%s}{%s}{%s}\n" - label abbrv full)))) - - (defun or-parse-acronym-entry (label) "Parse an acronym entry LABEL to a plist. Returns (:abbrv abbrv :full full :label label) @@ -470,7 +424,7 @@ The plist maps to \newacronym{