From 7d5b7e61855e6db536e6f59ae00a169c31a61ac9 Mon Sep 17 00:00:00 2001 From: Jethro Kuan Date: Tue, 20 Jul 2021 16:25:54 +0800 Subject: [PATCH] (fix): fix org-ref cite links (#1637) --- org-roam-db.el | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/org-roam-db.el b/org-roam-db.el index 363f578..a9d53f3 100644 --- a/org-roam-db.el +++ b/org-roam-db.el @@ -422,14 +422,23 @@ If UPDATE-P is non-nil, first remove the file in the database." (save-excursion (goto-char (org-element-property :begin link)) (let ((type (org-element-property :type link)) - (dest (org-element-property :path link)) + (path (org-element-property :path link)) (properties (list :outline (org-get-outline-path))) (source (org-roam-id-at-point))) - (when source + ;; For Org-ref links, we need to split the path into the cite keys + (when (and (boundp 'org-ref-cite-types) + (fboundp 'org-ref-split-and-strip-string) + (member type org-ref-cite-types)) + (setq path (org-ref-split-and-strip-string path))) + (unless (listp path) + (setq path (list path))) + (when (and source path) (org-roam-db-query [:insert :into links :values $v1] - (vector (point) source dest type properties)))))) + (mapcar (lambda (p) + (vector (point) source p type properties)) + path)))))) ;;;;; Fetching (defun org-roam-db--get-current-files ()