(fix)ref: fix org-roam-node-from-ref support for org-cite (#1919)

Support Elisp queries of form (org-roam-node-from-ref "@cite_key").
Closes #1918.
This commit is contained in:
Jethro Kuan
2021-10-22 16:15:58 +08:00
committed by GitHub
parent c8f8c3e876
commit 2c75b194d8

View File

@ -255,9 +255,15 @@ Throw an error if multiple choices exist."
"Return an `org-roam-node' from REF reference. "Return an `org-roam-node' from REF reference.
Return nil if there's no node with such REF." Return nil if there's no node with such REF."
(save-match-data (save-match-data
(when (string-match org-link-plain-re ref) (let (type path)
(let ((type (match-string 1 ref)) (cond
(path (match-string 2 ref))) ((string-match org-link-plain-re ref)
(setq type (match-string 1 ref)
path (match-string 2 ref)))
((string-equal (substring ref 0 1) "@")
(setq type "cite"
path (substring ref 1))))
(when (and type path)
(when-let ((id (caar (org-roam-db-query (when-let ((id (caar (org-roam-db-query
[:select [nodes:id] [:select [nodes:id]
:from refs :from refs