From 717c358ce3d7be5d4cd8a002691c58ee1dbf5994 Mon Sep 17 00:00:00 2001 From: Willem van den Ende Date: Sun, 8 Feb 2026 21:30:41 +0000 Subject: [PATCH] Fix: roam_refs now go in PROPERTIES at top of node --- .../journelly-convert-entry-to-org-roam.el | 42 +++++++++++-------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/mostalive/journelly-convert-entry-to-org-roam.el b/mostalive/journelly-convert-entry-to-org-roam.el index c455a42..fd7944f 100644 --- a/mostalive/journelly-convert-entry-to-org-roam.el +++ b/mostalive/journelly-convert-entry-to-org-roam.el @@ -29,10 +29,19 @@ :heading heading :url url-line))) +(defun my/journelly-add-properties (url journelly-heading) + "Add ROAM_REFS and JOURNELLY_TITLE to the current node's property drawer." + (org-with-point-at 1 + (when url + (org-roam-property-add "ROAM_REFS" url)) + (when journelly-heading + (org-roam-property-add "JOURNELLY_TITLE" journelly-heading)))) + (defun journelly-convert-entry-to-org-roam () "Interactive function to convert journelly entry to org-roam. -Opens the capture buffer for review before finalizing." +Opens the capture buffer, adds url as ROAM_REFS +and then lets you review before finalizing." (interactive) (let* ((entry-text (if (use-region-p) (buffer-substring-no-properties (region-beginning) (region-end)) @@ -41,23 +50,20 @@ Opens the capture buffer for review before finalizing." (title (journelly-entry-title parsed)) (content (journelly-entry-content parsed)) (heading (journelly-entry-heading parsed)) - (url (journelly-entry-url parsed))) - ;; Build the initial content without ID (org-roam will add it) - (let ((initial-content - (concat - (or content "") "\n"))) - (org-roam-capture- - :node (org-roam-node-create :title title) - :props (list :immediate-finish nil - :jump-to-captured t) - :templates `(("d" "default" plain - ,initial-content - :target (file+head "%<%Y%m%d%H%M%S>-${slug}.org" - ,(concat "\n" - (when url (concat "#+roam_refs: " url "\n")) - (when heading (concat "#+journelly_heading: " heading "\n")) - "\n#+title: ${title}\n" )) - :unnarrowed t)))))) + (url (journelly-entry-url parsed)) + (body (concat (or content "") "\n"))) + (org-roam-capture- + :node (org-roam-node-create :title title) + :props (list :immediate-finish nil + :jump-to-captured t) + :templates `(("d" "default" plain + ,body + :target (file+head "%<%Y%m%d%H%M%S>-${slug}.org" + "#+title: ${title}\n") + :unnarrowed t))) + (my/journelly-add-properties url heading))) + + (ert-deftest test-journelly-parse-basic () (let* ((entry " * [2025-10-08 Wed 22:39] @ - Paul is #XP