From 7dc76b708b436d9531b477001e8ac922e719ffd4 Mon Sep 17 00:00:00 2001 From: Noboru Ota Date: Sat, 4 Jan 2025 07:10:22 +0100 Subject: [PATCH] fix(db): Org-roam does not store Org-ID w/ search option add `:search-option` property to the `link` table when present. Fix: #2495 Close: #2496 --- org-roam-db.el | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/org-roam-db.el b/org-roam-db.el index ebf2d4e..93f2ad6 100644 --- a/org-roam-db.el +++ b/org-roam-db.el @@ -563,12 +563,18 @@ INFO is the org-element parsed buffer." "Insert link data for LINK at current point into the Org-roam cache." (save-excursion (goto-char (org-element-property :begin link)) - (let ((type (org-element-property :type link)) - (path (org-element-property :path link)) - (source (org-roam-id-at-point)) - (properties (list :outline (ignore-errors - ;; This can error if link is not under any headline - (org-get-outline-path 'with-self 'use-cache))))) + (let* ((type (org-element-property :type link)) + (path (org-element-property :path link)) + (option (and (string-match "::\\(.*\\)\\'" path) + (match-string 1 path))) + (path (if (not option) path + (substring path 0 (match-beginning 0)))) + (source (org-roam-id-at-point)) + (properties (list :outline (ignore-errors + ;; This can error if link is not under any headline + (org-get-outline-path 'with-self 'use-cache)))) + (properties (if option (plist-put properties :search-option option) + properties))) ;; For Org-ref links, we need to split the path into the cite keys (when (and source path) (if (and (boundp 'org-ref-cite-types)