diff --git a/org-roam.el b/org-roam.el index 1478416..62d8356 100644 --- a/org-roam.el +++ b/org-roam.el @@ -382,13 +382,17 @@ current buffer is used." (defun org-roam--extract-ref () "Extract the ref from current buffer and return the type and the key of the ref." - (if-let ((ref (cdr (assoc "ROAM_KEY" (org-roam--extract-global-props '("ROAM_KEY")))))) - (let* ((type (org-roam--ref-type ref)) - (key (cond ((string= "cite" type) - (s-chop-prefix (org-roam--cite-prefix ref) ref)) - (t ref)))) - (cons type key)) - nil)) + (pcase (cdr (assoc "ROAM_KEY" + (org-roam--extract-global-props '("ROAM_KEY")))) + ('nil nil) + ((pred string-empty-p) + (user-error "ROAM_KEY cannot be empty")) + (ref + (let* ((type (org-roam--ref-type ref)) + (key (cond ((string= "cite" type) + (s-chop-prefix (org-roam--cite-prefix ref) ref)) + (t ref)))) + (cons type key))))) (defun org-roam--ref-type (ref) "Determine the type of the REF from the prefix."