From a0d32ab16748b7b0c43d6421f1b497b7caf8e590 Mon Sep 17 00:00:00 2001 From: Titus von der Malsburg Date: Sun, 18 Jul 2021 12:34:17 +0200 Subject: [PATCH] Added `bibtex-completion-format-citation-org-cite`. --- README.org | 1 + bibtex-completion.el | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.org b/README.org index c7cf886..5fe27af 100644 --- a/README.org +++ b/README.org @@ -7,6 +7,7 @@ Ivy-bibtex: [[http://melpa.org/#/ivy-bibtex][http://melpa.org/packages/ivy-bibte Helm-bibtex and ivy-bibtex allow you to search and manage your BibTeX bibliography. They both share the same generic backend, bibtex-completion, but one uses the Helm completion framework and the other Ivy as a front-end. * News +- 2021-07-18: Added a citation function for Org’s new citation system: ~bibtex-completion-format-citation-org-cite~ (for use in configuration variable ~bibtex-completion-format-citation-functions~) - 2021-04-12: Added a section below explaining how the bibliography can be automatically reloaded when PDFs and notes are added. See [[https://github.com/tmalsburg/helm-bibtex#refresh-bibliography-when-new-pdfs-and-notes-are-added][here]]. - 2021-04-08: It is now possible to search for entries with PDFs and notes by entering ~=has-pdf=~ and ~=has-note=~. - 2020-04-29: New commands ~helm-bibtex-with-notes~ and ~ivy-bibtex-with-noted~ for searching just within the entries that have notes. diff --git a/bibtex-completion.el b/bibtex-completion.el index 4c659c7..2b24ab8 100644 --- a/bibtex-completion.el +++ b/bibtex-completion.el @@ -122,7 +122,7 @@ ebib:key depending on the major mode of the current buffer. Note that the functions should accept a list of keys as input. With multiple marked entries one can insert multiple keys at once, e.g. \cite{key1,key2}. See the functions -`bibtex-completion-format-citation-ebib' and +`bibtex-completion-format-citation-org-cite' and `bibtex-completion-format-citation-cite' as examples." :group 'bibtex-completion :type '(alist :key-type symbol :value-type function)) @@ -1047,6 +1047,12 @@ which no PDF is available are omitted." for pdfs = (bibtex-completion-find-pdf key bibtex-completion-find-additional-pdfs) append (with-no-warnings (--map (org-make-link-string it key) pdfs))))) +(defun bibtex-completion-format-citation-org-cite (keys) + "Format org-links using Org mode's own cite syntax." + (format "[cite:%s]" + (s-join ";" + (--map (format "@%s" it) keys)))) + (defun bibtex-completion-format-citation-org-apa-link-to-PDF (keys) "Format org-links to PDF for entries in KEYS. Link text loosely follows APA format. Uses first matching PDF if