From 684ab6795287ef43185f34a2bcbe1dba8fd6c32b Mon Sep 17 00:00:00 2001 From: Jethro Kuan Date: Fri, 14 Feb 2020 23:14:38 +0800 Subject: [PATCH] Insert org-roam-links relative to current file (#78) Fixes #77 --- org-roam.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/org-roam.el b/org-roam.el index 7838d9c..72e8f63 100644 --- a/org-roam.el +++ b/org-roam.el @@ -261,11 +261,16 @@ Optionally pass it the title, for a smart file name." (org-roam--find-all-files))) (title (completing-read "File: " completions)) (absolute-file-path (or (cadr (assoc title completions)) - (org-roam--get-file-path (org-roam--get-new-id title) t)))) + (org-roam--get-file-path (org-roam--get-new-id title) t))) + (current-file-path (-> (current-buffer) + (buffer-file-name) + (file-truename) + (file-name-directory)))) (unless (file-exists-p absolute-file-path) (org-roam--make-file absolute-file-path title)) (insert (format "[[%s][%s]]" - (concat "file:" (file-relative-name absolute-file-path org-roam-directory)) + (concat "file:" (file-relative-name absolute-file-path + current-file-path)) (format org-roam-link-title-format title))))) ;;; Finding org-roam files