Generate cite backlinks using all org ref cite types (#551)

This would fail on pathological cases where the key itself contains other prefixes e.g. if the key
is `cite:parencite:autocite:key`. Although this is unlikely...

To use org-ref-cite-types, we must ensure that org-ref is loaded. This would likely already be done
otherwise as the user is obviously using cite links.
This commit is contained in:
Tim Quelch 2020-05-02 20:50:11 +10:00 committed by GitHub
parent 0132546e56
commit e698ed7f53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -115,7 +115,11 @@ When non-nil, the window will not be closed when deleting other windows."
(if-let* ((roam-key (with-temp-buffer
(insert-buffer-substring org-roam-buffer--current)
(org-roam--extract-ref)))
(key-backlinks (org-roam--get-backlinks (s-chop-prefix "cite:" roam-key)))
(org-ref-p (require 'org-ref nil t)) ; Ensure that org-ref is present
(cite-prefixes (-map (lambda (type)
(concat type ":")) org-ref-cite-types))
(key-backlinks (org-roam--get-backlinks
(s-chop-prefixes cite-prefixes roam-key)))
(grouped-backlinks (--group-by (nth 0 it) key-backlinks)))
(progn
(insert (let ((l (length key-backlinks)))