(fix): fix org-roam-protocol--open-ref creating new files (#1375)

We need to split the ref into its type/file before querying the db for a
match. Throw a warning when `org-roam--capture-new-file` tries to
recreate an existing file.
This commit is contained in:
Jethro Kuan
2021-01-10 23:05:45 +08:00
committed by GitHub
parent 62bba9755c
commit 3fb4e21adf
4 changed files with 47 additions and 23 deletions

View File

@ -65,18 +65,18 @@ It opens or creates a note with the given ref.
(push (cons 'slug (funcall org-roam-title-to-slug-function title)) decoded-alist))
(let-alist decoded-alist
(let* ((ref (org-protocol-sanitize-uri .ref))
(type (and (string-match "^\\([a-z]+\\):" ref)
(type (and (string-match org-link-plain-re ref)
(match-string 1 ref)))
(title (or .title ""))
(body (or .body ""))
(orglink
(org-link-make-string ref (or (org-string-nw-p title) ref))))
(when org-roam-protocol-store-links
(push (list ref title) org-stored-links))
(org-link-store-props :type type
:link ref
:annotation orglink
:initial body)))
(push (list ref title) org-stored-links)
(org-link-store-props :type type
:link ref
:annotation orglink
:initial body))))
(let* ((org-roam-capture-templates org-roam-capture-ref-templates)
(org-roam-capture--context 'ref)
(org-roam-capture--info decoded-alist)